//update the peace time text to display the current peace time:
 public void Update(float currTime)
 {
     if (timeText == null || currTime <= 0.0f)
     {
         return; //do not proceed if the peace time text is not assigned or the peace time is invalid
     }
     timeText.text = RTSHelper.TimeToString(currTime);
 }
Example #2
0
        private void Update()
        {
            if (status != ScenarioStatus.active) //if the current scenario isn't active
            {
                return;
            }

            string nextDescription = currMissionDescription;

            if (currTimeCondition.survivalTimeEnabled)             //if survival time is enabled for the current mission
            {
                if (currTimeCondition.survivalTime <= 0.0f)        //survival time is done
                {
                    scenario.GetMission(currMissionID).Complete(); //complete the mission since the player survived for the assigned time
                    return;
                }

                //keep displaying the remaining survival time and run the timer as well
                nextDescription += "\nSurvival Time: " + RTSHelper.TimeToString(currTimeCondition.survivalTime);
                currTimeCondition.survivalTime -= Time.deltaTime;
            }

            if (currTimeCondition.timeLimitEnabled) //if time limit (time to finish the mission before it is forfeited) is enabled
            {
                //if the time limit is already over:
                if (currTimeCondition.timeLimit <= 0.0f)
                {
                    OnFailed(); //scenario hasn't been successfully completed
                    return;
                }

                //display the time limit and run the timer:
                nextDescription             += "\nTime Left: " + RTSHelper.TimeToString(currTimeCondition.timeLimit);
                currTimeCondition.timeLimit -= Time.deltaTime;
            }

            //update the mission's description
            missionDescriptionText.text = nextDescription;
        }