Exemple #1
0
    private void StartGame()
    {
        //Reset score
        score          = 0;
        scoreText.text = score.ToString();

        //Find gamemode script
        GameObject          audioControllerMain       = GameObject.Find("AudioControllerMain");
        AudioControllerMain audioControllerMainScript = audioControllerMain.GetComponent <AudioControllerMain>();

        //Play starting music
        audioControllerMainScript.playingMML = true;

        //Set death to false
        playerLost = false;

        //Reset player's powision to middle of area
        transform.position = new Vector2(0, 5);

        //Setting values to default starting value
        timeRemaining      = maxTime;
        timeBar.fillAmount = 1;

        sprintTime = sprintMaxTime;

        //Set start text to nothing
        deathText.text = "";

        //Set speech bubble to visible
        speechBubble.SetActive(true);

        //Call functions
        Think();
        ResetTurnCount();

        //Set values to 0
        turnCountEast  = 0;
        turnCountNorth = 0;
        turnCountWest  = 0;
        turnCountSouth = 0;

        //Set blockades to false
        eastBlockade.SetActive(false);
        northBlockade.SetActive(false);
        westBlockade.SetActive(false);
        southBlockade.SetActive(false);
    }
Exemple #2
0
    void SetLose()
    {
        //Find gamemode script
        GameObject gamemode       = GameObject.Find("Gamemode");
        Gamemode   gamemodeScript = gamemode.GetComponent <Gamemode>();

        //Sets screen text
        gamemodeScript.winCondition = false;
        gamemodeScript.SetRoundEnd();

        //Find Audio script
        GameObject          audioControllerMain       = GameObject.Find("AudioControllerMain");
        AudioControllerMain audioControllerMainScript = audioControllerMain.GetComponent <AudioControllerMain>();

        //Play correct path Audio
        audioControllerMainScript.pathWrong.pitch = Random.Range(.9f, 1.1f);
        audioControllerMainScript.pathWrong.Play();
    }
    // Update is called once per frame
    void Update()
    {
        if (playingMM && flag == false)
        {
            Playing();
        }

        if (playingMM == false)
        {
            flag = false;
            musicStart.enabled = false;
        }

        if (!musicStart.isPlaying)
        {
            //Find gamemode script
            GameObject          audioControllerMain       = GameObject.Find("AudioControllerMain");
            AudioControllerMain audioControllerMainScript = audioControllerMain.GetComponent <AudioControllerMain>();

            audioControllerMainScript.playingMML = true;
        }
    }
Exemple #4
0
    IEnumerator SetWin()
    {
        //Find gamemode script
        GameObject gamemode       = GameObject.Find("Gamemode");
        Gamemode   gamemodeScript = gamemode.GetComponent <Gamemode>();

        //Sets screen text
        gamemodeScript.winCondition = true;
        gamemodeScript.SetRoundEnd();

        //Find Audio script
        GameObject          audioControllerMain       = GameObject.Find("AudioControllerMain");
        AudioControllerMain audioControllerMainScript = audioControllerMain.GetComponent <AudioControllerMain>();

        //Play correct path Audio
        audioControllerMainScript.pathCorrect.pitch = Random.Range(.9f, 1.1f);
        audioControllerMainScript.pathCorrect.Play();

        yield return(new WaitForSeconds(0.1f));

        //Enemy thinks of new wrong answer
        gamemodeScript.Think();
    }
Exemple #5
0
    private void Update()
    {
        //If the player presses space
        if (Input.GetKeyDown("space") && playerLost)
        {
            player = GameObject.Find("Player");
            player.transform.position = new Vector2(-0.5f, 6f);

            //Find Audio script
            GameObject          audioControllerMain       = GameObject.Find("AudioControllerMain");
            AudioControllerMain audioControllerMainScript = audioControllerMain.GetComponent <AudioControllerMain>();

            //Play correct path Audio
            audioControllerMainScript.startGame.Play();

            //Call function
            StartGame();
        }

        //If player is not lost and still has sprint bar, deplete it
        if (!playerLost && Input.GetKey(KeyCode.LeftShift) && sprintTime > 0)
        {
            //time remaining decreases over time
            sprintTime -= sprintHoldBack;

            sprintBar.fillAmount = sprintTime;

            Player playerScript = player.GetComponent <Player>();
            playerScript.playerSpeed = playerScript.sprintSpeed;
        }

        if (!playerLost && sprintTime <= 0)
        {
            Player playerScript = player.GetComponent <Player>();
            playerScript.playerSpeed = playerScript.walkSpeed;
        }

        //If player presses escape, quit the game
        if (Input.GetKeyDown("escape"))
        {
            Application.Quit();
        }

        //If the player presses r, reset the highscore
        if (Input.GetKeyDown("r"))
        {
            PlayerPrefs.DeleteKey("HighScore");
            highScoreText.text = "Highscore 0";
        }

        //If the time is above 0, decrease it continuesly

        if (timeRemaining >= 0 && !playerLost)
        {
            //time remaining decreases over time
            timeRemaining -= Time.deltaTime * difficulty;

            timeBar.fillAmount = timeRemaining / 10;
        }

        //If timer gets to 0, play death SFX
        // & trigger gameover function
        if (timeRemaining <= 0)
        {
            //call function
            GameOver();
        }

        if (!playerLost)
        {
            highScoreText.text = "".ToString();
        }
    }
Exemple #6
0
    void IncreaseTurnCount()
    {
        //If east blockade is active, increase turncounteast count by 1
        if (eastBlockade.activeSelf)
        {
            turnCountEast++;

            //Call function to start blockade timer
            BlockadeTimer();
        }

        //If north blockade is active, increase turncounteast count by 1
        if (northBlockade.activeSelf)
        {
            turnCountNorth++;

            //Call function to start blockade timer
            BlockadeTimer();
        }

        //If west blockade is active, increase turncounteast count by 1
        if (westBlockade.activeSelf)
        {
            turnCountWest++;

            //Call function to start blockade timer
            BlockadeTimer();
        }

        //If south blockade is active, increase turncounteast count by 1
        if (southBlockade.activeSelf)
        {
            turnCountSouth++;

            //Call function to start blockade timer
            BlockadeTimer();
        }

        //Disable the images for turns left for East path
        if (blockEastCount == 1)
        {
            eastBlock1.SetActive(true);
            eastBlock2.SetActive(false);
            eastBlock3.SetActive(false);
        }

        if (blockEastCount == 2)
        {
            eastBlock2.SetActive(true);
            eastBlock1.SetActive(false);
            eastBlock3.SetActive(false);
        }

        if (blockEastCount == 3)
        {
            if (playedOnceE == false)
            {
                playedOnceE = true;

                //Find gamemode script
                GameObject          audioControllerMain       = GameObject.Find("AudioControllerMain");
                AudioControllerMain audioControllerMainScript = audioControllerMain.GetComponent <AudioControllerMain>();

                //Play audio for block up
                audioControllerMainScript.blockSpawn.Play();
            }

            eastBlock3.SetActive(true);
            eastBlock1.SetActive(false);
            eastBlock2.SetActive(false);
        }

        //Disable the images for turns left for North path
        if (blockNorthCount == 1)
        {
            northBlock1.SetActive(true);
            northBlock2.SetActive(false);
            northBlock3.SetActive(false);
        }

        if (blockNorthCount == 2)
        {
            northBlock2.SetActive(true);
            northBlock1.SetActive(false);
            northBlock3.SetActive(false);
        }

        if (blockNorthCount == 3)
        {
            if (playedOnceN == false)
            {
                playedOnceN = true;

                //Find gamemode script
                GameObject          audioControllerMain       = GameObject.Find("AudioControllerMain");
                AudioControllerMain audioControllerMainScript = audioControllerMain.GetComponent <AudioControllerMain>();

                //Play audio for block up
                audioControllerMainScript.blockSpawn.Play();
            }

            northBlock3.SetActive(true);
            northBlock1.SetActive(false);
            northBlock2.SetActive(false);
        }

        //Disable the images for turns left for West path
        if (blockWestCount == 1)
        {
            westBlock1.SetActive(true);
            westBlock2.SetActive(false);
            westBlock3.SetActive(false);
        }

        if (blockWestCount == 2)
        {
            westBlock2.SetActive(true);
            westBlock1.SetActive(false);
            westBlock3.SetActive(false);
        }

        if (blockWestCount == 3)
        {
            if (playedOnceW == false)
            {
                playedOnceW = true;

                //Find gamemode script
                GameObject          audioControllerMain       = GameObject.Find("AudioControllerMain");
                AudioControllerMain audioControllerMainScript = audioControllerMain.GetComponent <AudioControllerMain>();

                //Play audio for block up
                audioControllerMainScript.blockSpawn.Play();
            }

            westBlock3.SetActive(true);
            westBlock1.SetActive(false);
            westBlock2.SetActive(false);
        }

        //Disable the images for turns left for South path
        if (blockSouthCount == 1)
        {
            southBlock1.SetActive(true);
            southBlock2.SetActive(false);
            southBlock3.SetActive(false);
        }

        if (blockSouthCount == 2)
        {
            southBlock2.SetActive(true);
            southBlock1.SetActive(false);
            southBlock3.SetActive(false);
        }

        if (blockSouthCount == 3)
        {
            if (playedOnceS == false)
            {
                playedOnceS = true;

                //Find gamemode script
                GameObject          audioControllerMain       = GameObject.Find("AudioControllerMain");
                AudioControllerMain audioControllerMainScript = audioControllerMain.GetComponent <AudioControllerMain>();

                //Play audio for block up
                audioControllerMainScript.blockSpawn.Play();
            }

            southBlock3.SetActive(true);
            southBlock1.SetActive(false);
            southBlock2.SetActive(false);
        }

        //Call function
        //ResetTurnCount();
    }
Exemple #7
0
    //When the player chooses successfully
    IEnumerator ScoreUp()
    {
        //Set sprintbar to full
        sprintTime           = sprintMaxTime;
        sprintBar.fillAmount = 1f;

        //Set timebar to full
        timeRemaining = maxTime;

        //Increase difficulty
        difficulty += .25f;

        yield return(new WaitForSeconds(.1f));

        //Turns to wait until specific blockade goes down if it's active
        if (turnCountEast == turnCountMax && eastBlockade.activeSelf)
        {
            //Minus 1 block count due to one blockade despawning
            blockCount--;

            eastBlockade.SetActive(false);
            turnCountEast  = 0;
            blockEastCount = 0;

            //Reset variable
            playedOnceE = false;

            //Find gamemode script
            GameObject          audioControllerMain       = GameObject.Find("AudioControllerMain");
            AudioControllerMain audioControllerMainScript = audioControllerMain.GetComponent <AudioControllerMain>();

            //Play block over audio
            audioControllerMainScript.blockOver.Play();

            //Call function to reset East Path blockades
            ResetEastPath();

            /*if (northBlockade.activeSelf)
             * {
             *  northBlockade.SetActive(false);
             *  turnCountNorth = 0;
             *  blockNorthCount = 0;
             *
             *  if (westBlockade.activeSelf)
             *  {
             *      westBlockade.SetActive(false);
             *      turnCountWest = 0;
             *      blockWestCount = 0;
             *
             *      if (southBlockade.activeSelf)
             *      {
             *          southBlockade.SetActive(false);
             *          turnCountSouth = 0;
             *          blockSouthCount = 0;
             *      }
             *  }
             * } */
        }

        if (turnCountNorth == turnCountMax && northBlockade.activeSelf)
        {
            //Minus 1 block count due to one blockade despawning
            blockCount--;

            northBlockade.SetActive(false);
            turnCountNorth  = 0;
            blockNorthCount = 0;

            //Reset variable
            playedOnceN = false;

            //Find gamemode script
            GameObject          audioControllerMain       = GameObject.Find("AudioControllerMain");
            AudioControllerMain audioControllerMainScript = audioControllerMain.GetComponent <AudioControllerMain>();

            //Play block over audio

            audioControllerMainScript.blockOver.Play();
            //Call function to reset North Path blockades
            ResetNorthPath();

            /* if (eastBlockade.activeSelf)
             * {
             *  eastBlockade.SetActive(false);
             *  turnCountEast = 0;
             *  blockEastCount = 0;
             *
             *  if (westBlockade.activeSelf)
             *  {
             *      westBlockade.SetActive(false);
             *      turnCountWest = 0;
             *      blockWestCount = 0;
             *
             *      if (southBlockade.activeSelf)
             *      {
             *          southBlockade.SetActive(false);
             *          turnCountSouth = 0;
             *          blockSouthCount = 0;
             *      }
             *  }
             * } */
        }

        if (turnCountWest == turnCountMax && westBlockade.activeSelf)
        {
            //Minus 1 block count due to one blockade despawning
            blockCount--;

            westBlockade.SetActive(false);
            turnCountWest  = 0;
            blockWestCount = 0;

            //Reset variable
            playedOnceW = false;

            //Find gamemode script
            GameObject          audioControllerMain       = GameObject.Find("AudioControllerMain");
            AudioControllerMain audioControllerMainScript = audioControllerMain.GetComponent <AudioControllerMain>();

            //Play block over audio

            audioControllerMainScript.blockOver.Play();
            //Call function to reset West Path blockades
            ResetWestPath();

            /* if (northBlockade.activeSelf)
             * {
             *  northBlockade.SetActive(false);
             *  turnCountNorth = 0;
             *  blockNorthCount = 0;
             *
             *  if (eastBlockade.activeSelf)
             *  {
             *      eastBlockade.SetActive(false);
             *      turnCountEast = 0;
             *      blockEastCount = 0;
             *
             *      if (southBlockade.activeSelf)
             *      {
             *          southBlockade.SetActive(false);
             *          turnCountSouth = 0;
             *          blockSouthCount = 0;
             *      }
             *  }
             * } */
        }

        if (turnCountSouth == turnCountMax && southBlockade.activeSelf)
        {
            //Minus 1 block count due to one blockade despawning
            blockCount--;

            southBlockade.SetActive(false);
            turnCountSouth  = 0;
            blockSouthCount = 0;

            //Reset variable
            playedOnceS = false;

            //Find gamemode script
            GameObject          audioControllerMain       = GameObject.Find("AudioControllerMain");
            AudioControllerMain audioControllerMainScript = audioControllerMain.GetComponent <AudioControllerMain>();

            //Play block over audio
            audioControllerMainScript.blockOver.Play();

            //Call function to reset South Path blockades
            ResetSouthPath();

            /* if (northBlockade.activeSelf)
             * {
             * northBlockade.SetActive(false);
             * turnCountNorth = 0;
             * blockNorthCount = 0;
             *
             * if (westBlockade.activeSelf)
             * {
             *     westBlockade.SetActive(false);
             *     turnCountWest = 0;
             *     blockWestCount = 0;
             *
             *     if (eastBlockade.activeSelf)
             *     {
             *         eastBlockade.SetActive(false);
             *         turnCountEast = 0;
             *         blockEastCount = 0;
             *     }
             * }
             * } */
        }
    }