using System.Collections; using System.Collections.Generic; using System.ComponentModel; using Godot; using Godot.Bridge; using Godot.NativeInterop; [ScriptPath("res://Scripts/Bullets/DrillLaunch.cs")] public partial class DrillLaunch : Node2D { [Export(PropertyHint.None, "")] private Node2D drill; private Entity entity; private float cd = 30f; private float x; private Coroutine routine; private int z; private const float delay = 30f; public override void _EnterTree() { entity = BattleDR.current.activeBoard.caller.entity; entity.Modulate = Main.colorWhite; x = base.GlobalPosition.X + BattleDR.current.activeBoard.boardSize.X; z = entity.ZIndex; entity.ZIndex = 4000; } public override void _ExitTree() { entity.anim.Play("Idle"); entity.GlobalPosition = entity.startPos; Coroutine coroutine = routine; if (coroutine != null && !coroutine.done) { Coroutine.Stop(routine); } entity.anim.SpeedScale = 1f; entity.ZIndex = z; } public override void _Process(double delta) { Coroutine coroutine = routine; if (coroutine != null && !coroutine.done) { return; } if (cd > 0f) { entity.doTrail = true; cd -= Main.deltaTime; entity.GlobalPosition = entity.GlobalPosition.Lerp(new Vector2(x, BattleDR.current.soul.GlobalPosition.Y + 15f), Main.deltaTime * 0.15f); return; } entity.doTrail = false; if (BattleDR.current.activeBoard.timer > 30f) { routine = Coroutine.Start(Launch()); } cd = 30f; } private IEnumerator Launch() { entity.anim.SpeedScale = 2f; entity.anim.Play("Attack"); for (float i = 0f; i < 15f; i += Main.deltaTime) { yield return null; } Audio.PlaySound("snd_enemy_bullet_shot.wav", 0.9f, 0.8f); _ = (MoveAhead)BattleDR.NewBullet(in drill, entity.GlobalPosition + new Vector2(-20f, -15f), this); for (float i = 0f; i < 15f; i += Main.deltaTime) { yield return null; } entity.anim.SpeedScale = 1f; entity.anim.Play("Idle"); } }