Exemple #1
0
    // Update is called once per frame
    void Update()
    {
        //check whether a solution platform of the maze has been destroyed by comparing the newly destroyed platform with the solution array
        isSolutionDestroyed = initManager.getMazeSolution().Contains(this.destroyedPlatform);

        //check winning condition first
        //if the player has crossed the maze (canyon) and eliminate at least one platform belongs to the solution of maze, prompt win text
        if (player.transform.position.z >= mazeExit && isSolutionDestroyed)
        {
            winPrompt();
            //no further action can be perform after winning
            player.SetActive(false);
        }
        else
        {
            //losing condition check
            //if the player falls in the canyon
            if (player.transform.position.y <= canyonBottom)
            {
                losePrompt();
                //no further action can be perform after losing
                player.SetActive(false);
            }
            //if the player used all ammo in the map and not eliminated a solution platform
            else if (playerController.getAmmo() == 0 && playerController.getCollectedAmmo() == initManager.getTotalAmmo() && isSolutionDestroyed == false)
            {
                losePrompt();
                //no further action can be perform after losing
                player.SetActive(false);
            }
            //if the player eliminate a solution platform //(won't be able to get to the other side of canyon)
            else if (isSolutionDestroyed && player.transform.position.z < mazeExit)
            {
                losePrompt();
                //no further action can be perform after losing
                player.SetActive(false);
            }
        }
    }