using System; using System.Collections.Generic; using System.Linq; using Godot; using RogueTank.Actors; using RogueTank.Combat; using RogueTank.Upgrades; using RogueTank.Util; using RogueTank.World; namespace RogueTank; public partial class Game : Node2D { private static readonly Vector2 ArenaHalfSize = new(250, 150); // Scene roots private Node2D _world = null!; private Node2D _arena = null!; private Node2D _actors = null!; private Node2D _projectiles = null!; private Node2D _pickups = null!; private Camera2D _camera = null!; // UI private Label _hpLabel = null!; private Label _levelLabel = null!; private Label _coinLabel = null!; private Label _waveLabel = null!; private Label _hintLabel = null!; private Control _pauseOverlay = null!; private Button _resumeBtn = null!; private Button _restartBtn = null!; private Control _upgradeOverlay = null!; private Button _up1 = null!; private Button _up2 = null!; private Button _up3 = null!; private Control _gameOverOverlay = null!; private Label _gameOverStats = null!; private Button _gameOverRestartBtn = null!; // Gameplay private PlayerTank? _player; private readonly PackedScene _bulletScene; private readonly PackedScene _enemyScene; private readonly PackedScene _pickupScene; private readonly RandomNumberGenerator _rng = new(); private int _wave = 1; private int _enemiesAlive; private bool _paused; private bool _choosingUpgrade; private string _lastDebug = ""; private int _shotsFired; private readonly List _currentChoices = new(); public Game() { _bulletScene = MakeBulletScene(); _enemyScene = MakeEnemyScene(); _pickupScene = MakePickupScene(); } public override void _Ready() { _rng.Randomize(); // IMPORTANT: "WhenPaused" will prevent the game from processing during normal gameplay. // Keep the game running normally; only the UI should keep processing while paused. ProcessMode = ProcessModeEnum.Pausable; // Safety: ensure we start unpaused (some editor/debug states can leave the tree paused). GetTree().Paused = false; _world = GetNode("World"); _arena = GetNode("World/Arena"); _actors = GetNode("World/Actors"); _projectiles = GetNode("World/Projectiles"); _pickups = GetNode("World/Pickups"); _camera = GetNode("World/Camera2D"); var canvas = GetNode("CanvasLayer"); canvas.ProcessMode = ProcessModeEnum.WhenPaused; GetNode("CanvasLayer/HUD").ProcessMode = ProcessModeEnum.WhenPaused; _hpLabel = GetNode