예제 #1
0
        /// <summary>
        /// Deploy unit on the battlefield and set up the Character Map
        /// </summary>
        /// <param name="u">The unit deployed</param>
        /// <param name="m">The unit's organization is "main" (player-controlled)</param>
        private void deploy(Unit u, bool m)
        {
            Point off;

            if (m)
                off = new Point(4, 5);
            else
                off = new Point(4, 0);

            for (int i = 0; i < 4; i++)
                for (int e = 0; e < 4; e++)
                    if (u.isChar(i, e))
                    {
                        if (m)
                            u.get(i, e).Organization = "main";

                        cmap.set(off.X + i, off.Y + e, u.get(i, e));
                    }
        }
예제 #2
0
        public static XmlElement unit(XmlDocument doc, Unit u)
        {
            XmlElement e = doc.CreateElement("Unit");
            XmlElement te;

            e.SetAttribute("name", u.Name);
            e.SetAttribute("org", u.Organization);

            for (int i = 0; i < 4; i++)
                for (int j = 0; j < 4; j++)
                {
                    if (!u.isChar(i, j))
                        continue;

                    te = doc.CreateElement("Pos");
                    te.SetAttribute("x", i.ToString());
                    te.SetAttribute("y", j.ToString());
                    te.SetAttribute("leader", u.isLeader(i, j).ToString());
                    te.AppendChild(charToXml(doc, u.get(i, j)));
                    e.AppendChild(te);
                }

            e.AppendChild(inventory(doc, u.Inventory));

            return e;
        }