private void InitTiles() { foreach (var tile in initTileList) { string name = tile.name; string coords = name.Split(' ')[1]; string rowstring = coords.Split(',')[0]; string columnstring = coords.Split(',')[1]; int row = int.Parse(rowstring); int column = int.Parse(columnstring); Tile t = tile.GetComponent <NeutralTile>(); Tile.SIDE side = Tile.SIDE.RIGHT; if (column < width / 2) { side = Tile.SIDE.LEFT; } t.SetSide(side); t.gameBoard = this; SetTileValue(row, column, t); } }
private Vector2Int UpdatePosition(Vector2Int position, Vector2Int direction, bool allowOverlap) { Tile curTile = GetTile(position); Tile.SIDE side = curTile.GetSide(); Vector2Int newPosition = position; newPosition += direction; // Make sure new position is still on the board if (!IsOnBoard(newPosition) || (!allowOverlap && !GetTile(newPosition).IsEmpty())) { // not on board... do not update position return(position); } Tile newTile = GetTile(newPosition); if (side != newTile.GetSide()) { // we are not on the right side... revert! return(position); } return(newPosition); }
private void ClaimTile() { Debug.Log("Claim a tile"); Tile.SIDE mySide = GetTile().GetSide(); Vector2Int pos = gameBoard.GetTileEntityPosition(this); Tile tile = gameBoard.GetTile(pos.x, pos.y + (1 * (mySide == Tile.SIDE.LEFT ? 1 : -1))); if (tile != null) { this.ClaimTile(tile); } }