Exemplo n.º 1
0
        /** Registers that a given monster has been identified to given level */
        public void RegisterMonsterIdentified(MDRMonster monster, IdentificationLevel idLevel)
        {
            if (!Enabled)
            {
                return;
            }

            if (monster == null)
            {
                return;
            }

            if (idLevel == IdentificationLevel.Auto || idLevel == null)
            {
                return;
            }

            if (!MonsterStats.ContainsKey(monster))
            {
                MonsterStats[monster] = new MonsterStatRecord(monster);
            }
            MonsterStatRecord record = MonsterStats[monster];

            if (idLevel.ID > record.IDLevel.ID)
            {
                record.IDLevel = idLevel;
            }
        }
Exemplo n.º 2
0
        /** Reads game stats to XML */
        public override void ReadNode(XElement node)
        {
            base.ReadNode(node);

            Records = ReadDataObject <GameRecordLibrary>(node, "Records") ?? new GameRecordLibrary();
            InitDefaultGameRecords();

            // Monsters
            var monsterStatsNode = node.Element("MonsterStats");

            if (monsterStatsNode != null)
            {
                foreach (var subNode in monsterStatsNode.Elements("Monster"))
                {
                    int id      = int.Parse(subNode.Attribute("ID").Value);
                    var monster = CoM.Monsters.ByID(id);
                    if (monster == null)
                    {
                        Trace.LogWarning("Stat record for monster [{0}] but no matching monster.", subNode.Attribute("ID").Value);
                        continue;
                    }
                    var record = new MonsterStatRecord(monster);
                    record.ReadNode(subNode);
                    MonsterStats[monster] = record;
                }
            }

            // Items
            var itemStatsNode = node.Element("ItemStats");

            if (itemStatsNode != null)
            {
                foreach (var subNode in itemStatsNode.Elements("Item"))
                {
                    int id   = int.Parse(subNode.Attribute("ID").Value);
                    var item = CoM.Items.ByID(id);
                    if (item == null)
                    {
                        Trace.LogWarning("Data Error [Stat record]: Stats for item [{0}] but no matching item.", subNode.Attribute("ID").Value);
                        continue;
                    }
                    var record = new ItemStatRecord(item);
                    record.ReadNode(subNode);
                    ItemStats[item] = record;
                }
            }
        }