Пример #1
0
        private void AddMonster(XmlElement monsterDef, XmlNamespaceManager namespaceManager)
        {
            MonsterDef md      = MonsterDef.FromXml(monsterDef, namespaceManager);
            var        tilePos = new TilePos(int.Parse(monsterDef.GetAttribute("Left")), int.Parse(monsterDef.GetAttribute("Top")));

            md.Position = tilePos.ToPosition();
            this._gameState.AddMonster(md);
        }
Пример #2
0
        public static RandomMonsterDistribution FromXml(XmlElement node, XmlNamespaceManager xnm)
        {
            var result = new RandomMonsterDistribution
            {
                DiceRoll        = new DiceRoll(node.GetAttribute("DiceToRoll")),
                CountOfMonsters = int.Parse(node.GetAttribute("CountOfMonsters"))
            };

            // ReSharper disable once PossibleNullReferenceException
            foreach (XmlElement mdef in node.SelectNodes("ns:MonsterTemplates/ns:Monster", xnm))
            {
                var md = MonsterDef.FromXml(mdef, xnm);
                int matchingDiceRoll = int.Parse(mdef.GetAttribute("MatchingDiceRoll"));
                result.Templates.Add(matchingDiceRoll, md);
            }

            return(result);
        }