public MarkersSet GetFireZoneForMoveZone(Unit unit, MarkersSet moveZone = null) { if (moveZone == null) { moveZone = GetMoveZone(unit); } MarkersSet fullFireZone = new MarkersSet(); fullFireZone.Add(GetFireZoneFromCoord(unit.Coordinate, unit)); var moveCoords = moveZone.GetCoordList(); int availableActionPoints; foreach (var coord in moveCoords) { if (this[coord].Unit != null) { continue; } availableActionPoints = moveZone[coord]; if (availableActionPoints > 0) { fullFireZone.Add(GetFireZoneFromCoord(coord, unit)); } } return(fullFireZone); }
public Coord FindOptimalMovePoint(Unit unit, MarkersSet moveMarkers, Coord fireCoord) { var moveCoords = moveMarkers.GetCoordList(); int bestMarker = 0; Coord nearestCoord = Coord.Zero; foreach (var moveCoord in moveCoords) { if (moveMarkers[moveCoord] > bestMarker && (this[moveCoord].Unit == unit || this[moveCoord].Unit == null)) { if (IsCanFireFromCoord(unit, moveCoord, fireCoord)) { nearestCoord = moveCoord; bestMarker = moveMarkers[moveCoord]; } } } if (nearestCoord == Coord.Zero) { Debug.LogError("Can't find nearest fire point"); } return(nearestCoord); }