Ejemplo n.º 1
0
        private void Update()
        {
            if (target == null)
            {
                return;
            }

            if (isHoming && !target.GetIsDead())
            {
                transform.LookAt(GetAimPoint());
            }

            transform.Translate(Vector3.forward * projectileSpeed * Time.deltaTime);
        }
Ejemplo n.º 2
0
        // Update is called once per frame
        void Update()
        {
            //updat Time since last attack
            m_timeSinceLastAttack += Time.deltaTime;


            if (m_Target == null)
            {
                return;
            }

            if (m_Target.GetIsDead())
            {
                return;
            }
            bool isInRange = Vector3.Distance(transform.position, m_Target.transform.position) < m_WeaponRange;

            Mover mover = GetComponent <Mover>();

            //move to target
            if (!isInRange)
            {
                mover.MoveTo(m_Target.transform.position);
            }
            else
            {
                mover.Cancel();
                AttackBehavior();
            }
        }
Ejemplo n.º 3
0
        public bool CanAttack(GameObject combatTarget)
        {
            if (combatTarget == null)
            {
                return(false);
            }
            Health targetToTest = combatTarget.GetComponent <Health>();

            return(targetToTest != null && !targetToTest.GetIsDead());
        }
Ejemplo n.º 4
0
        // Public Methods
        public bool isValidTarget(GameObject candidate)
        {
            if (candidate == null)
            {
                return(false);
            }
            Health health = candidate.GetComponent <Health>();

            return(health != null && !health.GetIsDead());
        }
Ejemplo n.º 5
0
        private void OnTriggerEnter(Collider other)
        {
            Health candidate = other.GetComponent <Health>();

            if (candidate != target || candidate.GetIsDead())
            {
                return;
            }
            target.TakeDamage(instigater, damage);
            Destroy(gameObject);
        }
Ejemplo n.º 6
0
        public bool CanAttack(GameObject combatTarget)
        {
            if (combatTarget == null)
            {
                return(false);
            }
            Health targetHealth = combatTarget.GetComponent <Health>();

            if (targetHealth != null && targetHealth.GetIsDead() == false)
            {
                return(true);
            }
            return(false);
        }
Ejemplo n.º 7
0
 // Update is called once per frame
 void Update()
 {
     timeSinceLastAttack += Time.deltaTime;
     if (target == null)
     {
         return;
     }
     if (target.GetIsDead())
     {
         return;
     }
     if (!GetIsInRange())
     {
         GetComponent <Mover>().MoveTo(target.transform.position);
     }
     else
     {
         GetComponent <Mover>().Cancel();
         AttackBehaviour();
     }
 }
Ejemplo n.º 8
0
        private void Update()
        {
            timeSinceLastAttack += Time.deltaTime;

            if (target == null)
            {
                return;
            }

            if (target.GetIsDead())
            {
                return;
            }

            if (!GetIsInRange())
            {
                mover.MoveTo(target.transform.position);
            }
            else
            {
                mover.Cancel();
                AttackBehavior();
            }
        }