using System.Collections.Generic; using System.ComponentModel; using Godot; using Godot.Bridge; using Godot.NativeInterop; [ScriptPath("res://Scripts/Bullets/BellFall.cs")] public partial class BellFall : Node2D { [Export(PropertyHint.None, "")] private Node2D[] bullets; [Export(PropertyHint.None, "")] private AudioStream audio; [Export(PropertyHint.None, "")] private AudioStream hit; [Export(PropertyHint.None, "")] private float time = 50f; [Export(PropertyHint.None, "")] private float variance = 5f; [Export(PropertyHint.None, "")] private float pitchVar = 0.1f; [Export(PropertyHint.None, "")] private float playerChance = 20f; [Export(PropertyHint.None, "")] private float fallSpd = 0.8f; [Export(PropertyHint.None, "")] private int amt = 2; private List bulletObj = new List(); private float cd; private float limit; private float soundCD; public override void _EnterTree() { limit = BattleDR.current.activeBoard.boardSize.Y / 2f - 3f; } public override void _Process(double delta) { if (soundCD > 0f) { soundCD -= Main.deltaTime; } for (int num = bulletObj.Count - 1; num >= 0; num--) { bulletObj[num].Modulate = bulletObj[num].Modulate.Lerp(Main.colorWhite, Main.deltaTime * 0.25f); bulletObj[num].GlobalPosition += Vector2.Down * fallSpd * Main.deltaTime; if (bulletObj[num].Position.Y >= limit) { if (soundCD <= 0f) { Audio.PlaySound(hit); soundCD = 5f; } BattleDR.NewBullet(in bullets[1], new Vector2(bulletObj[num].GlobalPosition.X, limit + base.GlobalPosition.Y), this); bulletObj[num].QueueFree(); bulletObj.RemoveAt(num); } } if (cd > 0f) { cd -= Main.deltaTime; } else { if (!(BattleDR.current.activeBoard.timer > 10f)) { return; } cd = time + Main.RandomRange(0f - variance, variance); Audio.PlaySound(audio, 1f, 1f + Main.RandomRange(0f - pitchVar, pitchVar)); for (int i = 0; i < amt; i++) { Vector2 pos = new Vector2(0f, base.GlobalPosition.Y - 80f); int num2 = 0; do { pos = ((i != 0 || !(playerChance > 0f) || !((float)Main.RandomRange(0, 100) <= playerChance)) ? new Vector2(base.GlobalPosition.X + Main.RandomRange(0f - BattleDR.current.activeBoard.boardSize.X, BattleDR.current.activeBoard.boardSize.X) / 2.15f, pos.Y) : new Vector2(BattleDR.current.soul.GlobalPosition.X, pos.Y)); num2++; } while (AnyClose(pos.X) && num2 < 10); Blank blank = (Blank)BattleDR.NewBullet(in bullets[0], pos, this); blank.Modulate = Main.colorClear; bulletObj.Add(blank); } } } private bool AnyClose(float x) { for (int i = 0; i < bulletObj.Count; i++) { if (Mathf.Abs(x - bulletObj[i].GlobalPosition.X) < 15f) { return true; } } return false; } }