Beispiel #1
0
        void Update()
        {
            distanceToPlayer = Vector3.Distance(player.transform.position, transform.position);
            WeponSystem weponSystem = GetComponent <WeponSystem>();

            currentWeponRange = weponSystem.GetCurrentWepon().GetMaxAttackRange();

            bool inWeponCircle    = distanceToPlayer <= currentWeponRange;
            bool inChaseCircle    = distanceToPlayer > currentWeponRange && distanceToPlayer <= chaseRadius;
            bool outsideChaseRing = distanceToPlayer > chaseRadius;

            if (outsideChaseRing)
            {
                StopAllCoroutines();
                weponSystem.StopAttacking();
                StartCoroutine(Patrol());
            }
            if (inChaseCircle)
            {
                StopAllCoroutines();
                StartCoroutine(ChasePlayer());
            }
            if (inWeponCircle)
            {
                StopAllCoroutines();
                state = State.attacking;
                weponSystem.AttackTarget(player.gameObject);
            }
        }
Beispiel #2
0
 private void OnMouseOverEnemy(EnemyAI enemy)
 {
     if (Input.GetMouseButton(0) && IsEnemyInRange(enemy))
     {
         weponSystem.AttackTarget(enemy.gameObject);
     }
     else if (Input.GetMouseButton(0) && !IsEnemyInRange(enemy))
     {
         StartCoroutine(MoveAndAttack(enemy));
     }
     else if (Input.GetMouseButtonDown(1) && IsEnemyInRange(enemy))
     {
         abilities.UseSpecialAbilty(0, enemy.gameObject);
     }
     else if (Input.GetMouseButtonDown(1) && !IsEnemyInRange(enemy))
     {
         StartCoroutine(MoveAndPowerAttack(enemy));
     }
 }