private float GetStrengthenMoney(int curlevel, int nextLevel, int expTotal) { RoleInfo heroInfo = HeroStrengthenProxy.instance.StrengthenHeroInfo; int expTempTotal = expTotal; float moneyTotal = 0; float partMoney = 0; float addExpPercent = 0; float totalExpPercent = 0; if (expTotal != 0) { for (int i = curlevel; i <= nextLevel; i++) { HeroStrengthenNeedData needData = HeroStrengthenNeedData.GetHeroStrengthenNeedDataByLevel(i); if (needData == null) { needData = HeroStrengthenNeedData.LastNeedData(); } if (i == nextLevel) { partMoney = (expTempTotal + 0.0f) / expTotal * needData.gold_need; moneyTotal += partMoney; addExpPercent = (expTempTotal + 0.0f) / needData.exp_need; totalExpPercent += addExpPercent; } else if (i == curlevel) { int exp = needData.exp_need - heroInfo.strengthenExp; partMoney = (exp + 0.0f) / expTotal * needData.gold_need; moneyTotal += partMoney; expTempTotal -= exp; addExpPercent = (exp + 0.0f) / needData.exp_need; totalExpPercent += addExpPercent; } else { partMoney = (needData.exp_need + 0.0f) / expTotal * needData.gold_need; moneyTotal += partMoney; expTempTotal -= needData.exp_need; totalExpPercent += 1; } } } addExpText.text = string.Format("+{0}% EXP", (int)(totalExpPercent * 100)); return(moneyTotal); }
private void RefreshAttribute() { HeroInfo info; int expTotal = 0; float crit = 0; HeroInfo[] materials = HeroStrengthenProxy.instance.SelectedMaterialHeroInfos; int count = materials.Length; int selectMaterialCount = 0; for (int i = 0; i < count; i++) { info = materials[i]; if (info != null) { HeroStrengthenProvideData data = HeroStrengthenProvideData.GetHeroStrengthenProvideDataByID(info.advanceLevel); if (data != null) { expTotal += data.exp_provide; crit += (data.exp_provide * data.crit); } selectMaterialCount++; } } //crit if (expTotal != 0) { crit = crit / expTotal; } string s; if (crit >= 0 && crit < 10) { s = Localization.Get("ui.hero_strengthen_view.small"); } else if (crit >= 10 && crit < 30) { s = Localization.Get("ui.hero_strengthen_view.mid");; } else { s = Localization.Get("ui.hero_strengthen_view.big");; } currentCriticalChangeText.text = s; //level RoleInfo heroInfo = HeroStrengthenProxy.instance.StrengthenHeroInfo; HeroStrengthenNeedData curData = HeroStrengthenNeedData.GetHeroStrengthenNeedDataByLevel(heroInfo.strengthenLevel); HeroStrengthenNeedData nextData = HeroStrengthenNeedData.GetHeroStrengthenNeedDataByExp(HeroStrengthenNeedData.GetStrengthenTotalExp(heroInfo.strengthenLevel) + heroInfo.strengthenExp + expTotal); bool isMax = curData == null ? true : false; _isReachMaxLevel = isMax ? true : (nextData == null ? true : false); int addLevel = isMax ? 0 : (nextData == null) ? HeroStrengthenNeedData.LastNeedData().aggr_lv - heroInfo.strengthenLevel + 1 : nextData.aggr_lv - heroInfo.strengthenLevel; strengthenAddLevel = addLevel; int totalLv = heroInfo.strengthenLevel + addLevel; int stLv = RoleUtil.GetStrengthenAddShowValue(totalLv); if (stLv == 0) { strengthenLevelText.text = ""; } else { strengthenLevelText.text = string.Format("+{0}", stLv); } strengthenLevelDesText.text = string.Format(Localization.Get("ui.hero_strengthen_view.strengthen_level"), RoleUtil.GetStrengthenLevelColorName(totalLv)); HeroStrengthenNeedData heroStrengthenNeedData = HeroStrengthenNeedData.GetHeroStrengthenNeedDataByID(totalLv - 1); RoleStrengthenStage color = RoleStrengthenStage.White; if (heroStrengthenNeedData != null) { color = heroStrengthenNeedData.roleStrengthenStage; strengthenLevelText.color = UIUtil.GetRoleNameColor(color); strengthenLevelDesText.color = UIUtil.GetRoleNameColor(color); } else { strengthenLevelText.color = UIUtil.GetRoleNameColor(RoleStrengthenStage.White); strengthenLevelDesText.color = UIUtil.GetRoleNameColor(RoleStrengthenStage.White); } //属性 RefreshMainAttribute(addLevel); //money float moneyTotal = GetStrengthenMoney(heroInfo.strengthenLevel, heroInfo.strengthenLevel + addLevel, expTotal); moneyTotal = moneyTotal * selectMaterialCount; if (moneyTotal > GameProxy.instance.BaseResourceDictionary.GetValue(BaseResType.Gold)) { coinText.text = UIUtil.FormatToRedText(((int)moneyTotal).ToString()); } else { coinText.text = ((int)moneyTotal).ToString(); } RefreshExp(expTotal); }