Пример #1
0
        static private MonsterInfo MonsterXmlNodeToInfo(XmlNode node)
        {
            if (node?.Attributes == null)
            {
                throw new ArgumentNullException(nameof(node), "XmlNode and its attributes cannot be null!");
            }

            CrownInfo MonsterCrowns = new CrownInfo
            {
                Mini   = float.Parse(node.SelectSingleNode("Crown/@Mini")?.Value ?? "0.9", System.Globalization.CultureInfo.InvariantCulture),
                Silver = float.Parse(node.SelectSingleNode("Crown/@Silver")?.Value ?? "1.15", System.Globalization.CultureInfo.InvariantCulture),
                Gold   = float.Parse(node.SelectSingleNode("Crown/@Gold")?.Value ?? "1.23", System.Globalization.CultureInfo.InvariantCulture)
            };

            MonsterInfo monster = new MonsterInfo
            {
                Em         = node.Attributes["ID"].Value,
                Id         = int.Parse(node.Attributes["GameID"].Value),
                Crowns     = MonsterCrowns,
                Capture    = float.Parse(node.Attributes["Capture"].Value ?? "0"),
                Weaknesses = GetMonsterWeaknesses(node),
                MaxParts   = int.Parse(node.SelectSingleNode("Parts/@Max")?.Value ?? "0"),
                Parts      = GetMonsterPartsInfo(node)
            };

            monster.MaxRemovableParts = monster.Parts.Where(p => p.IsRemovable).Count();

            return(monster);
        }
        public void Update(CrownInfo crowns, float size)
        {
            this.LastSnapshot = new SizeSnapshot(crowns, size);

            var maxSize      = Math.Max(crowns.Gold, size) * 1.05f;
            var minSize      = Math.Min(crowns.Mini, size) * 0.9f;
            var alocatedSize = maxSize - minSize;

            MiniNotchShift    = CreateLeftThickness((crowns.Mini - minSize) / alocatedSize);
            MiddleNotchShift  = CreateLeftThickness((1 - minSize) / alocatedSize);
            SilverNotchShift  = CreateLeftThickness((crowns.Silver - minSize) / alocatedSize);
            GoldNotchShift    = CreateLeftThickness((crowns.Gold - minSize) / alocatedSize);
            BarWidth          = TotalWidth * ((size - minSize) / alocatedSize);
            this.SizeModifier = size;

            InvokePropertyChanged(nameof(MiniNotchShift));
            InvokePropertyChanged(nameof(MiddleNotchShift));
            InvokePropertyChanged(nameof(SilverNotchShift));
            InvokePropertyChanged(nameof(GoldNotchShift));
            InvokePropertyChanged(nameof(BarWidth));
            InvokePropertyChanged(nameof(TotalWidth));
            InvokePropertyChanged(nameof(this.SizeModifier));
        }
 public SizeSnapshot(CrownInfo crownInfo, float size)
 {
     this.CrownInfo = crownInfo;
     this.Size      = size;
 }