示例#1
0
        private void Update()
        {
            distanceToPlayer = Vector3.Distance(player.transform.position, transform.position);
            WeaponSystem weaponSystem = GetComponent <WeaponSystem>();

            currentWeaponRange = weaponSystem.GetCurrentWeaponInUse().GetMaxAttackRange();

            bool inWeaponCircle = distanceToPlayer <= currentWeaponRange;
            bool inChaseCircle  = distanceToPlayer > currentWeaponRange &&
                                  distanceToPlayer <= chaseRadius;
            bool outsideChaseRing = distanceToPlayer > chaseRadius;

            if (outsideChaseRing && state != State.patrolling)
            {
                StopAllCoroutines();
                weaponSystem.StopAttacking();
                StartCoroutine(Patrol());
            }
            if (inChaseCircle && state != State.chasing)
            {
                StopAllCoroutines();
                weaponSystem.StopAttacking();
                StartCoroutine(ChasePlayer());
            }
            if (inWeaponCircle && state != State.attacking)
            {
                StopAllCoroutines();
                weaponSystem.AttackTarget(player.gameObject);
            }
        }
示例#2
0
 void OnMouseOverEnemy(EnemyAI enemy)
 {
     if (Input.GetMouseButton(0) && IsTargetInRange(enemy.gameObject))
     {
         weaponSystem.AttackTarget(enemy.gameObject);
     }
     else if (Input.GetMouseButton(0) && !IsTargetInRange(enemy.gameObject))
     {
         StartCoroutine(MoveAndAttack(enemy));
     }
     else if (Input.GetMouseButtonDown(1) && IsTargetInRange(enemy.gameObject))
     {
         abilities.AttemptSpecialAbility(0, enemy.gameObject);
     }
     else if (Input.GetMouseButtonDown(1) && !IsTargetInRange(enemy.gameObject))
     {
         StartCoroutine(MoveAndPowerAttack(enemy));
     }
 }