override public Tile GetTile(HexCoordinates coords) { Vector3 offsets = BaseList.CoordsToOffsets(coords); if (offsets.x >= XDim || offsets.x < 0 || offsets.z >= ZDim || offsets.z < 0) { return(null); } return(BaseList.GetTile(new Vector3(offsets.x, TileHeight((int)offsets.x, (int)offsets.z), offsets.z))); }
override public void SetTile(HexCoordinates coords, Tile tile) { Tile holdme = tile; //prevent overwriting a tile when swapping Vector3 TargetOffsets = BaseList.CoordsToOffsets(coords); int TargetHeight = TileHeight((int)TargetOffsets.x, (int)TargetOffsets.z); if (TargetHeight > coords.Depth) //tile(s) exist at a higher level than where this tile is being set { SetTileHeight(coords, coords.Depth); } BaseList.SetTile(coords, holdme); }
override public Vector3 TileLocation(HexCoordinates coords) { return(TileLocation(BaseList.CoordsToOffsets(coords))); }
protected Tile GetTile(int index) { if (index >= Count || index < 0) { throw new ArgumentOutOfRangeException(String.Format("Index:{0}, Length:{1}", index, Count)); } int? TrueIndex; HexCoordinates trueCoords = IndexToCoords(index); TrueIndex = BaseList.CoordsToIndex(trueCoords); if (!TrueIndex.HasValue) { string errorstring = String.Format("Index:{0}, TrueIndex:null, TileHeight:{4}, trueCoords:{2}, TrueListCount:{3} Offsets:{5}", index, TrueIndex, trueCoords.ToString(), BaseList.Count, "n/a", BaseList.CoordsToOffsets(trueCoords)); throw new Exception(errorstring); //I dont know if this ever comes up. } Tile ret = BaseList.GetTile(BaseList.IndexToCoords(TrueIndex.Value)); //converting it to this then converting right back... oi. if (ret == null) //Also never comes up, but STILL... { string errorstring = String.Format("Index:{0}, TrueIndex:{1}, TileHeight:{4}, trueCoords:{2}, TrueListCount:{3}", index, TrueIndex, trueCoords.ToString(), BaseList.Count, "n/a"); throw new Exception(errorstring); } return(ret); }