Example #1
0
        public Map(byte[] content, string mapName)
        {
            using (MemoryStream stream = new MemoryStream(content))
            {
                using (BinaryReader reader = new BinaryReader(stream))
                {
                    Colliders  = ReadTiles(reader);
                    DimensionX = Colliders.GetUpperBound(0) + 1;
                    DimensionY = Colliders.GetUpperBound(1) + 1;
                    Width      = DimensionX - 1;
                    Height     = DimensionY - 1;

                    Tiles1 = ReadTiles(reader);
                    Tiles2 = ReadTiles(reader);
                    Tiles3 = ReadTiles(reader);
                    Tiles4 = ReadTiles(reader);

                    MapWeather = ReadString(reader);
                    reader.ReadInt16();
                    reader.ReadInt16();
                    IsOutside = reader.ReadByte() != 0;
                    Region    = ReadString(reader);

                    reader.ReadInt16();

                    int count = reader.ReadInt16() - 1;
                    reader.ReadInt16();
                    reader.ReadInt16();
                    reader.ReadInt16();
                    reader.ReadInt16();
                    reader.ReadInt16();
                    reader.ReadInt16();
                    reader.ReadInt16();
                    reader.ReadInt16();

                    Links            = new MapLink[DimensionX, DimensionY];
                    LinkDestinations = new Dictionary <string, List <Tuple <int, int> > >();
                    for (int i = 0; i < count; ++i)
                    {
                        string destination = ReadString(reader);
                        int    x           = reader.ReadInt16();
                        int    y           = reader.ReadInt16();
                        int    toX         = reader.ReadInt16();
                        int    toY         = reader.ReadInt16();

                        Links[x, y] = new MapLink(destination, toX, toY);

                        destination = destination.ToUpperInvariant();
                        if (!LinkDestinations.ContainsKey(destination))
                        {
                            LinkDestinations.Add(destination, new List <Tuple <int, int> >());
                        }
                        LinkDestinations[destination].Add(new Tuple <int, int>(x, y));
                    }

                    int k        = reader.ReadInt16();
                    int npcCount = reader.ReadInt16() - 1;
                    for (int i = 0; i < 45; ++i)
                    {
                        int b = reader.ReadInt16();
                    }

                    Npcs         = new List <Npc>();
                    OriginalNpcs = new List <Npc>();
                    for (int i = 0; i < npcCount; ++i)
                    {
                        string npcName = ReadString(reader);
                        int    x       = reader.ReadInt16();
                        int    y       = reader.ReadInt16();

                        //view direction and length
                        int       directionValue = reader.ReadByte();
                        Direction viewDirection  = DirectionExtensions.FromInt(directionValue);
                        int       losLength      = reader.ReadByte();
                        int       type           = reader.ReadInt16();

                        ReadString(reader);
                        string path = ReadString(reader);

                        reader.ReadInt16();
                        reader.ReadInt16();
                        reader.ReadInt16();
                        reader.ReadInt16();
                        reader.ReadInt16();
                        reader.ReadInt16();
                        reader.ReadInt16();
                        reader.ReadInt16();
                        reader.ReadInt16();
                        reader.ReadInt16();
                        reader.ReadInt16();
                        reader.ReadInt16();
                        reader.ReadInt16();
                        reader.ReadInt16();

                        bool isBattler = reader.ReadInt16() != 0;

                        reader.ReadInt16();
                        reader.ReadSingle();
                        reader.ReadSingle();

                        int npcId = reader.ReadInt16();

                        if (npcName != "TileScript")
                        {
                            if (mapName.Contains("Goldenrod Underground"))
                            {
                                OriginalNpcs.Add(new Npc(npcId, npcName, isBattler, type, x, y, viewDirection, losLength, path));
                            }
                            else if (mapName.Contains("Route 124"))
                            {
                                OriginalNpcs.Add(new Npc(npcId, npcName, isBattler, type, x, y, viewDirection, losLength, path));
                            }
                            else if (mapName == "Lilycove City")
                            {
                                OriginalNpcs.Add(new Npc(npcId, npcName, isBattler, type, x, y, viewDirection, losLength, path));
                            }
                            else if (mapName.Contains("Underground Warehouse"))
                            {
                                OriginalNpcs.Add(new Npc(npcId, npcName, isBattler, type, x, y, viewDirection, losLength, path));
                            }
                            else if (mapName.Contains("Player"))
                            {
                                OriginalNpcs.Add(new Npc(npcId, npcName, isBattler, type, x, y, viewDirection, losLength, path));
                            }
                            else if (mapName.Contains("Route 119A"))
                            {
                                OriginalNpcs.Add(new Npc(npcId, npcName, isBattler, type, x, y, viewDirection, losLength, path));
                            }
                            else
                            {
                                OriginalNpcs.Add(new Npc(npcId, npcName, isBattler, type, x, y, viewDirection, losLength, ""));
                            }
                        }

                        reader.ReadInt16();
                        reader.ReadInt16();
                        reader.ReadInt16();
                        reader.ReadInt16();
                        reader.ReadInt16();
                        reader.ReadInt16();
                        reader.ReadInt16();
                        reader.ReadInt16();
                        reader.ReadInt16();
                        reader.ReadInt16();
                        reader.ReadInt16();
                        reader.ReadInt16();
                        reader.ReadInt16();
                        reader.ReadInt16();
                    }
                }
            }
        }
Example #2
0
        public Map(byte[] content)
        {
            using (MemoryStream stream = new MemoryStream(content))
            {
                using (BinaryReader reader = new BinaryReader(stream))
                {
                    Colliders  = ReadTiles(reader);
                    DimensionX = Colliders.GetUpperBound(0) + 1;
                    DimensionY = Colliders.GetUpperBound(1) + 1;
                    Width      = DimensionX - 1;
                    Height     = DimensionY - 1;

                    Tiles1 = ReadTiles(reader);
                    Tiles2 = ReadTiles(reader);
                    Tiles3 = ReadTiles(reader);
                    Tiles4 = ReadTiles(reader);

                    MapWeather = ReadString(reader);
                    reader.ReadInt16();
                    reader.ReadInt16();
                    IsOutside = reader.ReadByte() != 0;
                    reader.ReadByte();
                    Region = ReadString(reader);

                    Links = new bool[DimensionX, DimensionY];
                    int linkCount = reader.ReadInt16();
                    for (int i = 0; i < linkCount; ++i)
                    {
                        int x = reader.ReadInt16();
                        int y = reader.ReadInt16();
                        Links[x, y] = true;
                    }

                    int npcCount = reader.ReadInt16();

                    Npcs         = new List <Npc>();
                    OriginalNpcs = new List <Npc>();
                    for (int i = 0; i < npcCount; ++i)
                    {
                        string npcName = ReadString(reader);
                        int    x       = reader.ReadInt16();
                        int    y       = reader.ReadInt16();

                        int direction = reader.ReadByte();
                        int losLength = reader.ReadByte();
                        int type      = reader.ReadInt16();

                        string path = ReadString(reader);

                        bool isBattler = reader.ReadInt16() != 0;

                        int npcId = reader.ReadInt16();

                        reader.ReadInt16();

                        OriginalNpcs.Add(new Npc(npcId, npcName, isBattler, type, x, y, DirectionExtensions.FromNumber(direction), losLength, path));
                    }
                }
            }
        }
Example #3
0
        public Map(byte[] content)
        {
            using (MemoryStream stream = new MemoryStream(content))
            {
                using (BinaryReader reader = new BinaryReader(stream))
                {
                    Colliders  = ReadTiles(reader);
                    DimensionX = Colliders.GetUpperBound(0) + 1;
                    DimensionY = Colliders.GetUpperBound(1) + 1;
                    Width      = DimensionX - 1;
                    Height     = DimensionY - 1;

                    Tiles1 = ReadTiles(reader);
                    Tiles2 = ReadTiles(reader);
                    Tiles3 = ReadTiles(reader);
                    Tiles4 = ReadTiles(reader);

                    MapWeather = ReadString(reader);
                    reader.ReadInt16();
                    reader.ReadInt16();
                    IsOutside = reader.ReadByte() != 0;
                    Region    = ReadString(reader);
                    reader.ReadInt16();

                    int count = reader.ReadInt16() - 1;
                    reader.ReadInt16();
                    reader.ReadInt16();
                    reader.ReadInt16();
                    reader.ReadInt16();
                    reader.ReadInt16();
                    reader.ReadInt16();
                    reader.ReadInt16();
                    reader.ReadInt16();

                    Links            = new MapLink[DimensionX, DimensionY];
                    LinkDestinations = new Dictionary <string, List <Tuple <int, int> > >();
                    for (int i = 0; i < count; ++i)
                    {
                        string destination = ReadString(reader);
                        int    x           = reader.ReadInt16();
                        int    y           = reader.ReadInt16();
                        int    toX         = reader.ReadInt16();
                        int    toY         = reader.ReadInt16();

                        Links[x, y] = new MapLink(destination, toX, toY);

                        destination = destination.ToUpperInvariant();
                        if (!LinkDestinations.ContainsKey(destination))
                        {
                            LinkDestinations.Add(destination, new List <Tuple <int, int> >());
                        }
                        LinkDestinations[destination].Add(new Tuple <int, int>(x, y));
                    }

                    int k        = reader.ReadInt16();
                    int npcCount = reader.ReadInt16() - 1;
                    for (int i = 0; i < 45; ++i)
                    {
                        int b = reader.ReadInt16();
                    }

                    Npcs         = new List <Npc>();
                    OriginalNpcs = new List <Npc>();
                    for (int i = 0; i < npcCount; ++i)
                    {
                        string npcName = ReadString(reader);
                        int    x       = reader.ReadInt16();
                        int    y       = reader.ReadInt16();

                        int direction = reader.ReadByte();
                        int losLength = reader.ReadByte();
                        int type      = reader.ReadInt16();

                        ReadString(reader);
                        string path = ReadString(reader);

                        reader.ReadInt16();
                        reader.ReadInt16();
                        reader.ReadInt16();
                        reader.ReadInt16();
                        reader.ReadInt16();
                        reader.ReadInt16();
                        reader.ReadInt16();
                        reader.ReadInt16();
                        reader.ReadInt16();
                        reader.ReadInt16();
                        reader.ReadInt16();
                        reader.ReadInt16();
                        reader.ReadInt16();
                        reader.ReadInt16();

                        bool isBattler = reader.ReadInt16() != 0;

                        reader.ReadInt16();
                        reader.ReadSingle();
                        reader.ReadSingle();

                        int npcId = reader.ReadInt16();

                        OriginalNpcs.Add(new Npc(npcId, npcName, isBattler, type, x, y, DirectionExtensions.FromNumber(direction), losLength, path));

                        reader.ReadInt16();
                        reader.ReadInt16();
                        reader.ReadInt16();
                        reader.ReadInt16();
                        reader.ReadInt16();
                        reader.ReadInt16();
                        reader.ReadInt16();
                        reader.ReadInt16();
                        reader.ReadInt16();
                        reader.ReadInt16();
                        reader.ReadInt16();
                        reader.ReadInt16();
                        reader.ReadInt16();
                        reader.ReadInt16();
                    }
                }
            }
        }