Example #1
0
    // M E T H O D S ////////////////////////////////////////////////////////////////////


    private void OnTriggerEnter(Collider c)
    {
        if (c.tag == "PlayerWeapon")
        {
            hp.UpdateHP(hp.GetHP() - settings.swordDamage);

            if (hp.GetHP() <= 0)
            {
                GameObject go = c.transform.parent.gameObject.transform.parent.gameObject.transform.parent.gameObject.transform.parent.gameObject.transform.parent.gameObject.transform.parent.gameObject.transform.parent.gameObject.transform.parent.gameObject.transform.parent.gameObject;
                go.GetComponent <Knight>().EnemyDestroyed();
            }
        }
    }
Example #2
0
 private void OnTriggerEnter(Collider other)
 {
     if (other.gameObject.CompareTag("Player"))
     {
         HP playerHP = other.GetComponent <HP>();
         if (playerHP?.GetHP() == 100f)
         {
             return;
         }
         playerHP.Heel(_heel);
         Debug.Log("Play audio");
         _audio.Play();
         gameObject.SetActive(false);
     }
 }
Example #3
0
    void Update()
    {
        if (_health.GetHP() <= 0)
        {
            Death.Invoke();
            _shoot.enabled = false;
        }

        float   xMove          = Input.GetAxisRaw("Horizontal");
        float   zMove          = Input.GetAxisRaw("Vertical");
        Vector3 moveHorizontal = transform.right * xMove;
        Vector3 moveVertical   = transform.forward * zMove;
        Vector3 velocity       = (moveHorizontal + moveVertical).normalized * _speed;

        _motor.SetVelocity(velocity);
        float   yRot     = Input.GetAxisRaw("Mouse X");
        Vector3 rotation = new Vector3(0f, yRot, 0f) * lookSensetivity;

        _motor.SetRotation(rotation);
        float xRot = Input.GetAxisRaw("Mouse Y") * lookSensetivity;

        _motor.SetCameraRotation(xRot);
    }