//when our player crosses the finish line we win and erase our lab if there are no more enemies
    private void OnTriggerEnter(Collider other)
    {
        if (other.tag == "Player")
        {
            if (!GameObject.Find("Enemy"))
            {
                YouWin = true;
                MazeScript.EraseLab();
            }

            else
            {
                Debug.Log("There are still enemies to be eliminated");
            }
        }
    }
Exemplo n.º 2
0
    private void Update()
    {
        //When we have a complete maze, we animate our UI Elements fading out and scale up our reset button
        if (MazeScript.MazeComplete)
        {
            UIAnimator.SetBool("UIFadeOut", true);

            //Make our UI Elements non interactable
            canvasGroup.interactable = false;

            LeanTween.scale(ResetButton, new Vector3(1.5f, 1.5f, 1.5f), 1f);
        }

        //If we reset the maze which means we didn't win and the maze is not complete we scale down the reset button
        else if (!MazeScript.MazeComplete && !VictoryScript.YouWin)
        {
            //Make our UI Elements interactable again
            canvasGroup.interactable = true;

            LeanTween.scale(ResetButton, new Vector3(0, 0, 0), 1f);
        }

        //If we win we scale up our victory text and the play again button and scale down the reset button
        if (VictoryScript.YouWin)
        {
            LeanTween.scale(VictoryText, new Vector3(1, 1, 1), 1f);
            LeanTween.scale(PlayAgainButton, new Vector3(1, 1, 1), 1f);

            LeanTween.scale(ResetButton, new Vector3(0, 0, 0), 1f);
        }

        //If we used the Hunt And Kill Algorithm we scale up the button that regenerates the maze using this Algorithm
        if (MazeScript.Regenerate_Hunt_And_Kill)
        {
            LeanTween.scale(Regenerate_Hunt_And_Kill, new Vector3(1.5f, 1.5f, 1.5f), 1f);
        }

        //If not then this button should be scaled down
        else
        {
            LeanTween.scale(Regenerate_Hunt_And_Kill, new Vector3(0, 0, 0), 1f);
        }

        //If we used the Aldous Broder Algorithm we scale up the button that regenerates the maze using this Algorithm
        if (MazeScript.Regenerate_Aldous_Broder)
        {
            LeanTween.scale(Regenerate_Aldous_Broder, new Vector3(1.5f, 1.5f, 1.5f), 1f);
        }

        //If not then this button should be scaled down
        else
        {
            LeanTween.scale(Regenerate_Aldous_Broder, new Vector3(0, 0, 0), 1f);
        }

        //if our maze is complete and we don't have our player
        if (MazeScript.MazeComplete && !player)
        {
            //start this coroutine which waits for our player to be instantiated before getting it's PlayerScript component
            StartCoroutine(WaitForPlayerInstantiate());
        }

        //now if we are playing and our player dies
        else if (MazeScript.MazeComplete && player.isDead)
        {
            //we delete the labirinth and reset the UI Elements
            MazeScript.EraseLab();
            SetAnimatorBoolToFalse();
        }

        else
        {
            return;
        }
    }