Example #1
0
    //Object collision
    public void OnTriggerEnter(Collider col)
    {
        AudioSource audio = player.GetComponent <AudioSource>();

        audio.Play();
        score++;
        gems_info.text = "GEMS: " + score.ToString() + "/" + menu_score.ToString();
        ShorterFunctions.SaveMainInfo(collectObj);
        collision_t = trial_t;
        collectObj.SetActive(false);
        if (score != menu_score)
        {
            //collectObj = UsefulFunctions.ChooseGem(gems);
            collectObj = UsefulFunctions.RandomizeGem(gems);
        }
        else
        {
            player.GetComponent <CharacterController>().enabled = false;
            tornado.SetActive(true);
            foreach (GameObject g in tornados)
            {
                g.SetActive(true);
            }
            tornadoFeedback.SetActive(true);
            StartCoroutine(WaitForIt(3.5f));
        }
    }
Example #2
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);
 }
Example #3
0
    public void onContinueClick()
    {
        bool checkStatus = false;

        checkStatus = ShorterFunctions.ExpStatus();

        if (!checkStatus)
        {
            if (ShorterFunctions.levelID == 1)
            {
                Application.LoadLevel(ShorterFunctions.geometry);
            }
            else if (ShorterFunctions.levelID == 2)
            {
                Application.LoadLevel(ShorterFunctions.distal_geometry);
            }
        }
        else
        {
            Application.LoadLevel("End");
        }
    }
Example #4
0
    // Update is called once per frame
    void FixedUpdate()
    {
        trial_t += Time.deltaTime; //updates time
        isPaused = UsefulFunctions.isGamePaused();
        if (isPaused)
        {
            pmenu = paused_menu;
            pmenu.SetActive(true);
            pause_t = trial_t;
            player.GetComponent <CharacterController>().enabled = false;
            player.GetComponent <MouseLook>().enabled           = false;
        }
        UsefulFunctions.PathTracing(player);
        if (score == menu_score && checkForButton)
        {
            feedbackEndTrial.GetComponent <Animator>().SetBool("hasToGoBack", showFeedback);
            if (UsefulFunctions.OnButtonPression() == true)
            {
                score_text = score_gained.text;
                ShorterFunctions.SaveMainInfo(player); //Saves last position
                last_position = player.transform.position;
                last_rotation = player.transform.rotation;
                distance      = Vector3.Distance(goal_position, last_position);
                //Saves all variables in files
                try
                {
                    isSaving = true;
                    _data    = UsefulFunctions.SerializeObject(trialInfo);
                    UsefulFunctions.CreateXML(_FileLocation, _data);
                    Debug.Log("Main trial data Saved");
                    _data = UsefulFunctions.SerializeObject(trialPath);
                    UsefulFunctions.CreateXML(_FileLocation, _data);
                    Debug.Log("Overall path data Saved");
                }
                catch (System.Exception ex)
                {
                    Debug.LogError(ex.ToString());
                }
                finally
                {
                    isSaving = false;
                }
                Application.LoadLevel("FeedbackShorter"); //Load feedback
            }
        }
        //if(startTrial)
        //{
        //    dummy++;
        //    if (dummy == 80)
        //    {
        //        treasure.SetActive(false);
        //        player.GetComponent<MouseLook>().enabled = true;
        //        player.GetComponent<CharacterController>().enabled = true;
        //        tilted = true;
        //        player.GetComponent<Animator>().SetBool("Tilted", tilted);
        //        startRot = true;
        //    }
        //}
        //if (player.transform.rotation.eulerAngles.x == 0.0f && startRot)
        //{
        //    player.GetComponent<Animator>().enabled = false;
        //    startRot = false;
        //}


        /*if (Input.GetButton("Y"))
         *  UsefulFunctions.RndEnvironment();*/
    }