示例#1
0
文件: Game.cs 项目: theowiik/tdws
        public override void _Ready()
        {
            _crosshair = GetNode <Sprite>("Crosshair");
            _hud       = GetNode <HUD>("CanvasLayer/HUD");

            // Hide the cursor
            Input.SetMouseMode(Input.MouseMode.Hidden);

            // Player
            SpawnPlayer();
            _player.AddChild(_camera);

            // HUD
            _player.Connect(nameof(AbstractActor.HealthChanged), _hud, nameof(HUD.HealthChanged));
            _player.Connect(nameof(AbstractActor.ChatAdded), _hud, nameof(HUD.AddChat));

            // Coins
            _player.Connect(nameof(AbstractActor.CoinDropped), this, nameof(OnCoinDropped));
            _player.Connect(nameof(AbstractActor.CoinsChanged), _hud, nameof(HUD.OnCoinsChanged));
            _coinScene = NodeService.LoadNotNull <PackedScene>("res://Scenes/Objects/Coin.tscn");

            // Projectile signal
            _player.Connect(nameof(Player.ProjectileShooterChanged), this, nameof(OnProjectileShooterChanged));

            // Room loader
            _roomLoader = GetNode <RoomLoader>("RoomLoader");
            _roomLoader.SetPlayer(_player);
            // _roomLoader
            NextRoom();

            SpawnBoss();
        }