2025-05-13 19:22:01 +08:00

109 lines
2.8 KiB
C#

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<BulletData> bullets = new List<BulletData>();
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<BulletData> list = bullets;
list[list.Count - 1].obj = BattleDR.NewBullet(in bullet[Main.RandomRange(0, bullet.Length - 1)], entity.GlobalPosition + Vector2.Up * 16f, this);
List<BulletData> list2 = bullets;
BulletData bulletData = list2[list2.Count - 1];
List<BulletData> list3 = bullets;
bulletData.scale = list3[list3.Count - 1].obj.Scale;
List<BulletData> list4 = bullets;
list4[list4.Count - 1].obj.Scale *= 0.5f;
List<BulletData> list5 = bullets;
BulletData bulletData2 = list5[list5.Count - 1];
List<BulletData> list6 = bullets;
bulletData2.startP = list6[list6.Count - 1].obj.GlobalPosition;
List<BulletData> list7 = bullets;
list7[list7.Count - 1].targetP = new Vector2(Main.RandomRange(0f - x, x), 0f);
List<BulletData> list8 = bullets;
BulletData bulletData3 = list8[list8.Count - 1];
List<BulletData> list9 = bullets;
float num = list9[list9.Count - 1].startP.X;
List<BulletData> list10 = bullets;
bulletData3.midP = new Vector2(Mathf.Lerp(num, list10[list10.Count - 1].targetP.X, 0.5f), BattleDR.current.activeBoard.boardSize.Y / 1.75f);
}
}