public List <Tile> getLegalMoves(List <Tile> list, Unit.moveType m, Tile t, int movePoints) { List <HexCoord> adjacent = t.getPosition().neighbors(); Tile temp; int[] moveCosts; foreach (HexCoord h in adjacent) { tiles.TryGetValue(h, out temp); if (temp != null) { moveCosts = temp.getMoveCosts(); } else { moveCosts = new int[] { -1, -1, -1 }; } switch (m) { case Unit.moveType.foot: if (moveCosts[0] != -1 && (movePoints - moveCosts[0]) >= 0) { if (!list.Contains(temp)) { list.Add(temp); } getLegalMoves(list, m, temp, movePoints - moveCosts[0]); } break; case Unit.moveType.tread: if (moveCosts[1] != -1 && (movePoints - moveCosts[1]) >= 0) { if (!list.Contains(temp)) { list.Add(temp); } getLegalMoves(list, m, temp, movePoints - moveCosts[1]); } break; case Unit.moveType.air: if (moveCosts[2] != -1 && (movePoints - moveCosts[2]) >= 0) { if (!list.Contains(temp)) { list.Add(temp); } getLegalMoves(list, m, temp, movePoints - moveCosts[2]); } break; } } return(list); }
public List <Tile> getLegalMoves(Tile t) { List <Tile> temp = new List <Tile>(); Unit u = t.getUnit(); int i = 0; if (u != null) { i = u.getMoveSpeed(); } Unit.moveType m = u.getMoveType(); temp = getLegalMoves(temp, m, t, i); return(temp); }