Example #1
0
    public override async void _Ready()
    {
        _crystal        = GetNode <Character>("Crystal");
        _waveSpawner    = GetNode <WaveSpawner>("WaveSpawner");
        _enemyContainer = _waveSpawner.GetEnemyContainer();
        _moneyNode      = GetNode <MoneyNode>("Hud/Money");
        _global         = GetTree().Root.GetNode <Global>("Global");
        _sceneChanger   = GetTree().Root.GetNode <SceneChanger>("SceneChanger");
        _jumpScreen     = GetNode <JumpScreen>("JumpScreen");
        _fireworks      = GetNode <Fireworks>("Fireworks");
        _deathScreen    = GetNode <DeathScreen>("DeathScreen");
        _musicPlayer    = GetNode <BattleGroundMusicPlayer>("BattleGroundMusicPlayer");

        _enemyContainer.Connect(nameof(EnemyContainer.Updated), this, nameof(_OnEnemyContainerUpdated));
        _enemyContainer.Connect(nameof(EnemyContainer.EnemyDeath), this, nameof(_OnEnemyDeath));

        _stateMachine     = new StateMachine();
        PauseState        = new PauseState(this, _stateMachine);
        PlayerAttackState = new PlayerAttackState(this, _stateMachine);

        _stateMachine.Initialize(PlayerAttackState);

        _jumpScreen.EnterAnimation();
        await ToSignal(_jumpScreen, nameof(JumpScreen.AnimationFinished));

        foreach (var effect in GetNode <HBoxContainer>("Hud/Effects").GetChildren())
        {
            (effect as Effect).Init(this);
        }

        Start(3, _global.Level);
    }
Example #2
0
    public override void _Ready()
    {
        _stateMachine = new StateMachine();
        _menuState    = new MenuState(this, _stateMachine);
        _storeState   = new StoreState(this, _stateMachine);
        _sceneChanger = GetTree().Root.GetNode <SceneChanger>("SceneChanger");

        _levelLabel = GetNode <Label>("MenuPanel/Level");
        _global     = GetTree().Root.GetNode <Global>("Global");
        _jumpScreen = GetNode <JumpScreen>("JumpScreen");

        _stateMachine.Initialize(_menuState);
        UpdateView();

        _jumpScreen.EnterAnimation();
    }