From 6cc79a5e3c7342d2118d17bae71bad1f36c02f5e Mon Sep 17 00:00:00 2001 From: rsxri Date: Wed, 23 Apr 2025 02:59:41 +0100 Subject: [PATCH] -feat: implement boss/ace wave logic --- MB_FYP/script/ai_fighter.cs | 2 +- MB_FYP/script/wavecontroller.cs | 23 ++++++++++++++++++++++- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/MB_FYP/script/ai_fighter.cs b/MB_FYP/script/ai_fighter.cs index 7de7491..0dcfc06 100644 --- a/MB_FYP/script/ai_fighter.cs +++ b/MB_FYP/script/ai_fighter.cs @@ -64,7 +64,7 @@ public partial class ai_fighter : ship return; } - private void UpdateHealthLabel(int health) + public void UpdateHealthLabel(int health) { _healthLabel.Text = health.ToString(); float percentage = (float)Health / MaxHealth; diff --git a/MB_FYP/script/wavecontroller.cs b/MB_FYP/script/wavecontroller.cs index d563721..829002c 100644 --- a/MB_FYP/script/wavecontroller.cs +++ b/MB_FYP/script/wavecontroller.cs @@ -73,7 +73,28 @@ public partial class wavecontroller : Node2D else if (CurrWave % 5 == 0) // ace/boss wave { - return; + // spawn enemies + + Random rand = new Random(); + + var spawn = _enemySpawns[rand.Next(0, 3)]; + + var enemy = _aiShipScene.Instantiate(); + enemy.Faction = ship.ShipFaction.ACE; + enemy.Type = (ship.ShipType)rand.Next(0, 3); + enemy.GlobalPosition = spawn.GlobalPosition; + enemy.StatModifier = (_aiStatModifier) * 1.2f; // make aces stronger + enemy.Scale = new Vector2(0.6f, 0.6f); + enemy.HitboxModifier = 1.3f; // make ace hitbox a bit bigger but smaller than regular enemies (balance) + _enemyNode.AddChild(enemy); + + enemy.MaxHealth += 400; // make aces health a bit higher + enemy.Health = enemy.MaxHealth; + enemy.UpdateHealthLabel(enemy.Health); + + _aiStatModifier += 0.1f; // increase ai stat modifier by 0.1f after an ace wave + if (_aiStatModifier >= 2f) _aiStatModifier = 2f; // cap ai stat modifier at 2f (10 ace waves) + } }