//Stops health overflow (although we may want that) public void addHealth(enemy Enemy) { if (Enemy != null) { if (Enemy.health > Enemy.startingHealth - healSpeed) { Enemy.health = Enemy.startingHealth; } else { Enemy.health += healSpeed; } } }
//Guts of the function: finds the enemy closest to the medship within a certain list that is not already being healed. public enemy closestEnemyInList(List<enemy> enemyList, List<enemy> alreadyHealing, List<enemy> impossibleList) { if (enemyList.Count > 0) { temporaryClosestEnemy = enemyList[0]; temporarySmallestDistance = workOutDistance(this.position, enemyList[0].position); foreach (enemy enemyHandling in enemyList) { if (!(alreadyHealing.Contains(enemyHandling) || impossibleList.Contains(enemyHandling))) { if (workOutDistance(this.position, enemyHandling.position) < temporarySmallestDistance) { temporaryClosestEnemy = enemyHandling; temporarySmallestDistance = workOutDistance(this.position, enemyHandling.position); } } } return temporaryClosestEnemy; } else return null; }
//Trying to make the Heal function as short as possible, because it won't be very simple. public bool isHealAble(enemy Enemy) { if (Enemy.health < Enemy.startingHealth) { return true; } else { return false; } }