Пример #1
0
    // Update is called once per frame
    void Update()
    {
        _crashTimer -= Time.deltaTime;

        if (pBar != null)
        {
            pBar.progress = ((_timerLength - _crashTimer) / _timerLength) * 100;
        }

        if (_crashTimer < 0)
        {
            if (_state == ComputerState.WaitingToCrash)
            {
                crashComputer();
            }
            else if (_state == ComputerState.Crashed)
            {
                _state = ComputerState.Exploding;
                CC.TriggerExplosionEffect();
                SetComputerColour(Color.black);
                pBar.gameObject.SetActive(false);

                // If user was in the process of selecting a tool to use on the computer, need to reset the player
                PlayerControl PC = FindObjectOfType <PlayerControl> ();
                if (PC._pState == PlayerControl.playerState.SelectComputerTool && PC.targettedComputer == computerID)
                {
                    // select a non-existant tool which is the same as essentially cancelling the tool selection
                    PC.UseComputerTool(-1);
                }
                _crashTimer = CM.TimeToEndGame;
                // TODO
            }
            else if (_state == ComputerState.RaptorCrashingComputer)
            {
                // Raptor has finished crashing the computer
                crashComputer();
            }
            else if (_state == ComputerState.Rebooting)
            {
                SetComputerColour(Color.white);
                CC.CancelCrashEffects();
                PlayRebootSound();
                _state        = ComputerState.WaitingToCrash;
                pBar.progress = 0;
                pBar.gameObject.SetActive(false);
                _crashTimer = Random.Range(CM.MinDefaultComputerCrashTime, CM.MaxDefaultComputerCrashTime);
                FindObjectOfType <PlayerControl> ()._pState = PlayerControl.playerState.Moving;
            }
            else if (_state == ComputerState.Exploding)
            {
                CM.EndGameLose();
            }
        }
        else if (_state == ComputerState.Crashed && _crashTimer < CC.audioData.clip.length && !CC.audioData.isPlaying)
        {
            CC.TriggerCountdownAudio();
        }
        else if (_state == ComputerState.Crashed && _crashTimer < CM.TimeFromCrashToExplode - 5f)
        {
            CC.StartSmokingEffect();
        }
    }