Пример #1
0
        private void Update()
        {
            distanceToPlayer   = Vector3.Distance(player.transform.position, transform.position);
            currentWeaponRange = weaponSystem.GetWeaponConfig().GetMaxAttackRange();

            bool inWeaponCircle = distanceToPlayer <= currentWeaponRange;
            bool inChaseRing    = distanceToPlayer > currentWeaponRange
                                  &&
                                  distanceToPlayer <= chaseRadius;

            bool outsideChaseRing = distanceToPlayer > chaseRadius;

            if (outsideChaseRing)
            {
                StopAttacking();
                character.setSelectedAnimatorForward();
                StartCoroutine(Patrol());
            }
            if (inChaseRing)
            {
                character.setMaximumAnimatorForward();
                StopAttacking();
                StartCoroutine(ChasePlayer());
            }
            if (inWeaponCircle)
            {
                StopAllCoroutines();
                weaponSystem.AttackTarget(player.gameObject);
            }
        }