|
@@ -23,8 +23,11 @@ namespace GFGGame
|
|
|
private int _maxCount;
|
|
|
private bool _openSource;
|
|
|
private bool _showTips;
|
|
|
+ private int _buyType;
|
|
|
+ private int _shopType;
|
|
|
private Action _onSuccess;
|
|
|
|
|
|
+
|
|
|
public override void Dispose()
|
|
|
{
|
|
|
base.Dispose();
|
|
@@ -60,7 +63,7 @@ namespace GFGGame
|
|
|
/// <param name="showTips">是否弹购买成功飘字,默认是</param>
|
|
|
/// <param name="openSource">是否打开来源界面。默认否</param>
|
|
|
/// <param name="count">兑换总量</param>
|
|
|
- public void SetParams(int itemId, int costId, int perCount, int perCostCount, int count, Action onSuccess = null, bool showTips = true, bool openSource = false, int maxCount = 9990)
|
|
|
+ public void SetParams(int itemId, int costId, int perCount, int perCostCount, int count, int buyType, int shopType = 0, Action onSuccess = null, bool showTips = true, bool openSource = false, int maxCount = 9990)
|
|
|
{
|
|
|
_itemId = itemId;
|
|
|
_costId = costId;
|
|
@@ -71,6 +74,8 @@ namespace GFGGame
|
|
|
_maxCount = maxCount;
|
|
|
_openSource = openSource;
|
|
|
_showTips = showTips;
|
|
|
+ _buyType = buyType;
|
|
|
+ _shopType = shopType;
|
|
|
}
|
|
|
protected override void OnShown()
|
|
|
{
|
|
@@ -105,8 +110,6 @@ namespace GFGGame
|
|
|
int count = int.Parse(_ui.m_txtCount.text.Trim());
|
|
|
|
|
|
int price = (int)Math.Ceiling((decimal)count / _perCount) * _perCostCount;
|
|
|
- // int price = ItemUtil.CostItemCount(_itemId, count);
|
|
|
-
|
|
|
_ui.m_txtPrice.text = "" + price;
|
|
|
SetBtnState();
|
|
|
}
|
|
@@ -216,7 +219,7 @@ namespace GFGGame
|
|
|
}
|
|
|
|
|
|
}
|
|
|
- private void OnClickBtnSure()
|
|
|
+ private async void OnClickBtnSure()
|
|
|
{
|
|
|
int count = int.Parse(_ui.m_txtCount.text.Trim());
|
|
|
int price = int.Parse(_ui.m_txtPrice.text.Trim());
|
|
@@ -243,13 +246,25 @@ namespace GFGGame
|
|
|
else
|
|
|
{
|
|
|
int buyCount = price / _perCostCount * _perCount;
|
|
|
- ItemUtil.AddItemUseCost(_itemId, buyCount, _costId, price);
|
|
|
- // GuideController.HideGuide();
|
|
|
+ // ItemUtil.AddItemUseCost(_itemId, buyCount, _costId, price);
|
|
|
+ bool result = false;
|
|
|
+ // result
|
|
|
+ switch (_buyType)
|
|
|
+ {
|
|
|
+ case ConstBuyType.TYPE_NORMAL:
|
|
|
+ break;
|
|
|
+ case ConstBuyType.TYPE_ITEM:
|
|
|
+ result = await ItemExchangeSProxy.ItemExchange(_itemId, count);
|
|
|
+ break;
|
|
|
+ case ConstBuyType.TYPE_SHOP:
|
|
|
+ result = await ShopSProxy.ShopBuy(_shopType, _itemId, count);
|
|
|
+ break;
|
|
|
+ }
|
|
|
if (_onSuccess != null)
|
|
|
{
|
|
|
_onSuccess();
|
|
|
}
|
|
|
- if (_showTips)
|
|
|
+ if (result && _showTips)
|
|
|
{
|
|
|
PromptController.Instance.ShowFloatTextPrompt("购买成功", MessageType.SUCCESS);
|
|
|
}
|
|
@@ -287,14 +302,6 @@ namespace GFGGame
|
|
|
Reset();
|
|
|
|
|
|
}
|
|
|
- protected override void UpdateToCheckGuide(object param)
|
|
|
- {
|
|
|
- if (!ViewManager.CheckIsTopView(this.viewCom)) return;
|
|
|
-
|
|
|
- GuideController.TryGuide(_ui.m_btnSure, ConstGuideId.BUY_CLOTHING, 3, "找到需要的物品了,点击购买吧");
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
/// <summary>
|
|
|
/// 是否显示购买提示
|
|
|
/// </summary>
|
|
@@ -306,5 +313,12 @@ namespace GFGGame
|
|
|
_ui.m_txtBuyTips.visible = value;
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ protected override void UpdateToCheckGuide(object param)
|
|
|
+ {
|
|
|
+ if (!ViewManager.CheckIsTopView(this.viewCom)) return;
|
|
|
+
|
|
|
+ GuideController.TryGuide(_ui.m_btnSure, ConstGuideId.BUY_CLOTHING, 3, "找到需要的物品了,点击购买吧");
|
|
|
+ }
|
|
|
}
|
|
|
}
|