Example #1
0
 //Called before any other function
 void Awake()
 {
     //If reloads the trial, reinitialize the variables
     if (UsefulFunctions.current_trial > 0)
     {
         ReinitializeVariables();
     }
     //Increase trial counter
     UsefulFunctions.old_trial = UsefulFunctions.current_trial;
     UsefulFunctions.sameTrial = false;
     UsefulFunctions.current_trial++;
     ShorterFunctions.levelCount++;
     //Player settings
     player.SetActive(true);
     //player.GetComponent<CharacterController>().enabled = false;
     //player.GetComponent<MouseLook>().enabled = false;
     Debug.Log("Activate player prefab");
     //Randomize gem position and assign it to the variable
     UsefulFunctions.isShorterVersion = true;
     collectObj = UsefulFunctions.RandomizeGem(gems);
     ShorterFunctions.RandomizeGemPosition(collectObj, randomPositions);
     ShorterFunctions.SaveMainInfo(player); //Saves player and treasure position
     //Randomize number of collectable obj
     menu_score = 1;
     //Update score and gems UI
     gems_info.text = "GEMS: " + score.ToString() + "/" + menu_score.ToString();
     if (UsefulFunctions.current_trial == 0 || UsefulFunctions.current_trial == 1)
     {
         score_gained.text = "0";
     }
     else
     {
         score_gained.text = PlayerPrefs.GetString("Score");
     }
     startTrial     = true;
     showFeedback   = false;
     tilted         = false;
     startRot       = false;
     checkForButton = false;
     feedbackEndTrial.SetActive(false);
     if (UsefulFunctions.changeSky)
     {
         if (Camera.main != null)
         {
             int index = UsefulFunctions.SetSkyIndex(UsefulFunctions.skyIndex);
             Camera.main.GetComponent <Skybox>().material = skies[index];
             UsefulFunctions.changeSky = false;
         }
     }
     else
     {
         if (UsefulFunctions.skyIndex != -1)
         {
             Camera.main.GetComponent <Skybox>().material = skies[UsefulFunctions.skyIndex];
         }
     }
     PlayerPrefs.SetInt("isMapping", 1);
 }