Пример #1
0
        private void ImportMapInfoButton_Click(object sender, EventArgs e)
        {
            OpenFileDialog ofd = new OpenFileDialog();
            ofd.Filter = "Text File|*.txt";
            ofd.ShowDialog();

            if (ofd.FileName == string.Empty) return;

            MirForms.ConvertMapInfo.Path = ofd.FileName;

            MirForms.ConvertMapInfo.Start(Envir);

            for (int i = 0; i < MirForms.ConvertMapInfo.MapInfo.Count; i++)
            {

                MapInfo mi = new MapInfo
                {
                    Index = ++Envir.MapIndex,
                    FileName = MirForms.ConvertMapInfo.MapInfo[i].MapFile,
                    Title = MirForms.ConvertMapInfo.MapInfo[i].MapName.Replace('*', ' '),
                    NoTeleport = MirForms.ConvertMapInfo.MapInfo[i].NoTeleport,
                    NoReconnect = MirForms.ConvertMapInfo.MapInfo[i].NoReconnect,
                    NoRandom = MirForms.ConvertMapInfo.MapInfo[i].NoRandom,
                    NoEscape = MirForms.ConvertMapInfo.MapInfo[i].NoEscape,
                    NoRecall = MirForms.ConvertMapInfo.MapInfo[i].NoRecall,
                    NoDrug = MirForms.ConvertMapInfo.MapInfo[i].NoDrug,
                    NoPosition = MirForms.ConvertMapInfo.MapInfo[i].NoPositionMove,
                    NoThrowItem = MirForms.ConvertMapInfo.MapInfo[i].NoThrowItem,
                    NoDropPlayer = MirForms.ConvertMapInfo.MapInfo[i].NoPlayerDrop,
                    NoDropMonster = MirForms.ConvertMapInfo.MapInfo[i].NoMonsterDrop,
                    NoNames = MirForms.ConvertMapInfo.MapInfo[i].NoNames,
                    Fight = MirForms.ConvertMapInfo.MapInfo[i].Fight,
                    NoFight = MirForms.ConvertMapInfo.MapInfo[i].NoFight,
                    Fire = MirForms.ConvertMapInfo.MapInfo[i].Fire,
                    Lightning = MirForms.ConvertMapInfo.MapInfo[i].Lightning,
                    Light = MirForms.ConvertMapInfo.MapInfo[i].Light,
                    MiniMap = MirForms.ConvertMapInfo.MapInfo[i].MiniMapNumber,
                    BigMap = MirForms.ConvertMapInfo.MapInfo[i].BigMapNumber,
                    Music = MirForms.ConvertMapInfo.MapInfo[i].MusicNumber,
                    MineIndex = (byte)MirForms.ConvertMapInfo.MapInfo[i].MineIndex,
                };

                if (mi.NoReconnect == true)
                    mi.NoReconnectMap = MirForms.ConvertMapInfo.MapInfo[i].ReconnectMap;
                if (mi.Fire == true)
                    mi.FireDamage = MirForms.ConvertMapInfo.MapInfo[i].FireDamage;
                if (mi.Lightning == true)
                    mi.LightningDamage = MirForms.ConvertMapInfo.MapInfo[i].LightningDamage;
                if (MirForms.ConvertMapInfo.MapInfo[i].MapLight == true)
                    mi.MapDarkLight = MirForms.ConvertMapInfo.MapInfo[i].MapLightValue;

                Envir.MapInfoList.Add(mi);
            }

            for (int j = 0; j < MirForms.ConvertMapInfo.MapMovements.Count; j++)
            {
                try
                {
                    MovementInfo newmoveinfo = new MovementInfo();

                    newmoveinfo.MapIndex = Convert.ToInt16(MirForms.ConvertMapInfo.MapMovements[j].toMap);

                    newmoveinfo.Source = new Point
                        (Convert.ToInt16(MirForms.ConvertMapInfo.MapMovements[j].fromX),
                        (Convert.ToInt16(MirForms.ConvertMapInfo.MapMovements[j].fromY)));

                    newmoveinfo.Destination = new Point
                        (Convert.ToInt16(MirForms.ConvertMapInfo.MapMovements[j].toX),
                        (Convert.ToInt16(MirForms.ConvertMapInfo.MapMovements[j].toY)));

                    newmoveinfo.NeedHole = false;
                    newmoveinfo.NeedMove = false;

                    Envir.MapInfoList[Envir.MapInfoList.FindIndex(a => a.Index == (MirForms.ConvertMapInfo.MapMovements[j].fromIndex))].Movements.Add(newmoveinfo);
                }
                catch (Exception)
                {
                    continue;
                }
            }

            for (int i = 0; i < MirForms.ConvertMapInfo.MineInfo.Count; i++)
            {
                MineZone mz = new MineZone();

                try
                {
                    mz.Location = MirForms.ConvertMapInfo.MineInfo[i].Location;
                    mz.Size = (ushort)MirForms.ConvertMapInfo.MineInfo[i].Range;
                    mz.Mine = (byte)MirForms.ConvertMapInfo.MineInfo[i].MineIndex;

                    Envir.MapInfoList[MirForms.ConvertMapInfo.MineInfo[i].MapIndex - 1].MineZones.Add(mz);
                }
                catch (Exception) { continue; }
            }

            MirForms.ConvertMapInfo.End();
            UpdateInterface();

            MessageBox.Show("Map Info Import Complete");
        }
Пример #2
0
        public static void FromText(string text)
        {
            string[] data = text.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries);

            if (data.Length < 8) return;

            MapInfo info = new MapInfo {FileName = data[0], Title = data[1]};

            if (!ushort.TryParse(data[2], out info.MiniMap)) return;

            if (!Enum.TryParse(data[3], out info.Light)) return;
            int sziCount, miCount, riCount, npcCount;

            if (!int.TryParse(data[4], out sziCount)) return;
            if (!int.TryParse(data[5], out miCount)) return;
            if (!int.TryParse(data[6], out riCount)) return;
            if (!int.TryParse(data[7], out npcCount)) return;

            int start = 8;

            for (int i = 0; i < sziCount; i++)
            {
                SafeZoneInfo temp = new SafeZoneInfo { Info = info };
                int x, y;

                if (!int.TryParse(data[start + (i * 4)], out x)) return;
                if (!int.TryParse(data[start + 1 + (i * 4)], out y)) return;
                if (!ushort.TryParse(data[start + 2 + (i * 4)], out temp.Size)) return;
                if (!bool.TryParse(data[start + 3 + (i * 4)], out temp.StartPoint)) return;

                temp.Location = new Point(x, y);
                info.SafeZones.Add(temp);
            }
            start += sziCount * 4;

            for (int i = 0; i < miCount; i++)
            {
                MovementInfo temp = new MovementInfo();
                int x, y;

                if (!int.TryParse(data[start + (i * 5)], out x)) return;
                if (!int.TryParse(data[start + 1 + (i * 5)], out y)) return;
                temp.Source = new Point(x, y);

                if (!int.TryParse(data[start + 2 + (i * 5)], out temp.MapIndex)) return;

                if (!int.TryParse(data[start + 3 + (i * 5)], out x)) return;
                if (!int.TryParse(data[start + 4 + (i * 5)], out y)) return;
                temp.Destination = new Point(x, y);

                info.Movements.Add(temp);
            }
            start += miCount * 5;

            for (int i = 0; i < riCount; i++)
            {
                RespawnInfo temp = new RespawnInfo();
                int x, y;

                if (!int.TryParse(data[start + (i * 7)], out temp.MonsterIndex)) return;
                if (!int.TryParse(data[start + 1 + (i * 7)], out x)) return;
                if (!int.TryParse(data[start + 2 + (i * 7)], out y)) return;

                temp.Location = new Point(x, y);

                if (!ushort.TryParse(data[start + 3 + (i * 7)], out temp.Count)) return;
                if (!ushort.TryParse(data[start + 4 + (i * 7)], out temp.Spread)) return;
                if (!ushort.TryParse(data[start + 5 + (i * 7)], out temp.Delay)) return;
                if (!byte.TryParse(data[start + 6 + (i * 7)], out temp.Direction)) return;

                info.Respawns.Add(temp);
            }
            start += riCount * 7;

            for (int i = 0; i < npcCount; i++)
            {
                NPCInfo temp = new NPCInfo { FileName = data[start + (i * 6)], Name = data[start + 1 + (i * 6)] };
                int x, y;

                if (!int.TryParse(data[start + 2 + (i * 6)], out x)) return;
                if (!int.TryParse(data[start + 3 + (i * 6)], out y)) return;

                temp.Location = new Point(x, y);

                if (!ushort.TryParse(data[start + 4 + (i * 6)], out temp.Rate)) return;
                if (!byte.TryParse(data[start + 5 + (i * 6)], out temp.Image)) return;

                info.NPCs.Add(temp);
            }

            info.Index = ++SMain.EditEnvir.MapIndex;
            SMain.EditEnvir.MapInfoList.Add(info);
        }
Пример #3
0
        public static void FromText(string text)
        {
            string[] data = text.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries);

            if (data.Length < 8)
            {
                return;
            }

            MapInfo info = new MapInfo {
                FileName = data[0], Title = data[1]
            };


            if (!ushort.TryParse(data[2], out info.MiniMap))
            {
                return;
            }

            if (!Enum.TryParse(data[3], out info.Light))
            {
                return;
            }
            int sziCount, miCount, riCount, npcCount;

            if (!int.TryParse(data[4], out sziCount))
            {
                return;
            }
            if (!int.TryParse(data[5], out miCount))
            {
                return;
            }
            if (!int.TryParse(data[6], out riCount))
            {
                return;
            }
            if (!int.TryParse(data[7], out npcCount))
            {
                return;
            }


            int start = 8;

            for (int i = 0; i < sziCount; i++)
            {
                SafeZoneInfo temp = new SafeZoneInfo {
                    Info = info
                };
                int x, y;

                if (!int.TryParse(data[start + (i * 4)], out x))
                {
                    return;
                }
                if (!int.TryParse(data[start + 1 + (i * 4)], out y))
                {
                    return;
                }
                if (!ushort.TryParse(data[start + 2 + (i * 4)], out temp.Size))
                {
                    return;
                }
                if (!bool.TryParse(data[start + 3 + (i * 4)], out temp.StartPoint))
                {
                    return;
                }

                temp.Location = new Point(x, y);
                info.SafeZones.Add(temp);
            }
            start += sziCount * 4;



            for (int i = 0; i < miCount; i++)
            {
                MovementInfo temp = new MovementInfo();
                int          x, y;

                if (!int.TryParse(data[start + (i * 5)], out x))
                {
                    return;
                }
                if (!int.TryParse(data[start + 1 + (i * 5)], out y))
                {
                    return;
                }
                temp.Source = new Point(x, y);

                if (!int.TryParse(data[start + 2 + (i * 5)], out temp.MapIndex))
                {
                    return;
                }

                if (!int.TryParse(data[start + 3 + (i * 5)], out x))
                {
                    return;
                }
                if (!int.TryParse(data[start + 4 + (i * 5)], out y))
                {
                    return;
                }
                temp.Destination = new Point(x, y);

                info.Movements.Add(temp);
            }
            start += miCount * 5;


            for (int i = 0; i < riCount; i++)
            {
                RespawnInfo temp = new RespawnInfo();
                int         x, y;

                if (!int.TryParse(data[start + (i * 7)], out temp.MonsterIndex))
                {
                    return;
                }
                if (!int.TryParse(data[start + 1 + (i * 7)], out x))
                {
                    return;
                }
                if (!int.TryParse(data[start + 2 + (i * 7)], out y))
                {
                    return;
                }

                temp.Location = new Point(x, y);

                if (!ushort.TryParse(data[start + 3 + (i * 7)], out temp.Count))
                {
                    return;
                }
                if (!ushort.TryParse(data[start + 4 + (i * 7)], out temp.Spread))
                {
                    return;
                }
                if (!ushort.TryParse(data[start + 5 + (i * 7)], out temp.Delay))
                {
                    return;
                }
                if (!byte.TryParse(data[start + 6 + (i * 7)], out temp.Direction))
                {
                    return;
                }
                if (!int.TryParse(data[start + 7 + (i * 7)], out temp.RespawnIndex))
                {
                    return;
                }
                if (!bool.TryParse(data[start + 8 + (i * 7)], out temp.SaveRespawnTime))
                {
                    return;
                }
                if (!ushort.TryParse(data[start + 9 + (i * 7)], out temp.RespawnTicks))
                {
                    return;
                }

                info.Respawns.Add(temp);
            }
            start += riCount * 7;


            for (int i = 0; i < npcCount; i++)
            {
                NPCInfo temp = new NPCInfo {
                    FileName = data[start + (i * 6)], Name = data[start + 1 + (i * 6)]
                };
                int x, y;

                if (!int.TryParse(data[start + 2 + (i * 6)], out x))
                {
                    return;
                }
                if (!int.TryParse(data[start + 3 + (i * 6)], out y))
                {
                    return;
                }

                temp.Location = new Point(x, y);

                if (!ushort.TryParse(data[start + 4 + (i * 6)], out temp.Rate))
                {
                    return;
                }
                if (!ushort.TryParse(data[start + 5 + (i * 6)], out temp.Image))
                {
                    return;
                }

                info.NPCs.Add(temp);
            }



            info.Index = ++SMain.EditEnvir.MapIndex;
            SMain.EditEnvir.MapInfoList.Add(info);
        }