Пример #1
0
        public Tactic(Maps maps, Tanks tanks, Icons icons, string map_or_path)
        {
            this.maps = maps;
            this.tanks = tanks;
            this.icons = icons;

            int mapId;
            if (int.TryParse(map_or_path, out mapId)) {
                staticTactic = new StaticTactic(maps, tanks, icons);
                dynamicTactic = new DynamicTactic(maps, tanks, icons);
                staticTactic.setMap(map_or_path);
                dynamicTactic.setMap(map_or_path);

                this.map = maps.getMap(map_or_path);
            } else {
                load(map_or_path);
            }
        }
Пример #2
0
        public Maps(string mapsDescriptor, Icons icons)
        {
            maps = new Dictionary<string, Map>();
            sortedMaps = new SortedList<string, Map>();

            XmlDocument XD = new XmlDocument();
            XD.Load(mapsDescriptor);
            XmlNode XN = XD.DocumentElement;
            XmlNodeList XNL = XN.SelectNodes("/maps/map");

            for (int i = 0; i < XNL.Count; i++) {
                XmlNodeList presets = XNL.Item(i).SelectSingleNode("gamemodes").ChildNodes;
                List<MapIcon> presetIcons = new List<MapIcon>();
                for (int j = 0; j < presets.Count; j++) {
                    XmlNodeList iconlist = presets[j].ChildNodes;
                    for (int k = 0; k < iconlist.Count; k++) {
                        StaticIcon sicon = (StaticIcon)icons.getStaticIcon(iconlist[k].Attributes["id"].InnerText).Clone();
                        sicon.position = new Point(
                            Convert.ToDouble(iconlist[k].Attributes["X"].InnerText, CultureInfo.InvariantCulture) * 1024,
                            Convert.ToDouble(iconlist[k].Attributes["Y"].InnerText, CultureInfo.InvariantCulture) * 1024
                            );
                        MapIcon icon = new MapIcon(
                            sicon,
                            presets[j].Name == "normal" ? BattleType.Normal :
                                presets[j].Name == "encounter" ? BattleType.Encounter :
                                presets[j].Name == "assault" ? BattleType.Assault : BattleType.Undefined,
                            presets[j].Attributes["variation"].InnerText
                            );
                        presetIcons.Add(icon);
                    }
                }

                Map map = new Map(
                    XNL.Item(i).Attributes["id"].InnerText,
                    XNL.Item(i).SelectSingleNode("name").InnerText,
                    System.IO.Path.GetDirectoryName(mapsDescriptor) + "\\" + XNL.Item(i).SelectSingleNode("original").InnerText,
                    System.IO.Path.GetDirectoryName(mapsDescriptor) + "\\" + XNL.Item(i).SelectSingleNode("hd").InnerText,
                    presetIcons.ToArray()
                    );
                maps.Add(map.id, map);
                sortedMaps.Add(map.name, map);
            }
        }
Пример #3
0
        public void unserialize(Stream stream)
        {
            staticTactic = new StaticTactic(maps, tanks, icons);
            dynamicTactic = new DynamicTactic(maps, tanks, icons);

            Package zip = ZipPackage.Open(stream, FileMode.Open, FileAccess.Read);
            staticTactic.load(zip);
            dynamicTactic.load(zip);
            zip.Close();

            this.map = staticTactic.getMap();
        }
Пример #4
0
 public virtual void setMap(string id, BattleType type = BattleType.Undefined, string variation = "")
 {
     this.map = maps.getMap(id);
     this.map.Battletype = type;
     this.map.Variation = variation;
 }