using System.Collections; using System.Collections.Generic; using System.ComponentModel; using Godot; using Godot.Bridge; using Godot.NativeInterop; [ScriptPath("res://Scripts/Battle/AttackActionCommand.cs")] public partial class AttackActionCommand : Sprite2D { [Export(PropertyHint.None, "")] public Sprite2D bar; public Battlers linked; public static bool same; public bool active; private AttackActionCommand together; private const float speed = 2f; public static float actionCD; private static List all = new List(); private static List other = new List(); public const float dist = 15f; public const float missX = -45f; private static readonly Color bright = new Color(20f, 20f, 20f, 0f); private static readonly Color critical = new Color(1f, 20f, 1f, 0f); public override void _EnterTree() { base.Modulate = Main.instance.partyColors[linked.internalID]; bar.Position = new Vector2(Main.RandomRange(75, 150), 0f); } public override void _Process(double delta) { bar.Position += Vector2.Left * Main.deltaTime * 2f; if (bar.Position.X <= -45f) { Activate(); } } public void Activate() { if (!active) { active = true; Coroutine.Start(DoAttack()); base.ProcessMode = ProcessModeEnum.Disabled; } } private IEnumerator DoAttack() { linked.entity.anim.Play(); bool miss = !active || bar.Position.X >= 35f || bar.Position.X <= -45f; bool part = false; float p = 1f - Mathf.Clamp(Mathf.Abs(-28f - bar.Position.X), 0f, 60f) / 60f; if (actionCD <= 0f) { Audio.PlaySound("snd_laz_c_ch1.wav"); } if (p >= 0.9f) { if (actionCD <= 0f) { Audio.PlaySound("snd_criticalswing_ch1.wav"); } p *= 1.15f; } actionCD = 3f; for (float a = 0f; a < 15f; a += Main.deltaTime) { if (!miss) { bar.Scale = Vector2.One.Lerp(new Vector2(1.5f, 2f), a / 10f); } if (a >= 5f && !part) { if (linked.selectedAction[1] < BattleDR.current.enemies.Count) { Main.Particle("AttackShine", linked.atkPartOffset, 4086, linked.entity); Main.Particle(Party.party[linked.internalID].hitPart, BattleDR.current.enemies[linked.selectedAction[1]].GetCenter(), 4086, BattleDR.current.enemies[linked.selectedAction[1]].entity); } part = true; } bar.SelfModulate = Main.colorWhite.Lerp(miss ? Main.colorClear : ((p >= 0.9f) ? critical : bright), a / 15f); yield return null; } bar.Visible = false; if (linked.selectedAction[1] < BattleDR.current.enemies.Count) { BattleDR.current.DoDamage(linked, BattleDR.current.enemies[linked.selectedAction[1]], p, miss); } for (float a = 0f; a < 30f; a += Main.deltaTime) { yield return null; } linked.entity.currentAnim = Entity.Animations.BattleIdle; QueueFree(); } }