Example #1
0
        public static RespawnInfo FromText(string text)
        {
            string[] data = text.Split(new[] {','}, StringSplitOptions.RemoveEmptyEntries);

            if (data.Length != 7) return null;

            RespawnInfo info = new RespawnInfo();

            int x,y ;

            if (!int.TryParse(data[0], out info.MonsterIndex)) return null;
            if (!int.TryParse(data[1], out x)) return null;
            if (!int.TryParse(data[2], out y)) return null;

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

            if (!ushort.TryParse(data[3], out info.Count)) return null;
            if (!ushort.TryParse(data[4], out info.Spread)) return null;
            if (!ushort.TryParse(data[5], out info.Delay)) return null;
            if (!byte.TryParse(data[6], out info.Direction)) return null;
            if (!ushort.TryParse(data[7], out info.RandomDelay)) return null;
            if (!int.TryParse(data[8], out info.RespawnIndex)) return null;
            if (!bool.TryParse(data[9], out info.SaveRespawnTime)) return null;
            if (!ushort.TryParse(data[10], out info.RespawnTicks)) return null;

            return info;
        }
Example #2
0
        public static RespawnInfo FromText(string text)
        {
            string[] data = text.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries);

            if (data.Length != 7)
            {
                return(null);
            }

            RespawnInfo info = new RespawnInfo();

            int x, y;

            if (!int.TryParse(data[0], out info.MonsterIndex))
            {
                return(null);
            }
            if (!int.TryParse(data[1], out x))
            {
                return(null);
            }
            if (!int.TryParse(data[2], out y))
            {
                return(null);
            }

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

            if (!ushort.TryParse(data[3], out info.Count))
            {
                return(null);
            }
            if (!ushort.TryParse(data[4], out info.Spread))
            {
                return(null);
            }
            if (!ushort.TryParse(data[5], out info.Delay))
            {
                return(null);
            }
            if (!byte.TryParse(data[6], out info.Direction))
            {
                return(null);
            }

            return(info);
        }
Example #3
0
        static void LoadRespawnInfo()
        {
            for (int M = 0; M < MapInfoList.Count; M++)
            {
                MapInfo MInfo = MapInfoList[M];

                if (MInfo.RespawnList.Count > 0)
                {
                    continue;
                }

                DataSet DSet = new DataSet();

                DBCommand.CommandText = string.Format("SELECT * FROM [Respawn Info] WHERE (([Map Index] = {0}) AND ([Enabled] = 1))", MInfo.MapIndex);

                SqlDataAdapter Adapter = new SqlDataAdapter(DBCommand);
                Adapter.Fill(DSet);
                DataTable DTable = DSet.Tables[0];
                int       MonsterIndex;

                for (int R = 0; R < DTable.Rows.Count; R++)
                {
                    DataRow     Row   = DTable.Rows[R];
                    RespawnInfo RInfo = new RespawnInfo(Row)
                    {
                        MInfo = MInfo
                    };

                    MonsterIndex  = Row["Monster Index"] is DBNull ? -1 : (int)Row["Monster Index"];
                    RInfo.Monster = MonsterInfoList.FirstOrDefault(O => O.MonsterIndex == MonsterIndex);

                    if (RInfo.Monster != null)
                    {
                        MInfo.RespawnList.Add(RInfo);
                    }
                }
            }
        }
Example #4
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 (!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);
        }
Example #5
0
        public MapRespawn(RespawnInfo info)
        {
            Info = info;
            Monster = SMain.Envir.GetMonsterInfo(info.MonsterIndex);

            LoadRoutes();
        }
Example #6
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);
        }
Example #7
0
        private void ImportMonGenButton_Click(object sender, EventArgs e)
        {
            bool hasImported = false;

            if (Envir.MapInfoList.Count == 0) return;

            MirForms.ConvertMonGenInfo.Start();

            for (int i = 0; i < MirForms.ConvertMonGenInfo.monGenList.Count; i++)
            {
                try
                {
                    int monsterIndex = Envir.MonsterInfoList.FindIndex(a => a.Name.Replace(" ","") == MirForms.ConvertMonGenInfo.monGenList[i].Name.Replace('*', ' '));
                    if (monsterIndex == -1) continue;

                    RespawnInfo respawnInfo = new RespawnInfo
                    {
                        MonsterIndex = monsterIndex + 1,
                        Location = new Point(MirForms.ConvertMonGenInfo.monGenList[i].X, MirForms.ConvertMonGenInfo.monGenList[i].Y),
                        Count = (ushort)MirForms.ConvertMonGenInfo.monGenList[i].Count,
                        Spread = (ushort)MirForms.ConvertMonGenInfo.monGenList[i].Range,
                        Delay = (ushort)MirForms.ConvertMonGenInfo.monGenList[i].Delay,
                        Direction = (byte)MirForms.ConvertMonGenInfo.monGenList[i].Direction
                    };

                    int index = Envir.MapInfoList.FindIndex(a => a.FileName == MirForms.ConvertMonGenInfo.monGenList[i].Map);
                    if (index == -1) continue;

                    Envir.MapInfoList[index].Respawns.Add(respawnInfo);
                    hasImported = true;
                }
                catch (Exception)
                {
                    continue;
                }
            }
            MirForms.ConvertMonGenInfo.Stop();

            if (!hasImported) return;

            UpdateInterface();
            MessageBox.Show("MonGen Import complete");
        }