void CreateCityStateUnit() { HexCell cell = GetCellUnderCursor(); if (cityStates.options.Count > 0 && cell && cell.CanUnitMoveToCell(HexUnit.UnitType.COMBAT)) { string name = cityStateUnits.options[cityStateUnits.value].text; int cityStateID = System.Convert.ToInt32(cityStates.options[cityStates.value].text); gameController.CreateCityStateUnit(name, cell, cityStateID); } }
public static HexCell FindFreeCell(HexUnit hexUnit, HexCell hexCell) { if (hexCell.hexUnits.Count == 0) { return(hexCell); } for (HexDirection d = HexDirection.NE; d <= HexDirection.NW; d++) { HexCell neighbour = hexCell.GetNeighbor(d); if (neighbour && neighbour.CanUnitMoveToCell(hexUnit)) { return(neighbour); } } return(null); }
void CreateUnit() { HexCell cell = GetCellUnderCursor(); if (players.options.Count > 0 && cell && cell.CanUnitMoveToCell(HexUnit.UnitType.AGENT)) { string name = playerUnits.options[playerUnits.value].text; string playerName = players.options[players.value].text; Player player; if (playerName == "Human Player") { player = gameController.HumanPlayer; } else { int playerID = System.Convert.ToInt32(players.options[players.value].text); player = gameController.GetPlayer(playerID); } HexUnit unit = gameController.CreateAgent("Builder", cell, player); } }
public bool IsValidDestination(HexCell cell, bool allowUnxplored = false) { return((cell.IsExplored || allowUnxplored) && !cell.IsUnderwater && cell.CanUnitMoveToCell(this)); }