예제 #1
0
파일: GameRecords.cs 프로젝트: bsimser/CoM
        /** 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;
            }
        }
예제 #2
0
파일: GameRecords.cs 프로젝트: bsimser/CoM
        /** 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;
                }
            }
        }