|
@@ -1,5 +1,6 @@
|
|
|
using System;
|
|
|
using System.Collections.Generic;
|
|
|
+using System.Linq;
|
|
|
using FairyGUI;
|
|
|
using UI.ClothingDecompose;
|
|
|
|
|
@@ -10,8 +11,9 @@ namespace GFGGame
|
|
|
private UI_ClothingDecomposeUI _ui;
|
|
|
private ValueBarController _valueBarController;
|
|
|
|
|
|
- private List<int> _datas = new List<int>();
|
|
|
+ private List<int> _clothingDatas = new List<int>();
|
|
|
private Dictionary<int, int> _decomposeData = new Dictionary<int, int>();
|
|
|
+
|
|
|
private int _decomposeCount = 0;//要分解物品的数量
|
|
|
private int _curRarity = 0;
|
|
|
public override void Dispose()
|
|
@@ -71,11 +73,11 @@ namespace GFGGame
|
|
|
private void OnClickBtnRarity(int rarity)
|
|
|
{
|
|
|
_curRarity = rarity;
|
|
|
- _datas = DecomposeDataManager.Instance.GetDecomposeDataByRarity(rarity);
|
|
|
- _ui.m_list.visible = _datas != null && _datas.Count > 0;
|
|
|
- _ui.m_txtNone.visible = _datas == null || _datas.Count == 0;
|
|
|
- if (_datas == null) return;
|
|
|
- _ui.m_list.numItems = _datas.Count;
|
|
|
+ _clothingDatas = DecomposeDataManager.Instance.GetDecomposeDataByRarity(rarity);
|
|
|
+ _ui.m_list.visible = _clothingDatas != null && _clothingDatas.Count > 0;
|
|
|
+ _ui.m_txtNone.visible = _clothingDatas == null || _clothingDatas.Count == 0;
|
|
|
+ if (_clothingDatas == null) return;
|
|
|
+ _ui.m_list.numItems = _clothingDatas.Count;
|
|
|
_ui.m_btnSelect.selected = false;
|
|
|
CancleAll();
|
|
|
UpdateConsume();
|
|
@@ -84,7 +86,7 @@ namespace GFGGame
|
|
|
private void ListItemRander(int index, GObject obj)
|
|
|
{
|
|
|
UI_ListItem item = UI_ListItem.Proxy(obj);
|
|
|
- ItemCfg itemCfg = ItemCfgArray.Instance.GetCfg(_datas[index]);
|
|
|
+ ItemCfg itemCfg = ItemCfgArray.Instance.GetCfg(_clothingDatas[index]);
|
|
|
RarityIconController.UpdateRarityIcon(item.m_loaRarity, itemCfg.id, false);
|
|
|
string ext = ItemUtil.GetItemResExt(itemCfg.itemType, itemCfg.subType);
|
|
|
item.m_loaIcon.url = ResPathUtil.GetIconPath(itemCfg.res, ext);
|
|
@@ -92,7 +94,7 @@ namespace GFGGame
|
|
|
item.m_imgSelect.visible = false;
|
|
|
int itemHasCount = DecomposeDataManager.Instance.ItemCanDecomposeCount(itemCfg.id);
|
|
|
item.m_txtHasCount.text = itemHasCount.ToString();
|
|
|
- int itemCount = _decomposeData.ContainsKey(_datas[index]) ? _decomposeData[_datas[index]] : 0;
|
|
|
+ int itemCount = _decomposeData.ContainsKey(_clothingDatas[index]) ? _decomposeData[_clothingDatas[index]] : 0;
|
|
|
item.m_txtCount.text = itemCount.ToString();
|
|
|
item.m_imgSelect.visible = itemCount > 0;
|
|
|
item.m_btnMinus.visible = itemCount > 0;
|
|
@@ -175,9 +177,9 @@ namespace GFGGame
|
|
|
{
|
|
|
int lastCount = DecomposeDataManager.MaxCount - _decomposeCount;
|
|
|
|
|
|
- for (int i = 0; i < _datas.Count; i++)
|
|
|
+ for (int i = 0; i < _clothingDatas.Count; i++)
|
|
|
{
|
|
|
- int itemId = _datas[i];
|
|
|
+ int itemId = _clothingDatas[i];
|
|
|
int itemHasCount = DecomposeDataManager.Instance.ItemCanDecomposeCount(itemId);
|
|
|
int itemLastCount = _decomposeData.ContainsKey(itemId) ? itemHasCount - _decomposeData[itemId] : itemHasCount;
|
|
|
|
|
@@ -188,12 +190,12 @@ namespace GFGGame
|
|
|
_decomposeCount += count;
|
|
|
if (lastCount == 0) break;
|
|
|
}
|
|
|
- _ui.m_list.numItems = _datas.Count;
|
|
|
+ _ui.m_list.numItems = _clothingDatas.Count;
|
|
|
}
|
|
|
private void CancleAll()
|
|
|
{
|
|
|
_decomposeData.Clear();
|
|
|
- _ui.m_list.numItems = _datas.Count;
|
|
|
+ _ui.m_list.numItems = _clothingDatas.Count;
|
|
|
_decomposeCount = 0;
|
|
|
|
|
|
}
|
|
@@ -204,8 +206,8 @@ namespace GFGGame
|
|
|
DecomposeCfg cfg = DecomposeCfgArray.Instance.GetCfg(_curRarity);
|
|
|
ItemCfg itemCfg = ItemCfgArray.Instance.GetCfg(cfg.consumeId);
|
|
|
_ui.m_listReward.numItems = _decomposeCount > 0 ? cfg.itemsArr.Length : 0;
|
|
|
- _ui.m_txtConsume.text = string.Format("消耗{0}X{1}", itemCfg.name, (_decomposeCount * cfg.consumeCount));
|
|
|
_ui.m_txtShow.text = string.Format("* 分解{0}件{1}可获得 *", StringUtil.GetColorText(_decomposeCount.ToString(), "#DA826E"), ConstDressRarity.DressRarityList()[_curRarity]);
|
|
|
+ _ui.m_txtConsume.text = string.Format("消耗{0}X{1}", itemCfg.name, (_decomposeCount * cfg.consumeCount));
|
|
|
}
|
|
|
private void ListRewardItemRander(int index, GObject obj)
|
|
|
{
|
|
@@ -234,7 +236,7 @@ namespace GFGGame
|
|
|
DecomposeItem();
|
|
|
}
|
|
|
}
|
|
|
- private void DecomposeItem()
|
|
|
+ private async void DecomposeItem()
|
|
|
{
|
|
|
DecomposeCfg cfg = DecomposeCfgArray.Instance.GetCfg(_curRarity);
|
|
|
ItemCfg itemCfg = ItemCfgArray.Instance.GetCfg(cfg.consumeId);
|
|
@@ -245,23 +247,14 @@ namespace GFGGame
|
|
|
PromptController.Instance.ShowFloatTextPrompt(string.Format("{0}不足", itemCfg.name));
|
|
|
return;
|
|
|
}
|
|
|
- ItemDataManager.Remove(cfg.consumeId, consumeCount);
|
|
|
- foreach (int key in _decomposeData.Keys)
|
|
|
- {
|
|
|
- ItemDataManager.Remove(key, _decomposeData[key]);
|
|
|
- }
|
|
|
- List<ItemData> listReward = new List<ItemData>();
|
|
|
- for (int i = 0; i < cfg.itemsArr.Length; i++)
|
|
|
+
|
|
|
+ List<int> itemIds = _decomposeData.Keys.ToList<int>();
|
|
|
+ List<int> itemNums = _decomposeData.Values.ToList<int>();
|
|
|
+ bool result = await ClothingDecomposeSProxy.ClothingDecompose(itemIds, itemNums);
|
|
|
+ if (result)
|
|
|
{
|
|
|
- ItemData itemData = new ItemData();
|
|
|
- itemData.id = cfg.itemsArr[i][0];
|
|
|
- itemData.num = cfg.itemsArr[i][1] * _decomposeCount;
|
|
|
- listReward.Add(itemData);
|
|
|
- ItemDataManager.Add(itemData.id, itemData.num);
|
|
|
+ OnClickBtnRarity(_curRarity);
|
|
|
}
|
|
|
-
|
|
|
- BonusController.TryShowBonusList(listReward);
|
|
|
- OnClickBtnRarity(_curRarity);
|
|
|
}
|
|
|
private void OnClickBtnRule()
|
|
|
{
|