Пример #1
0
        private void Attack()
        {
            if (m_CurrentAttackCooldown > 0f)
            {
                m_CurrentAttackCooldown -= Time.deltaTime;

                AttackTarget = null; // we're not ready to attack, ignore the mouse hold or npc targeting from this frame
            }
            else if (AttackTargetIsInAttackRange())
            {
                CharacterBehaviour characterBehaviour = AttackTarget.GetComponent <CharacterBehaviour>();
                if (characterBehaviour != null && !characterBehaviour.Dead())
                {
                    m_CurrentAttackCooldown = AttackCooldown;
                    m_Animator.ResetTrigger("Hit");
                    m_Animator.SetTrigger("Attack");
                    characterBehaviour.ApplyDamage(Damage);
                }

                AttackTarget = null; // we've executed the attack, require a new mouse hold/click or npc targeting
            }
            else if (InteractTargetIsInInteractRange())
            {
                ItemPickup itemPickup = InteractTarget.GetComponent <ItemPickup>();
                if (itemPickup != null)
                {
                    GetComponent <CharacterInventory>().AddItem(itemPickup.ItemId);
                    Destroy(InteractTarget);
                }

                InteractTarget = null;
            }
        }
Пример #2
0
 private void Awake()
 {
     m_CharacterBehaviour = GetComponent <CharacterBehaviour>();
     m_NavMeshAgent       = GetComponent <NavMeshAgent>();
 }
Пример #3
0
 private void Awake()
 {
     m_CharacterBehaviour = GetComponent <CharacterBehaviour>();
 }