void FindNearestFoe() { nearestFoe = null; bc.board.Search(actor.tile, delegate(Tile arg1, Tile arg2) { if (nearestFoe == null && arg2.content != null) { Alliance other = arg2.content.GetComponentInChildren <Alliance>(); if (other != null && alliance.IsMatch(other, Targets.Foe)) { Unit unit = other.GetComponent <Unit>(); Stats stats = unit.GetComponent <Stats>(); if (stats[StatTypes.HP] > 0) { nearestFoe = unit; return(true); } } } return(nearestFoe == null); }); }
/// <summary> /// Updates the nearestFoe property to be the first foe that is not dead. /// /// @todo Replace this with something that takes into account the /// HP / debuffs / armor of the targets to find the highest priority target. /// </summary> private void UpdateNearestFoe() { nearestFoe = null; bc.board.Search(actor.tile, delegate(Tile tile, Tile otherTile) { // If the other tile is a foe and alive, set it as the nearest for and return true. if (nearestFoe == null && otherTile.content != null) { Alliance otherAlliance = otherTile.content.GetComponentInChildren <Alliance>(); if (otherAlliance != null && alliance.IsMatch(otherAlliance, Targets.Foe)) { Unit unit = otherAlliance.GetComponent <Unit>(); Stats stats = unit.GetComponent <Stats>(); if (stats[StatTypes.HP] > 0) { nearestFoe = unit; return(true); } } } return(nearestFoe == null); }); }