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

70 lines
1.8 KiB
C#

using System.Collections.Generic;
using System.ComponentModel;
using Godot;
using Godot.Bridge;
using Godot.NativeInterop;
[ScriptPath("res://Scripts/Bullets/AxisSpin.cs")]
public partial class AxisSpin : Node2D
{
[Export(PropertyHint.None, "")]
private Node2D[] bullet;
[Export(PropertyHint.None, "")]
private AudioStream sound;
private float cd = 30f;
private float current;
private int z;
private const float time = 150f;
private Entity entity;
public override void _EnterTree()
{
entity = BattleDR.current.enemies[0].entity;
entity.Modulate = Main.colorWhite;
entity.anim.Play("SpinAtk");
z = entity.ZIndex;
entity.ZIndex = 4000;
}
public override void _Process(double delta)
{
float s = Mathf.DegToRad(Mathf.Lerp(0f, 360f, current / 150f));
entity.GlobalPosition = entity.GlobalPosition.Lerp(base.GlobalPosition + new Vector2(Mathf.Cos(s) * BattleDR.current.activeBoard.boardSize.X, Mathf.Sin(s) * (BattleDR.current.activeBoard.boardSize.Y / 1.25f) + 20f), Main.deltaTime * 0.1f);
current = Main.Repeat(current + Main.deltaTime, 150f);
if (cd <= 0f)
{
Audio.PlaySound(sound, 1f, 1.1f);
for (int i = 0; i < 2; i++)
{
MoveAhead moveAhead = (MoveAhead)BattleDR.NewBullet(in bullet[Main.RandomRange(0, bullet.Length - 1)], entity.GlobalPosition + Vector2.Up * 16f, this);
if (i == 0)
{
moveAhead.speed = moveAhead.GlobalPosition.DirectionTo(BattleDR.current.soul.GlobalPosition) * 0.7f;
continue;
}
moveAhead.speed = Vector2.Up.Rotated(Mathf.DegToRad(Main.RandomRange(0, 360))) * 1f;
moveAhead.Scale *= 0.75f;
moveAhead.lifeTime *= 0.5f;
}
cd = Main.RandomRange(20, 40);
}
else
{
cd -= Main.deltaTime;
}
}
public override void _ExitTree()
{
entity.anim.Play("Idle");
entity.ZIndex = z;
}
}