public void ClickStartStrengthen() { EquipmentInfo equipInfo = EquipmentStrengthenProxy.instance.StrengthenEquipInfo; EquipmentInfo[] materials = EquipmentStrengthenProxy.instance.materialsEquipInfo; List <int> selectedMaterialIDList = new List <int>(); int count = materials.Length; int selectCount = 0; bool hasHighStrengthenLevel = false; bool hasHighStar = false; for (int i = 0; i < count; i++) { if (materials[i] != null) { selectedMaterialIDList.Add(materials[i].instanceID); selectCount++; if (materials[i].strengthenLevel >= GlobalData.GetGlobalData().equipStrengthenLevelNotice) { hasHighStrengthenLevel = true; } if (materials[i].equipmentData.star >= 4) { hasHighStar = true; } } } int money = GameProxy.instance.BaseResourceDictionary.GetValue(BaseResType.Gold); int needMoney = coinText.text.ToInt32(); if (EquipmentStrengthenNeedData.IsMaxLevel(equipInfo.strengthenLevel)) { CommonErrorTipsView.Open(Localization.Get("ui.hero_strengthen_view.arrival_max_level")); return; } if (selectCount == 0) { CommonErrorTipsView.Open(Localization.Get("ui.hero_strengthen_view.material_not_enough")); return; } if (money < needMoney) { CommonErrorTipsView.Open(Localization.Get("ui.hero_strengthen_view.gold_not enough")); return; } if (hasHighStar) { string confirmTipsStr = Localization.Get("ui.equipment_strengthen_view.strengthen_materials_contains_high_star_equipment"); Logic.UI.Tips.View.ConfirmTipsView.Open(confirmTipsStr, ConfirmStrengthen); return; } if (hasHighStrengthenLevel) { string confirmTipsStr = string.Format(Localization.Get("ui.equipment_strengthen_view.strengthen_materials_contains_high_strengthen_level_equipment"), GlobalData.GetGlobalData().equipStrengthenLevelNotice); Logic.UI.Tips.View.ConfirmTipsView.Open(confirmTipsStr, ConfirmStrengthen); return; } ConfirmStrengthen(); }
private void RefreshExp() { EquipmentInfo equipmentInfo = EquipmentStrengthenProxy.instance.StrengthenEquipInfo; EquipmentInfo[] materials = EquipmentStrengthenProxy.instance.materialsEquipInfo; int count = materials.Length; int totalExpProvide = 0; int selectMaterialCount = 0; for (int i = 0; i < count; i++) { EquipmentInfo info = materials[i]; if (info != null) { EquipmentStrengthenData data = EquipmentStrengthenData.GetStrengthenDataByStar(info.equipmentData.star); totalExpProvide += data.exp_provide; selectMaterialCount++; } } //current int curLvel = equipmentInfo.strengthenLevel; EquipmentStrengthenNeedData needData = EquipmentStrengthenNeedData.GetStrengthenNeedDataByLv(curLvel); bool isMax = (needData == null); //level EquipmentStrengthenNeedData nextData = EquipmentStrengthenNeedData.GetStrengthenNeedDataByExp(EquipmentStrengthenNeedData.GetStrengthenTotalExp(curLvel) + equipmentInfo.strengthenExp + totalExpProvide); _isReachMaxLevel = isMax ? true: (nextData == null ? true : false); int addLevel = isMax ? 0:(nextData == null ? 1 : nextData.aggr_lv - equipmentInfo.strengthenLevel); strengthenLevelText.text = string.Format(Localization.Get("ui.equipment_strengthen_view.strengthen_level"), equipmentInfo.strengthenLevel, addLevel); if (isMax) { addExpText.text = "MAX"; sliderCurrentExpBar.value = 0; sliderAddExpBar.value = 0; coinText.text = "0"; } else { sliderCurrentExpBar.value = (equipmentInfo.strengthenExp + 0.0f) / needData.exp_need; sliderAddExpBar.value = (equipmentInfo.strengthenExp + totalExpProvide + 0.0f) / needData.exp_need; float money = GetStrengthenMoney(equipmentInfo.strengthenLevel, curLvel + addLevel, totalExpProvide); int totalMoney = (int)(money * selectMaterialCount); coinText.text = totalMoney.ToString(); } RefreshAttribute(curLvel + addLevel, isMax); }
private float GetStrengthenMoney(int curlevel, int nextLevel, int expTotal) { EquipmentInfo equipmentInfo = EquipmentStrengthenProxy.instance.StrengthenEquipInfo; int expTempTotal = expTotal; float moneyTotal = 0; float partMoney = 0; int goldNeed = 0; float addExpPercent = 0; float totalExpPercent = 0; if (expTotal != 0) { for (int i = curlevel; i <= nextLevel; i++) { EquipmentStrengthenNeedData needData = EquipmentStrengthenNeedData.GetStrengthenNeedDataByLv(i); if (needData == null) { needData = EquipmentStrengthenNeedData.LastNeedData(); } goldNeed = needData.GetGoldNeedByStar(equipmentInfo.equipmentData.star); if (i == nextLevel) { partMoney = (expTempTotal + 0.0f) / expTotal * goldNeed; moneyTotal += partMoney; addExpPercent = (expTempTotal + 0.0f) / needData.exp_need; totalExpPercent += addExpPercent; } else if (i == curlevel) { int exp = needData.exp_need - equipmentInfo.strengthenExp; partMoney = (exp + 0.0f) / expTotal * goldNeed; moneyTotal += partMoney; expTempTotal -= exp; addExpPercent = (exp + 0.0f) / needData.exp_need; totalExpPercent += addExpPercent; } else { partMoney = (needData.exp_need + 0.0f) / expTotal * goldNeed; moneyTotal += partMoney; expTempTotal -= needData.exp_need; totalExpPercent += 1; } } } addExpText.text = string.Format("+{0}% EXP", (int)(totalExpPercent * 100)); return(moneyTotal); }