diff --git a/DungeonShooting_Godot/resource/sprite/role/enemy0001/enemy0001.png.import b/DungeonShooting_Godot/resource/sprite/role/enemy0001/enemy0001.png.import
index c36be94..b20c9a6 100644
--- a/DungeonShooting_Godot/resource/sprite/role/enemy0001/enemy0001.png.import
+++ b/DungeonShooting_Godot/resource/sprite/role/enemy0001/enemy0001.png.import
@@ -3,15 +3,15 @@
importer="texture"
type="CompressedTexture2D"
uid="uid://chd2vtesap5cf"
-path="res://.godot/imported/Enemy0001.png-148a38dfa95953b26d890356e8875de4.ctex"
+path="res://.godot/imported/enemy0001.png-1247a3ddf8a1a163d812cad12c4340fd.ctex"
metadata={
"vram_texture": false
}
[deps]
-source_file="res://resource/sprite/role/enemy0001/Enemy0001.png"
-dest_files=["res://.godot/imported/Enemy0001.png-148a38dfa95953b26d890356e8875de4.ctex"]
+source_file="res://resource/sprite/role/enemy0001/enemy0001.png"
+dest_files=["res://.godot/imported/enemy0001.png-1247a3ddf8a1a163d812cad12c4340fd.ctex"]
[params]
diff --git a/DungeonShooting_Godot/resource/sprite/role/enemy0001/enemy0001_Debris.png.import b/DungeonShooting_Godot/resource/sprite/role/enemy0001/enemy0001_Debris.png.import
index d563acf..56388a2 100644
--- a/DungeonShooting_Godot/resource/sprite/role/enemy0001/enemy0001_Debris.png.import
+++ b/DungeonShooting_Godot/resource/sprite/role/enemy0001/enemy0001_Debris.png.import
@@ -3,15 +3,15 @@
importer="texture"
type="CompressedTexture2D"
uid="uid://d2f55lu60x64i"
-path="res://.godot/imported/Enemy0001_Debris.png-ac416dc79cd3c1217b27e1ef1fbe0d0b.ctex"
+path="res://.godot/imported/enemy0001_Debris.png-297a2fb6680cb862a9a085cf58f8268c.ctex"
metadata={
"vram_texture": false
}
[deps]
-source_file="res://resource/sprite/role/enemy0001/Enemy0001_Debris.png"
-dest_files=["res://.godot/imported/Enemy0001_Debris.png-ac416dc79cd3c1217b27e1ef1fbe0d0b.ctex"]
+source_file="res://resource/sprite/role/enemy0001/enemy0001_Debris.png"
+dest_files=["res://.godot/imported/enemy0001_Debris.png-297a2fb6680cb862a9a085cf58f8268c.ctex"]
[params]
diff --git a/DungeonShooting_Godot/src/game/activity/package/IPackageItem.cs b/DungeonShooting_Godot/src/game/activity/package/IPackageItem.cs
index 2cf1e93..aca7c9d 100644
--- a/DungeonShooting_Godot/src/game/activity/package/IPackageItem.cs
+++ b/DungeonShooting_Godot/src/game/activity/package/IPackageItem.cs
@@ -15,12 +15,12 @@
int PackageIndex { get; set; }
///
- /// 当物体拾起并放入背包时调用
+ /// 当物体拾起并放入背包时调用 (在 Master 赋值之后调用)
///
void OnPickUpItem();
///
- /// 当物体从背包中移除时调用
+ /// 当物体从背包中移除时调用 (在 Master 置为 null 之前调用)
///
void OnRemoveItem();
diff --git a/DungeonShooting_Godot/src/game/activity/package/Package.cs b/DungeonShooting_Godot/src/game/activity/package/Package.cs
index a4bd76f..14c2dba 100644
--- a/DungeonShooting_Godot/src/game/activity/package/Package.cs
+++ b/DungeonShooting_Godot/src/game/activity/package/Package.cs
@@ -11,7 +11,7 @@
///
/// 归属者
///
- public Role Master { get; }
+ public Role Master { get; private set; }
///
/// 当前使用的物体对象
diff --git a/DungeonShooting_Godot/src/game/activity/prop/Prop.cs b/DungeonShooting_Godot/src/game/activity/prop/Prop.cs
index 88c3aa2..c578444 100644
--- a/DungeonShooting_Godot/src/game/activity/prop/Prop.cs
+++ b/DungeonShooting_Godot/src/game/activity/prop/Prop.cs
@@ -1,25 +1,25 @@
+using Godot;
+
///
/// 道具基类
///
-public abstract partial class Prop : ActivityObject, IPackageItem
+public abstract partial class Prop : ActivityObject
{
+ ///
+ /// 道具所属角色
+ ///
public Role Master { get; set; }
- public int PackageIndex { get; set; } = -1;
+ ///
+ /// 当道具被拾起时调用 (在 Master 赋值之后调用)
+ ///
+ public abstract void OnPickUpItem();
///
- /// 当被动被道具被拾起时调用
+ /// 当道具被移除时调用 (在 Master 置为 null 之前调用)
///
- /// 拾起该道具的角色
- protected abstract void OnPickUp(Role master);
-
- ///
- /// 当被动道具被移除时调用
- ///
- /// 移除该道具的角色
- protected abstract void OnRemove(Role master);
-
+ public abstract void OnRemoveItem();
///
/// 如果道具放入了角色背包中, 则每帧调用
@@ -28,57 +28,37 @@
{
}
-
- public virtual void OnRemoveItem()
+ ///
+ /// 触发扔掉道具效果, 并不会管道具是否在道具背包中
+ ///
+ /// 触发扔掉该道具的的角色
+ public void ThrowProp(Role master)
{
-
- }
-
- public virtual void OnPickUpItem()
- {
-
- }
-
- public virtual void OnActiveItem()
- {
-
- }
-
- public virtual void OnConcealItem()
- {
-
- }
-
- public virtual void OnOverflowItem()
- {
-
+ ThrowProp(master, master.GlobalPosition);
}
///
- /// 执行将当前道具放入角色背包的操作
+ /// 触发扔掉道具效果, 并不会管道具是否在道具背包中
///
- protected void PushToRole(Role role)
+ /// 触发扔掉该道具的的角色
+ /// 投抛起始位置
+ public void ThrowProp(Role master, Vector2 startPosition)
{
- Pickup();
- role.PushProp(this);
- OnPickUp(role);
- }
-
- public override void Interactive(ActivityObject master)
- {
- if (master is Role role)
- {
- PushToRole(role);
- }
- }
+ //阴影偏移
+ ShadowOffset = new Vector2(0, 2);
- public override CheckInteractiveResult CheckInteractive(ActivityObject master)
- {
- if (master is Player)
+ if (master.Face == FaceDirection.Left)
{
- return new CheckInteractiveResult(this, true, CheckInteractiveResult.InteractiveType.PickUp);
+ Scale *= new Vector2(1, -1);
}
- return base.CheckInteractive(master);
- }
+ var rotation = master.MountPoint.GlobalRotation;
+ GlobalRotation = rotation;
+
+ var startHeight = -master.MountPoint.Position.Y;
+ Throw(startPosition, startHeight, 0, Vector2.Zero, 0);
+
+ //继承role的移动速度
+ InheritVelocity(master);
+ }
}
\ No newline at end of file
diff --git a/DungeonShooting_Godot/src/game/activity/prop/active/ActiveProp.cs b/DungeonShooting_Godot/src/game/activity/prop/active/ActiveProp.cs
index 6f3acb3..08b26a4 100644
--- a/DungeonShooting_Godot/src/game/activity/prop/active/ActiveProp.cs
+++ b/DungeonShooting_Godot/src/game/activity/prop/active/ActiveProp.cs
@@ -4,8 +4,10 @@
///
/// 主动使用道具
///
-public abstract partial class ActiveProp : Prop
+public abstract partial class ActiveProp : Prop, IPackageItem
{
+ public int PackageIndex { get; set; }
+
///
/// 道具是否可以叠加
///
@@ -101,14 +103,6 @@
///
protected abstract int OnUse();
- protected override void OnPickUp(Role master)
- {
- }
-
- protected override void OnRemove(Role master)
- {
- }
-
///
/// 道具数量改变时调用
///
@@ -175,7 +169,7 @@
{
if (Master != null)
{
- Master.RemoveProp(this);
+ Master.ActivePropsPack.RemoveItem(this);
}
Destroy();
return true;
@@ -231,11 +225,22 @@
{
if (master is Player player)
{
- //查找相同类型的物体
- ActiveProp item;
- if (Superposition && (item = player.ActivePropsPack.GetItemById(ItemConfig.Id)) != null) //走叠加逻辑
+ var item = player.ActivePropsPack.GetItemById(ItemConfig.Id);
+ if (item == null) //没有同类型物体
{
- if (item.Count < item.MaxCount) //可以叠加
+ if (player.ActivePropsPack.HasVacancy()) //还有空位, 拾起道具
+ {
+ Pickup();
+ player.PickUpActiveProp(this);
+ }
+
+ //替换手中的道具
+ player.ThrowActiveProp(player.ActivePropsPack.ActiveIndex);
+ }
+ else
+ {
+ //处理同类型道具
+ if (Superposition && item.Count < item.MaxCount) //允许叠加
{
if (item.Count + Count > item.MaxCount)
{
@@ -248,60 +253,57 @@
Count = 0;
}
}
- else //该道具不能拾起
- {
- return;
- }
}
- else //正常拾起
- {
- if (player.ActivePropsPack.HasVacancy()) //还有空位
- {
- PushToRole(player);
- }
- else //没有空位了
- {
- //替换手中的道具
-
- }
- }
-
- return;
}
-
- base.Interactive(master);
}
public override CheckInteractiveResult CheckInteractive(ActivityObject master)
{
if (master is Player player)
{
- //查找相同类型的物体
- ActiveProp item;
- if (Superposition && (item = player.ActivePropsPack.GetItemById(ItemConfig.Id)) != null) //走叠加逻辑
+ //查找相同类型的道具
+ var item = player.ActivePropsPack.GetItemById(ItemConfig.Id);
+ if (item == null) //没有同类型物体
{
- if (item.Count < item.MaxCount) //可以叠加
- {
- return new CheckInteractiveResult(this, true, CheckInteractiveResult.InteractiveType.Bullet);
- }
- else //该道具不能拾起
- {
- return new CheckInteractiveResult(this);
- }
- }
- else //正常拾起
- {
- if (player.ActivePropsPack.HasVacancy()) //还有空位
+ if (player.ActivePropsPack.HasVacancy()) //还有空位, 拾起道具
{
return new CheckInteractiveResult(this, true, CheckInteractiveResult.InteractiveType.PickUp);
}
- else //没有空位了
- {
- //替换手中的道具
- return new CheckInteractiveResult(this, true, CheckInteractiveResult.InteractiveType.Replace);
- }
+
+ //替换手中的道具
+ return new CheckInteractiveResult(this, true, CheckInteractiveResult.InteractiveType.Replace);
}
+
+ //处理同类型道具
+ if (Superposition && item.Count < item.MaxCount) //允许叠加
+ {
+ return new CheckInteractiveResult(this, true, CheckInteractiveResult.InteractiveType.Bullet);
+ }
+
+ //该道具不能拾起
+ return new CheckInteractiveResult(this);
}
- return base.CheckInteractive(master);
+
+ return new CheckInteractiveResult(this);
+ }
+
+ public override void OnPickUpItem()
+ {
+ }
+
+ public override void OnRemoveItem()
+ {
+ }
+
+ public virtual void OnActiveItem()
+ {
+ }
+
+ public virtual void OnConcealItem()
+ {
+ }
+
+ public virtual void OnOverflowItem()
+ {
}
}
\ No newline at end of file
diff --git a/DungeonShooting_Godot/src/game/activity/prop/active/ActiveProp5000.cs b/DungeonShooting_Godot/src/game/activity/prop/active/ActiveProp5000.cs
index 55f185a..2770ac7 100644
--- a/DungeonShooting_Godot/src/game/activity/prop/active/ActiveProp5000.cs
+++ b/DungeonShooting_Godot/src/game/activity/prop/active/ActiveProp5000.cs
@@ -10,7 +10,7 @@
public override void OnInit()
{
AutoDestroy = true;
- MaxCount = 20;
+ MaxCount = 10;
Superposition = true;
}
diff --git a/DungeonShooting_Godot/src/game/activity/prop/active/ActiveProp5001.cs b/DungeonShooting_Godot/src/game/activity/prop/active/ActiveProp5001.cs
new file mode 100644
index 0000000..e9f0852
--- /dev/null
+++ b/DungeonShooting_Godot/src/game/activity/prop/active/ActiveProp5001.cs
@@ -0,0 +1,32 @@
+
+using Godot;
+
+///
+/// 弹药箱, 使用后补全当前武器备用弹药
+///
+[Tool]
+public partial class ActiveProp5001 : ActiveProp
+{
+ public override void OnInit()
+ {
+ Superposition = true;
+ AutoDestroy = true;
+ MaxCount = 10;
+ }
+
+ public override bool OnCheckUse()
+ {
+ return Master.WeaponPack.ActiveItem != null && !Master.WeaponPack.ActiveItem.IsAmmoFull();
+ }
+
+ protected override int OnUse()
+ {
+ var weapon = Master.WeaponPack.ActiveItem;
+ if (weapon != null)
+ {
+ weapon.SetTotalAmmo(weapon.Attribute.MaxAmmoCapacity);
+ return 1;
+ }
+ return 0;
+ }
+}
\ No newline at end of file
diff --git a/DungeonShooting_Godot/src/game/activity/prop/buff/BuffProp.cs b/DungeonShooting_Godot/src/game/activity/prop/buff/BuffProp.cs
index 5b52ef8..de5cd38 100644
--- a/DungeonShooting_Godot/src/game/activity/prop/buff/BuffProp.cs
+++ b/DungeonShooting_Godot/src/game/activity/prop/buff/BuffProp.cs
@@ -4,5 +4,21 @@
///
public abstract partial class BuffProp : Prop
{
+ public override void Interactive(ActivityObject master)
+ {
+ if (master is Player role)
+ {
+ Pickup();
+ role.PickUpBuffProp(this);
+ }
+ }
+ public override CheckInteractiveResult CheckInteractive(ActivityObject master)
+ {
+ if (master is Player)
+ {
+ return new CheckInteractiveResult(this, true, CheckInteractiveResult.InteractiveType.PickUp);
+ }
+ return base.CheckInteractive(master);
+ }
}
\ No newline at end of file
diff --git a/DungeonShooting_Godot/src/game/activity/prop/buff/BuffPropProp0001.cs b/DungeonShooting_Godot/src/game/activity/prop/buff/BuffPropProp0001.cs
index 28c67cb..5ee7937 100644
--- a/DungeonShooting_Godot/src/game/activity/prop/buff/BuffPropProp0001.cs
+++ b/DungeonShooting_Godot/src/game/activity/prop/buff/BuffPropProp0001.cs
@@ -7,17 +7,17 @@
[Tool]
public partial class BuffPropProp0001 : BuffProp
{
- protected override void OnPickUp(Role master)
+ public override void OnPickUpItem()
{
- master.RoleState.MoveSpeed += 30;
- master.RoleState.Acceleration += 400;
- master.RoleState.Friction += 300;
+ Master.RoleState.MoveSpeed += 30;
+ Master.RoleState.Acceleration += 400;
+ Master.RoleState.Friction += 300;
}
- protected override void OnRemove(Role master)
+ public override void OnRemoveItem()
{
- master.RoleState.MoveSpeed -= 30;
- master.RoleState.Acceleration -= 400;
- master.RoleState.Friction -= 300;
+ Master.RoleState.MoveSpeed -= 30;
+ Master.RoleState.Acceleration -= 400;
+ Master.RoleState.Friction -= 300;
}
}
\ No newline at end of file
diff --git a/DungeonShooting_Godot/src/game/activity/prop/buff/BuffPropProp0002.cs b/DungeonShooting_Godot/src/game/activity/prop/buff/BuffPropProp0002.cs
index 792dbf6..198ad79 100644
--- a/DungeonShooting_Godot/src/game/activity/prop/buff/BuffPropProp0002.cs
+++ b/DungeonShooting_Godot/src/game/activity/prop/buff/BuffPropProp0002.cs
@@ -7,14 +7,14 @@
[Tool]
public partial class BuffPropProp0002 : BuffProp
{
- protected override void OnPickUp(Role master)
+ public override void OnPickUpItem()
{
- master.MaxHp += 2;
- master.Hp += 2;
+ Master.MaxHp += 2;
+ Master.Hp += 2;
}
- protected override void OnRemove(Role master)
+ public override void OnRemoveItem()
{
- master.MaxHp -= 2;
+ Master.MaxHp -= 2;
}
}
\ No newline at end of file
diff --git a/DungeonShooting_Godot/src/game/activity/prop/buff/BuffPropProp0003.cs b/DungeonShooting_Godot/src/game/activity/prop/buff/BuffPropProp0003.cs
index 9cb0241..64f9fde 100644
--- a/DungeonShooting_Godot/src/game/activity/prop/buff/BuffPropProp0003.cs
+++ b/DungeonShooting_Godot/src/game/activity/prop/buff/BuffPropProp0003.cs
@@ -7,14 +7,14 @@
[Tool]
public partial class BuffPropProp0003 : BuffProp
{
- protected override void OnPickUp(Role master)
+ public override void OnPickUpItem()
{
- master.MaxShield += 1;
- master.Shield += 1;
+ Master.MaxShield += 1;
+ Master.Shield += 1;
}
- protected override void OnRemove(Role master)
+ public override void OnRemoveItem()
{
- master.MaxShield -= 1;
+ Master.MaxShield -= 1;
}
}
\ No newline at end of file
diff --git a/DungeonShooting_Godot/src/game/activity/prop/buff/BuffPropProp0004.cs b/DungeonShooting_Godot/src/game/activity/prop/buff/BuffPropProp0004.cs
index d686fc4..306ae09 100644
--- a/DungeonShooting_Godot/src/game/activity/prop/buff/BuffPropProp0004.cs
+++ b/DungeonShooting_Godot/src/game/activity/prop/buff/BuffPropProp0004.cs
@@ -7,13 +7,13 @@
[Tool]
public partial class BuffPropProp0004 : BuffProp
{
- protected override void OnPickUp(Role master)
+ public override void OnPickUpItem()
{
- master.RoleState.ShieldRecoveryTime -= 1.5f;
+ Master.RoleState.ShieldRecoveryTime -= 1.5f;
}
- protected override void OnRemove(Role master)
+ public override void OnRemoveItem()
{
- master.RoleState.ShieldRecoveryTime += 1.5f;
+ Master.RoleState.ShieldRecoveryTime += 1.5f;
}
}
\ No newline at end of file
diff --git a/DungeonShooting_Godot/src/game/activity/prop/buff/BuffPropProp0005.cs b/DungeonShooting_Godot/src/game/activity/prop/buff/BuffPropProp0005.cs
index 6b8f493..8beac22 100644
--- a/DungeonShooting_Godot/src/game/activity/prop/buff/BuffPropProp0005.cs
+++ b/DungeonShooting_Godot/src/game/activity/prop/buff/BuffPropProp0005.cs
@@ -7,14 +7,14 @@
[Tool]
public partial class BuffPropProp0005 : BuffProp
{
- protected override void OnPickUp(Role master)
+ public override void OnPickUpItem()
{
- master.RoleState.CalcDamageEvent += CalcDamage;
+ Master.RoleState.CalcDamageEvent += CalcDamage;
}
- protected override void OnRemove(Role master)
+ public override void OnRemoveItem()
{
- master.RoleState.CalcDamageEvent -= CalcDamage;
+ Master.RoleState.CalcDamageEvent -= CalcDamage;
}
private void CalcDamage(int originDamage, RefValue refValue)
diff --git a/DungeonShooting_Godot/src/game/activity/prop/buff/BuffPropProp0006.cs b/DungeonShooting_Godot/src/game/activity/prop/buff/BuffPropProp0006.cs
index 55694f3..4c91d6d 100644
--- a/DungeonShooting_Godot/src/game/activity/prop/buff/BuffPropProp0006.cs
+++ b/DungeonShooting_Godot/src/game/activity/prop/buff/BuffPropProp0006.cs
@@ -7,13 +7,13 @@
[Tool]
public partial class BuffPropProp0006 : BuffProp
{
- protected override void OnPickUp(Role master)
+ public override void OnPickUpItem()
{
- master.RoleState.WoundedInvincibleTime += 2f;
+ Master.RoleState.WoundedInvincibleTime += 2f;
}
- protected override void OnRemove(Role master)
+ public override void OnRemoveItem()
{
- master.RoleState.WoundedInvincibleTime -= 2f;
+ Master.RoleState.WoundedInvincibleTime -= 2f;
}
}
\ No newline at end of file
diff --git a/DungeonShooting_Godot/src/game/activity/prop/buff/BuffPropProp0007.cs b/DungeonShooting_Godot/src/game/activity/prop/buff/BuffPropProp0007.cs
index b844401..14133e0 100644
--- a/DungeonShooting_Godot/src/game/activity/prop/buff/BuffPropProp0007.cs
+++ b/DungeonShooting_Godot/src/game/activity/prop/buff/BuffPropProp0007.cs
@@ -7,14 +7,14 @@
[Tool]
public partial class BuffPropProp0007 : BuffProp
{
- protected override void OnPickUp(Role master)
+ public override void OnPickUpItem()
{
- master.RoleState.CalcHurtDamageEvent += CalcHurtDamageEvent;
+ Master.RoleState.CalcHurtDamageEvent += CalcHurtDamageEvent;
}
- protected override void OnRemove(Role master)
+ public override void OnRemoveItem()
{
- master.RoleState.CalcHurtDamageEvent -= CalcHurtDamageEvent;
+ Master.RoleState.CalcHurtDamageEvent -= CalcHurtDamageEvent;
}
private void CalcHurtDamageEvent(int originDamage, RefValue refValue)
diff --git a/DungeonShooting_Godot/src/game/activity/prop/buff/BuffPropProp0008.cs b/DungeonShooting_Godot/src/game/activity/prop/buff/BuffPropProp0008.cs
index 4557483..7946f62 100644
--- a/DungeonShooting_Godot/src/game/activity/prop/buff/BuffPropProp0008.cs
+++ b/DungeonShooting_Godot/src/game/activity/prop/buff/BuffPropProp0008.cs
@@ -7,16 +7,16 @@
[Tool]
public partial class BuffPropProp0008 : BuffProp
{
- protected override void OnPickUp(Role master)
+ public override void OnPickUpItem()
{
- master.RoleState.CalcStartScatteringEvent += CalcStartScatteringEvent;
- master.RoleState.CalcFinalScatteringEvent += CalcFinalScatteringEvent;
+ Master.RoleState.CalcStartScatteringEvent += CalcStartScatteringEvent;
+ Master.RoleState.CalcFinalScatteringEvent += CalcFinalScatteringEvent;
}
- protected override void OnRemove(Role master)
+ public override void OnRemoveItem()
{
- master.RoleState.CalcStartScatteringEvent -= CalcStartScatteringEvent;
- master.RoleState.CalcFinalScatteringEvent -= CalcFinalScatteringEvent;
+ Master.RoleState.CalcStartScatteringEvent -= CalcStartScatteringEvent;
+ Master.RoleState.CalcFinalScatteringEvent -= CalcFinalScatteringEvent;
}
private void CalcStartScatteringEvent(Weapon weapon, float originValue, RefValue refValue)
diff --git a/DungeonShooting_Godot/src/game/activity/prop/buff/BuffPropProp0009.cs b/DungeonShooting_Godot/src/game/activity/prop/buff/BuffPropProp0009.cs
index 099eb96..38b9e45 100644
--- a/DungeonShooting_Godot/src/game/activity/prop/buff/BuffPropProp0009.cs
+++ b/DungeonShooting_Godot/src/game/activity/prop/buff/BuffPropProp0009.cs
@@ -7,16 +7,16 @@
[Tool]
public partial class BuffPropProp0009 : BuffProp
{
- protected override void OnPickUp(Role master)
+ public override void OnPickUpItem()
{
- master.RoleState.CalcBulletSpeedEvent += CalcBulletSpeedEvent;
- master.RoleState.CalcBulletDistanceEvent += CalcBulletDistanceEvent;
+ Master.RoleState.CalcBulletSpeedEvent += CalcBulletSpeedEvent;
+ Master.RoleState.CalcBulletDistanceEvent += CalcBulletDistanceEvent;
}
- protected override void OnRemove(Role master)
+ public override void OnRemoveItem()
{
- master.RoleState.CalcBulletSpeedEvent -= CalcBulletSpeedEvent;
- master.RoleState.CalcBulletDistanceEvent -= CalcBulletDistanceEvent;
+ Master.RoleState.CalcBulletSpeedEvent -= CalcBulletSpeedEvent;
+ Master.RoleState.CalcBulletDistanceEvent -= CalcBulletDistanceEvent;
}
private void CalcBulletSpeedEvent(Weapon weapon, float originSpeed, RefValue speed)
diff --git a/DungeonShooting_Godot/src/game/activity/prop/buff/BuffPropProp0010.cs b/DungeonShooting_Godot/src/game/activity/prop/buff/BuffPropProp0010.cs
index 104f51b..787107a 100644
--- a/DungeonShooting_Godot/src/game/activity/prop/buff/BuffPropProp0010.cs
+++ b/DungeonShooting_Godot/src/game/activity/prop/buff/BuffPropProp0010.cs
@@ -7,20 +7,20 @@
[Tool]
public partial class BuffPropProp0010 : BuffProp
{
- protected override void OnPickUp(Role master)
+ public override void OnPickUpItem()
{
- master.RoleState.CalcBulletCountEvent += CalcBulletCountEvent;
- master.RoleState.CalcBulletDeviationAngleEvent += CalcBulletDeviationAngleEvent;
- master.RoleState.CalcDamageEvent += CalcDamageEvent;
- master.RoleState.CalcBulletSpeedEvent += CalcBulletSpeedEvent;
+ Master.RoleState.CalcBulletCountEvent += CalcBulletCountEvent;
+ Master.RoleState.CalcBulletDeviationAngleEvent += CalcBulletDeviationAngleEvent;
+ Master.RoleState.CalcDamageEvent += CalcDamageEvent;
+ Master.RoleState.CalcBulletSpeedEvent += CalcBulletSpeedEvent;
}
- protected override void OnRemove(Role master)
+ public override void OnRemoveItem()
{
- master.RoleState.CalcBulletCountEvent -= CalcBulletCountEvent;
- master.RoleState.CalcBulletDeviationAngleEvent -= CalcBulletDeviationAngleEvent;
- master.RoleState.CalcDamageEvent -= CalcDamageEvent;
- master.RoleState.CalcBulletSpeedEvent -= CalcBulletSpeedEvent;
+ Master.RoleState.CalcBulletCountEvent -= CalcBulletCountEvent;
+ Master.RoleState.CalcBulletDeviationAngleEvent -= CalcBulletDeviationAngleEvent;
+ Master.RoleState.CalcDamageEvent -= CalcDamageEvent;
+ Master.RoleState.CalcBulletSpeedEvent -= CalcBulletSpeedEvent;
}
private void CalcBulletCountEvent(Weapon weapon, int originCount, RefValue refValue)
diff --git a/DungeonShooting_Godot/src/game/activity/role/Player.cs b/DungeonShooting_Godot/src/game/activity/role/Player.cs
index 02867ee..564f543 100644
--- a/DungeonShooting_Godot/src/game/activity/role/Player.cs
+++ b/DungeonShooting_Godot/src/game/activity/role/Player.cs
@@ -77,7 +77,7 @@
if (InputManager.ExchangeWeapon) //切换武器
{
- ExchangeNext();
+ ExchangeNextWeapon();
}
else if (InputManager.ThrowWeapon) //扔掉武器
{
@@ -136,30 +136,13 @@
PlayAnim();
}
- public override bool PickUpWeapon(Weapon weapon, bool exchange = true)
+ protected override void OnPickUpWeapon(Weapon weapon)
{
- //拾起武器
- var result = base.PickUpWeapon(weapon, exchange);
- if (result)
- {
- EventManager.EmitEvent(EventEnum.OnPlayerPickUpWeapon, weapon);
- }
- return result;
+ EventManager.EmitEvent(EventEnum.OnPlayerPickUpWeapon, weapon);
}
- public override void ThrowWeapon()
+ protected override void OnThrowWeapon(Weapon weapon)
{
- //扔掉武器
- var weapon = WeaponPack.ActiveItem;
- base.ThrowWeapon();
- EventManager.EmitEvent(EventEnum.OnPlayerRemoveWeapon, weapon);
- }
-
- public override void ThrowWeapon(int index)
- {
- //扔掉武器
- var weapon = WeaponPack.GetItem(index);
- base.ThrowWeapon(index);
EventManager.EmitEvent(EventEnum.OnPlayerRemoveWeapon, weapon);
}
@@ -229,7 +212,7 @@
//GameApplication.Instance.World.ProcessMode = ProcessModeEnum.WhenPaused;
}
- protected override void OnPushProp(Prop prop)
+ protected override void OnPickUpProp(Prop prop)
{
EventManager.EmitEvent(EventEnum.OnPlayerPickUpProp, prop);
}
diff --git a/DungeonShooting_Godot/src/game/activity/role/Role.cs b/DungeonShooting_Godot/src/game/activity/role/Role.cs
index 4b6242c..62d9cbf 100644
--- a/DungeonShooting_Godot/src/game/activity/role/Role.cs
+++ b/DungeonShooting_Godot/src/game/activity/role/Role.cs
@@ -296,14 +296,35 @@
}
///
- /// 当往背包中添加道具时调用
+ /// 当拾起某个武器时调用
///
- protected virtual void OnPushProp(Prop prop)
+ protected virtual void OnPickUpWeapon(Weapon weapon)
+ {
+ }
+
+ ///
+ /// 当扔掉某个武器时调用
+ ///
+ protected virtual void OnThrowWeapon(Weapon weapon)
{
}
///
- /// 当从背包中移除道具时调用
+ /// 当切换到某个武器时调用
+ ///
+ protected virtual void OnExchangeWeapon(Weapon weapon)
+ {
+ }
+
+ ///
+ /// 当拾起某个道具时调用
+ ///
+ protected virtual void OnPickUpProp(Prop prop)
+ {
+ }
+
+ ///
+ /// 当移除某个道具时调用
///
protected virtual void OnRemoveProp(Prop prop)
{
@@ -456,7 +477,7 @@
/// 当武器放到后背时调用, 用于设置武器位置和角度
///
/// 武器实例
- /// 放入武器袋的位置
+ /// 放入武器背包的位置
public virtual void OnPutBackMount(Weapon weapon, int index)
{
if (index < 8)
@@ -560,17 +581,20 @@
return true;
}
+ //-------------------------------------------------------------------------------------
+
///
- /// 拾起一个武器, 返回是否成功拾取, 如果不想立刻切换到该武器, exchange 请传 false
+ /// 拾起一个武器, 返回是否成功拾起, 如果不想立刻切换到该武器, exchange 请传 false
///
/// 武器对象
/// 是否立即切换到该武器, 默认 true
- public virtual bool PickUpWeapon(Weapon weapon, bool exchange = true)
+ public bool PickUpWeapon(Weapon weapon, bool exchange = true)
{
if (WeaponPack.PickupItem(weapon, exchange) != -1)
{
//从可互动队列中移除
_interactiveItemList.Remove(weapon);
+ OnPickUpWeapon(weapon);
return true;
}
@@ -580,23 +604,33 @@
///
/// 切换到下一个武器
///
- public virtual void ExchangeNext()
+ public void ExchangeNextWeapon()
{
+ var weapon = WeaponPack.ActiveItem;
WeaponPack.ExchangeNext();
+ if (WeaponPack.ActiveItem != weapon)
+ {
+ OnExchangeWeapon(WeaponPack.ActiveItem);
+ }
}
///
/// 切换到上一个武器
///
- public virtual void ExchangePrev()
+ public void ExchangePrevWeapon()
{
+ var weapon = WeaponPack.ActiveItem;
WeaponPack.ExchangePrev();
+ if (WeaponPack.ActiveItem != weapon)
+ {
+ OnExchangeWeapon(WeaponPack.ActiveItem);
+ }
}
///
/// 扔掉当前使用的武器, 切换到上一个武器
///
- public virtual void ThrowWeapon()
+ public void ThrowWeapon()
{
ThrowWeapon(WeaponPack.ActiveIndex);
}
@@ -604,8 +638,8 @@
///
/// 扔掉指定位置的武器
///
- /// 武器在武器袋中的位置
- public virtual void ThrowWeapon(int index)
+ /// 武器在武器背包中的位置
+ public void ThrowWeapon(int index)
{
var weapon = WeaponPack.GetItem(index);
if (weapon == null)
@@ -625,6 +659,120 @@
}
///
+ /// 拾起主动道具, 返回是否成功拾起, 如果不想立刻切换到该道具, exchange 请传 false
+ ///
+ /// 主动道具对象
+ /// 是否立即切换到该道具, 默认 true
+ public bool PickUpActiveProp(ActiveProp activeProp, bool exchange = true)
+ {
+ if (ActivePropsPack.PickupItem(activeProp, exchange) != -1)
+ {
+ //从可互动队列中移除
+ _interactiveItemList.Remove(activeProp);
+ OnPickUpProp(activeProp);
+ return true;
+ }
+
+ return false;
+ }
+
+ ///
+ /// 切换到下一个武器
+ ///
+ public void ExchangeNextActiveProp()
+ {
+ ActivePropsPack.ExchangeNext();
+ }
+
+ ///
+ /// 切换到上一个武器
+ ///
+ public void ExchangePrevActiveProp()
+ {
+ ActivePropsPack.ExchangePrev();
+ }
+
+ ///
+ /// 扔掉当前使用的道具
+ ///
+ public void ThrowActiveProp()
+ {
+ ThrowActiveProp(ActivePropsPack.ActiveIndex);
+ }
+
+ ///
+ /// 扔掉指定位置上的主动道具
+ ///
+ public void ThrowActiveProp(int index)
+ {
+ var activeProp = ActivePropsPack.GetItem(index);
+ if (activeProp == null)
+ {
+ return;
+ }
+
+ ActivePropsPack.RemoveItem(index);
+ OnRemoveProp(activeProp);
+ //播放抛出效果
+ activeProp.ThrowProp(this, GlobalPosition);
+ }
+
+ ///
+ /// 拾起被动道具, 返回是否成功拾起
+ ///
+ /// 被动道具对象
+ public bool PickUpBuffProp(BuffProp buffProp)
+ {
+ if (BuffPropPack.Contains(buffProp))
+ {
+ GD.PrintErr("被动道具已经在背包中了!");
+ return false;
+ }
+ BuffPropPack.Add(buffProp);
+ buffProp.Master = this;
+ OnPickUpProp(buffProp);
+ buffProp.OnPickUpItem();
+ return true;
+ }
+
+ ///
+ /// 扔掉指定的被动道具
+ ///
+ ///
+ public void ThrowBuffProp(BuffProp buffProp)
+ {
+ var index = BuffPropPack.IndexOf(buffProp);
+ if (index < 0)
+ {
+ GD.PrintErr("当前道具不在角色背包中!");
+ return;
+ }
+
+ ThrowBuffProp(index);
+ }
+
+ ///
+ /// 扔掉指定位置上的被动道具
+ ///
+ public void ThrowBuffProp(int index)
+ {
+ if (index < 0 || index >= BuffPropPack.Count)
+ {
+ return;
+ }
+
+ var buffProp = BuffPropPack[index];
+ BuffPropPack.RemoveAt(index);
+ buffProp.OnRemoveItem();
+ OnRemoveProp(buffProp);
+ buffProp.Master = null;
+ //播放抛出效果
+ buffProp.ThrowProp(this, GlobalPosition);
+ }
+
+ //-------------------------------------------------------------------------------------
+
+ ///
/// 返回是否存在可互动的物体
///
public bool HasInteractive()
@@ -826,66 +974,6 @@
}
}
- ///
- /// 添加道具
- ///
- public void PushProp(Prop prop)
- {
- if (prop is ActiveProp activeProp) //主动道具
- {
- if (ActivePropsPack.PickupItem(activeProp) == -1)
- {
- GD.PrintErr("主动道具无法存入背包中!");
- return;
- }
- OnPushProp(prop);
- }
- else if (prop is BuffProp buffProp) //被动道具
- {
- if (BuffPropPack.Contains(buffProp))
- {
- GD.PrintErr("被动道具已经在背包中了!");
- return;
- }
- BuffPropPack.Add(buffProp);
- OnPushProp(prop);
- }
- else
- {
- GD.PrintErr("尚未被支持的道具类型: " + prop.GetType().FullName);
- }
- }
-
- ///
- /// 移除道具
- ///
- public bool RemoveProp(Prop prop)
- {
- if (prop is ActiveProp activeProp) //主动道具
- {
- if (ActivePropsPack.RemoveItem(activeProp) != null)
- {
- OnRemoveProp(prop);
- return true;
- }
- GD.PrintErr("当前道具不在角色背包中!");
- return false;
- }
- else if (prop is BuffProp buffProp) //被动道具
- {
- if (BuffPropPack.Contains(buffProp))
- {
- OnRemoveProp(prop);
- BuffPropPack.Remove(buffProp);
- return true;
- }
- GD.PrintErr("被动道具不在背包中!");
- return false;
- }
- GD.PrintErr("尚未被支持的道具类型: " + prop.GetType().FullName);
- return false;
- }
-
protected override void OnDestroy()
{
//销毁道具
diff --git a/DungeonShooting_Godot/src/game/activity/role/enemy/Enemy.cs b/DungeonShooting_Godot/src/game/activity/role/enemy/Enemy.cs
index b7e3f48..8979979 100644
--- a/DungeonShooting_Godot/src/game/activity/role/enemy/Enemy.cs
+++ b/DungeonShooting_Godot/src/game/activity/role/enemy/Enemy.cs
@@ -428,7 +428,7 @@
}
var index = WeaponPack.FindIndex((we, i) => we.ItemConfig.Id == weapon.ItemConfig.Id);
- if (index != -1) //与武器袋中武器类型相同, 补充子弹
+ if (index != -1) //与武器背包中武器类型相同, 补充子弹
{
if (!WeaponPack.GetItem(index).IsAmmoFull())
{
diff --git a/DungeonShooting_Godot/src/game/activity/weapon/Weapon.cs b/DungeonShooting_Godot/src/game/activity/weapon/Weapon.cs
index 223f47b..072a9c9 100644
--- a/DungeonShooting_Godot/src/game/activity/weapon/Weapon.cs
+++ b/DungeonShooting_Godot/src/game/activity/weapon/Weapon.cs
@@ -109,7 +109,7 @@
public bool IsCharging => _looseShootFlag;
///
- /// 返回武器是否在武器袋中
+ /// 返回武器是否在武器背包中
///
public bool IsInHolster => Master != null;
@@ -363,7 +363,7 @@
}
///
- /// 当武器从武器袋中移除时调用
+ /// 当武器从武器背包中移除时调用
///
/// 移除该武器的角色
protected virtual void OnRemove(Role master)
@@ -1553,7 +1553,7 @@
}
///
- /// 触发扔掉武器抛出的效果, 并不会管武器是否在武器袋中
+ /// 触发扔掉武器时抛出的效果, 并不会管武器是否在武器背包中
///
/// 触发扔掉该武器的的角色
public void ThrowWeapon(Role master)
@@ -1562,7 +1562,7 @@
}
///
- /// 触发扔掉武器抛出的效果, 并不会管武器是否在武器袋中
+ /// 触发扔掉武器时抛出的效果, 并不会管武器是否在武器背包中
///
/// 触发扔掉该武器的的角色
/// 投抛起始位置