Exemplo n.º 1
0
        private static Tile ConvertFromTileJson(TileJson source, VectorBase position)
        {
            var result = new Tile();

            result.Visible    = source.Visible;
            result.Type       = TileTypeFactory.Instance.GetById(source.TileType);
            result.IsExplored = source.IsExplored;
            result.Position   = source.Position ?? position;
            return(result);
        }
Exemplo n.º 2
0
        private static TileJson ConvertToTileJson(Tile source, VectorBase position)
        {
            var result = new TileJson();

            result.Visible    = source.Visible;
            result.TileType   = source.Type.Name;
            result.IsExplored = source.IsExplored;
            result.Position   = source.Position ?? position;

            return(result);
        }
Exemplo n.º 3
0
        private static TileJson[,] ConvertToJsonMatrix(Tile[,] source)
        {
            var matrixWidth  = source.GetUpperBound(0) + 1;
            var matrixHeight = source.GetUpperBound(1) + 1;

            var result = new TileJson[matrixWidth, matrixHeight];

            for (var rowIndex = 0; rowIndex < matrixHeight; rowIndex++)
            {
                for (var columnIndex = 0; columnIndex < matrixWidth; columnIndex++)
                {
                    result[columnIndex, rowIndex] = ConvertToTileJson(source[columnIndex, rowIndex], new VectorBase(columnIndex, rowIndex));
                }
            }

            return(result);
        }