예제 #1
0
 void Update()
 {
     if (gc.GetIsGameplay())         //gameplay specific in here
     {
         if (!needReset)             //allows for a reset when the player goes to gameplay
         {
             needReset = true;
         }
         if (build.GetPlayerSpawned() && needPlayer)             //initialises the player this loop
         {
             Debug.Log("Initialising player(Platforming)");
             player     = FindObjectOfType <Player>();
             needPlayer = false;
         }
         if (!hasInitialised)             //initalises values for this script on play
         {
             player         = null;
             timeLeft       = build.GetTime();
             timeText.text  = "Time: " + timeLeft;
             coinText.text  = "Coins: " + coins;
             scoreText.text = "Score: " + score;
             hasInitialised = true;
         }
         if (player == null)
         {
             player = FindObjectOfType <Player>();
         }
         if (!gc.GetIsPaused())
         {
             timeLeft -= Time.deltaTime;
         }
         roundedTime = Mathf.FloorToInt(timeLeft);
         if (player != null)
         {
             UpdateUI();
         }
         if (timeLeft <= 0.0f)            //boot to build if failed clear in time
         {
             gc.SetIsBuilding(true);
         }
     }
     if (gc.GetIsBuilding() && needReset)         //resets, etc. here when entering building
     {
         ResetPlatformStats();
     }
 }