using System; using System.Collections.Generic; using System.ComponentModel; using Godot; using Godot.Bridge; using Godot.NativeInterop; [ScriptPath("res://Scripts/Bullets/EraserSolo.cs")] public partial class EraserSolo : Node2D, IBullet { [Export(PropertyHint.None, "")] private float jump = 110f; [Export(PropertyHint.None, "")] private float time = 60f; [Export(PropertyHint.None, "")] private float variance = 15f; [Export(PropertyHint.None, "")] private float startDelay; [Export(PropertyHint.None, "")] private float jumpVariance = 15f; [Export(PropertyHint.None, "")] private bool alwaysRandom; private float cd; private float x; private bool first; private bool bouncing; private bool resetGraze; private Vector2 sp; private Vector2 tp; private Vector2 mp; private float floor; private float currentTime; private static readonly Vector2 bounceScale = new Vector2(1.5f, 0.5f); private static readonly Vector2 jumpScale = new Vector2(0.65f, 1.35f); private const float bounceTime = 10f; public bool grazed { get; set; } public Node2D node { get; set; } public Action onShot { get; set; } public AnimationPlayer anim { get; set; } public BulletGenerator generatedFrom { get; set; } [Export(PropertyHint.None, "")] public int HP { get; set; } = 1; [Export(PropertyHint.None, "")] public IBullet.Type type { get; set; } public override void _EnterTree() { x = DWMenu.instance.bulletBoard.Size.X / 2f - 10f; floor = DWMenu.instance.bulletBoard.Size.Y / 2f; sp = base.Position; tp = new Vector2(base.Position.X, floor); currentTime = time; } public override void _Process(double delta) { if (startDelay > 0f) { startDelay -= Main.deltaTime; return; } if (bouncing) { base.Scale = Vector2.One.Lerp(bounceScale, cd / 10f); if (cd >= 10f) { bouncing = false; cd = 0f; } } else { if (startDelay > -50f) { startDelay = -100f; } if (cd < currentTime) { if (cd < currentTime / 2f) { base.Scale = jumpScale.Lerp(Vector2.One, cd * 2f / currentTime); resetGraze = true; } else if (resetGraze) { grazed = false; resetGraze = false; } if (!first) { base.Position = sp.Lerp(tp, cd / currentTime); } else { base.Position = Common.Beizier(sp, mp, tp, cd / currentTime); } } else { sp = base.Position; if (alwaysRandom || Main.RandomRange(0, 10) < 3) { tp = new Vector2(Main.RandomRange(0f - x, x), floor); } else { tp = new Vector2(Mathf.Clamp(GetParent().ToLocal(DWMenu.instance.soulBody.GlobalPosition).X, 0f - x, x), floor); } mp = sp.Lerp(tp, 0.5f) + Vector2.Up * (jump + Main.RandomRange(0f, jumpVariance)); cd = 0f; currentTime = time + Main.RandomRange(0f, variance); first = true; Audio.PlaySound("snd_jump_ch1.wav"); bouncing = true; } } cd += Main.deltaTime; } }