// Update is called once per frame
    void Update()
    {
        spawnCountdown = spawnCountdown - Time.deltaTime;
        if (spawnCountdown < 0)
        {
            Message message = new Message();
            message.text        = messageText[messageIndex];
            message.displayTime = messageDisplayTime;
            //Debug.Log("spawning object: " + spawnPrefab.name);
            if (isFirstObject)
            {
                messageQueueHandler.PushMessage(message);
                isFirstObject = false;
            }

            messageIndex++;
            if (messageIndex >= messageText.Count)
            {
                messageIndex = 0;
            }
            spawnCountdown = spawnInterval;

            GameObject newObject = GameObject.Instantiate(spawnPrefab, new Vector3(spawnPosition.x + Random.Range(0f, spawnRadius), spawnPosition.y, spawnPosition.z + Random.Range(0f, spawnRadius)), Quaternion.identity) as GameObject;
            CheckAndApplyColor(message, newObject);
        }
    }
Esempio n. 2
0
 // Update is called once per frame
 void Update()
 {
     if (!messagePause)
     {
         messageCountdown = messageCountdown - Time.deltaTime;
         if (messageCountdown < 0)
         {
             Debug.Log("about to create new message to push onto queue");
             Message message = new Message();
             message.text        = messageText[messageIndex];
             message.displayTime = messageDisplayTime;
             messageQueueHandler.PushMessage(message);
             messageCountdown = GetCountDownValue(messageInterval);
             messageIndex++;
             if (messageIndex >= messageText.Count)
             {
                 messageIndex = 0;
             }
         }
     }
 }
Esempio n. 3
0
 // Update is called once per frame
 void Update()
 {
     if (middleIsAttached && topIsAttached && handleIsAttached && spoutIsAttached && !isCompleted)
     {
         // Check if completed
         isCompleted    = true;
         breakCountdown = breakTime;
         Message message = new Message();
         message.text        = "Pump completed!!! Pump the handle to get water.";
         message.displayTime = 3f;
         messageQueue.PushMessage(message);
     }
     if (isCompleted && handleHingeJoint.angle < -pumpAngleThreshold)
     {         // check if handle is pumped
         if (!isBroken)
         {     // check if pump is broken
             if (!waterParticleSystem.isPlaying)
             { // if handle pumped, pump is not broken, then start water flow if it isnt' flowing already
                 waterParticleSystem.Play();
                 waterSound.Play();
             }
         }
         else
         {     // handle is pumped but pump is broken
             if (!pumpFailMessageDisplayed)
             { // check if we're already displaying a fail message.  If not, then display it
                 pumpFailMessageDisplayed = true;
                 Message message = new Message();
                 message.text        = "Can't pump! Need maintenance to fix pump!";
                 message.displayTime = pumpFailDisplayTime;
                 messageQueue.PushMessage(message);
                 pumpFailDisplayCountdown = pumpFailDisplayTime;
             }
         }
     }
     else
     {     // handle is not being pumped
         if (waterParticleSystem.isPlaying)
         { // stop water if it's playing
             waterParticleSystem.Stop();
             waterSound.Stop();
         }
     }
     if (isCompleted && !isBroken)
     {   // if pump is completed but it's not broken yet, then continue counting down
         breakCountdown = breakCountdown - Time.deltaTime;
     }
     if (!isBroken && breakCountdown < 0)
     { // finished break countdown, so flag pump as broken
         isBroken = true;
         Message message = new Message();
         message.text        = "Pump is broken!  Need maintenance staff!";
         message.displayTime = 3f;
         messageQueue.PushMessage(message);
     }
     if (pumpFailMessageDisplayed)
     {  // if pump fail message is being displayed then count down
         pumpFailDisplayCountdown = pumpFailDisplayCountdown - Time.deltaTime;
     }
     if (pumpFailDisplayCountdown < 0)
     {   // already displayed pump fail message, so can clear flag so it can be displayed again if user attempts to pump again
         pumpFailMessageDisplayed = false;
     }
 }