Example #1
0
        static void LoadSafeZoneInfo()
        {
            for (int M = 0; M < MapInfoList.Count; M++)
            {
                MapInfo MInfo = MapInfoList[M];

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

                DataSet DSet = new DataSet();

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

                SqlDataAdapter Adapter = new SqlDataAdapter(DBCommand);
                Adapter.Fill(DSet);
                DataTable    DTable = DSet.Tables[0];
                SafeZoneInfo SZI;
                for (int R = 0; R < DTable.Rows.Count; R++)
                {
                    SZI = new SafeZoneInfo(DTable.Rows[R]);
                    MInfo.SafeZoneList.Add(SZI);
                    if (SZI.StartPoint)
                    {
                        StartPoints.Add(SZI);
                    }
                }
            }
        }
Example #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;
                }
                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 #3
0
        private void CreateSafeZone(SafeZoneInfo info)
        {
            if (Settings.SafeZoneBorder)
            {
                for (int y = info.Location.Y - info.Size; y <= info.Location.Y + info.Size; y++)
                {
                    if (y < 0) continue;
                    if (y >= Height) break;
                    for (int x = info.Location.X - info.Size; x <= info.Location.X + info.Size; x += Math.Abs(y - info.Location.Y) == info.Size ? 1 : info.Size * 2)
                    {
                        if (x < 0) continue;
                        if (x >= Width) break;
                        if (!Cells[x, y].Valid) continue;

                        SpellObject spell = new SpellObject
                        {
                            ExpireTime = long.MaxValue,
                            Spell = Spell.TrapHexagon,
                            TickSpeed = int.MaxValue,
                            CurrentLocation = new Point(x, y),
                            CurrentMap = this
                        };

                        Cells[x, y].Add(spell);

                        spell.Spawned();
                    }
                }
            }

            if (Settings.SafeZoneHealing)
            {
                for (int y = info.Location.Y - info.Size; y <= info.Location.Y + info.Size; y++)
                {
                    if (y < 0) continue;
                    if (y >= Height) break;
                    for (int x = info.Location.X - info.Size; x <= info.Location.X + info.Size; x++)
                    {
                        if (x < 0) continue;
                        if (x >= Width) break;
                        if (!Cells[x, y].Valid) continue;

                        SpellObject spell = new SpellObject
                            {
                                ExpireTime = long.MaxValue,
                                Value = 25,
                                TickSpeed = 2000,
                                Spell = Spell.Healing,
                                CurrentLocation = new Point(x, y),
                                CurrentMap = this
                            };

                        Cells[x, y].Add(spell);

                        spell.Spawned();
                    }
                }
            }
        }
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;

                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);
        }