Esempio n. 1
0
        public AddTank(Tanks _tanks, DynamicTank _tank = null)
        {
            InitializeComponent();

            tanks = _tanks;

            if (_tank == null) {
                newtank = new DynamicTank();
                newtank.positions.Add(900, new Point(500, 500));
            } else {
                newtank = _tank;
                add.Content = "Modify";
            }

            dialogResult = false;
        }
 public void setTankActionId(DynamicTank tank, int time, string action)
 {
     tactic.setTankActionId(tank, time, action);
     mainwindow.refreshMap();
 }
 public void setKill(DynamicTank tank, int time)
 {
     tactic.setKill(tank, time);
     mainwindow.refreshDynamicPanel();
     mainwindow.refreshMap();
 }
 public void removePosition(DynamicTank tank, int time)
 {
     tactic.removePosition(tank, time);
     mainwindow.refreshMap();
 }
        public Point getTankPosition(DynamicTank tank, int time)
        {
            int roundTime = (int)(Math.Ceiling((float)time / 30.0) * 30.0);

            while (!tank.positions.ContainsKey(roundTime)) {
                roundTime += 30;
            }

            Point from = tank.positions[roundTime];
            int fromTime = roundTime;

            roundTime = (time / 30) * 30;
            while (!tank.positions.ContainsKey(roundTime) && (roundTime >= 0)) {
                roundTime -= 30;
            }

            if (roundTime < 0 || fromTime == roundTime) {
                return from;
            } else {
                Point to = tank.positions[roundTime];
                int toTime = roundTime;

                return new Point(
                    from.X - (int)((float)(from.X - to.X) * Math.Abs((float)(fromTime - time) / (float)(fromTime - toTime))),
                    from.Y - (int)((float)(from.Y - to.Y) * Math.Abs((float)(fromTime - time) / (float)(fromTime - toTime)))
                );
            }
        }
Esempio n. 6
0
 public void setTankActionId(DynamicTank tank, int time, string action)
 {
     dynamicTactic.setDynamicTankAction(tank, time, action);
 }
Esempio n. 7
0
 public void removeTank(DynamicTank tank)
 {
     dynamicTactic.removeDynamicTank(tank);
 }
Esempio n. 8
0
 public bool isAlive(DynamicTank tank, int time)
 {
     return dynamicTactic.isAlive(tank, time);
 }
        public void unserialize(Stream stream)
        {
            reset();

            StreamReader sr = new StreamReader(stream);
            XmlDocument XD = new XmlDocument();
            XD.LoadXml(sr.ReadToEnd());
            XmlNode XNDocument = XD.DocumentElement;
            XmlNode XN = XNDocument.SelectSingleNode("/mapData/map");
            if (XN.Attributes["BattleType"].InnerText != "") {
                setMap(
                    XN.Attributes["id"].InnerText,
                    (BattleType)Enum.Parse(typeof(BattleType), XN.Attributes["BattleType"].InnerText),
                    XN.Attributes["Variation"].InnerText
                    );
            } else {
                setMap(XN.Attributes["id"].InnerText);
            }
            timer = Convert.ToBoolean(XN.Attributes["timer"].InnerText);

            XmlNodeList XNL = XNDocument.SelectNodes("/mapData/map/staticIcons/icon");
            for (int i = 0; i < XNL.Count; i++) {
                StaticIcon staticIcon = icons.getStaticIcon(XNL.Item(i).SelectSingleNode("id").InnerText);
                XN = XNL.Item(i).SelectSingleNode("position");
                staticIcon.position = new Point(
                    Convert.ToDouble(XN.Attributes["X"].InnerText.Replace(',', '.'), CultureInfo.InvariantCulture),
                    Convert.ToDouble(XN.Attributes["Y"].InnerText.Replace(',', '.'), CultureInfo.InvariantCulture)
                );
                staticIcons.Add(staticIcon);
            }

            XNL = XNDocument.SelectNodes("/mapData/map/tanks/tank");
            XmlNodeList XNLtemp;
            for (int i = 0; i < XNL.Count; i++) {
                DynamicTank tank = new DynamicTank();
                tank.name = XNL.Item(i).SelectSingleNode("name").InnerText;
                tank.isAlly = Convert.ToBoolean(XNL.Item(i).SelectSingleNode("isAlly").InnerText);
                tank.tank = tanks.getTank(XNL.Item(i).SelectSingleNode("tankId").InnerText);
                XNLtemp = XNL.Item(i).SelectNodes("positions/position");
                for (int j = 0; j < XNLtemp.Count; j++) {
                    tank.positions.Add(
                        Convert.ToInt32(XNLtemp.Item(j).Attributes["id"].InnerText),
                        new Point(
                            Convert.ToDouble(XNLtemp.Item(j).Attributes["X"].InnerText.Replace(',', '.'), CultureInfo.InvariantCulture),
                            Convert.ToDouble(XNLtemp.Item(j).Attributes["Y"].InnerText.Replace(',', '.'), CultureInfo.InvariantCulture)
                        )
                    );
                }
                XNLtemp = XNL.Item(i).SelectNodes("actions/action");
                for (int j = 0; j < XNLtemp.Count; j++) {
                    tank.actions.Add(
                        Convert.ToInt32(XNLtemp.Item(j).Attributes["id"].InnerText),
                        XNLtemp.Item(j).Attributes["actionId"].InnerText
                    );
                }
                tank.killTime = Convert.ToInt32(XNL.Item(i).SelectSingleNode("killTime").InnerText);
                dynamicTanks.Add(tank);
            }
        }
Esempio n. 10
0
 public void setKill(DynamicTank tank, int time)
 {
     tank.killTime = time;
 }
Esempio n. 11
0
 public void setDynamicTankAction(DynamicTank tank, int time, string actionId)
 {
     tank.actions.Remove(time);
     if (actionId != "") {
         tank.actions.Add(time, actionId);
     }
 }
Esempio n. 12
0
 public void selectItem(DynamicTank tank)
 {
     selectedDynamicTank.Add(tank);
 }
Esempio n. 13
0
 public void removeDynamicTank(DynamicTank tank)
 {
     dynamicTanks.Remove(tank);
 }
Esempio n. 14
0
 public void removeDynamicPosition(DynamicTank tank, int time)
 {
     if (time != 900) {
         tank.positions.Remove(time);
     }
 }
Esempio n. 15
0
 public bool isAlive(DynamicTank tank, int time)
 {
     if (tank.killTime < time) {
         return true;
     } else {
         return false;
     }
 }
 public void addTank(DynamicTank tank)
 {
     tactic.addTank(tank);
     mainwindow.refreshMap();
     mainwindow.refreshDynamicTactic();
 }
Esempio n. 17
0
 public string getTankActionId(DynamicTank tank, int time)
 {
     return dynamicTactic.getDynamicTankActionId(tank, time);
 }
Esempio n. 18
0
        private void loadVersion110(Package zip)
        {
            PackagePart part = zip.GetPart(new Uri("/dynamic/maps.xml", UriKind.Relative));
            Stream zipStream = part.GetStream(FileMode.Open, FileAccess.Read);

            StreamReader sr = new StreamReader(zipStream);
            XmlDocument XD = new XmlDocument();
            XD.LoadXml(sr.ReadToEnd());
            XmlNode XNDocument = XD.DocumentElement;
            XmlNode XN = XNDocument.SelectSingleNode("/mapData/map");
            if (XN.Attributes["BattleType"].InnerText != "") {
                setMap(
                    XN.Attributes["id"].InnerText,
                    (BattleType)Enum.Parse(typeof(BattleType), XN.Attributes["BattleType"].InnerText),
                    XN.Attributes["Variation"].InnerText
                    );
            } else {
                setMap(XN.Attributes["id"].InnerText);
            }
            timer = Convert.ToBoolean(XN.Attributes["timer"].InnerText);

            XmlNodeList XNL = XNDocument.SelectNodes("/mapData/map/staticIcons/icon");
            for (int i = 0; i < XNL.Count; i++) {
                StaticIcon staticIcon = icons.getStaticIcon(XNL.Item(i).SelectSingleNode("id").InnerText);
                XN = XNL.Item(i).SelectSingleNode("position");
                staticIcon.position = new Point(
                    Convert.ToDouble(XN.Attributes["X"].InnerText.Replace(',', '.'), CultureInfo.InvariantCulture),
                    Convert.ToDouble(XN.Attributes["Y"].InnerText.Replace(',', '.'), CultureInfo.InvariantCulture)
                );
                staticIcons.Add(staticIcon);
            }

            XNL = XNDocument.SelectNodes("/mapData/map/tanks/tank");
            XmlNodeList XNLtemp;
            for (int i = 0; i < XNL.Count; i++) {
                DynamicTank tank = new DynamicTank();
                tank.name = XNL.Item(i).SelectSingleNode("name").InnerText;
                tank.isAlly = Convert.ToBoolean(XNL.Item(i).SelectSingleNode("isAlly").InnerText);
                try
                {
                    tank.tank = tanks.getTank(XNL.Item(i).SelectSingleNode("tankId").InnerText);
                }
                catch (KeyNotFoundException)
                {
                    tank.tank = tanks.getTank("1");
                }
                XNLtemp = XNL.Item(i).SelectNodes("positions/position");
                for (int j = 0; j < XNLtemp.Count; j++) {
                    tank.positions.Add(
                        Convert.ToInt32(XNLtemp.Item(j).Attributes["id"].InnerText),
                        new Point(
                            Convert.ToDouble(XNLtemp.Item(j).Attributes["X"].InnerText.Replace(',', '.'), CultureInfo.InvariantCulture),
                            Convert.ToDouble(XNLtemp.Item(j).Attributes["Y"].InnerText.Replace(',', '.'), CultureInfo.InvariantCulture)
                        )
                    );
                }
                XNLtemp = XNL.Item(i).SelectNodes("actions/action");
                for (int j = 0; j < XNLtemp.Count; j++) {
                    tank.actions.Add(
                        Convert.ToInt32(XNLtemp.Item(j).Attributes["id"].InnerText),
                        XNLtemp.Item(j).Attributes["actionId"].InnerText
                    );
                }
                tank.killTime = Convert.ToInt32(XNL.Item(i).SelectSingleNode("killTime").InnerText);
                dynamicTanks.Add(tank);
            }
        }
Esempio n. 19
0
 public void removePosition(DynamicTank tank, int time)
 {
     dynamicTactic.removeDynamicPosition(tank, time);
 }
Esempio n. 20
0
 public void addDynamicTank(DynamicTank tank)
 {
     dynamicTanks.Add(tank);
 }
Esempio n. 21
0
 public void setKill(DynamicTank tank, int time)
 {
     dynamicTactic.setKill(tank, time);
 }
 public void editTank(DynamicTank tank)
 {
     mainwindow.refreshMap();
     mainwindow.refreshDynamicTactic();
 }
Esempio n. 23
0
 public void addTank(DynamicTank tank)
 {
     dynamicTactic.addDynamicTank(tank);
 }
Esempio n. 24
0
 public string getDynamicTankActionId(DynamicTank tank, int time)
 {
     if (tank.actions.ContainsKey(time)) {
         return tank.actions[time];
     } else {
         return "";
     }
 }