|
@@ -17,6 +17,8 @@ namespace GFGGame
|
|
|
private int[] upgradeCardItemsArr = GlobalCfgArray.globalCfg.upgradeCardItemsArr;
|
|
|
private CardData _cardData;
|
|
|
private List<int> itemsCount;
|
|
|
+ private Dictionary<int,int> _listItemChose = new Dictionary<int, int>();
|
|
|
+ private List<GObject> _listItemObj = new List<GObject>();
|
|
|
private int _countCanUpMaxLevel = 0;
|
|
|
private int _nowCountCanUpLevel = 0;
|
|
|
private long _goldsHasNum = 0;
|
|
@@ -56,14 +58,14 @@ namespace GFGGame
|
|
|
private void OnChangeUpLevel()
|
|
|
{
|
|
|
float volumn = (float)_ui.m_slideUpLevel.value / 100;
|
|
|
- _nowCountCanUpLevel = (int)(volumn * (_countCanUpMaxLevel - _cardData.lv + 1));
|
|
|
+ _nowCountCanUpLevel = _cardData.lv + (int)(volumn * (_countCanUpMaxLevel - _cardData.lv));
|
|
|
tidyData(_nowCountCanUpLevel);
|
|
|
ReferViewInfo();
|
|
|
}
|
|
|
|
|
|
private void ReferSlide()
|
|
|
{
|
|
|
- _ui.m_slideUpLevel.value = (float)_nowCountCanUpLevel / (_countCanUpMaxLevel - _cardData.lv + 1)*100;
|
|
|
+ _ui.m_slideUpLevel.value = (float)(_nowCountCanUpLevel - _cardData.lv ) / (_countCanUpMaxLevel - _cardData.lv)*100;
|
|
|
}
|
|
|
|
|
|
protected override void OnShown()
|
|
@@ -87,32 +89,42 @@ namespace GFGGame
|
|
|
_goldsHasNum = 0;
|
|
|
_cumulativeGold = 0;
|
|
|
int CumulativeExp = 0;
|
|
|
- int needExp = CardLvlCfgArray.Instance.GetCfgByrarityAndcardLvl(_cardData.itemCfg.rarity, setLevel).needExp; //需要升级到的经验值
|
|
|
- needExp = needExp - _cardData.exp; //缺的经验值
|
|
|
-
|
|
|
+ long needExp = 0;
|
|
|
+ long allNeedLevelExp = 0;
|
|
|
+
|
|
|
+ if (setLevel > 0){
|
|
|
+ for (int i = _cardData.lv; i < setLevel; i++)
|
|
|
+ {
|
|
|
+ allNeedLevelExp += CardLvlCfgArray.Instance.GetCfgByrarityAndcardLvl(_cardData.itemCfg.rarity, i).needExp;
|
|
|
+ }
|
|
|
+ needExp = allNeedLevelExp - _cardData.exp; //缺的经验值
|
|
|
+ }
|
|
|
//先计算出可以升满的最高级别
|
|
|
for (int i = 0; i < upgradeCardItemsArr.Length; i++)
|
|
|
{
|
|
|
- int itemId = upgradeCardItemsArr[i];
|
|
|
- ItemCfg itemCfg = ItemCfgArray.Instance.GetCfg(itemId);
|
|
|
- int num = 0;
|
|
|
- if(setLevel> _cardData.lv)
|
|
|
- num = (int)Math.Ceiling((needExp - CumulativeExp) / (decimal)itemCfg.cardUpLvExp); //需要购买的数量
|
|
|
- long itemNum = Math.Min(num, ItemDataManager.GetItemNum(itemId)); //物品可购买数量
|
|
|
- int[] cardUpLvGolds = ItemCfgArray.Instance.GetCfg(upgradeCardItemsArr[i]).cardUpLvGoldsArr[_cardData.itemCfg.rarity - 1];
|
|
|
- _goldsHasNum = ItemDataManager.GetItemNum(cardUpLvGolds[0]);
|
|
|
- int goldNum = (int)Math.Floor((_goldsHasNum - _cumulativeGold) / (decimal)cardUpLvGolds[1]);//货币可购买数量
|
|
|
- int sumNum = (int)Math.Min(goldNum, itemNum);
|
|
|
- itemsCount[i] = sumNum;
|
|
|
- CumulativeExp = CumulativeExp + (sumNum * itemCfg.cardUpLvExp);
|
|
|
- _cumulativeGold = _cumulativeGold + (sumNum * cardUpLvGolds[1]);
|
|
|
+ if (!_listItemChose.ContainsKey(i) || _listItemChose[i] == 1) {
|
|
|
+ int itemId = upgradeCardItemsArr[i];
|
|
|
+ ItemCfg itemCfg = ItemCfgArray.Instance.GetCfg(itemId);
|
|
|
+ int num = 0;
|
|
|
+ if(setLevel> _cardData.lv)
|
|
|
+ num = (int)Math.Ceiling((needExp - CumulativeExp) / (decimal)itemCfg.cardUpLvExp); //需要购买的数量
|
|
|
+ long itemNum = Math.Min(num, ItemDataManager.GetItemNum(itemId)); //物品可购买数量
|
|
|
+ int[] cardUpLvGolds = ItemCfgArray.Instance.GetCfg(upgradeCardItemsArr[i]).cardUpLvGoldsArr[_cardData.itemCfg.rarity - 1];
|
|
|
+ _goldsHasNum = ItemDataManager.GetItemNum(cardUpLvGolds[0]);
|
|
|
+ int goldNum = (int)Math.Floor((_goldsHasNum - _cumulativeGold) / (decimal)cardUpLvGolds[1]);//货币可购买数量
|
|
|
+ int sumNum = (int)Math.Min(goldNum, itemNum);
|
|
|
+ itemsCount[i] = sumNum;
|
|
|
+ CumulativeExp = CumulativeExp + (sumNum * itemCfg.cardUpLvExp);
|
|
|
+ _cumulativeGold = _cumulativeGold + (sumNum * cardUpLvGolds[1]);
|
|
|
+ }
|
|
|
}
|
|
|
-
|
|
|
_nowCountCanUpLevel = _cardData.lv;
|
|
|
+ allNeedLevelExp = _cardData.exp + CumulativeExp;
|
|
|
for (int i = _cardData.lv; i < setLevel; i++)
|
|
|
{
|
|
|
int needLevelExp = CardLvlCfgArray.Instance.GetCfgByrarityAndcardLvl(_cardData.itemCfg.rarity, i).needExp;
|
|
|
- if (_cardData.exp + CumulativeExp >= needLevelExp)
|
|
|
+ allNeedLevelExp -= needLevelExp;
|
|
|
+ if (allNeedLevelExp >= 0)
|
|
|
_nowCountCanUpLevel += 1;
|
|
|
else
|
|
|
break;
|
|
@@ -140,30 +152,58 @@ namespace GFGGame
|
|
|
|
|
|
private void AddEffect()
|
|
|
{
|
|
|
- //邊框左上角特效
|
|
|
+ //边框左上角特效
|
|
|
_effectUI1 = EffectUIPool.CreateEffectUI(_ui.m_holderLeftTop, "ui_Activity", "Com_window_L_up");
|
|
|
- //邊框右下角特效
|
|
|
+ //边框右下角特效
|
|
|
_effectUI2 = EffectUIPool.CreateEffectUI(_ui.m_holderRightDowm, "ui_Activity", "Com_window_R_Down");
|
|
|
}
|
|
|
|
|
|
private void RenderListItem(int index, GObject obj)
|
|
|
{
|
|
|
UI_ComItem listItem = UI_ComItem.Proxy(obj);
|
|
|
+ _listItemObj.Add(obj);
|
|
|
CardLvlCfg cardLvCfg = CardLvlCfgArray.Instance.GetCfgByrarityAndcardLvl(_cardData.itemCfg.rarity, _cardData.lv);
|
|
|
ItemCfg itemCfg = ItemCfgArray.Instance.GetCfg(upgradeCardItemsArr[index]);
|
|
|
+ listItem.m_ButtonType.selectedIndex = 4;
|
|
|
+ if (!_listItemChose.ContainsKey(index))
|
|
|
+ _listItemChose.Add(index,1);
|
|
|
+ listItem.m_ImgpinkGot.visible = (_listItemChose[index] != 0);
|
|
|
listItem.m_loaIcon.url = ResPathUtil.GetIconPath(itemCfg);
|
|
|
+
|
|
|
+ if (listItem.target.data == null)
|
|
|
+ listItem.target.onClick.Add(OnListItemClick);
|
|
|
+ listItem.target.data = index;
|
|
|
+
|
|
|
listItem.m_CountType.selectedIndex = 1;
|
|
|
listItem.m_txtDecomCount.text = itemsCount[index].ToString();
|
|
|
listItem.m_txtDecomHasCount.text = "/" + ItemDataManager.GetItemNum(itemCfg.id).ToString();
|
|
|
UI_ComItem.ProxyEnd();
|
|
|
}
|
|
|
|
|
|
+ private void OnListItemClick(EventContext context)
|
|
|
+ {
|
|
|
+ int index = (int)(context.sender as GObject).data;
|
|
|
+ UI_ComItem listItem = UI_ComItem.Proxy(_listItemObj[index]);
|
|
|
+ if (_listItemChose[index] == 0)
|
|
|
+ _listItemChose[index] = 1;
|
|
|
+ else
|
|
|
+ _listItemChose[index] = 0;
|
|
|
+
|
|
|
+ listItem.m_ImgpinkGot.visible = (_listItemChose[index] != 0);
|
|
|
+ UI_ComItem.ProxyEnd();
|
|
|
+ ClearItemsCountList();
|
|
|
+ tidyData(_nowCountCanUpLevel);
|
|
|
+ ReferViewInfo();
|
|
|
+ ReferSlide();
|
|
|
+ }
|
|
|
+
|
|
|
private void ReferViewInfo()
|
|
|
{
|
|
|
_ui.m_txtChooseLevel.SetVar("value1", _nowCountCanUpLevel.ToString()).FlushVars();
|
|
|
_ui.m_txtChooseLevel.SetVar("value2", _countCanUpMaxLevel.ToString()).FlushVars();
|
|
|
_ui.m_txtCost.SetVar("value1", _cumulativeGold.ToString()).FlushVars();
|
|
|
_ui.m_txtCost.SetVar("value2", _goldsHasNum.ToString()).FlushVars();
|
|
|
+ _listItemObj.Clear();
|
|
|
_ui.m_list.numItems = upgradeCardItemsArr.Length;
|
|
|
}
|
|
|
|
|
@@ -173,6 +213,10 @@ namespace GFGGame
|
|
|
if (result)
|
|
|
{
|
|
|
this.Hide();
|
|
|
+ if (_cardData.lv - _nowCountCanUpLevel >= 1)
|
|
|
+ {
|
|
|
+ ViewManager.Show<CardUpView>(new object[] { _cardData.scores, "lv", _nowCountCanUpLevel, _cardData.lv, _cardData.id });
|
|
|
+ }
|
|
|
LogServerHelper.SendPlayParticipationLog((int)PlayParticipationEnum.CI_PAI, 2);
|
|
|
}
|
|
|
}
|