diff --git a/MB_FYP/script/Laser.cs b/MB_FYP/script/Laser.cs index 8e8b0e4..5ccf110 100644 --- a/MB_FYP/script/Laser.cs +++ b/MB_FYP/script/Laser.cs @@ -8,7 +8,7 @@ public partial class Laser : Area2D public ship Shooter; - public Vector2 MovementVector { get; set; } = new Vector2(0, -1); + private Vector2 MovementVector { get; set; } = new Vector2(0, -1); private void _on_visible_on_screen_notifier_2d_screen_exited() @@ -26,10 +26,9 @@ public partial class Laser : Area2D } private void OnAreaEntered(Area2D area) { - if (area is asteroid) + if (area is asteroid asteroid) { - asteroid a = (asteroid)area; - a.Explode(); + asteroid.Explode(); QueueFree(); } } @@ -56,7 +55,6 @@ public partial class Laser : Area2D { GD.Print("friendly fire"); QueueFree(); - return; // prevent friendly fire } else { diff --git a/MB_FYP/script/ai_fighter.cs b/MB_FYP/script/ai_fighter.cs index 734d96b..119e538 100644 --- a/MB_FYP/script/ai_fighter.cs +++ b/MB_FYP/script/ai_fighter.cs @@ -11,24 +11,24 @@ public partial class ai_fighter : ship [Export] public float EngageDistance = 300f; - private Label HealthLabel; - private Label HPLabel; + private Label _healthLabel; + private Label _hpLabel; //retreat logic - private float previousDistance = 0f; - private float stuckTime = 0f; - private const float stuckThreshold = 0.5f; - private const float distanceTolerance = 5f; + private float _previousDistance; + private float _stuckTime; + private const float StuckThreshold = 0.5f; + private const float DistanceTolerance = 5f; - private Node2D currentTarget; + private Node2D _currentTarget; public override void _Ready() { SetShipStats(); SetupVisual(); - Sprite.Texture = GD.Load(spritePath); + Sprite.Texture = GD.Load(SpritePath); - HealthLabel = GetNode