Exemple #1
0
        void Update()
        {
            bool targetIsDead;
            bool targetIsOutOfRange;
            bool characterIsDead = !character.StillAlive();

            if (currentTarget == null)
            {
                targetIsDead       = false;
                targetIsOutOfRange = false;
            }
            else
            {
                var targetDistance = Vector3.Distance(currentTarget.transform.position, transform.position);
                targetIsDead       = !currentTarget.GetComponent <Character>().StillAlive();
                targetIsOutOfRange = targetDistance > weaponInUse.AttackRadius();
            }

            if (characterIsDead || targetIsDead || targetIsOutOfRange)
            {
                StopAllCoroutines();
            }
        }