Пример #1
0
    protected new void Update()
    {
        base.Update();

        if (!_machine.Running)
        {
            return;
        }

        if (IsGrounded && Input.GetButtonDown("Repair"))
        {
            Repair();
            BuyUpgrade();
        }
        if (_repairing)
        {
            if (!_audio.isPlaying)
            {
                _audio.PlayOneShot(_repairSfx[Random.Range(0, _repairSfx.Count)]);
            }
            if (_pipe == null || Input.GetButtonUp("Repair"))
            {
                EndRepair();
            }
            else
            {
                _pipe.Fix(FixLevel * Time.deltaTime);
            }
        }
        int prev = PanicLevel;

        PanicLevel = 2 - Mathf.RoundToInt(_machine.LifeRatio * 2);
        _bgm.SetPitch(1f + PanicLevel * 0.15f);
        if (prev < 2 && PanicLevel >= 2)
        {
            _animator.SetTrigger("Panic");
        }
        if (prev >= 2 && PanicLevel < 2)
        {
            _animator.SetTrigger("StopPanic");
        }
        _animator.SetInteger("PanicLevel", PanicLevel);
    }