using System; using System.Collections.Generic; using System.ComponentModel; using Godot; using Godot.Bridge; using Godot.NativeInterop; [ScriptPath("res://Scripts/Bullets/BellShoot.cs")] public partial class BellShoot : Node2D { [Export(PropertyHint.None, "")] private MoveAhead bullet; [Export(PropertyHint.None, "")] private float time = 35f; [Export(PropertyHint.None, "")] private float variance = 8f; [Export(PropertyHint.None, "")] private float bulletSpeed = 0.9f; [Export(PropertyHint.None, "")] private AudioStream sound; private Entity entity; private Vector2 point; private Vector2 start; private float cd; private bool anim; private bool weak; public override void _EnterTree() { entity = BattleDR.current.enemies[0].entity; entity.Modulate = Main.colorWhite; start = entity.GlobalPosition; point = Vector2.Up * 40f; weak = BattleDR.current.enemies[0].HPPercent() <= 0.5f || BattleDR.current.enemies[0].spare >= 50; } public override void _Process(double delta) { entity.GlobalPosition = entity.GlobalPosition.Lerp(start + Vector2.Up * Common.SinOverTime(0.15f) * 70f, Main.deltaTime * 0.15f); if (cd > 0f) { cd -= Main.deltaTime; } else if (BattleDR.current.activeBoard.timer > 10f) { cd = time + Main.RandomRange(0f - variance, variance); entity.anim.Play(anim ? "Ring1" : "Ring2"); anim = !anim; Audio.PlaySound(sound); Vector2 pos = entity.GlobalPosition + point; Node2D type = bullet; MoveAhead moveAhead = (MoveAhead)BattleDR.NewBullet(in type, pos, this); moveAhead.speed = bulletSpeed * pos.DirectionTo(BattleDR.current.soul.GlobalPosition); moveAhead.LookAt(BattleDR.current.soul.GlobalPosition); moveAhead.RotationDegrees += 180f; moveAhead.onShot = (Action)Delegate.Combine(moveAhead.onShot, new Action(Shot)); if (weak && Main.RandomRange(0, 100) <= 30) { moveAhead.Modulate = Main.colorWhite; moveAhead.type = IBullet.Type.Normal; } } } public void Shot(Node node) { IBullet bullet = (IBullet)node; if (bullet.HP > 0) { node.GetChild(3).GetChild(0).QueueFree(); Main.SetActive(node.GetChild(2 - bullet.HP), state: false); } } }