예제 #1
0
        public void GetNewAttack(float distanceFromTarget)
        {
            int maxScore = 0;

            foreach (EnemyAttackAction attack in enemyAttacks)
            {
                if (distanceFromTarget > attack.minimumDistanceNeededToAttack)
                {
                    maxScore += attack.attackScore;
                }
            }

            int randomValue    = Random.Range(0, maxScore);
            int temporaryScore = 0;

            foreach (EnemyAttackAction attack in enemyAttacks)
            {
                if (distanceFromTarget > attack.minimumDistanceNeededToAttack)
                {
                    temporaryScore += attack.attackScore;

                    if (temporaryScore >= randomValue)
                    {
                        currentAttack = attack;
                        return;
                    }
                }
            }
        }
예제 #2
0
 public void Attack()
 {
     animatorHandler.StopMovement();
     animatorHandler.PlayTargetAnimation(currentAttack.actionAnimation, true, true);
     enemyManager.isPerformingAction  = true;
     enemyManager.currentRecoveryTime = currentAttack.recoveryTime;
     lastAttack    = currentAttack;
     currentAttack = null;
 }