Exemplo n.º 1
0
        static TibiaMapFile ParseOdysseyMap(int baseX, int baseY, int baseZ)
        {
            TibiaMapFile  mapFile    = new TibiaMapFile(baseX, baseY, baseZ);
            List <string> filesToUse = new List <string>();

            // Construct the map.
            filesToUse = new List <string>();
            if (File.Exists(@"C:\Users\Reece\Recordings\JsonMaps\" + ((baseZ << 16) + (baseY << 8) + (baseX << 0)).ToString() + ".json"))
            {
                filesToUse.Add(@"C:\Users\Reece\Recordings\JsonMaps\" + ((baseZ << 16) + (baseY << 8) + (baseX << 0)).ToString() + ".json");
            }

            for (int n = 0; n < filesToUse.Count; n++)
            {
                MapView view = MapView.FromJSON(File.ReadAllText(filesToUse[n]));
                for (int x = 0; x < 256; x++)
                {
                    for (int y = 0; y < 256; y++)
                    {
                        MapTile tile = view.GetTile(x, y);
                        if (tile != null)
                        {
                            for (int i = 0; i < tile.Items.Count; i++)
                            {
                                DatItem dItem = dat.GetItem(tile.Items[i].ID);
                                if (dItem.IsStackable)
                                {
                                    // Map files don't care for stack count.
                                }
                                if (dItem.IsFluid)
                                {
                                    // Map files don't care for fluids.
                                }
                                if (dItem.IsFluidContainer)
                                {
                                    // Map files don't care for fluid containers.
                                }
                                if (dItem.IsAnimated)
                                {
                                    // Map files don't care for sprite animations.
                                }

                                if (dItem.HasMapColor)
                                {
                                    // Set the map color for the position.
                                    mapFile.SetMapColor(x, y, dItem.MapColor);
                                }

                                if (dItem.IsGround)
                                {
                                    mapFile.SetSpeed(x, y, dItem.Speed);
                                    mapFile.SetHasTile(x, y, true);
                                }

                                if (dItem.IsBlocking || dItem.BlocksPath)
                                {
                                    mapFile.SetIsUnwalkable(x, y, true);
                                }
                            }
                        }
                    }
                }
            }

            Console.WriteLine("Done " + TibiaMapFile.GetTibiaMapFileName(baseX, baseY, baseZ));

            return(mapFile);
        }