예제 #1
0
    // Check If Game Meets certain rule trigger
    void Update()
    {
        if (remainTimeOfLevel > 0 && waveSpawner.timeBeforeFirstWave <= 0 && controller.getGameState() == GameState.Running)
        {
            remainTimeOfLevel -= Time.deltaTime;
            controller.updateCountDownUI("Level Remain Time: " + remainTimeOfLevel.ToString("F1") + "s");
        }
        //Win Condition 1: Level Time finish && alive
        //Critical Condition: When current star == 0 and ramain time == 0 is satisfied at the same time, consider as winning.
        else if (remainTimeOfLevel <= 0 && controller.getCurrentStar() >= 0)
        {
            controller.updateCountDownUI("");
            controller.endGame();
        }

        //Win Condition 2: All Waves finished spawning, All Enemy killed, User Health more than 0
        if (waveSpawner.waveFinish() && enemyFactory.allSpriteRecycled() && controller.getCurrentStar() > 0)
        {
            controller.updateCountDownUI("");
            controller.endGame();
        }
        //Fail Condition: User Health equal to 0
        else if (controller.getCurrentStar() == 0)
        {
            controller.updateCountDownUI("");
            controller.failGame();
        }
    }
예제 #2
0
    public void endGame()
    {
        enemySpawner.SetActive(false);
        GameMenu.SetActive(false);
        SummaryGUI.SetActive(true);

        //Calculate Level End Reward
        int stars = gameSceneController.getCurrentStar();

        if (stars == 3)
        {
            fm.increaseMoney(1000);
        }
        else if (stars == 2)
        {
            fm.increaseMoney(400);
        }
        else if (stars == 1)
        {
            fm.increaseMoney(250);
        }

        //Persist balance into global
        data.balance = fm.getBalance();
    }
예제 #3
0
    public void endGame()
    {
        enemySpawner.SetActive(false);
        GameMenu.SetActive(false);
        SummaryGUI.SetActive(true);

        //Calculate Level End Reward
        int stars = gameSceneController.getCurrentStar();

        //TODO: [?] Determine if the player should be rewarded with/or without previous star count?

        if (stars == 3)
        {
            fm.increaseMoney(1000);
        }
        else if (stars == 2)
        {
            fm.increaseMoney(400);
        }
        else if (stars == 1)
        {
            fm.increaseMoney(250);
        }

        //Persist balance into global
        data.balance = fm.getBalance();
        //Persist stars into global
        data.LevelStar[level] = stars;
    }