diff --git a/DungeonShooting_Godot/DungeonShooting.csproj b/DungeonShooting_Godot/DungeonShooting.csproj index 97e725f..672ba00 100644 --- a/DungeonShooting_Godot/DungeonShooting.csproj +++ b/DungeonShooting_Godot/DungeonShooting.csproj @@ -1,4 +1,4 @@ - + net7.0 true diff --git a/DungeonShooting_Godot/DungeonShooting.csproj.old b/DungeonShooting_Godot/DungeonShooting.csproj.old new file mode 100644 index 0000000..97e725f --- /dev/null +++ b/DungeonShooting_Godot/DungeonShooting.csproj.old @@ -0,0 +1,11 @@ + + + net7.0 + true + + + + + + + \ No newline at end of file diff --git a/DungeonShooting_Godot/prefab/role/Enemy0002.tscn b/DungeonShooting_Godot/prefab/role/Enemy0002.tscn index e869f0e..81da50f 100644 --- a/DungeonShooting_Godot/prefab/role/Enemy0002.tscn +++ b/DungeonShooting_Godot/prefab/role/Enemy0002.tscn @@ -119,7 +119,7 @@ material = SubResource("ShaderMaterial_4qvs8") sprite_frames = ExtResource("3_hbsqi") animation = &"attack" -offset = Vector2(0, -10) +offset = Vector2(0, -9) [node name="HurtCollision" parent="HurtArea" index="0"] position = Vector2(0, -7) diff --git a/DungeonShooting_Godot/src/game/activity/role/enemy/NoWeaponEnemy.cs b/DungeonShooting_Godot/src/game/activity/role/enemy/NoWeaponEnemy.cs index 406dc9f..0c7ce65 100644 --- a/DungeonShooting_Godot/src/game/activity/role/enemy/NoWeaponEnemy.cs +++ b/DungeonShooting_Godot/src/game/activity/role/enemy/NoWeaponEnemy.cs @@ -16,17 +16,23 @@ public override void Attack() { - if (AnimatedSprite.Animation != AnimatorNames.Attack) + if (AnimationPlayer.CurrentAnimation != AnimatorNames.Attack) { - Debug.Log("attack..."); - AnimatedSprite.Play(AnimatorNames.Attack); + AnimationPlayer.Play(AnimatorNames.Attack); } } public void ShootBullet() { - var bulletData = FireManager.GetBulletData(this, FirePoint.GlobalPosition.AngleTo(LookTarget.Position), ExcelConfig.BulletBase_Map["0006"]); - FireManager.ShootBullet(bulletData, AttackLayer); + var targetPosition = LookTarget.GetCenterPosition(); + var bulletData = FireManager.GetBulletData(this, 0, ExcelConfig.BulletBase_Map["0006"]); + for (var i = 0; i < 8; i++) + { + var data = bulletData.Clone(); + var tempPos = new Vector2(targetPosition.X + Utils.Random.RandomRangeInt(-30, 30), targetPosition.Y + + Utils.Random.RandomRangeInt(-30, 30)); + FireManager.SetParabolaTarget(data, tempPos); + FireManager.ShootBullet(data, AttackLayer); + } } private void OnAnimationFinished(StringName name) diff --git a/DungeonShooting_Godot/src/game/data/BulletData.cs b/DungeonShooting_Godot/src/game/data/BulletData.cs index 1df47cc..a53fc26 100644 --- a/DungeonShooting_Godot/src/game/data/BulletData.cs +++ b/DungeonShooting_Godot/src/game/data/BulletData.cs @@ -5,7 +5,7 @@ /// /// 子弹数据 /// -public class BulletData +public class BulletData : IClone { /// /// 发射该子弹的武器, 可能为null @@ -76,4 +76,25 @@ /// 旋转角度 /// public float Rotation; + + public BulletData Clone() + { + return new BulletData + { + Weapon = Weapon, + BulletBase = BulletBase, + TriggerRole = TriggerRole, + Harm = Harm, + Repel = Repel, + MaxDistance = MaxDistance, + FlySpeed = FlySpeed, + Altitude = Altitude, + VerticalSpeed = VerticalSpeed, + BounceCount = BounceCount, + Penetration = Penetration, + LifeTime = LifeTime, + Position = Position, + Rotation = Rotation + }; + } } \ No newline at end of file diff --git a/DungeonShooting_Godot/src/game/manager/FireManager.cs b/DungeonShooting_Godot/src/game/manager/FireManager.cs index b7c50db..1a77262 100644 --- a/DungeonShooting_Godot/src/game/manager/FireManager.cs +++ b/DungeonShooting_Godot/src/game/manager/FireManager.cs @@ -78,6 +78,15 @@ return null; } + public static void SetParabolaTarget(BulletData bulletData, Vector2 targetPosition) + { + var distance = bulletData.Position.DistanceTo(targetPosition); + var height = bulletData.Altitude; + var time = distance / bulletData.FlySpeed; + bulletData.VerticalSpeed = -(height - 0.5f * GameConfig.G * time * time) / time; + bulletData.Rotation = bulletData.Position.AngleToPoint(targetPosition); + } + /// /// 通过武器发射子弹 ///