using System; using System.Collections.Generic; using System.ComponentModel; using Godot; using Godot.Bridge; using Godot.NativeInterop; [ScriptPath("res://Scripts/Bullets/BellCircleSwap.cs")] public partial class BellCircleSwap : Node2D { [Export(PropertyHint.None, "")] private MoveAhead bullet; [Export(PropertyHint.None, "")] private Blank hitbox; [Export(PropertyHint.None, "")] private AudioStream noise; [Export(PropertyHint.None, "")] private float time = 60f; [Export(PropertyHint.None, "")] private float variance = 5f; [Export(PropertyHint.None, "")] private float expansionRate = 1.025f; private Entity entity; private List bullets = new List(); private float cd; private float shotCD; private Vector2 offset; private bool alter; private bool anim; public override void _EnterTree() { entity = BattleDR.current.enemies[0].entity; hitbox.GlobalPosition = entity.GlobalPosition + new Vector2(0f, -32f); Blank blank = hitbox; blank.onShot = (Action)Delegate.Combine(blank.onShot, new Action(Shot)); offset = entity.GlobalPosition + new Vector2(0f, -40f); if (BattleDR.current.enemies[0].HPPercent() <= 0.5f || BattleDR.current.enemies[0].spare >= 50) { time = 45f; variance = 12f; } } public override void _Process(double delta) { for (int i = 0; i < bullets.Count; i++) { if (GodotObject.IsInstanceValid(bullets[i]) && !bullets[i].IsQueuedForDeletion()) { bullets[i].Scale *= expansionRate * Main.deltaTime; if (bullets[i].ProcessMode == ProcessModeEnum.Disabled) { bullets[i]._Process(delta); } } } if (shotCD > 0f) { shotCD -= Main.deltaTime; } if (cd > 0f) { cd -= Main.deltaTime; } else if (BattleDR.current.activeBoard.timer > 40f) { Audio.PlaySound(noise); bullets.RemoveAll((MoveAhead x) => !GodotObject.IsInstanceValid(x)); Node2D type = bullet; MoveAhead item = (MoveAhead)BattleDR.NewBullet(in type, offset, this); bullets.Add(item); if (alter) { Alter(item); } else { alter = !alter; } entity.anim.Play(anim ? "Ring1" : "Ring2"); anim = !anim; cd = time + Main.RandomRange(0f - variance, variance); } entity.Modulate = entity.Modulate.Lerp(Main.colorWhite, Main.deltaTime * 0.2f); } public void Shot(Node node) { if (shotCD > 0f) { return; } Audio.PlaySound(noise); entity.Modulate = Main.colorGlow; for (int i = 0; i < bullets.Count; i++) { if (GodotObject.IsInstanceValid(bullets[i])) { Alter(bullets[i]); } } } private void Alter(MoveAhead bullet) { if (bullet.ProcessMode == ProcessModeEnum.Inherit) { bullet.ProcessMode = ProcessModeEnum.Disabled; bullet.Modulate = Main.colorDark; } else { bullet.ProcessMode = ProcessModeEnum.Inherit; bullet.Modulate = Main.colorWhite; } alter = !alter; } public override void _ExitTree() { entity.Modulate = Main.colorWhite; } }