/// <summary>
 /// Handles if the fusebox blows while recording
 /// Acts as if the recording button had been pushed to end recording.
 /// </summary>
 void Update()
 {
     if (fuseBox.getState() == FuseBox.FuseState.broken)
     {
         if (comm.recording)
         {
             audioSource.clip = AudioClips[1];
             audioSource.Play();
             comm.RecordStop();
         }
     }
 }
    /// <summary>
    /// Handles Charging
    /// </summary>
    void Update()
    {
        //If the player is looking at the terminal charge
        if (gazing == true)
        {
            PowerMan.charging();
        }


        if (GetComponent <TextMesh> () != null)
        {
            //if working change color to percent charge and display charge
            if (fuseBox.getState() == FuseBox.FuseState.working)
            {
                //GetComponent<Renderer> ().material.color = new Color (1.0f-(PowerMan.getCharge()/100.0f), (PowerMan.getCharge()/100.0f), 0);
                GetComponent <TextMesh> ().text = ((int)PowerMan.getCharge()).ToString() + '%';
            }
            else
            {
                //if not working change color to red and diaply text offline
                GetComponent <TextMesh> ().text  = "OFFLINE";
                GetComponent <TextMesh> ().color = Color.red;
            }
        }
    }
    /// <summary>
    /// Powerup gameplay management
    ///
    /// Handle unlocking powerups
    /// Using powerups
    /// Cooldowns for powerups
    ///
    /// dismiss tooltips
    /// </summary>
    void Update()
    {
        //if the fusebox is working
        if (fuseBox.getState() == FuseBox.FuseState.working)
        {
            //Play sound when enough charge has been reached to unlock a powerup
            for (int i = 0; i <= 2; i++)
            {
                if ((int)charge >= powerUps[i].getChargeRequired() && powerUps[i].getSoundPlayed() == false)
                {
                    audioSource.clip = audioClips [0];
                    audioSource.Play();
                    powerUps [i].unlockedSoundPlayed();
                }
            }

            //flagged that powerup is unlocking
            if (terminalState == TerminalState.Unlocking)
            {
                //increment timer waiting for powerup
                powerUps[unlockID].coolDown();

                //when unlocked
                if (powerUps[unlockID].OnCoolDown() == false)
                {
                    //dismiss can unlock tool tip
                    tipManager.DismissTip(2);
                    tipManager.DismissTip(9);

                    //show unlocked and send tip
                    tipManager.ShowTip(4);
                    tipManager.ShowTip(5);


                    //power up has finished unlocking and player can charge again
                    terminalState = TerminalState.Idle;

                    //unlock correct powerup
                    powerUps[unlockID].Unlock();
                }
            }

            else
            {
                //not currently unlocking but powerup is being used
                if (terminalState == TerminalState.UsingPowerUp)
                {
                    //reset timer

                    powerUps [useID].resetCoolDown();
                    terminalState = TerminalState.Idle;
                }

                //manage timers for cooldowns after use
                for (int i = 0; i < 3; i++)
                {
                    if (powerUps [i].isLocked() == false && powerUps [i].OnCoolDown())
                    {
                        powerUps [i].coolDown();
                    }
                    else
                    {
                        //dismiss cooldown tip
                        tipManager.DismissTip(8);
                    }
                }
            }
        }

        //dismiss gaze tip show win tip
        if ((int)charge == 10)
        {
            tipManager.DismissTip(0);                   //gaze
            tipManager.ShowTip(1);                      //win
        }

        //show unlock tip
        if (charge >= powerUps [0].getChargeRequired())
        {
            tipManager.ShowTip(2);
            tipManager.ShowTip(3);
        }
    }