Пример #1
0
        /// <summary>
        /// 显示英雄三围属性成长
        /// </summary>
        private async void ShowTheHeroAttr()
        {
            heroAttr = await DotaHeroHelper.GetHeroAttr(Array.IndexOf(ConstantsHelper.HeroID, SelectedHero.ID).ToString());

            if (heroAttr == null)
            {
                ShowDialog("抱歉,获取英雄三围数据时出现问题,请联系开发人员[email protected]");
                return;
            }
            //初始属性
            StrTextBlock.Text = heroAttr.Base_str;
            AgiTextBlock.Text = heroAttr.Base_agi;
            IntTextBlock.Text = heroAttr.Base_int;

            HealthTextBlock.Text      = (200 + ConvertString2Double(heroAttr.Base_str) * 20).ToString("f0");
            ManaTextBlock.Text        = (75 + ConvertString2Double(heroAttr.Base_int) * 12).ToString("f0");
            MsTextBlock.Text          = (ConvertString2Double(heroAttr.Move_speed) * (1 + ConvertString2Double(heroAttr.Base_agi) * 0.0005)).ToString("f0");
            ArmorTextBlock.Text       = (ConvertString2Double(heroAttr.Base_armor) + ConvertString2Double(heroAttr.Base_agi) * 0.16).ToString("f1");
            HealthRegenTextBlock.Text = (ConvertString2Double(heroAttr.Base_health_regen) + 0.09 * ConvertString2Double(heroAttr.Base_str)).ToString("f1");
            ManaRegenTextBlock.Text   = (ConvertString2Double(heroAttr.Base_mana_regen) + 0.05 * ConvertString2Double(heroAttr.Base_int)).ToString("f1");

            double DmgAddition = 0;

            switch (HeroesPage.selectedHeroPA)
            {
            case 1:
                DmgAddition             = ConvertString2Double(heroAttr.Base_str);
                StrTextBlock.FontWeight = Windows.UI.Text.FontWeights.Bold;
                StrEllipse.Visibility   = Visibility.Visible;
                break;

            case 2:
                DmgAddition             = ConvertString2Double(heroAttr.Base_agi);
                AgiTextBlock.FontWeight = Windows.UI.Text.FontWeights.Bold;
                AgiEllipse.Visibility   = Visibility.Visible;
                break;

            case 3:
                DmgAddition             = ConvertString2Double(heroAttr.Base_int);
                IntTextBlock.FontWeight = Windows.UI.Text.FontWeights.Bold;
                IntEllipse.Visibility   = Visibility.Visible;
                break;

            default:
                break;
            }
            DmgTextBlock.Text             = (ConvertString2Double(heroAttr.Base_attack_min) + DmgAddition) + " - " + (ConvertString2Double(heroAttr.Base_attack_max) + DmgAddition);
            AttackRangeTextBlock.Text     = heroAttr.Attack_range;
            AttkRateTextBlock.Text        = heroAttr.Attack_rate;
            TurnRateTextBlock.Text        = heroAttr.Turn_rate;
            ProjectileSpeedTextBlock.Text = heroAttr.Projectile_speed;
            CMModeTextBlock.Text          = heroAttr.Cm_enabled == "true" ? "是" : "否";

            double[] pick  = new double[] { ConvertString2Double(heroAttr._1_pick), ConvertString2Double(heroAttr._2_pick), ConvertString2Double(heroAttr._3_pick), ConvertString2Double(heroAttr._4_pick), ConvertString2Double(heroAttr._5_pick), ConvertString2Double(heroAttr._6_pick), ConvertString2Double(heroAttr._7_pick), ConvertString2Double(heroAttr._8_pick) };
            double[] win   = new double[] { ConvertString2Double(heroAttr._1_win), ConvertString2Double(heroAttr._2_win), ConvertString2Double(heroAttr._3_win), ConvertString2Double(heroAttr._4_win), ConvertString2Double(heroAttr._5_win), ConvertString2Double(heroAttr._6_win), ConvertString2Double(heroAttr._7_win), ConvertString2Double(heroAttr._8_win) };
            double   max   = pick.Max();
            double   ratio = 328.0 / max;

            Pick_1Rectangle.Width = ConvertString2Double(heroAttr._1_pick) * ratio;
            Pick_2Rectangle.Width = ConvertString2Double(heroAttr._2_pick) * ratio;
            Pick_3Rectangle.Width = ConvertString2Double(heroAttr._3_pick) * ratio;
            Pick_4Rectangle.Width = ConvertString2Double(heroAttr._4_pick) * ratio;
            Pick_5Rectangle.Width = ConvertString2Double(heroAttr._5_pick) * ratio;
            Pick_6Rectangle.Width = ConvertString2Double(heroAttr._6_pick) * ratio;
            Pick_7Rectangle.Width = ConvertString2Double(heroAttr._7_pick) * ratio;
            Pick_8Rectangle.Width = ConvertString2Double(heroAttr._8_pick) * ratio;

            Win_1Rectangle.Width = ConvertString2Double(heroAttr._1_win) * ratio;
            Win_2Rectangle.Width = ConvertString2Double(heroAttr._2_win) * ratio;
            Win_3Rectangle.Width = ConvertString2Double(heroAttr._3_win) * ratio;
            Win_4Rectangle.Width = ConvertString2Double(heroAttr._4_win) * ratio;
            Win_5Rectangle.Width = ConvertString2Double(heroAttr._5_win) * ratio;
            Win_6Rectangle.Width = ConvertString2Double(heroAttr._6_win) * ratio;
            Win_7Rectangle.Width = ConvertString2Double(heroAttr._7_win) * ratio;
            Win_8Rectangle.Width = ConvertString2Double(heroAttr._8_win) * ratio;

            Win_1TextBlock.Text  = heroAttr._1_win;
            Pick_1TextBlock.Text = heroAttr._1_pick;
            Rate_1TextBlock.Text = (100 * ConvertString2Double(heroAttr._1_win) / ConvertString2Double(heroAttr._1_pick)).ToString("f1") + "%";
            Win_2TextBlock.Text  = heroAttr._2_win;
            Pick_2TextBlock.Text = heroAttr._2_pick;
            Rate_2TextBlock.Text = (100 * ConvertString2Double(heroAttr._2_win) / ConvertString2Double(heroAttr._2_pick)).ToString("f1") + "%";
            Win_3TextBlock.Text  = heroAttr._3_win;
            Pick_3TextBlock.Text = heroAttr._3_pick;
            Rate_3TextBlock.Text = (100 * ConvertString2Double(heroAttr._3_win) / ConvertString2Double(heroAttr._3_pick)).ToString("f1") + "%";
            Win_4TextBlock.Text  = heroAttr._4_win;
            Pick_4TextBlock.Text = heroAttr._4_pick;
            Rate_4TextBlock.Text = (100 * ConvertString2Double(heroAttr._4_win) / ConvertString2Double(heroAttr._4_pick)).ToString("f1") + "%";
            Win_5TextBlock.Text  = heroAttr._5_win;
            Pick_5TextBlock.Text = heroAttr._5_pick;
            Rate_5TextBlock.Text = (100 * ConvertString2Double(heroAttr._5_win) / ConvertString2Double(heroAttr._5_pick)).ToString("f1") + "%";
            Win_6TextBlock.Text  = heroAttr._6_win;
            Pick_6TextBlock.Text = heroAttr._6_pick;
            Rate_6TextBlock.Text = (100 * ConvertString2Double(heroAttr._6_win) / ConvertString2Double(heroAttr._6_pick)).ToString("f1") + "%";
            Win_7TextBlock.Text  = heroAttr._7_win;
            Pick_7TextBlock.Text = heroAttr._7_pick;
            Rate_7TextBlock.Text = (100 * ConvertString2Double(heroAttr._7_win) / ConvertString2Double(heroAttr._7_pick)).ToString("f1") + "%";
            Win_8TextBlock.Text  = heroAttr._8_win;
            Pick_8TextBlock.Text = heroAttr._8_pick;
            Rate_8TextBlock.Text = (100 * ConvertString2Double(heroAttr._8_win) / ConvertString2Double(heroAttr._8_pick)).ToString("f1") + "%";
        }
Пример #2
0
        /// <summary>
        /// 使用正则表达式获取指定英雄的属性
        /// </summary>
        /// <returns></returns>
        public static async Task <HeroAttr> GetHeroAttr(string id)
        {
            if (_data.Length < 256)
            {
                await DotaHeroHelper.GetHeroAttributesDataAsync();
            }
            HeroAttr result = null;

            try
            {
                Match  match    = Regex.Match(_data, "{\\\"id\\\":" + id + ",[\\d\\D]*?}");
                string jsonPart = match.Groups[0].Value
                                  .Replace("1_pick", "_1_pick")
                                  .Replace("2_pick", "_2_pick")
                                  .Replace("3_pick", "_3_pick")
                                  .Replace("4_pick", "_4_pick")
                                  .Replace("5_pick", "_5_pick")
                                  .Replace("6_pick", "_6_pick")
                                  .Replace("7_pick", "_7_pick")
                                  .Replace("8_pick", "_8_pick")
                                  .Replace("1_win", "_1_win")
                                  .Replace("2_win", "_2_win")
                                  .Replace("3_win", "_3_win")
                                  .Replace("4_win", "_4_win")
                                  .Replace("5_win", "_5_win")
                                  .Replace("6_win", "_6_win")
                                  .Replace("7_win", "_7_win")
                                  .Replace("8_win", "_8_win");
                result = JsonConvert.DeserializeObject <HeroAttr>(jsonPart);
            }
            catch
            {
                return(null);
            }
            return(result);
            //Match matchAttr = Regex.Match(_data, "\\\"id\\\":" + id + ",[\\d\\D]*?\\\"base_health\\\":([\\d\\D]*?)," +
            //    "\\\"base_health_regen\\\":([\\d\\D]*?),\\\"base_mana\\\":([\\d\\D]*?),\\\"base_mana_regen\\\":" +
            //    "([\\d\\D]*?),\\\"base_armor\\\":([\\d\\D]*?),\\\"[\\d\\D]*?,\\\"base_attack_min\\\":([\\d\\D]*?)," +
            //    "\\\"base_attack_max\\\":([\\d\\D]*?),\\\"base_str\\\":([\\d\\D]*?),\\\"base_agi\\\":([\\d\\D]*?)," +
            //    "\\\"base_int\\\":([\\d\\D]*?),\\\"str_gain\\\":([\\d\\D]*?),\\\"agi_gain\\\":([\\d\\D]*?)," +
            //    "\\\"int_gain\\\":([\\d\\D]*?),\\\"attack_range\\\":([\\d\\D]*?)," +
            //    "\\\"projectile_speed\\\":([\\d\\D]*?),\\\"attack_rate\\\":([\\d\\D]*?)," +
            //    "\\\"move_speed\\\":([\\d\\D]*?),\\\"turn_rate\\\":([\\d\\D]*?)," +
            //    "\\\"cm_enabled\\\":([\\d\\D]*?),\\\"[\\d\\D]*?\\\"pro_ban\\\":[\\d\\D]*?,([\\d\\D]*?)}");
            //HeroAttr hero = new HeroAttr();
            //hero.Base_health = matchAttr.Groups[1].Value;
            //hero.Base_health_regen = matchAttr.Groups[2].Value;
            //hero.Base_mana = matchAttr.Groups[3].Value;
            //hero.Base_mana_regen = matchAttr.Groups[4].Value;
            //hero.Base_armor = matchAttr.Groups[5].Value;
            //hero.Base_attack_min = matchAttr.Groups[6].Value;
            //hero.Base_attack_max = matchAttr.Groups[7].Value;
            //hero.Base_str = matchAttr.Groups[8].Value;
            //hero.Base_agi = matchAttr.Groups[9].Value;
            //hero.Base_int = matchAttr.Groups[10].Value;
            //hero.Str_gain = matchAttr.Groups[11].Value;
            //hero.Agi_gain = matchAttr.Groups[12].Value;
            //hero.Int_gain = matchAttr.Groups[13].Value;
            //hero.Attack_range = matchAttr.Groups[14].Value;
            //hero.Projectile_speed = matchAttr.Groups[15].Value;
            //hero.Attack_rate = matchAttr.Groups[16].Value;
            //hero.Move_speed = matchAttr.Groups[17].Value;
            //hero.Turn_rate = matchAttr.Groups[18].Value;
            //hero.Cm_enabled = matchAttr.Groups[19].Value;

            //string pick_win = matchAttr.Groups[20].Value;
            //Match pick1Match = Regex.Match(pick_win, "\\\"1_pick\\\":([\\d\\D]*?)");
            //Match pick2Match = Regex.Match(pick_win, "\\\"2_pick\\\":([\\d\\D]*?)");
            //Match pick3Match = Regex.Match(pick_win, "\\\"3_pick\\\":([\\d\\D]*?)");
            //Match pick4Match = Regex.Match(pick_win, "\\\"4_pick\\\":([\\d\\D]*?)");
            //Match pick5Match = Regex.Match(pick_win, "\\\"5_pick\\\":([\\d\\D]*?)");
            //Match pick6Match = Regex.Match(pick_win, "\\\"6_pick\\\":([\\d\\D]*?)");
            //Match pick7Match = Regex.Match(pick_win, "\\\"7_pick\\\":([\\d\\D]*?)");
            //Match win1Match = Regex.Match(pick_win, "\\\"1_win\\\":([\\d\\D]*?)");
            //Match win2Match = Regex.Match(pick_win, "\\\"2_win\\\":([\\d\\D]*?)");
            //Match win3Match = Regex.Match(pick_win, "\\\"3_win\\\":([\\d\\D]*?)");
            //Match win4Match = Regex.Match(pick_win, "\\\"4_win\\\":([\\d\\D]*?)");
            //Match win5Match = Regex.Match(pick_win, "\\\"5_win\\\":([\\d\\D]*?)");
            //Match win6Match = Regex.Match(pick_win, "\\\"6_win\\\":([\\d\\D]*?)");
            //Match win7Match = Regex.Match(pick_win, "\\\"7_win\\\":([\\d\\D]*?)");

            //hero._1_pick = pick1Match.Groups[1].Value;
            //hero._2_pick = pick2Match.Groups[1].Value;
            //hero._3_pick = pick3Match.Groups[1].Value;
            //hero._4_pick = pick4Match.Groups[1].Value;
            //hero._5_pick = pick5Match.Groups[1].Value;
            //hero._6_pick = pick6Match.Groups[1].Value;
            //hero._7_pick = pick7Match.Groups[1].Value;
            //hero._1_win = win1Match.Groups[1].Value;
            //hero._2_win = win2Match.Groups[1].Value;
            //hero._3_win = win3Match.Groups[1].Value;
            //hero._4_win = win4Match.Groups[1].Value;
            //hero._5_win = win5Match.Groups[1].Value;
            //hero._6_win = win6Match.Groups[1].Value;
            //hero._7_win = win7Match.Groups[1].Value;
        }