Ejemplo n.º 1
0
    void LoadLevel(string levelName)
    {
        CleanupLevel();

        LevelDesc = LevelLoader.GetLevel(levelName);
        LevelLoader.LoadAndValidateLevel(LevelDesc);
        GameObjectFactory.Initialize(LevelDesc);
        Waves       = new WaveManager(LevelDesc);
        Turrets     = new TurretManager(LevelDesc);
        Projectiles = new ProjectileManager(LevelDesc);
        Utilities.Log("Creating road objects");
        GameObjectFactory.CreateMapObjects(LevelDesc);
        InitializeGameplayUISettings();

        Coin            = LevelDesc.StartingCoins;
        LivesRemaining  = LevelDesc.Lives;
        GameTime        = 0.0F;
        LastMissileTime = 0.0F;

        CountdownStartTime = GameTime;
        State = LevelState.WaveCountdown;
        Waves.AdvanceToNextWave(GameTime);
        ShowHUDUI();
        ShowCountdownUI();
    }
Ejemplo n.º 2
0
    void TickGameplay()
    {
        Waves.CurrentWave.Advance(GameTime);
        Coin           += Waves.CurrentWave.ReportCoinEarned();
        LivesRemaining -= Waves.CurrentWave.ReportLivesLost();

        Projectiles.AdvanceAll(GameTime);

        Turrets.Fire(GameTime);

        if (Waves.IsComplete)
        {
            OnLevelComplete();
        }
        else if (Waves.CurrentWave.IsCompleted)
        {
            Utilities.Log("State ==> WaveCountdown");
            ShowCountdownUI();
            Waves.AdvanceToNextWave(GameTime);
            State = LevelState.WaveCountdown;
            CountdownStartTime = GameTime;
        }

        if (null != Pointer.Hitting)
        {
            GameObject go = Pointer.Hitting;
            if (go.name.StartsWith("TurretSpace"))
            {
                TurretInstance turret = Turrets.GetTurretAtPosition(GameObjectFactory.WorldVec3ToMapPos(go.transform.position));

                if (null != turret)
                {
                    go = turret.go;
                }
            }

            GameplayUI.CursorOver(go);
        }

        bool value = false;

        if (Pointer.State.ButtonDown.TryGetValue(InputState.InputIntent.Selection, out value) && value)
        {
            GameplayUI.TriggerSelectAction();
        }
        if (Pointer.State.ButtonDown.TryGetValue(InputState.InputIntent.MissileTrigger, out value) && value)
        {
            ProcessMissileTrigger();
        }


        UpdateHUD();
    }