Exemplo n.º 1
0
    public void InitGame(LevelManager.LEVEL playingLevel)
    {
        //don't initiate the game if the game is already running!
        if (currState == State.Playing)
        {
            return;
        }

        // set the state
        currState = State.Playing;

        audioEnemyMovement.Play();

        // get level info
        LevelManager.LevelInfo lvlInfo = LevelManager.GetLevelInfo(playingLevel);

        // set current level to starting level
        currentLevel = playingLevel;

        // create enemy wave
        enemyManager.CreateEnemyWave(lvlInfo.enemyInXPos, lvlInfo.enemyInYPos, lvlInfo.enemyInZPos, lvlInfo.enemyMovingSpeedFactor, lvlInfo.enemySeparationSpacing);

        // update player lives in ui
        uiManager.updateLivesRemaining(player1.StartingTotalLives);

        // update current level in ui
        uiManager.updateLevelNumber((int)playingLevel + 1);

        // show text on the graffiti
        RefreshUI();
    }
Exemplo n.º 2
0
    // checks whether we've won, and if we did win, refresh UI
    public void HandleEnemyDead()
    {
        if (currState != State.Playing)
        {
            return;
        }

        // update player total score, accumulative/carry over across levels
        // TODO: scoring multiplier per level. E.g. Lv1, 1pt per enemy, Lv2, 2 pt per enemy, etc...
        this.player1.TotalScore++;

        RefreshUI();

        // have we won the game?
        if (enemyManager.numEnemies <= 0)
        {
            audioEnemyMovement.Stop();              // stop playing the enemy movement audio

            // get the next level
            currentLevel = LevelManager.GetNextLevel(currentLevel);

            // is this the last level?
            if (currentLevel == LevelManager.LEVEL.LEVEL_NULL)
            {
                // this is the last level, display congratulations message and add to leaderboard
                Debug.Log("YES YOU WIN!");

                // set the state of the game
                currState = State.WonGame;
            }
            else
            {
                currState = State.TransitionLevel;

                Debug.Log("Loading next level: " + currentLevel);
                this.InitGame(currentLevel);

                // remove all enemies
                if (removeAllEnemiesUponLevelTransition)
                {
                    enemyManager.KillAll();
                }
            }

            // show text on the graffiti
            RefreshUI();
        }
    }
Exemplo n.º 3
0
    /**
     * Reset the whole game
     */
    public void ResetGame()
    {
        Debug.Log("Game reset!");
        currState = State.NotStarted;

        // reset player score and total lives remains
        player1.ResetData();

        // clear all aliens on the field
        enemyManager.KillAll();

        // set starting level
        currentLevel = startingLevel;

        // hide any existing panel
        gameOverPanel.SetActive(false);

        // initialize game
        this.InitGame(currentLevel);
    }