示例#1
0
        private void BuildMap(JsonMapData loadedMapData)
        {
            foreach (JsonTiles tile in loadedMapData.tiles)
            {
                if ((TileType)tile.type == TileType.Transition)
                {
                    TransitionTile newTileTransition = TileFactory.CreateTile(TileType.Transition) as TransitionTile;
                    newTileTransition.IsOpenForTransition = tile.IsOpenForTransition;
                    newTileTransition.X = tile.xCoord;
                    newTileTransition.Y = tile.yCoord;
                    CurrentMap.Add(newTileTransition);
                }
                if (tile != null)
                {
                    BaseTile newTile = TileFactory.CreateTile((TileType)tile.type);
                    newTile.X = tile.xCoord;
                    newTile.Y = tile.yCoord;
                    CurrentMap.Add(newTile);
                }
            }

            CurrentMap.Sort((leftTile, rightTile) =>
                            leftTile.X <= rightTile.X &&
                            leftTile.Y <= rightTile.Y ?
                            1 : -1);

            rows = loadedMapData.rows;
            cols = loadedMapData.cols;
        }
示例#2
0
        private BaseTile GetTileAtLocation(int xCor, int yCor)
        {
            BaseTile tile = CurrentMap.Find((BaseTile obj) =>
                                            obj.X == xCor &&
                                            obj.Y == yCor);

            if (tile == null)
            {
                return(TileFactory.CreateTile(TileType.Void));
            }
            return(tile);
        }