Ejemplo n.º 1
0
        public void Load(BinaryReader reader)
        {
            //read from memory stream
            Title = reader.ReadString();
            Music = reader.ReadString();
            Indoors = reader.ReadBoolean();
            Darkness = reader.ReadInt32();
            Weather = (Enums.Weather)reader.ReadInt32();
            TimeLimit = reader.ReadInt32();
            MinNpcs = reader.ReadInt32();
            MaxNpcs = reader.ReadInt32();
            NpcSpawnTime = reader.ReadInt32();

            int npcSpawnCount = reader.ReadInt32();
            for (int i = 0; i < NpcSpawns.Count; i++)
            {
                NpcSpawnData spawnData = new NpcSpawnData();
                spawnData.Data.Species = reader.ReadInt32();
                spawnData.Data.Form = reader.ReadInt32();
                spawnData.Data.Gender = (Enums.Gender)reader.ReadInt32();
                spawnData.Data.Shiny = (Enums.Coloration)reader.ReadInt32();

                spawnData.Loc.X = reader.ReadInt32();
                spawnData.Loc.Y = reader.ReadInt32();

                spawnData.MinLevel = reader.ReadInt32();
                spawnData.MaxLevel = reader.ReadInt32();

                for (int j = 0; j < spawnData.Moves.Length; i++)
                {
                    spawnData.Moves[j] = reader.ReadInt32();
                }

                spawnData.AppearanceRate = reader.ReadInt32();

                NpcSpawns.Add(spawnData);
            }

            int width = reader.ReadInt32();
            int height = reader.ReadInt32();

            MapArray = new Tile[width, height];
            for (int y = 0; y < Height; y++)
            {
                for (int x = 0; x < Width; x++)
                {
                    MapArray[x, y] = new Tile();
                    MapArray[x, y].Data.Type = (Enums.TileType)reader.ReadInt32();
                    MapArray[x, y].Data.Data1 = reader.ReadInt32();
                    MapArray[x, y].Data.Data2 = reader.ReadInt32();
                    MapArray[x, y].Data.Data3 = reader.ReadInt32();
                    MapArray[x, y].Data.String1 = reader.ReadString();
                    MapArray[x, y].Data.String2 = reader.ReadString();
                    MapArray[x, y].Data.String3 = reader.ReadString();
                }
            }

            int groundLayerCount = reader.ReadInt32();
            for (int i = 0; i < groundLayerCount; i++)
            {
                string name = reader.ReadString();
                MapLayer layerAnim = new MapLayer(name, width, height);
                Game.UpdateLoadMsg("Loading Map... (Layer " + layerAnim.Name + ")");
                for (int y = 0; y < Height; y++)
                {
                    for (int x = 0; x < Width; x++)
                    {
                        layerAnim.Tiles[x, y] = new TileAnim();
                        layerAnim.Tiles[x, y].Load(reader);
                    }
                }
                GroundLayers.Add(layerAnim);
            }

            int propBackLayerCount = reader.ReadInt32();
            for (int i = 0; i < propBackLayerCount; i++)
            {
                string name = reader.ReadString();
                MapLayer layerAnim = new MapLayer(name, width, height);
                Game.UpdateLoadMsg("Loading Map... (Layer " + layerAnim.Name + ")");
                for (int y = 0; y < Height; y++)
                {
                    for (int x = 0; x < Width; x++)
                    {
                        layerAnim.Tiles[x, y] = new TileAnim();
                        layerAnim.Tiles[x, y].Load(reader);
                    }
                }
                PropBackLayers.Add(layerAnim);
            }

            int propFrontLayerCount = reader.ReadInt32();
            for (int i = 0; i < propFrontLayerCount; i++)
            {
                string name = reader.ReadString();
                MapLayer layerAnim = new MapLayer(name, width, height);
                Game.UpdateLoadMsg("Loading Map... (Layer " + layerAnim.Name + ")");
                for (int y = 0; y < Height; y++)
                {
                    for (int x = 0; x < Width; x++)
                    {
                        layerAnim.Tiles[x, y] = new TileAnim();
                        layerAnim.Tiles[x, y].Load(reader);
                    }
                }
                PropFrontLayers.Add(layerAnim);
            }

            int fringeLayerCount = reader.ReadInt32();
            for (int i = 0; i < fringeLayerCount; i++)
            {
                string name = reader.ReadString();
                MapLayer layerAnim = new MapLayer(name, width, height);
                Game.UpdateLoadMsg("Loading Map... (Layer " + layerAnim.Name + ")");
                for (int y = 0; y < Height; y++)
                {
                    for (int x = 0; x < Width; x++)
                    {
                        layerAnim.Tiles[x, y] = new TileAnim();
                        layerAnim.Tiles[x, y].Load(reader);
                    }
                }
                FringeLayers.Add(layerAnim);
            }
        }
Ejemplo n.º 2
0
        public void Load(BinaryReader reader)
        {
            //read from memory stream
            Title        = reader.ReadString();
            Music        = reader.ReadString();
            Indoors      = reader.ReadBoolean();
            Darkness     = reader.ReadInt32();
            Weather      = (Enums.Weather)reader.ReadInt32();
            TimeLimit    = reader.ReadInt32();
            MinNpcs      = reader.ReadInt32();
            MaxNpcs      = reader.ReadInt32();
            NpcSpawnTime = reader.ReadInt32();

            int npcSpawnCount = reader.ReadInt32();

            for (int i = 0; i < NpcSpawns.Count; i++)
            {
                NpcSpawnData spawnData = new NpcSpawnData();
                spawnData.Data.Species = reader.ReadInt32();
                spawnData.Data.Form    = reader.ReadInt32();
                spawnData.Data.Gender  = (Enums.Gender)reader.ReadInt32();
                spawnData.Data.Shiny   = (Enums.Coloration)reader.ReadInt32();

                spawnData.Loc.X = reader.ReadInt32();
                spawnData.Loc.Y = reader.ReadInt32();

                spawnData.MinLevel = reader.ReadInt32();
                spawnData.MaxLevel = reader.ReadInt32();

                for (int j = 0; j < spawnData.Moves.Length; i++)
                {
                    spawnData.Moves[j] = reader.ReadInt32();
                }

                spawnData.AppearanceRate = reader.ReadInt32();

                NpcSpawns.Add(spawnData);
            }

            int width  = reader.ReadInt32();
            int height = reader.ReadInt32();

            MapArray = new Tile[width, height];
            for (int y = 0; y < Height; y++)
            {
                for (int x = 0; x < Width; x++)
                {
                    MapArray[x, y]              = new Tile();
                    MapArray[x, y].Data.Type    = (Enums.TileType)reader.ReadInt32();
                    MapArray[x, y].Data.Data1   = reader.ReadInt32();
                    MapArray[x, y].Data.Data2   = reader.ReadInt32();
                    MapArray[x, y].Data.Data3   = reader.ReadInt32();
                    MapArray[x, y].Data.String1 = reader.ReadString();
                    MapArray[x, y].Data.String2 = reader.ReadString();
                    MapArray[x, y].Data.String3 = reader.ReadString();
                }
            }

            int groundLayerCount = reader.ReadInt32();

            for (int i = 0; i < groundLayerCount; i++)
            {
                string   name      = reader.ReadString();
                MapLayer layerAnim = new MapLayer(name, width, height);
                Game.UpdateLoadMsg("Loading Map... (Layer " + layerAnim.Name + ")");
                for (int y = 0; y < Height; y++)
                {
                    for (int x = 0; x < Width; x++)
                    {
                        layerAnim.Tiles[x, y] = new TileAnim();
                        layerAnim.Tiles[x, y].Load(reader);
                    }
                }
                GroundLayers.Add(layerAnim);
            }

            int propBackLayerCount = reader.ReadInt32();

            for (int i = 0; i < propBackLayerCount; i++)
            {
                string   name      = reader.ReadString();
                MapLayer layerAnim = new MapLayer(name, width, height);
                Game.UpdateLoadMsg("Loading Map... (Layer " + layerAnim.Name + ")");
                for (int y = 0; y < Height; y++)
                {
                    for (int x = 0; x < Width; x++)
                    {
                        layerAnim.Tiles[x, y] = new TileAnim();
                        layerAnim.Tiles[x, y].Load(reader);
                    }
                }
                PropBackLayers.Add(layerAnim);
            }

            int propFrontLayerCount = reader.ReadInt32();

            for (int i = 0; i < propFrontLayerCount; i++)
            {
                string   name      = reader.ReadString();
                MapLayer layerAnim = new MapLayer(name, width, height);
                Game.UpdateLoadMsg("Loading Map... (Layer " + layerAnim.Name + ")");
                for (int y = 0; y < Height; y++)
                {
                    for (int x = 0; x < Width; x++)
                    {
                        layerAnim.Tiles[x, y] = new TileAnim();
                        layerAnim.Tiles[x, y].Load(reader);
                    }
                }
                PropFrontLayers.Add(layerAnim);
            }

            int fringeLayerCount = reader.ReadInt32();

            for (int i = 0; i < fringeLayerCount; i++)
            {
                string   name      = reader.ReadString();
                MapLayer layerAnim = new MapLayer(name, width, height);
                Game.UpdateLoadMsg("Loading Map... (Layer " + layerAnim.Name + ")");
                for (int y = 0; y < Height; y++)
                {
                    for (int x = 0; x < Width; x++)
                    {
                        layerAnim.Tiles[x, y] = new TileAnim();
                        layerAnim.Tiles[x, y].Load(reader);
                    }
                }
                FringeLayers.Add(layerAnim);
            }
        }