GameObject FindPersonToEnhance() { Collider[] objectsInArea = Physics.OverlapSphere(transform.position, 10); List <EnemyBase> nearByEnemies = new List <EnemyBase>(); for (int i = 0; i < objectsInArea.Length; i++) { EnemyBase enemy = objectsInArea[i].GetComponent <EnemyBase>(); if (enemy != null && enemy != this) { nearByEnemies.Add(enemy); } } if (nearByEnemies.Count == 0) { witchType = WitchType.AttackerMage; bulletColor = attackerHatColor; SetWitchHat(); return(FindPersonToAttack()); } int ranNum = Random.Range(0, nearByEnemies.Count); chosenEnemy = nearByEnemies[ranNum]; GameObject target = nearByEnemies[ranNum].gameObject; return(target); }
GameObject FindPersonToHeal() { EnemyBase enemy = null; Collider[] objectsInArea = Physics.OverlapSphere(transform.position, 10); for (int i = 0; i < objectsInArea.Length; i++) { EnemyBase newEnemy = objectsInArea[i].GetComponent <EnemyBase>(); if (newEnemy != null && newEnemy != this) { enemy = newEnemy; if (newEnemy.health < newEnemy.maxHealth) { chosenEnemy = newEnemy; return(newEnemy.gameObject); } } } if (enemy != null) { chosenEnemy = enemy; return(enemy.gameObject); } witchType = WitchType.AttackerMage; bulletColor = attackerHatColor; SetWitchHat(); return(FindPersonToAttack()); }