示例#1
0
 public void Talk()
 {
     _soundShotPlayer.PlayVoice(_isAngry ? "AngryChat" : "IdleChat");
 }
示例#2
0
    public void Update()
    {
        Face.SetActive(IsAlive);

        if (IsAlive)
        {
            var toCamera = Vector3.SignedAngle(transform.forward, Vector3.back, Vector3.up);
            if (Mathf.Abs(toCamera) > 90)
            {
                _rigidbody.AddTorque(Vector3.up * toCamera * 0.05f, ForceMode.Force);
            }

            var toUpAxis = Vector3.Cross(Vector3.up, transform.up);
            var faceUp   = Vector3.SignedAngle(Vector3.up, transform.up, toUpAxis);
            if (Mathf.Abs(faceUp) > 45)
            {
                _rigidbody.AddRelativeTorque(toUpAxis * faceUp * 0.05f, ForceMode.Force);
            }
        }

        _rigidbody.angularVelocity *= 0.95f;


        if (IsAlive && !TimerActive)
        {
            TimerActive = true;
            _soundShotPlayer.PlayVoice("Woke");
            if (_firstTimeWoke)
            {
                _firstTimeWoke = false;
                Destroy(_spoonJoint);
                _soundShotPlayer.PlaySound("WokeSpoonSound");
                _spoonRigidbody.AddForce(-transform.up * 3, ForceMode.Impulse);
            }
            else
            {
                _soundShotPlayer.PlaySound("WokeSound");
            }

            _explodeTimer = Time.time + ExplodeTime;
        }
        if (!IsAlive && TimerActive)
        {
            TimerActive = false;
            _soundShotPlayer.PlaySound("PinLocked");
            _rewokeTimer = Time.time + RewokeDelay;
        }

        if (!HasExploded && TimerActive && _explodeTimer < Time.time)
        {
            HasExploded = true;
            Instantiate(ExplosionPrefab, transform.position, Quaternion.identity);
            _soundShotPlayer.PlayVoice("ExplosionVoice");
            _soundShotPlayer.PlaySound("Explosion");
            GameState.GameOver = true;
        }

        if (_pushOutPin && !IsAlive && ActivePin != null)
        {
            ActivePin.AddForce(ActivePin.rotation * Vector3.forward * 6, ForceMode.Force);
            _rigidbody.AddForceAtPosition(-transform.up * 10, PinHoleCenter.position, ForceMode.Force);
        }
        else
        {
            _pushOutPin = false;
        }
    }