diff --git a/DungeonShooting_Godot/src/framework/ActivityObject.cs b/DungeonShooting_Godot/src/framework/ActivityObject.cs index 1d448bd..d9c8233 100644 --- a/DungeonShooting_Godot/src/framework/ActivityObject.cs +++ b/DungeonShooting_Godot/src/framework/ActivityObject.cs @@ -243,6 +243,13 @@ } /// + /// 开始投抛该物体时调用 + /// + protected virtual void OnThrowStart() + { + } + + /// /// 投抛该物体达到最高点时调用 /// protected virtual void OnThrowMaxHeight(float height) @@ -676,6 +683,7 @@ } } + //计算位置 private void CalcThrowAnimatedPosition() { if (Scale.y < 0) @@ -756,6 +764,7 @@ CalcThrowAnimatedPosition(); //显示阴影 ShowShadowSprite(); + OnThrowStart(); } /// diff --git a/DungeonShooting_Godot/src/game/item/package/Holster.cs b/DungeonShooting_Godot/src/game/item/package/Holster.cs index 8cdac81..c1fc36c 100644 --- a/DungeonShooting_Godot/src/game/item/package/Holster.cs +++ b/DungeonShooting_Godot/src/game/item/package/Holster.cs @@ -90,8 +90,9 @@ /// /// 根据索引获取武器 /// - public Weapon GetWeapon(int index) { - if (index >= SlotList.Length) + public Weapon GetWeapon(int index) + { + if (index < 0 || index >= SlotList.Length) { return null; } diff --git a/DungeonShooting_Godot/src/game/item/weapon/Weapon.cs b/DungeonShooting_Godot/src/game/item/weapon/Weapon.cs index adcadc9..0c86c92 100644 --- a/DungeonShooting_Godot/src/game/item/weapon/Weapon.cs +++ b/DungeonShooting_Godot/src/game/item/weapon/Weapon.cs @@ -901,7 +901,17 @@ /// 触发扔掉武器抛出的效果, 并不会管武器是否在武器袋中 /// /// 触发扔掉该武器的的角色 - public virtual void ThrowWeapon(Role master) + public void ThrowWeapon(Role master) + { + ThrowWeapon(master, master.GlobalPosition); + } + + /// + /// 触发扔掉武器抛出的效果, 并不会管武器是否在武器袋中 + /// + /// 触发扔掉该武器的的角色 + /// 投抛起始位置 + public void ThrowWeapon(Role master, Vector2 startPosition) { //阴影偏移 ShadowOffset = new Vector2(0, 2); @@ -919,7 +929,7 @@ var xf = 20; var yf = Utils.RandRangeInt(50, 70); var rotate = Utils.RandRangeInt(-90, 90); - Throw(new Vector2(30, 15), master.GetCenterPosition(), startHeight, direction, xf, yf, rotate, true); + Throw(new Vector2(30, 15), startPosition, startHeight, direction, xf, yf, rotate, true); } protected override void OnThrowOver()