private static MapCellState DeserializeMapCellState(BinaryReader Reader, MapCell cell, MapPoint point)
        {
            if (cell == null)
            {
                return(null);
            }
            MapCellState state = new MapCellState(cell, point);

            state.Place = DeserializeMapPlaceState(Reader, cell.Place);

            MapWall northWall = cell.GetWall(MapDirection.North);
            MapWall southWall = cell.GetWall(MapDirection.South);
            MapWall westWall  = cell.GetWall(MapDirection.West);
            MapWall eastWall  = cell.GetWall(MapDirection.East);

            if (northWall != null)
            {
                state.SetWall(MapDirection.North, DeserializeMapWallState(Reader, northWall, MapDirection.North));
            }
            if (southWall != null)
            {
                state.SetWall(MapDirection.South, DeserializeMapWallState(Reader, southWall, MapDirection.South));
            }
            if (westWall != null)
            {
                state.SetWall(MapDirection.North, DeserializeMapWallState(Reader, westWall, MapDirection.West));
            }
            if (eastWall != null)
            {
                state.SetWall(MapDirection.North, DeserializeMapWallState(Reader, eastWall, MapDirection.East));
            }

            return(state);
        }
Exemplo n.º 2
0
 void OnWizardCreate()
 {
     if (wall == null && Selection.activeGameObject != null)
     {
         wall = Selection.activeGameObject.GetComponent <MapWall> ();
     }
     MapEventActionManager.CreateResetWallAction(Selection.activeGameObject, wall, show);
 }
        private static MapWallState DeserializeMapWallState(BinaryReader Reader, MapWall wall, MapDirection direction)
        {
            MapWallState state = new MapWallState(wall, direction);

            state.Mode   = DeserializeMapWallMode(Reader);
            state.Health = Reader.ReadUInt16();
            return(state);
        }
Exemplo n.º 4
0
    public static void CreateResetWallAction(GameObject target, MapWall wall, bool show)
    {
        var action = CreateAction <ResetWallAction> (target, Example.MapEventAction.Type.SHOW_WALL, null);

        action.wall = wall;
        action.show = show;

        Selection.activeGameObject = action.gameObject;
    }
Exemplo n.º 5
0
    public static void CreateClearWallAction(GameObject target, MapWall wall, int winKey)
    {
        var action = CreateAction <ClearWallAction> (target, Example.MapEventAction.Type.CLEARWALL, null);

        action.wall = wall;
        action.key  = winKey;

        Selection.activeGameObject = action.gameObject;
    }
Exemplo n.º 6
0
        public GameMap MapCreation(UInt16 MapWidth, UInt16 MapHeight, UInt16 LevelsCount, UInt16 WallsCountOnWalledCells, double WalledCellProbability)
        {
            GameMap game = null;
            Map     map;

            Random rand = new Random();

            try
            {
                MapImage image         = new MapImage(MapImageType.Bmp, null);
                MapPlace place         = new MapPlace(image, (float)0.8);
                MapWall  destroyedWall = new MapWall(image, MapDirection.North, 200);
                MapWall  wall          = new MapWall(image, MapDirection.North, 200);
                Dictionary <MapDirection, MapWall> walls = new Dictionary <MapDirection, MapWall>();

                if (WallsCountOnWalledCells > 0)
                {
                    walls.Add(MapDirection.North, wall);
                }
                if (WallsCountOnWalledCells > 1)
                {
                    walls.Add(MapDirection.South, wall);
                }
                if (WallsCountOnWalledCells > 2)
                {
                    walls.Add(MapDirection.West, wall);
                }
                if (WallsCountOnWalledCells > 3)
                {
                    walls.Add(MapDirection.East, wall);
                }

                bool isWall      = false;
                int  probability = (int)Math.Round(WalledCellProbability * 100.0);

                map = new Map(LevelsCount, new MapSize(MapWidth, MapHeight));
                for (int z = 0; z < map.LevelsCount; z++)
                {
                    for (int x = 0; x < map.Size.Width; x++)
                    {
                        for (int y = 0; y < map.Size.Height; y++)
                        {
                            isWall = rand.Next(0, 100) < probability;
                            map.Levels[z].Cells[x, y] = new MapCell(place, isWall ? walls : null);
                        }
                    }
                }
                game = new GameMap(new MapState(map));
            }
            catch
            {
            }

            return(game);
        }
Exemplo n.º 7
0
 protected override void OnUpdate()
 {
     if (wall != null)
     {
         objPath = MapEventHelper.GetGameObjectPath(wall.transform);
     }
     else if (objPath != null && wall == null)
     {
         wall = GameObject.Find(objPath).GetComponent <MapWall> ();
     }
 }
Exemplo n.º 8
0
    //Create wall between the current cell and the other cell, called if other cell is null
    void CreateWall(Cell cell, Cell otherCell, MapDirection dir)
    {
        //Instantiate a wall on the correct side of the cell
        MapWall wall = Instantiate(wallPrefab) as MapWall;

        wall.Initialise(cell, otherCell, dir);
        //Instantiate a wall on the opposite side of the other cell if it isn't null
        if (otherCell != null)
        {
            wall = Instantiate(wallPrefab) as MapWall;
            wall.Initialise(otherCell, cell, dir.GetOpposite());
        }
    }
Exemplo n.º 9
0
 public static void SerializeMapWall(BinaryWriter Writer, MapWall Wall)
 {
     SerializeMapVisualObject(Writer, Wall);
     SerializeMapDirection(Writer, Wall.BaseDirection);
     SerializeMapDirection(Writer, Wall.CornerDirection);
     SerializeMapImage(Writer, Wall.ImageWindow);
     SerializeMapImage(Writer, Wall.ImageDoor);
     SerializeMapImage(Writer, Wall.ImageCorner);
     //SerializeMapObjectReference(Writer, Wall.DestroyedWall);
     SerializeMapWallMode(Writer, Wall.Mode);
     SerializeMapArmorType(Writer, Wall.ArmorType);
     Writer.Write(Wall.Health);
 }
Exemplo n.º 10
0
	static Example.MapWall ExportMapWall(List<Example.MapWall> walls,MapWall sceneWall){

		var size = MapUtil.ToVector3f(sceneWall.GetComponent<BoxCollider> ().size); 
		size.X *= sceneWall.transform.localScale.x;
		size.Y *= sceneWall.transform.localScale.y;
		size.Z *= sceneWall.transform.localScale.z;

		Example.MapWall mapWall = new Example.MapWall ();
		mapWall.Center = MapUtil.ToVector3f(sceneWall.transform.position);
		mapWall.Size = size;
		mapWall.Rotation =  MapUtil.ToVector3f(sceneWall.transform.rotation.eulerAngles);
		mapWall.RequiredKey = sceneWall.requiredKey; 
		mapWall.Autoshow = sceneWall.autoshow;
		mapWall.EffectPath = sceneWall.effectPath;

		walls.Add (mapWall);
		mapWall.Id = walls.Count; 
		sceneWall.wallId = mapWall.Id;
		return mapWall;
	}
        private static MapWall DeserializeMapWall(BinaryReader Reader, ref Guid DestroyedReference)
        {
            MapWall wall = new MapWall();

            DeserializeMapVisualObject(Reader, wall);
            wall.BaseDirection   = DeserializeMapDirection(Reader);
            wall.CornerDirection = DeserializeMapDirection(Reader);
            wall.ImageWindow     = DeserializeMapImage(Reader);
            wall.ImageDoor       = DeserializeMapImage(Reader);
            wall.ImageCorner     = DeserializeMapImage(Reader);


            //Guid destroyed = DeserializeMapObjectReference(Reader);
            //if (destroyed != Guid.Empty) DestroyedReference = destroyed;

            wall.Mode      = DeserializeMapWallMode(Reader);
            wall.ArmorType = DeserializeMapArmorType(Reader);
            wall.Health    = Reader.ReadUInt16();

            return(wall);
        }
Exemplo n.º 12
0
        public Map GenerateMapFromBlueprint()
        {
            var map = new Map(_width * 2 + 1, _height * 2 + 1);

            for (int x = 0; x < _width; ++x)
            {
                for (int y = 0; y < _height; ++y)
                {
                    var room = _roomsArray[x, y];
                    if (room == null)
                    {
                        continue;
                    }

                    var point = new Point(x, y);
                    var px    = 1 + x * 2;
                    var py    = 1 + y * 2;

                    if (x == 0 || _roomsArray[x - 1, y] != room)
                    {
                        map.AddMapEntity(MapWall.WestWall(point));
                    }
                    if (x == _width - 1 || _roomsArray[x + 1, y] != room)
                    {
                        map.AddMapEntity(MapWall.EastWall(point));
                    }
                    if (y == 0 || _roomsArray[x, y - 1] != room)
                    {
                        map.AddMapEntity(MapWall.NorthWall(point));
                    }
                    if (y == _height - 1 || _roomsArray[x, y + 1] != room)
                    {
                        map.AddMapEntity(MapWall.SouthWall(point));
                    }

                    map.AddMapEntity(new MapTile(new Point(px, py), TileType.Empty));
                }
            }
            return(map);
        }
Exemplo n.º 13
0
        private static void SerializeMapCell(BinaryWriter Writer, MapCell Cell, List <Guid> IdTable)
        {
            if (Cell == null)
            {
                SerializeMapCellType(Writer, MapCellSerializationType.Null); return;
            }

            int idIndexBytesCount = 1;

            if (IdTable.Count > byte.MaxValue - 5)
            {
                idIndexBytesCount = 2;
            }
            if (IdTable.Count > UInt16.MaxValue - 5)
            {
                idIndexBytesCount = 4;
            }

            MapCellSerializationType type = MapCellSerializationType.Place;
            MapWall northWall             = Cell.GetWall(MapDirection.North);
            MapWall southWall             = Cell.GetWall(MapDirection.South);
            MapWall westWall = Cell.GetWall(MapDirection.West);
            MapWall eastWall = Cell.GetWall(MapDirection.East);

            if (northWall != null)
            {
                type = type | MapCellSerializationType.NorthWall;
            }
            if (southWall != null)
            {
                type = type | MapCellSerializationType.SouthWall;
            }
            if (westWall != null)
            {
                type = type | MapCellSerializationType.WestWall;
            }
            if (eastWall != null)
            {
                type = type | MapCellSerializationType.EastWall;
            }
            if (idIndexBytesCount == 1)
            {
                type = type | MapCellSerializationType.IdIndex8;
            }
            else
            if (idIndexBytesCount == 2)
            {
                type = type | MapCellSerializationType.IdIndex16;
            }
            else
            if (idIndexBytesCount == 4)
            {
                type = type | MapCellSerializationType.IdIndex32;
            }

            SerializeMapCellType(Writer, type);

            int placeIndex = IdTable.IndexOf(Cell.Place.Id);

            if (placeIndex < 0)
            {
                IdTable.Add(Cell.Place.Id); placeIndex = IdTable.Count - 1;
            }

            SerializeMapCellIdIndex(Writer, idIndexBytesCount, placeIndex);

            if (northWall != null)
            {
                int wallIndex = IdTable.IndexOf(northWall.Id);
                if (wallIndex < 0)
                {
                    IdTable.Add(northWall.Id); wallIndex = IdTable.Count - 1;
                }
                SerializeMapCellIdIndex(Writer, idIndexBytesCount, wallIndex);
            }

            if (southWall != null)
            {
                int wallIndex = IdTable.IndexOf(southWall.Id);
                if (wallIndex < 0)
                {
                    IdTable.Add(southWall.Id); wallIndex = IdTable.Count - 1;
                }
                SerializeMapCellIdIndex(Writer, idIndexBytesCount, wallIndex);
            }

            if (westWall != null)
            {
                int wallIndex = IdTable.IndexOf(westWall.Id);
                if (wallIndex < 0)
                {
                    IdTable.Add(westWall.Id); wallIndex = IdTable.Count - 1;
                }
                SerializeMapCellIdIndex(Writer, idIndexBytesCount, wallIndex);
            }

            if (eastWall != null)
            {
                int wallIndex = IdTable.IndexOf(eastWall.Id);
                if (wallIndex < 0)
                {
                    IdTable.Add(eastWall.Id); wallIndex = IdTable.Count - 1;
                }
                SerializeMapCellIdIndex(Writer, idIndexBytesCount, wallIndex);
            }
        }
Exemplo n.º 14
0
        public static void PathTest()
        {
            GameMap game;
            Map     map;

            Random rand = new Random();

            try
            {
                MapImage image = new MapImage(MapImageType.Bmp, null);
                MapPlace place = new MapPlace(image, (float)0.8)
                {
                    Name = "1"
                };
                //MapWall destroyedWall = new MapWall("2", image, MapDirection.North, 200);
                MapWall wall = new MapWall(image, MapDirection.North, 200)
                {
                    Name = "3"
                };
                Dictionary <MapDirection, MapWall> walls = new Dictionary <MapDirection, MapWall>();

                map = new Map(1, new MapSize(16, 16))
                {
                    Name = "Map"
                };
                for (int z = 0; z < map.LevelsCount; z++)
                {
                    for (int x = 0; x < map.Size.Width; x++)
                    {
                        for (int y = 0; y < map.Size.Height; y++)
                        {
                            map.Levels[z].Cells[x, y] = new MapCell(place, null);
                        }
                    }
                }
                MapAreas areas = new MapAreas();
                //   MapAreaTransitionPoint pnt1=new MapAreaTransitionPoint("", "",
                areas.Areas.Add(new MapArea(new MapPoint(0, 0, 0), new MapSize(4, 4)));
                areas.Areas.Add(new MapArea(new MapPoint(0, 4, 0), new MapSize(4, 4)));
                areas.Areas.Add(new MapArea(new MapPoint(0, 8, 0), new MapSize(4, 4)));
                areas.Areas.Add(new MapArea(new MapPoint(0, 12, 0), new MapSize(4, 4)));
                areas.Areas.Add(new MapArea(new MapPoint(0, 0, 4), new MapSize(4, 4)));
                areas.Areas.Add(new MapArea(new MapPoint(0, 4, 4), new MapSize(4, 4)));
                areas.Areas.Add(new MapArea(new MapPoint(0, 8, 4), new MapSize(4, 4)));
                areas.Areas.Add(new MapArea(new MapPoint(0, 12, 4), new MapSize(4, 4)));
                areas.Areas.Add(new MapArea(new MapPoint(0, 0, 8), new MapSize(4, 4)));
                areas.Areas.Add(new MapArea(new MapPoint(0, 4, 8), new MapSize(4, 4)));
                areas.Areas.Add(new MapArea(new MapPoint(0, 8, 8), new MapSize(4, 4)));
                areas.Areas.Add(new MapArea(new MapPoint(0, 12, 8), new MapSize(4, 4)));
                areas.Areas.Add(new MapArea(new MapPoint(0, 0, 12), new MapSize(4, 4)));
                areas.Areas.Add(new MapArea(new MapPoint(0, 4, 12), new MapSize(4, 4)));
                areas.Areas.Add(new MapArea(new MapPoint(0, 8, 12), new MapSize(4, 4)));
                areas.Areas.Add(new MapArea(new MapPoint(0, 12, 12), new MapSize(4, 4)));
                MapAreaTransitionPoint[] tr0  = new MapAreaTransitionPoint[] { new MapAreaTransitionPoint(areas.Areas[0], areas.Areas[1], new MapPoint(0, 0, 0), new MapSize(1, 1)), new MapAreaTransitionPoint(areas.Areas[0], areas.Areas[5], new MapPoint(0, 1, 1), new MapSize(1, 1)) };
                MapAreaTransitionPoint[] tr1  = new MapAreaTransitionPoint[] { new MapAreaTransitionPoint(areas.Areas[1], areas.Areas[0], new MapPoint(0, 0, 0), new MapSize(1, 1)) };
                MapAreaTransitionPoint[] tr5  = new MapAreaTransitionPoint[] { new MapAreaTransitionPoint(areas.Areas[5], areas.Areas[0], new MapPoint(0, 0, 0), new MapSize(1, 1)), new MapAreaTransitionPoint(areas.Areas[5], areas.Areas[2], new MapPoint(0, 0, 0), new MapSize(1, 1)) };
                MapAreaTransitionPoint[] tr2  = new MapAreaTransitionPoint[] { new MapAreaTransitionPoint(areas.Areas[2], areas.Areas[5], new MapPoint(0, 0, 0), new MapSize(1, 1)), new MapAreaTransitionPoint(areas.Areas[2], areas.Areas[7], new MapPoint(0, 0, 0), new MapSize(1, 1)) };
                MapAreaTransitionPoint[] tr3  = new MapAreaTransitionPoint[] { new MapAreaTransitionPoint(areas.Areas[3], areas.Areas[6], new MapPoint(0, 0, 0), new MapSize(1, 1)) };
                MapAreaTransitionPoint[] tr4  = new MapAreaTransitionPoint[] { new MapAreaTransitionPoint(areas.Areas[4], areas.Areas[8], new MapPoint(0, 0, 0), new MapSize(1, 1)) };
                MapAreaTransitionPoint[] tr6  = new MapAreaTransitionPoint[] { new MapAreaTransitionPoint(areas.Areas[6], areas.Areas[3], new MapPoint(0, 0, 0), new MapSize(1, 1)), new MapAreaTransitionPoint(areas.Areas[6], areas.Areas[10], new MapPoint(0, 0, 0), new MapSize(1, 1)) };
                MapAreaTransitionPoint[] tr7  = new MapAreaTransitionPoint[] { new MapAreaTransitionPoint(areas.Areas[7], areas.Areas[2], new MapPoint(0, 0, 0), new MapSize(1, 1)), new MapAreaTransitionPoint(areas.Areas[7], areas.Areas[10], new MapPoint(0, 0, 0), new MapSize(1, 1)) };
                MapAreaTransitionPoint[] tr8  = new MapAreaTransitionPoint[] { new MapAreaTransitionPoint(areas.Areas[8], areas.Areas[4], new MapPoint(0, 0, 0), new MapSize(1, 1)), new MapAreaTransitionPoint(areas.Areas[8], areas.Areas[9], new MapPoint(0, 0, 0), new MapSize(1, 1)), new MapAreaTransitionPoint(areas.Areas[8], areas.Areas[12], new MapPoint(0, 0, 0), new MapSize(1, 1)) };
                MapAreaTransitionPoint[] tr13 = new MapAreaTransitionPoint[] { new MapAreaTransitionPoint(areas.Areas[13], areas.Areas[9], new MapPoint(0, 0, 0), new MapSize(1, 1)), new MapAreaTransitionPoint(areas.Areas[13], areas.Areas[14], new MapPoint(0, 0, 0), new MapSize(1, 1)), new MapAreaTransitionPoint(areas.Areas[13], areas.Areas[10], new MapPoint(0, 0, 0), new MapSize(1, 1)) };
                MapAreaTransitionPoint[] tr9  = new MapAreaTransitionPoint[] { new MapAreaTransitionPoint(areas.Areas[9], areas.Areas[8], new MapPoint(0, 0, 0), new MapSize(1, 1)), new MapAreaTransitionPoint(areas.Areas[9], areas.Areas[13], new MapPoint(0, 0, 0), new MapSize(1, 1)) };
                MapAreaTransitionPoint[] tr12 = new MapAreaTransitionPoint[] { new MapAreaTransitionPoint(areas.Areas[12], areas.Areas[8], new MapPoint(0, 0, 0), new MapSize(1, 1)) };
                MapAreaTransitionPoint[] tr14 = new MapAreaTransitionPoint[] { new MapAreaTransitionPoint(areas.Areas[14], areas.Areas[13], new MapPoint(0, 0, 0), new MapSize(1, 1)) };
                MapAreaTransitionPoint[] tr15 = new MapAreaTransitionPoint[] { new MapAreaTransitionPoint(areas.Areas[15], areas.Areas[10], new MapPoint(0, 0, 0), new MapSize(1, 1)) };
                MapAreaTransitionPoint[] tr11 = new MapAreaTransitionPoint[] { new MapAreaTransitionPoint(areas.Areas[11], areas.Areas[10], new MapPoint(0, 0, 0), new MapSize(1, 1)) };
                MapAreaTransitionPoint[] tr10 = new MapAreaTransitionPoint[] { new MapAreaTransitionPoint(areas.Areas[10], areas.Areas[6], new MapPoint(0, 0, 0), new MapSize(1, 1)), new MapAreaTransitionPoint(areas.Areas[10], areas.Areas[7], new MapPoint(0, 0, 0), new MapSize(1, 1)), new MapAreaTransitionPoint(areas.Areas[10], areas.Areas[11], new MapPoint(0, 0, 0), new MapSize(1, 1)), new MapAreaTransitionPoint(areas.Areas[10], areas.Areas[15], new MapPoint(0, 0, 0), new MapSize(1, 1)), new MapAreaTransitionPoint(areas.Areas[10], areas.Areas[13], new MapPoint(0, 0, 0), new MapSize(1, 1)) };
                areas.Areas[0].TransitionPoints.AddRange(tr0);
                areas.Areas[1].TransitionPoints.AddRange(tr1);
                areas.Areas[2].TransitionPoints.AddRange(tr2);
                areas.Areas[3].TransitionPoints.AddRange(tr3);
                areas.Areas[4].TransitionPoints.AddRange(tr4);
                areas.Areas[5].TransitionPoints.AddRange(tr5);
                areas.Areas[6].TransitionPoints.AddRange(tr6);
                areas.Areas[7].TransitionPoints.AddRange(tr7);
                areas.Areas[8].TransitionPoints.AddRange(tr8);
                areas.Areas[9].TransitionPoints.AddRange(tr9);
                areas.Areas[10].TransitionPoints.AddRange(tr10);
                areas.Areas[11].TransitionPoints.AddRange(tr11);
                areas.Areas[12].TransitionPoints.AddRange(tr12);
                areas.Areas[13].TransitionPoints.AddRange(tr13);
                areas.Areas[14].TransitionPoints.AddRange(tr14);
                areas.Areas[15].TransitionPoints.AddRange(tr15);

                map.Areas = areas;

                MapState state = new MapState(map);


                game = new GameMap(new MapState(map));
            }
            catch
            {
            }

            Int64 memory = GC.GetTotalMemory(false);

            map  = null;
            game = null;
            GC.Collect();
        }
 private static MapWallState DeserializeMapWallState(BinaryReader Reader, MapWall wall, MapDirection direction)
 {
     MapWallState state = new MapWallState(wall, direction);
     state.Mode = DeserializeMapWallMode(Reader);
     state.Health = Reader.ReadUInt16();
     return state;
 }
        private static MapWall DeserializeMapWall(BinaryReader Reader, ref Guid DestroyedReference)
        {
            MapWall wall = new MapWall();
            DeserializeMapVisualObject(Reader, wall);
            wall.BaseDirection = DeserializeMapDirection(Reader);
            wall.CornerDirection = DeserializeMapDirection(Reader);
            wall.ImageWindow = DeserializeMapImage(Reader);
            wall.ImageDoor = DeserializeMapImage(Reader);
            wall.ImageCorner = DeserializeMapImage(Reader);

            //Guid destroyed = DeserializeMapObjectReference(Reader);
            //if (destroyed != Guid.Empty) DestroyedReference = destroyed;

            wall.Mode = DeserializeMapWallMode(Reader);
            wall.ArmorType = DeserializeMapArmorType(Reader);
            wall.Health = Reader.ReadUInt16();

            return wall;
        }
Exemplo n.º 17
0
 public WallViewModel(MapWall wall)
     : base(wall)
 {
     Source = wall;
 }
Exemplo n.º 18
0
        //[TestMethod]
        public void TestSaveMap()
        {
            MapImage image   = new MapImage(MapImageType.Bmp, null);
            MapSize  mapSize = new MapSize(1000, 1000);
            Map      map     = new Map(1, mapSize);

            map.Version = new Version(1, 2, 3, 4);
            MapPlace place1 = new MapPlace(image, 1);
            MapPlace place2 = new MapPlace(image, 0.8f);
            MapWall  wall   = new MapWall(image, MapDirection.North, 200);

            MapActiveObject testObj1 = new MapActiveObject(image, null, new MapSize(2, 3), MapDirection.West, MapArmorType.Heavy, 120, 1);
            MapActiveObject testObj2 = new MapActiveObject(image, null, new MapSize(20, 30), MapDirection.West, MapArmorType.Machine, 121, 1);
            MapActiveObject testObj3 = new MapActiveObject(image, null, new MapSize(200, 300), MapDirection.West, MapArmorType.None, 122, 1);
            MapActiveObject testObj4 = new MapActiveObject(image, null, new MapSize(259, 355), MapDirection.West, MapArmorType.Undead, 123, 1);

            MapArea area1 = new MapArea(new MapPoint(0, 20, 30), new MapSize(50, 50));
            MapArea area2 = new MapArea(new MapPoint(0, 200, 300), new MapSize(100, 100));
            MapArea area3 = new MapArea(new MapPoint(0, 100, 100), new MapSize(10, 10));

            MapAreaTransitionPoint transPoint1 = new MapAreaTransitionPoint(area1, area2, new MapPoint(0, 25, 35), new MapSize(5, 5));
            MapAreaTransitionPoint transPoint2 = new MapAreaTransitionPoint(area2, area3, new MapPoint(0, 225, 325), new MapSize(5, 5));
            MapAreaTransitionPoint transPoint3 = new MapAreaTransitionPoint(area3, area1, new MapPoint(0, 105, 105), new MapSize(2, 2));

            area1.TransitionPoints.Add(transPoint1);
            area2.TransitionPoints.Add(transPoint2);
            area3.TransitionPoints.Add(transPoint3);



            map.TileSet.Add(place1);
            map.TileSet.Add(place2);
            map.TileSet.Add(wall);
            map.TileSet.Add(testObj1);
            map.TileSet.Add(testObj2);
            map.TileSet.Add(testObj3);
            map.TileSet.Add(testObj4);
            map.Areas.Areas.Add(area1);
            map.Areas.Areas.Add(area2);
            map.Areas.Areas.Add(area3);

            for (int x = 0; x < mapSize.Width / 2; x++)
            {
                for (int y = 0; y < mapSize.Height; y++)
                {
                    map.Levels[0].Cells[x, y] = new MapCell(place1, new Dictionary <MapDirection, MapWall>());
                }
            }

            for (int x = mapSize.Width / 2; x < mapSize.Width; x++)
            {
                for (int y = 0; y < mapSize.Height; y++)
                {
                    map.Levels[0].Cells[x, y] = new MapCell(place2, new Dictionary <MapDirection, MapWall>());
                }
            }

            map.Levels[0].Cells[5, 6].SetWall(MapDirection.South, wall);

            Exception exception = null;

            MapState mapState = new MapState(map);

            mapState.AddActiveObject(testObj1, new MapPoint(0, 1, 1));
            mapState.AddActiveObject(testObj2, new MapPoint(0, 100, 100));
            mapState.AddActiveObject(testObj3, new MapPoint(0, 200, 200));
            mapState.AddActiveObject(testObj4, new MapPoint(0, 500, 500));
            Map      map2      = null;
            MapState mapState2 = null;

            try
            {
                DateTime start  = DateTime.Now;
                byte[]   data   = MapSerializer.Instance.SerializeMapState(mapState);
                DateTime finish = DateTime.Now;
                mapState2 = MapSerializer.Instance.DeserializeMapState(data);
                map2      = mapState2.Map;
            }
            catch (Exception ex)
            {
                exception = ex;
            }

            Assert.IsNull(exception);

            Assert.IsNotNull(map2);
            Assert.AreEqual(map2[0, 0, 0].Place.Id, place1.Id);
            Assert.AreEqual(map2[0, 0, 0].Place.Passability, place1.Passability);
            Assert.AreEqual(map2[0, mapSize.Width - 1, 0].Place.Id, place2.Id);
            Assert.AreEqual(map2[0, mapSize.Width - 1, 0].Place.Passability, place2.Passability);
            Assert.AreEqual(map2[0, 5, 6].Walls[MapDirection.South].Id, wall.Id);
            Assert.AreEqual(map2[0, 5, 6].Walls[MapDirection.South].Health, wall.Health);
            Assert.AreEqual(map2.Areas.Areas[1].Position, map.Areas.Areas[1].Position);
            Assert.AreEqual(map2.Areas.Areas[2].TransitionPoints[0].From.Name, map.Areas.Areas[2].TransitionPoints[0].From.Name);
            Assert.AreEqual(map2.Areas.Areas[2].TransitionPoints[0].To.Name, map.Areas.Areas[2].TransitionPoints[0].To.Name);
            Assert.AreEqual(map2.Areas.Areas[2].TransitionPoints[0].Position, map.Areas.Areas[2].TransitionPoints[0].Position);
            Assert.AreEqual(mapState2.ActiveObjects.Count, mapState.ActiveObjects.Count);
        }
 public static void SerializeMapWall(BinaryWriter Writer, MapWall Wall)
 {
     SerializeMapVisualObject(Writer, Wall);
     SerializeMapDirection(Writer, Wall.BaseDirection);
     SerializeMapDirection(Writer, Wall.CornerDirection);
     SerializeMapImage(Writer, Wall.ImageWindow);
     SerializeMapImage(Writer, Wall.ImageDoor);
     SerializeMapImage(Writer, Wall.ImageCorner);
     //SerializeMapObjectReference(Writer, Wall.DestroyedWall);
     SerializeMapWallMode(Writer, Wall.Mode);
     SerializeMapArmorType(Writer, Wall.ArmorType);
     Writer.Write(Wall.Health);
 }