Ejemplo n.º 1
0
        //设置玩家
        public void SetCharId(Player player, int charId)
        {
            player.charId = charId;

            ConfigPlayer configPlayer = ReadConfig.instance.configPlayers[charId];

            player.HP        = configPlayer.hp;
            player.HPMax     = configPlayer.hpMax;
            player.speed     = configPlayer.speed;
            player.speedMax  = configPlayer.speedMax;
            player.damage    = configPlayer.damage;
            player.damageMax = configPlayer.damageMax;
        }
Ejemplo n.º 2
0
        public static void ReadXML()
        {
            XmlDocument doc = new XmlDocument();

            doc.Load("../../../Config/Config.xml");

            XmlElement  rootElem      = doc.DocumentElement;
            XmlNodeList ItemMapNodes1 = rootElem.GetElementsByTagName("ItemMap1");
            XmlNodeList ItemMapNodes2 = rootElem.GetElementsByTagName("ItemMap2");
            XmlNodeList ItemMapNodes3 = rootElem.GetElementsByTagName("ItemMap3");
            XmlNodeList CharNodes     = rootElem.GetElementsByTagName("Char");
            XmlNodeList ItemNodes     = rootElem.GetElementsByTagName("Item");

            foreach (var item in ItemMapNodes1)
            {
                int id    = int.Parse(((XmlElement)item).GetAttribute("id"));
                int count = int.Parse(((XmlElement)item).GetAttribute("count"));
                ReadConfig.instance.itemCount1.Add(id, count);
            }

            foreach (var item in ItemMapNodes2)
            {
                int id    = int.Parse(((XmlElement)item).GetAttribute("id"));
                int count = int.Parse(((XmlElement)item).GetAttribute("count"));
                ReadConfig.instance.itemCount2.Add(id, count);
            }

            foreach (var item in ItemMapNodes3)
            {
                int id    = int.Parse(((XmlElement)item).GetAttribute("id"));
                int count = int.Parse(((XmlElement)item).GetAttribute("count"));
                ReadConfig.instance.itemCount3.Add(id, count);
            }

            foreach (var item in CharNodes)
            {
                int charid    = int.Parse(((XmlElement)item).GetAttribute("charid"));
                int hp        = int.Parse(((XmlElement)item).GetAttribute("hp"));
                int hpMax     = int.Parse(((XmlElement)item).GetAttribute("hpMax"));
                int speed     = int.Parse(((XmlElement)item).GetAttribute("speed"));
                int speedMax  = int.Parse(((XmlElement)item).GetAttribute("speedMax"));
                int damage    = int.Parse(((XmlElement)item).GetAttribute("damage"));
                int damageMax = int.Parse(((XmlElement)item).GetAttribute("damageMax"));

                ConfigPlayer configPlayer = new ConfigPlayer();
                configPlayer.charid    = charid;
                configPlayer.hp        = hp;
                configPlayer.hpMax     = hpMax;
                configPlayer.speed     = speed;
                configPlayer.speedMax  = speedMax;
                configPlayer.damage    = damage;
                configPlayer.damageMax = damageMax;
                ReadConfig.instance.configPlayers.Add(charid, configPlayer);
            }

            foreach (var item in ItemNodes)
            {
                int id    = int.Parse(((XmlElement)item).GetAttribute("id"));
                int value = int.Parse(((XmlElement)item).GetAttribute("value"));
                ReadConfig.instance.ItemId2Value.Add(id, value);
            }
        }