using System.Collections.Generic; using System.ComponentModel; using Godot; using Godot.Bridge; using Godot.NativeInterop; [ScriptPath("res://Scripts/Bullets/AxisSmoke.cs")] public partial class AxisSmoke : Node2D { public partial class BulletData { public Node2D obj; public float time; public Vector2 startP; public Vector2 targetP; public Vector2 midP; public Vector2 scale; public const float bulTime = 80f; } [Export(PropertyHint.None, "")] private Node2D[] bullet; [Export(PropertyHint.None, "")] private float delay = 20f; [Export(PropertyHint.None, "")] private AudioStream sound; private List bullets = new List(); private float cd; private float x; private Entity entity; public override void _EnterTree() { entity = BattleDR.current.enemies[0].entity; entity.Modulate = Main.colorWhite; x = BattleDR.current.activeBoard.boardSize.X / 2.15f; entity.anim.Play("SpinAtk"); } public override void _ExitTree() { entity.anim.Play("Idle"); } public override void _Process(double delta) { if (bullets.Count > 0) { for (int i = 0; i < bullets.Count; i++) { bullets[i].time += Main.deltaTime; if (bullets[i].time <= 80f) { bullets[i].obj.Scale = bullets[i].obj.Scale.Lerp(bullets[i].scale, Main.deltaTime * 0.1f); bullets[i].obj.GlobalPosition = Common.Beizier(bullets[i].startP, bullets[i].midP, bullets[i].targetP, Mathf.SmoothStep(0f, 1f, bullets[i].time / 80f)); } else { bullets[i].obj.GlobalPosition += Vector2.Up * Main.deltaTime; } } } if (cd > 0f) { cd -= Main.deltaTime; return; } cd = delay; if (sound != null) { Audio.PlaySound(sound); } bullets.Add(new BulletData()); List list = bullets; list[list.Count - 1].obj = BattleDR.NewBullet(in bullet[Main.RandomRange(0, bullet.Length - 1)], entity.GlobalPosition + Vector2.Up * 16f, this); List list2 = bullets; BulletData bulletData = list2[list2.Count - 1]; List list3 = bullets; bulletData.scale = list3[list3.Count - 1].obj.Scale; List list4 = bullets; list4[list4.Count - 1].obj.Scale *= 0.5f; List list5 = bullets; BulletData bulletData2 = list5[list5.Count - 1]; List list6 = bullets; bulletData2.startP = list6[list6.Count - 1].obj.GlobalPosition; List list7 = bullets; list7[list7.Count - 1].targetP = new Vector2(Main.RandomRange(0f - x, x), 0f); List list8 = bullets; BulletData bulletData3 = list8[list8.Count - 1]; List list9 = bullets; float num = list9[list9.Count - 1].startP.X; List list10 = bullets; bulletData3.midP = new Vector2(Mathf.Lerp(num, list10[list10.Count - 1].targetP.X, 0.5f), BattleDR.current.activeBoard.boardSize.Y / 1.75f); } }