public void selectTile() { Cursor c = currentCursor.GetComponent <Cursor> (); if (!selected) { TileStack ts = gameMap.GetComponent <BoardMap> ().getTile(c.getX(), c.getY()).GetComponent <TileStack> (); if (ts.getHeight() != 1 || ts.getPlayer() != null) { if (ts.getPlayer() == null || ts.getPlayer().GetComponent <Player> ().getTeam() == c.getTeam()) { selectX = c.getX(); selectY = c.getY(); selected = true; newNeutralCursor(c.getX(), c.getY(), c.getTeam()); } } } else { BoardMap bm = gameMap.GetComponent <BoardMap> (); Deselect(); if (bm.Move(bm.getTile(selectX, selectY), bm.getTile(c.getX(), c.getY()))) { newCursor(c.getX(), c.getY(), !c.getTeam()); } } }
public int countOpenAdj(BoardMap map, int x, int y) { int sum; sum = 0; if (map.hasPosition(x, y + 1)) { if (map.tiles[x][y + 1].GetWater() == false) { sum++; } } if (map.hasPosition(x + 1, y + 1)) { if (map.tiles[x + 1][y + 1].GetWater() == false) { sum++; } } if (map.hasPosition(x - 1, y)) { if (map.tiles[x - 1][y].GetWater() == false) { sum++; } } if (map.hasPosition(x + 1, y)) { if (map.tiles[x + 1][y].GetWater() == false) { sum++; } } if (map.hasPosition(x - 1, y - 1)) { if (map.tiles[x - 1][y - 1].GetWater() == false) { sum++; } } if (map.hasPosition(x, y - 1)) { if (map.tiles[x][y - 1].GetWater() == false) { sum++; } } return(sum); }