예제 #1
0
    private void OnCollisionEnter(Collision collision)
    {
        if (wsc.GetStabbing())
        {
            if (!PlaySound)
            {
                FindObjectOfType <RandomSoundGenerator>().PlayRandomAudioClip();

                PlaySound = true;

                _OnHit.Invoke();
            }
        }
    }
예제 #2
0
    private void OnCollisionEnter(Collision collision)
    {
        if (collision.transform.root == transform.root)
        {
            return;
        }
        if (_attacked)
        {
            return;
        }

        //are we stabbing?
        _isStabbing = _wsCheck.GetStabbing();


        //See if we are stabbing an agent
        AIAgent agent = collision.transform.GetComponentInParent <AIAgent>();

        //if we are then the parent is the agent
        if (agent)
        {
            _parent         = agent.gameObject;
            _attackedHealth = _parent.GetComponent <Health>();
        }
        else
        {
            _parent         = _player;
            _attackedHealth = _player.GetComponent <Health>();
            if (!collision.gameObject.CompareTag("Player"))
            {
                return;
            }
        }

        //Get the health of the attacked object and deal damage
        if (_isStabbing)
        {
            _attacked = true;
            _attackedHealth.TakeDamage(_meleeConfig.DamageType, _meleeConfig.Damage);
        }
    }
예제 #3
0
    public void Update()
    {
        //Makes the AI chase the player
        _navAgent.SetDestination(_agent.Player.position);

        //if the distance between the player and the agent is less than 1.5f
        if (_navAgent.remainingDistance < 1.5f)
        {
            //Set Stab Trigger
            _animController.SetTrigger("Stab");
        }

        if (_stabCheck.GetStabbing())
        {
            _navAgent.isStopped = true;
        }
        else
        {
            _navAgent.isStopped = false;
        }
    }