Ejemplo n.º 1
0
        /// <summary>
        ///
        /// Define whether characters can do attack behaviour.
        ///
        /// </summary>
        /// <param name="combatTarget">Attack attackTarget</param>
        /// <returns>
        ///     True: characters can attack;
        ///     False: characters can't attack.
        /// </returns>
        public bool CanAttack(GameObject combatTarget)
        {
            if (!combatTarget)
            {
                return(false);
            }
            Health targetToTest = combatTarget.GetComponent <Health>();

            // Health component can tell us whether this character is dead.
            return(targetToTest && !targetToTest.IsDead());
        }
Ejemplo n.º 2
0
        public bool CanAttack(GameObject combatTarget)
        {
            if (combatTarget == null)
            {
                return(false);
            }
            if (GetComponent <Mover>().CanMoveTo(combatTarget.transform.position) &&
                !GetIsInRange(combatTarget.transform))
            {
                return(false);
            }
            Health targetToTest = combatTarget.GetComponent <Health>();

            return(targetToTest != null && !targetToTest.IsDead());
        }
Ejemplo n.º 3
0
        public bool CanAttack(GameObject target)
        {
            if (target == null)
            {
                return(false);
            }
            if (!_mover.CanMoveTo(target.transform.position) && !IsInRange(target.transform))
            {
                return(false);
            }

            Health targetToTest = target.GetComponent <Health>();

            return(targetToTest != null && !targetToTest.IsDead());
        }
Ejemplo n.º 4
0
        private void Update()
        {
            _timeSinceLastAttack += Time.deltaTime;

            if (_target == null)
            {
                return;
            }
            if (_target.IsDead())
            {
                return;
            }

            if (_target != null && !GetIsInRange(_target.transform))
            {
                GetComponent <Mover>().MoveTo(_target.transform.position, 1f);
            }
            else
            {
                GetComponent <Mover>().Cancel();
                AttackBehavior();
            }
        }
Ejemplo n.º 5
0
        private void Update()
        {
            _timeSinceLastAttack += Time.deltaTime;

            if (_target == null)
            {
                return;
            }
            if (_target.IsDead())
            {
                return;
            }

            if (!IsInRange(_target.transform))
            {
                _mover.MoveTo(_target.transform.position, 1f);
            }
            else
            {
                _mover.Cancel();
                AttackBehaviour();
            }
        }