Ejemplo n.º 1
0
 //Function called when the player or mirror object enters a collision with another object
 private void OnTriggerEnter(Collider other)
 {
     //if the object is the end cube and its in the tutorial, move to the next tutorial stage
     if (other.gameObject == endCube && gameObject.name == "Player" && gameManagerScr.tutorialCount < 3)
     {
         gameManagerScr.NextTutorialStage();
     }
     else if (other.gameObject == endCube && gameObject.name == "Player" && gameManagerScr.tutorialCount == 3)
     {
         //if the object is the end cube and the tutorial is finished then call next level
         gameManagerScr.bTutorialFinished = true; //bool to let other scripts know tutorial is finished
         gameManagerScr.OnLevelCompleted();
     }
     //if the object is a barrier
     if (other.gameObject.tag == "Barrier" && gameObject.tag == "Player")
     {
         bInCollision = true;                                               //lock used to only run code once per object
         if (gameManagerScr.shieldCount > 0 && !gameManagerScr.bInvincible) //if player has a shield active and isnt in invincible state
         {
             //play negative feedback sound
             gameManagerScr.FailedLevelSound();
             gameManagerScr.bInvincible = true;                         //set player and mirror to invincible state
             Invoke("ResetInvincibility", 2.0f);                        //start a timer to reset the invincibility after 2 seconds
             gameManagerScr.shieldCount--;                              //reduce players shield count by one
             gameManagerScr.UpdateScores();                             //update UI
             gameObject.GetComponent <Renderer>().material = shieldMat; //set objects material to invincible texture
             //apply material to opposite object also
             if (gameObject.name == "Player")
             {
                 otherMat = GameObject.Find("Mirror").GetComponent <Renderer>().material;
                 GameObject.Find("Mirror").GetComponent <Renderer>().material = shieldMat;
             }
             else
             {
                 otherMat = GameObject.Find("Player").GetComponent <Renderer>().material;
                 GameObject.Find("Player").GetComponent <Renderer>().material = shieldMat;
             }
         }
         else if (gameManagerScr.shieldCount <= 0 && !gameManagerScr.bInvincible) //if player doesn't have a shield available
         {
             gameManagerScr.OnLevelFailed();                                      //call level failed function to reset the level
         }
     }
     if (other.gameObject.tag == "Coin")                  //if the collision is with a coin object
     {
         gameManagerScr.CoinCollectSound();               //play coin collect sound
         other.GetComponent <Collider>().enabled = false; //turn the coins collider off to stop it triggering if it hits the other object on way to top UI
         StartCoroutine(DeleteCoin(other.gameObject));    //use co-routine to move, expand and then delete coin object
     }
 }
Ejemplo n.º 2
0
    //Function called when skip tutorial is clicked
    public void SkipTutorial()
    {
        //reports that the tutorial was skipped to analytics dashboard
        Analytics.CustomEvent("tutorialSkipped", new Dictionary <string, object> {
            { "skipped", true }
        });

        gameManagerScr.currentLevel      = 1;    //sets current level to level 1 to skip tutorial
        gameManagerScr.tutorialCount     = 3;    //sets variables as if tutorial has been completed
        gameManagerScr.coins            += 4;    //add extra coins that could have been earnt in tutorial
        gameManagerScr.bTutorialFinished = true; //set flag that tutorial is finished for other scripts
        gameManagerScr.OnLevelCompleted();       //call function to move to next level
        //play feedback sound if sound isn't already playing
        if (!mySound.isPlaying)
        {
            mySound.PlayOneShot(gameManagerScr.buttonClickSound, gameManagerScr.SFXVolume);
        }
    }