상속: IExtZone
예제 #1
0
        public List<IZone> LoadZones(string FileName, EncounterGroupParser GroupParser)
        {
            if(!File.Exists(FileName))
            {
                Message.Show("Couldn't open " + FileName, MessageBoxButtons.OK, MessageBoxIcon.Error);
                return null;
            }

            //try
               // {
                List<IZone> Zones = new List<IZone>();
                List<string> lines = new List<string>(File.ReadAllLines(FileName));

                if (lines.Count == 0)
                {
                    Message.Show("Worldmap file is empty.", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return null;
                }

                string version;
                if (!WorldMapUtils.VerifyFormat(lines[0], FileName, "2238", out version))
                    return null;

                foreach (string line in lines)
                {
                    if (line.Length == 0 || (line.Contains("Format") && line.Contains("Version")))
                        continue;

                    List<EncounterZoneLocation> AddLocations = new List<EncounterZoneLocation>();
                    List<EncounterZoneGroup> AddGroups = new List<EncounterZoneGroup>();
                    List<String> AddFlags = new List<String>();

                    String[] SplittedLine = line.Split('|');
                    String[] Coords = SplittedLine[0].Split(',');
                    String[] Parameters = SplittedLine[1].Split(',');

                    Zone zone = new Zone(Int32.Parse(Coords[0]), Int32.Parse(Coords[1]));
                    zone.Difficulty = Int32.Parse(Parameters[0]);
                    zone.Terrain = Parameters[1];
                    zone.Fill = Parameters[2];
                    zone.Chance = Parameters[3];

                    if (SplittedLine.Length > 2)
                    {
                        if (SplittedLine[2].Length > 2)
                            zone.EncounterLocations = ParseLocations(SplittedLine[2].Split(','), SplittedLine[0]);
                    }
                    if (SplittedLine.Length > 3)
                    {
                        if (SplittedLine[3].Length > 2)
                            zone.EncounterGroups = ParseGroups(SplittedLine[3].Split(','), GroupParser, SplittedLine[0]);
                    }
                    if (SplittedLine.Length > 4)
                    {
                        zone.Flags = ParseFlags(SplittedLine[4].Split(','), SplittedLine[0]);
                    }

                    Zones.Add(zone);
                }
                return Zones;
        }
예제 #2
0
        public IZone NewZone(int x, int y)
        {
            if (Utils.IsOutOfZoneBoundries(x,y))
                return null;

            IZone zone = new Zone(x, y);

            zone.Chance = EditorData.Chances[0];
            zone.Terrain = EditorData.Terrains[0];
            zone.Fill = "FILL_No_Fill";
            zone.Modified = true;
            return zone;
        }
예제 #3
0
        private int ItemsInZone(Zone i, int ItemPid)
        {
            int num = 0;
            if (i.EncounterGroups == null)
                return 0;

            foreach (EncounterZoneGroup gr in i.EncounterGroups)
            {
                EncounterGroup realgroup = GroupParser.GetGroupByName(gr.Name); // Because gr contains only small amount of data parsed
                                                                                // from worldmap.fowm, rest is in parser.
                foreach (EncounterNpc npc in realgroup.Npcs)
                    foreach (EncounterItem item in npc.Items)
                        if (item.Item.Pid == ItemPid)
                            num++;
            }
            return num;
        }
예제 #4
0
 private bool ZoneContains(String var, Zone zone, String error)
 {
     String zoneStr = "Zone[" + zone.X + "," + zone.Y + "]:";
     if (!Defines.ContainsKey(var))
     {
         Message.Show(zoneStr + " Unable to find "+error+" define for " + var, MessageBoxButtons.OK, MessageBoxIcon.Error);
         return false;
     }
     return true;
 }