Example #1
0
        public List<Zone> getFlyZoneTemplates(Map world)
        {
            List<Zone> templates = new List<Zone>();
            Zone template = new Zone();

            // Other map / zone data must me loaded from individual level / mission files.
            try {
                // If no level data exists, most likely test level thats missing data, ignore
                // without level data the level can not be properly loaded in retail client
                if (!File.Exists(path + world.map.ToLower() + @"\leveldata.xml")) {
                    return templates;
                }

                Console.WriteLine("Loading Level Mission Data: " + world.map);
                Utility.LoadMissionFile(path + world.map.ToLower() + @"\mission_mission0.xml");

                // If no flying templates return the empty list
                if (Utility.MissionFile.CommonShapeList.flying_zones.flying_zone == null) {
                    return templates;
                }

                IEnumerable flyzones = Utility.MissionFile.CommonShapeList.flying_zones.flying_zone.Where(n => n != null);

                foreach (MissionCommonShapeListFlying_zonesFlying_zone_zone flyzone in flyzones) {
                    template.mapid = world.id;
                    template.zone_type = "FLY";

                    template.name = getFormattedZoneName(flyzone.name, 0);

                    template.description = stripCharacters(flyzone.name);
                    zoneDescription.Add(template.name + " // " + world.id.ToString() + " : " + template.description);

                    template.area_type = flyzone.points_info.type.ToUpper();

                    template.points = new Points();
                    template.points.top = flyzone.points_info.top;
                    template.points.bottom = flyzone.points_info.bottom;
                    template.points.point = new List<Point>();

                    var points = flyzone.points_info.points.data.Where(n => n != null);

                    foreach (points_infoPointsData point in points) {
                        Point newpoint = new Point();
                        newpoint.x = Math.Round(point.x, 4);
                        newpoint.y = Math.Round(point.y, 4);
                        template.points.point.Add(newpoint);
                    }

                    templates.Add(template);
                }
            }
            catch (Exception ex) {
                Debug.Print("Error Processing Level Data File: '{0}'", ex.InnerException);
            }

            return templates;
        }
Example #2
0
        public Zone getZoneTemplate(SubZone subzone, Map world, string zone_type)
        {
            var template = new Zone();

            template.mapid = world.id;
            template.priority = subzone.priority;
            template.zone_type = zone_type;
            template.area_type = subzone.points_info.type.ToUpper();

            string desc = Utility.LevelStringIndex.GetString(subzone.desc);
            if (desc.StartsWith("_") || desc == "") desc = subzone.name + desc;
            if (zone_type == "ITEM_USE") {
                template.name = getFormattedZoneName(desc, 0);
            }
            else {
                template.name = getFormattedZoneName(desc, world.id);
            }
            //template.description = (Utility.LevelStringIndex.GetString(subzone.desc) + "_" + world.id.ToString()).ToUpper();
            zoneDescription.Add(template.name + " // " + subzone.name + " : " + world.id.ToString());

            if (subzone.norecall != null) template.norecall = subzone.norecall.ToUpper() == "TRUE" ? true : false;
            if (subzone.noride != null) template.noride = subzone.noride.ToUpper() == "TRUE" ? true : false;

            if (zone_type == "ARTIFACT") {

                // make list of siege artifacts that affect this area
                var artifact_infos = Utility.ZoneDataFile.artifact_infos != null ? Utility.ZoneDataFile.artifact_infos.artifact_info.Where(n => n != null) : new List<ArtifactInfo>();
                List<int> siegeId = new List<int>();
                foreach (var artifact in artifact_infos) {
                    if (artifact.artifact_result_area1 == subzone.name) {
                        siegeId.Add(Convert.ToInt32(artifact.artifact_name.Split('_')[1].Substring(0, 4)));
                    }

                }
                if (siegeId.Count > 0) template.siege_id = siegeId;
            }
            else {
                template.siege_id = null;
            }
            if (zone_type == "FORT") {
                List<int> abyssid = new List<int>();
                abyssid.Add(subzone.abyss_id);
                template.siege_id = abyssid;
            }

            template.points = new Points();
            template.points.top = subzone.points_info.top;
            template.points.bottom = subzone.points_info.bottom;
            template.points.point = new List<Point>();

            IEnumerable points = subzone.points_info.points.data as IEnumerable;
            foreach (ParserBase.Data point in points) {
                Point newpoint = new Point();
                newpoint.x = Math.Round(point.x, 4);
                newpoint.y = Math.Round(point.y, 4);
                template.points.point.Add(newpoint);
            }

            return template;
        }