|
@@ -1,7 +1,8 @@
|
|
|
using System;
|
|
|
using ET;
|
|
|
using FairyGUI;
|
|
|
-using UI.RechargeStore;
|
|
|
+using UI.CommonGame;
|
|
|
+// using UI.RechargeStore;
|
|
|
|
|
|
namespace GFGGame
|
|
|
{
|
|
@@ -28,17 +29,18 @@ namespace GFGGame
|
|
|
protected override void OnInit()
|
|
|
{
|
|
|
base.OnInit();
|
|
|
- packageName = UI_GiftBagBuyUI.PACKAGE_NAME;
|
|
|
+ packageName = UI_ItemExchangeUI.PACKAGE_NAME;
|
|
|
_ui = UI_ItemExchangeUI.Create();
|
|
|
this.viewCom = _ui.target;
|
|
|
this.viewCom.Center();
|
|
|
this.modal = true;
|
|
|
viewAnimationType = EnumViewAnimationType.ZOOM_CENTER;
|
|
|
|
|
|
- _ui.m_btnPlus.onClick.Add(OnBtnPlusClick);
|
|
|
- _ui.m_btnMinus.onClick.Add(OnBtnMinusClick);
|
|
|
- _ui.m_btnAll.onClick.Add(OnBtnAllClick);
|
|
|
- _ui.m_btnExchange.onClick.Add(OnBtnExchangeClick);
|
|
|
+ _ui.m_btnAdd.target.onClick.Add(OnBtnPlusClick);
|
|
|
+ _ui.m_btnMinus.target.onClick.Add(OnBtnMinusClick);
|
|
|
+ _ui.m_btnMax.target.onClick.Add(OnBtnAllClick);
|
|
|
+ _ui.m_btnConfirm.onClick.Add(OnBtnExchangeClick);
|
|
|
+ _ui.m_btnCancle.onClick.Add(this.Hide);
|
|
|
}
|
|
|
|
|
|
protected override void OnShown()
|
|
@@ -49,15 +51,19 @@ namespace GFGGame
|
|
|
ShopExchangeCfg cfg = ShopExchangeCfgArray.Instance.GetCfg(_exchangeId);
|
|
|
|
|
|
_buyCount = 1;
|
|
|
+ int curMoneyCanBuy = ItemDataManager.GetItemNum(cfg.costId) / cfg.costNum;
|
|
|
if (cfg.maxLimit == 0)
|
|
|
{
|
|
|
- _maxCanBuy = Math.Min(ItemDataManager.GetItemNum(cfg.costId) / cfg.costNum, GameConst.MAX_COUNT_TO_BUY_ITEMS);
|
|
|
+ _maxCanBuy = Math.Min(curMoneyCanBuy, GameConst.MAX_COUNT_TO_BUY_ITEMS);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- _maxCanBuy = Math.Min(ItemDataManager.GetItemNum(cfg.costId) / cfg.costNum, cfg.maxLimit - RechargeDataManager.Instance.GetExchangeBuyNumById(cfg.id));
|
|
|
+ int lastBuyCount = cfg.maxLimit - RechargeDataManager.Instance.GetExchangeBuyNumById(cfg.id);//剩余购买次数
|
|
|
+ _maxCanBuy = Math.Min(curMoneyCanBuy, lastBuyCount);
|
|
|
}
|
|
|
-
|
|
|
+ _maxCanBuy = Math.Max(1, _maxCanBuy);
|
|
|
+ _ui.m_txtExchangeCount.visible = true;
|
|
|
+ _ui.m_comCost.target.visible = true;
|
|
|
UpdateStaticView();
|
|
|
UpdateView();
|
|
|
}
|
|
@@ -66,56 +72,60 @@ namespace GFGGame
|
|
|
ShopExchangeCfg cfg = ShopExchangeCfgArray.Instance.GetCfg(_exchangeId);
|
|
|
ItemCfg itemCfg = ItemCfgArray.Instance.GetCfg(cfg.itemId);
|
|
|
_ui.m_txtName.text = itemCfg.name;
|
|
|
- _ui.m_txtDiscribe.text = itemCfg.desc;
|
|
|
- _ui.m_txtHasCount.text = string.Format("已拥有:{0}", StringUtil.GetColorText(ItemDataManager.GetItemNum(cfg.itemId).ToString(), "#BC8068"));
|
|
|
- _ui.m_icon.url = ResPathUtil.GetIconPath(itemCfg);
|
|
|
- _ui.m_rarity.visible = false;
|
|
|
+ _ui.m_txtDesc.text = string.IsNullOrEmpty(itemCfg.desc) ? "暂无描述" : itemCfg.desc;
|
|
|
+ _ui.m_txtOwned.SetVar("count", ItemDataManager.GetItemNum(cfg.itemId).ToString()).FlushVars();
|
|
|
+ _ui.m_loaIcon.url = ResPathUtil.GetIconPath(itemCfg);
|
|
|
+ _ui.m_loaRarity.visible = false;
|
|
|
if (ItemUtilCS.IsDressUpItem(cfg.itemId))
|
|
|
{
|
|
|
- _ui.m_rarity.visible = true;
|
|
|
- RarityIconController.UpdateRarityIcon(_ui.m_rarity, cfg.itemId, false);
|
|
|
+ _ui.m_loaRarity.visible = true;
|
|
|
+ RarityIconController.UpdateRarityIcon(_ui.m_loaRarity, cfg.itemId, false);
|
|
|
}
|
|
|
- _ui.m_txtLastCount.text = string.Format("剩余:{0}", cfg.maxLimit - RechargeDataManager.Instance.GetExchangeBuyNumById(cfg.id));
|
|
|
- if (cfg.maxLimit == 0) _ui.m_txtLastCount.text = "剩余:不限";
|
|
|
-
|
|
|
- ItemCfg costItemCfg = ItemCfgArray.Instance.GetCfg(cfg.costId);
|
|
|
- _ui.m_iconPrice.url = ResPathUtil.GetCommonGameResPath(costItemCfg.res);
|
|
|
-
|
|
|
}
|
|
|
private void UpdateView()
|
|
|
{
|
|
|
|
|
|
- _ui.m_btnAll.enabled = _buyCount < _maxCanBuy;
|
|
|
- _ui.m_btnPlus.enabled = _buyCount < _maxCanBuy;
|
|
|
-
|
|
|
ShopExchangeCfg cfg = ShopExchangeCfgArray.Instance.GetCfg(_exchangeId);
|
|
|
- _ui.m_txtNum.text = string.Format("x{0}", cfg.num * _buyCount);
|
|
|
- _ui.m_txtCount.text = _buyCount.ToString();
|
|
|
- _ui.m_txtPrice.text = (_buyCount * cfg.costNum).ToString();
|
|
|
+ _ui.m_txtExchangeCount.text = string.Format("x{0}", cfg.num * _buyCount);
|
|
|
+
|
|
|
+ ItemCfg itemCfg = ItemCfgArray.Instance.GetCfg(cfg.itemId);
|
|
|
+ _ui.m_txtCostCount.text = _buyCount.ToString();
|
|
|
+ _ui.m_btnMinus.m_c1.selectedIndex = _buyCount == 1 ? 1 : 0;
|
|
|
+ _ui.m_btnMinus.target.touchable = _buyCount == 1 ? false : true;
|
|
|
+ // int hasCount = ItemDataManager.GetItemNum(cfg.itemId);
|
|
|
+ _ui.m_btnAdd.m_c1.selectedIndex = _buyCount == _maxCanBuy ? 1 : 0;
|
|
|
+ _ui.m_btnAdd.target.touchable = _buyCount == _maxCanBuy ? false : true;
|
|
|
+ _ui.m_btnMax.m_c1.selectedIndex = _buyCount == _maxCanBuy ? 1 : 0;
|
|
|
+ _ui.m_btnMax.target.touchable = _buyCount == _maxCanBuy ? false : true;
|
|
|
+
|
|
|
+ _ui.m_txtTips.text = string.Format("确定购买{0}个{1}?", _buyCount, itemCfg.name);
|
|
|
+ ItemUtil.SetItemNeedNum(_ui.m_comCost.target, cfg.costId, _buyCount * cfg.costNum);
|
|
|
}
|
|
|
|
|
|
|
|
|
private void OnBtnPlusClick()
|
|
|
{
|
|
|
_buyCount++;
|
|
|
+ _buyCount = Math.Min(_buyCount, _maxCanBuy);
|
|
|
UpdateView();
|
|
|
|
|
|
}
|
|
|
|
|
|
private void OnBtnMinusClick()
|
|
|
{
|
|
|
- if (_buyCount == 1)
|
|
|
- {
|
|
|
- PromptController.Instance.ShowFloatTextPrompt("已经是最小数量了");
|
|
|
- return;
|
|
|
- }
|
|
|
+ // if (_buyCount == 1)
|
|
|
+ // {
|
|
|
+ // PromptController.Instance.ShowFloatTextPrompt("已经是最小数量了");
|
|
|
+ // return;
|
|
|
+ // }
|
|
|
|
|
|
_buyCount--;
|
|
|
+ _buyCount = Math.Max(1, _buyCount);
|
|
|
UpdateView();
|
|
|
}
|
|
|
private void OnBtnAllClick()
|
|
|
{
|
|
|
- _buyCount = _maxCanBuy;
|
|
|
+ _buyCount = Math.Max(1, _maxCanBuy);
|
|
|
UpdateView();
|
|
|
}
|
|
|
private async void OnBtnExchangeClick()
|