diff --git a/DungeonShooting_Godot/src/game/activity/currency/Gold.cs b/DungeonShooting_Godot/src/game/activity/currency/Gold.cs index 29eb440..991d072 100644 --- a/DungeonShooting_Godot/src/game/activity/currency/Gold.cs +++ b/DungeonShooting_Godot/src/game/activity/currency/Gold.cs @@ -1,4 +1,5 @@ +using System.Collections.Generic; using Godot; /// @@ -70,4 +71,29 @@ MoveController.ClearForce(); MoveController.SetAllVelocity(Vector2.Zero); } + + /// + /// 创建散落的金币 + /// + /// 位置 + /// 金币数量 + /// 投抛力度 + public static List CreateGold(Vector2 position, int count, int force = 10) + { + var list = new List(); + var goldList = Utils.GetGoldList(count); + foreach (var id in goldList) + { + var o = ObjectManager.GetActivityObject(id); + o.Position = position; + o.Throw(0, + Utils.Random.RandomRangeInt(5 * force, 11 * force), + new Vector2(Utils.Random.RandomRangeInt(-2 * force, 2 * force), Utils.Random.RandomRangeInt(-2 * force, 2 * force)), + 0 + ); + list.Add(o); + } + + return list; + } } diff --git a/DungeonShooting_Godot/src/game/activity/role/enemy/Enemy.cs b/DungeonShooting_Godot/src/game/activity/role/enemy/Enemy.cs index e67c7aa..b18d1e3 100644 --- a/DungeonShooting_Godot/src/game/activity/role/enemy/Enemy.cs +++ b/DungeonShooting_Godot/src/game/activity/role/enemy/Enemy.cs @@ -131,11 +131,12 @@ } //创建金币 - CreateGold(); + Gold.CreateGold(Position, RoleState.Gold); //派发敌人死亡信号 EventManager.EmitEvent(EventEnum.OnEnemyDie, this); Destroy(); + } protected override void Process(float delta) @@ -172,24 +173,6 @@ } } - /// - /// 创建散落的金币 - /// - protected void CreateGold() - { - var goldList = Utils.GetGoldList(RoleState.Gold); - foreach (var id in goldList) - { - var o = ObjectManager.GetActivityObject(id); - o.Position = Position; - o.Throw(0, - Utils.Random.RandomRangeInt(50, 110), - new Vector2(Utils.Random.RandomRangeInt(-20, 20), Utils.Random.RandomRangeInt(-20, 20)), - 0 - ); - } - } - public override bool IsAllWeaponTotalAmmoEmpty() { if (!_enemyAttribute.CanPickUpWeapon) diff --git a/DungeonShooting_Godot/src/game/activity/role/enemy/NoWeaponEnemy.cs b/DungeonShooting_Godot/src/game/activity/role/enemy/NoWeaponEnemy.cs index 495337c..89d9ccc 100644 --- a/DungeonShooting_Godot/src/game/activity/role/enemy/NoWeaponEnemy.cs +++ b/DungeonShooting_Godot/src/game/activity/role/enemy/NoWeaponEnemy.cs @@ -71,7 +71,7 @@ debris.BrushPrevPosition = BrushPrevPosition; //创建金币 - CreateGold(); + Gold.CreateGold(Position, RoleState.Gold); //派发敌人死亡信号 EventManager.EmitEvent(EventEnum.OnEnemyDie, this); diff --git a/DungeonShooting_Godot/src/game/buff/effect/Eff_GetGold.cs b/DungeonShooting_Godot/src/game/buff/effect/Eff_GetGold.cs index 11bec51..0a28d6e 100644 --- a/DungeonShooting_Godot/src/game/buff/effect/Eff_GetGold.cs +++ b/DungeonShooting_Godot/src/game/buff/effect/Eff_GetGold.cs @@ -18,16 +18,6 @@ public override void OnUse() { - var goldList = Utils.GetGoldList(Mathf.FloorToInt(_value)); - foreach (var id in goldList) - { - var o = ObjectManager.GetActivityObject(id); - o.Position = Role.Position; - o.Throw(0, - Utils.Random.RandomRangeInt(50, 110), - new Vector2(Utils.Random.RandomRangeInt(-20, 20), Utils.Random.RandomRangeInt(-20, 20)), - 0 - ); - } + Gold.CreateGold(Role.Position, _value); } } \ No newline at end of file diff --git a/DungeonShooting_Godot/src/game/buff/effect/Eff_PiggyBank.cs b/DungeonShooting_Godot/src/game/buff/effect/Eff_PiggyBank.cs index c7a7c37..0f40b2e 100644 --- a/DungeonShooting_Godot/src/game/buff/effect/Eff_PiggyBank.cs +++ b/DungeonShooting_Godot/src/game/buff/effect/Eff_PiggyBank.cs @@ -25,17 +25,7 @@ public override void OnUse() { - var goldList = Utils.GetGoldList(Mathf.FloorToInt(_currValue * _value)); - foreach (var id in goldList) - { - var o = ObjectManager.GetActivityObject(id); - o.Position = Role.Position; - o.Throw(0, - Utils.Random.RandomRangeInt(50, 110), - new Vector2(Utils.Random.RandomRangeInt(-20, 20), Utils.Random.RandomRangeInt(-20, 20)), - 0 - ); - } + Gold.CreateGold(Role.Position, Mathf.FloorToInt(_currValue * _value)); _currValue = 0; }