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; } } } }
public void Attack() { animatorHandler.StopMovement(); animatorHandler.PlayTargetAnimation(currentAttack.actionAnimation, true, true); enemyManager.isPerformingAction = true; enemyManager.currentRecoveryTime = currentAttack.recoveryTime; lastAttack = currentAttack; currentAttack = null; }