private IEnumerable <TileSide> GetTileSidesInCorner(TileCorner corner) { switch (corner) { case TileCorner.Top: return(new TileSide[] { TileSide.TopLeft, TileSide.TopRight }); case TileCorner.TopRight: return(new TileSide[] { TileSide.TopRight, TileSide.Right }); case TileCorner.BottomRight: return(new TileSide[] { TileSide.Right, TileSide.BottomRight }); case TileCorner.Bottom: return(new TileSide[] { TileSide.BottomRight, TileSide.BottomLeft }); case TileCorner.BottomLeft: return(new TileSide[] { TileSide.BottomLeft, TileSide.Left }); case TileCorner.TopLeft: return(new TileSide[] { TileSide.Left, TileSide.TopLeft }); default: throw new InvalidOperationException("Invalid Tile side"); } }
public override void readCustomFileProperties(String[] customProperties) { this.fruitful = Boolean.Parse(customProperties[0]); this.treeRotation = float.Parse(customProperties[1]); switch (int.Parse(customProperties[2])) { case 0: this.treeCorner = TileCorner.TopLeft; break; case 1: this.treeCorner = TileCorner.TopRight; break; case 2: this.treeCorner = TileCorner.BottomLeft; break; case 3: this.treeCorner = TileCorner.BottomRight; break; } base.readCustomFileProperties(customProperties); }
public override void readCustomNetworkProperties(ref NetIncomingMessage message) { this.fruitful = message.ReadBoolean(); this.treeRotation = message.ReadDouble(); switch (message.ReadInt32()) { case 0: this.treeCorner = TileCorner.TopLeft; break; case 1: this.treeCorner = TileCorner.TopRight; break; case 2: this.treeCorner = TileCorner.BottomLeft; break; case 3: this.treeCorner = TileCorner.BottomRight; break; } base.readCustomNetworkProperties(ref message); }
public Color32 GetColor(Tile tile, int u, int v) { int h = v > Size / 2.0 ? 0 : 2; int w = u > Size / 2.0 ? 0 : 1; TileCorner tc = (TileCorner)h + w; return(tile[tc].GetPixel(v, Size - (u + 1))); }
public static void TryRemoveCornerFiller(Tile tile, TileCorner tileCorner) { if (tile == null) { return; } tile.TryRemoveCornerFiller(tileCorner); }
public void SetSettlement(PlayerColor player, TileCorner tileCorner) { var index = (int)tileCorner; if (this._settlements[index] == null) { this._settlements[index] = player; } throw new InvalidOperationException("Location already contains a settlement"); }
public override void PlaceCornerFiler(TileCorner tileCorner) { //create cornerfiller GameObject backgroundGO = GameObject.Instantiate(OverworldGameplayManager.Instance.GetTileBackgroundPrefab <TileCornerFiller>(), Tile.BackgroundsContainer); TileCornerFiller cornerFiller = backgroundGO.GetComponent <TileCornerFiller>(); cornerFiller.SetTile(Tile); cornerFiller.WithType(new OverworldDefaultGroundType()); cornerFiller.WithCorner(tileCorner); // pick sprite based on corner Tile.AddCornerFiller(cornerFiller); }
/// /// <summary> /// Gets the height of a particular corner of the tile. /// </summary> /// /// <param name="corner">The corner in question.</param> /// /// <returns> /// The height of the specified corner of the tile. /// </returns> /// public int getHeight(TileCorner corner) { switch (corner) { case TileCorner.BottomLeft: return(heights[0]); case TileCorner.TopLeft: return(heights[1]); case TileCorner.TopRight: return(heights[2]); case TileCorner.BottomRight: return(heights[3]); default: return(0); } }
/// /// <summary> /// Return the corner which is horizontally opposite from the specified corner. /// </summary> /// /// <param name="corner">The corner to swap.</param> /// public static TileCorner swapHorizontally(TileCorner corner) { switch (corner) { case TileCorner.TopLeft: return(TileCorner.TopRight); case TileCorner.BottomLeft: return(TileCorner.BottomRight); case TileCorner.TopRight: return(TileCorner.TopLeft); case TileCorner.BottomRight: return(TileCorner.BottomLeft); default: return(TileCorner.TopLeft); } }
/// /// <summary> /// Initializes a new instance of the <see cref="TreeTile"/> class. /// </summary> /// public TreeTile() : base() { this.networkID = NETWORK_TREE; this.slipperiness = 0.71F; // Make all tree tiles have a random chance of starting foragable. this.fruitful = (Program.random.Next(2) == 0); this.diggable = false; // Start the tree's growth at 0. this.growthLevel = 0; // Randomise the tree's position on the tile. this.treeCorner = Tile.getRandomCorner(); this.treeRotation = MathHelper.ToRadians((float)Program.random.NextDouble() * 360.0F); }
public IEnumerable <NeighbourTile> GetNeighbours(TileCorner corner) { var neighbourTileSides = this.GetTileSidesInCorner(corner); IList <NeighbourTile> tiles = new List <NeighbourTile>(); neighbourTileSides.ToList().ForEach(tileSide => { Tile tile = null; if (this._neighbours.TryGetValue(tileSide, out tile)) { tiles.Add(new NeighbourTile() { Tile = tile, Side = tileSide, Corner = this.GetMatchingCorner(corner, tileSide) }); } }); return(tiles); }
public static void TryAddCornerFiller(Tile tile, TileCorner tileCorner) { if (tile == null) { return; } //Check if there is already a tilecorner if (tile.TryGetCornerFiller(tileCorner)) { return; } //create cornerfiller GameObject backgroundGO = GameObject.Instantiate(GameManager.Instance.GameplayManager.GetTileBackgroundPrefab <TileCornerFiller>(), tile.BackgroundsContainer); TileCornerFiller cornerFiller = backgroundGO.GetComponent <TileCornerFiller>(); cornerFiller.SetTile(tile); cornerFiller.WithType(new OverworldDefaultGroundType()); cornerFiller.WithCorner(tileCorner); // pick sprite based on corner tile.AddCornerFiller(cornerFiller); }
/// /// <summary> /// Changes the height of a corner of the tile. /// </summary> /// /// <param name="corner">The corner to change.</param> /// <param name="change">The amount to change the corner by (positive or negative integer.</param> /// public virtual void changeHeight(TileCorner corner, int change) { switch (corner) { case TileCorner.TopLeft: heights[1] += change; return; case TileCorner.TopRight: heights[2] += change; return; case TileCorner.BottomLeft: heights[0] += change; return; case TileCorner.BottomRight: heights[3] += change; return; default: return; } }
public abstract void PlaceCornerFiler(TileCorner tileCorner);
private TileCorner GetMatchingCorner(TileCorner thisCorner, TileSide neighboursTileSide) { var errorMessage = "There are no matching corners for this corner and tile side match"; switch (thisCorner) { case TileCorner.Top: if (neighboursTileSide == TileSide.TopLeft) { return(TileCorner.BottomLeft); } else if (neighboursTileSide == TileSide.TopRight) { return(TileCorner.BottomRight); } else { throw new InvalidOperationException(errorMessage); } case TileCorner.TopRight: if (neighboursTileSide == TileSide.TopRight) { return(TileCorner.Bottom); } else if (neighboursTileSide == TileSide.Right) { return(TileCorner.TopLeft); } else { throw new InvalidOperationException(errorMessage); } case TileCorner.BottomRight: if (neighboursTileSide == TileSide.Right) { return(TileCorner.BottomLeft); } else if (neighboursTileSide == TileSide.BottomRight) { return(TileCorner.Top); } else { throw new InvalidOperationException(errorMessage); } case TileCorner.Bottom: if (neighboursTileSide == TileSide.BottomRight) { return(TileCorner.TopLeft); } else if (neighboursTileSide == TileSide.BottomLeft) { return(TileCorner.TopRight); } else { throw new InvalidOperationException(errorMessage); } case TileCorner.BottomLeft: if (neighboursTileSide == TileSide.BottomLeft) { return(TileCorner.Top); } else if (neighboursTileSide == TileSide.Left) { return(TileCorner.BottomRight); } else { throw new InvalidOperationException(errorMessage); } case TileCorner.TopLeft: if (neighboursTileSide == TileSide.Left) { return(TileCorner.TopRight); } else if (neighboursTileSide == TileSide.TopLeft) { return(TileCorner.Bottom); } else { throw new InvalidOperationException(errorMessage); } default: throw new InvalidOperationException(errorMessage); } }
public bool IsCornerEmpty(TileCorner tileCorner) { return(this._settlements[(int)tileCorner] == null); }