| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270 | 
							- using System;
 
- using Core.Language;
 
- using Core.Utility;
 
- using Excel2Json;
 
- using Fort23.Core;
 
- using Fort23.UTool;
 
- using GameLogic.Bag;
 
- namespace Fort23.Mono
 
- {
 
-     /// <summary>
 
-     /// 商店购买确认弹框
 
-     /// </summary>
 
-     [UIBinding(prefab = "ShopBuyItemPanel")]
 
-     public partial class ShopBuyItemPanel : UIPanel
 
-     {
 
-         private string _poolName = "ShopBuyItemPanelItemWidget";
 
-         private string _ShopPackBuyItemPanelPoolName = "ShopPackBuyItemPanelPoolName";
 
-         public int currentSelectCount;
 
-         public int maxCount;
 
-         private AccountFileInfo.ShopItem _shopItem;
 
-         private ShopItemConfig _shopItemConfig;
 
-         private Action<bool, int> _callback;
 
-         private bool _buyMark = false;
 
-         private void Init()
 
-         {
 
-         }
 
-         public override CTask GetFocus()
 
-         {
 
-             if (PlayerGuideManager.Instance.GuideIsCanDo(7, 5))
 
-             {
 
-                 PlayerGuideManager.Instance.NextGuide();
 
-             }
 
-             return base.GetFocus();
 
-         }
 
-         public async void CustomInit(AccountFileInfo.ShopItem shopItem, Action<bool, int> callback)
 
-         {
 
-             _buyMark = false;
 
-             UIManager.Instance.DormancyAllGComponent<WidgetItem>(_poolName);
 
-             _shopItem = shopItem;
 
-             _shopItemConfig = ConfigComponent.Instance.Get<ShopItemConfig>(shopItem.id);
 
-             _callback = callback;
 
-             WidgetItem itemWidget =
 
-                 await UIManager.Instance.CreateGComponent<WidgetItem>(null, ItemRoot, poolName: _poolName);
 
-             itemWidget.InitWidget(new ItemInfo(_shopItemConfig.itemId[0], _shopItemConfig.itemCount[0]));
 
-             ItemConfig itemConfig = ConfigComponent.Instance.Get<ItemConfig>(_shopItemConfig.itemId[0]);
 
-             Text_name.text = LanguageManager.Instance.Text(itemConfig.itemName);
 
-             Text_desc.text = LanguageManager.Instance.Text(itemWidget.itemInfo.config.itemDesc);
 
-             Text_ItemCount.text =
 
-                 "当前持有:" + PlayerManager.Instance.BagController.GetItemCount(_shopItemConfig.itemId[0]);
 
-             // UseSlider.value = 1;
 
-             // UseSlider.minValue = 1;
 
-             Text_BuyCount.text = "1";
 
-             Refresh();
 
-             UpdateShowData(1);
 
-             ChangeBtnState();
 
-         }
 
-         private void Refresh()
 
-         {
 
-             //无限制 最多购买十个
 
-             if (_shopItemConfig.buyCount == -1)
 
-             {
 
-                 LimitObj.SetActive(false);
 
-                 Text_LimitCount.text = "无";
 
-                 if (_shopItemConfig.price != 0)
 
-                 {
 
-                     int total = (int)(PlayerManager.Instance.BagController.GetItemCount(_shopItemConfig.costItemId) /
 
-                                       _shopItemConfig.price);
 
-                     maxCount = total >= 10 ? 10 : total;
 
-                 }
 
-                 if (maxCount <= 1)
 
-                 {
 
-                     maxCount = 1;
 
-                 }
 
-                 SliderObj.SetActive(maxCount > 1);
 
-                 // UseSlider.maxValue = maxCount;
 
-                 // UseSlider.value = 1;
 
-             }
 
-             else
 
-             {
 
-                 LimitObj.SetActive(true);
 
-                 Text_LimitCount.text = $"{_shopItem.buyCount}/{_shopItemConfig.buyCount}";
 
-                 maxCount = _shopItemConfig.buyCount - _shopItem.buyCount;
 
-                 if (_shopItemConfig.price != 0)
 
-                 {
 
-                     int temp = (int)(PlayerManager.Instance.BagController.GetItemCount(_shopItemConfig.costItemId) /
 
-                                      _shopItemConfig.price);
 
-                     if (temp < maxCount)
 
-                     {
 
-                         maxCount = temp;
 
-                     }
 
-                 }
 
-                 if (maxCount <= 1)
 
-                 {
 
-                     maxCount = 1;
 
-                 }
 
-                 SliderObj.SetActive(maxCount > 1);
 
-                 // UseSlider.maxValue = maxCount;
 
-                 // UseSlider.value = 1;
 
-             }
 
-             if (_shopItemConfig.costItemId == GlobalParam.RMB_1031)
 
-             {
 
-                 Text_Price.text = "¥" + _shopItemConfig.price.ToString();
 
-                 ImageCurrency.gameObject.SetActive(false);
 
-             }
 
-             else if (_shopItemConfig.costItemId == 0)
 
-             {
 
-                 ImageCurrency.gameObject.SetActive(false);
 
-                 Text_Price.text = "免费";
 
-             }
 
-             else
 
-             {
 
-                 Text_Price.text = _shopItemConfig.price.ToString();
 
-                 ImageCurrency.gameObject.SetActive(true);
 
-             }
 
-             ImageCurrency.icon_name = ConfigComponent.Instance.Get<ItemConfig>(_shopItemConfig.costItemId).icon;
 
-         }
 
-         protected override void AddEvent()
 
-         {
 
-         }
 
-         protected override void DelEvent()
 
-         {
 
-         }
 
-         public override void AddButtonEvent()
 
-         {
 
-             // Btn_Close.onClick.AddListener((() => { UIManager.Instance.HideUIUIPanel(this); }));
 
-             Btn_Close1.onClick.AddListener((() => { UIManager.Instance.HideUIUIPanel(this); }));
 
-             // UseSlider.onValueChanged.AddListener(OnValueChanged);
 
-             Btn_Add.onClick.AddListener(Add);
 
-             Btn_Reduce.onClick.AddListener(Reduce);
 
-             Btn_Function.onClick.AddListener(Function);
 
-             Btn_Min.onClick.AddListener(ReduceMin);
 
-             Btn_Max.onClick.AddListener(AddMax);
 
-         }
 
-         private async void Function()
 
-         {
 
-             _buyMark = true;
 
-             UIManager.Instance.HideUIUIPanel(this);
 
-             
 
-             if (PlayerGuideManager.Instance.GuideIsCanDo(7, 6))
 
-             {
 
-                 PlayerGuideManager.Instance.NextGuide();
 
-             }
 
-         }
 
-         private void Reduce()
 
-         {
 
-             currentSelectCount--;
 
-             if (currentSelectCount < 1)
 
-             {
 
-                 currentSelectCount = 1;
 
-             }
 
-             ChangeBtnState();
 
-             OnValueChanged(currentSelectCount);
 
-             // UseSlider.value = currentSelectCount;
 
-         }
 
-         private void Add()
 
-         {
 
-             currentSelectCount++;
 
-             if (currentSelectCount > maxCount)
 
-             {
 
-                 currentSelectCount = maxCount;
 
-             }
 
-             ChangeBtnState();
 
-             OnValueChanged(currentSelectCount);
 
-             // UseSlider.value = currentSelectCount;
 
-         }
 
-         private void ReduceMin()
 
-         {
 
-             currentSelectCount = 1;
 
-             ChangeBtnState();
 
-             OnValueChanged(currentSelectCount);
 
-         }
 
-         private void AddMax()
 
-         {
 
-             currentSelectCount = maxCount;
 
-             ChangeBtnState();
 
-             OnValueChanged(currentSelectCount);
 
-         }
 
-         private void ChangeBtnState()
 
-         {
 
-             if (currentSelectCount == 1)
 
-             {
 
-                 Btn_Min.transform.Gray();
 
-                 Btn_Reduce.transform.Gray();
 
-             }
 
-             else
 
-             {
 
-                 Btn_Min.transform.RecoverColor();
 
-                 Btn_Reduce.transform.RecoverColor();
 
-             }
 
-             if (currentSelectCount == maxCount)
 
-             {
 
-                 Btn_Max.transform.Gray();
 
-                 Btn_Add.transform.Gray();
 
-             }
 
-             else
 
-             {
 
-                 Btn_Max.transform.RecoverColor();
 
-                 Btn_Add.transform.RecoverColor();
 
-             }
 
-         }
 
-         private void OnValueChanged(float arg0)
 
-         {
 
-             UpdateShowData(arg0);
 
-         }
 
-         private void UpdateShowData(float arg0)
 
-         {
 
-             int count = (int)arg0;
 
-             currentSelectCount = count;
 
-             Text_BuyCount.text = count.ToString();
 
-             if (_shopItemConfig.costItemId == GlobalParam.RMB_1031)
 
-             {
 
-                 Text_Price.text = $"¥{(count * _shopItemConfig.price).ToString()}";
 
-                 ImageCurrency.gameObject.SetActive(false);
 
-             }
 
-             else if (_shopItemConfig.costItemId == 0)
 
-             {
 
-                 Text_Price.text = "免费";
 
-             }
 
-             else
 
-             {
 
-                 Text_Price.text = $"{(count * _shopItemConfig.price).ToString()}";
 
-                 ImageCurrency.gameObject.SetActive(true);
 
-             }
 
-             // Text_Price.text = $"{(count * _shopItemConfig.price).ToString()}";
 
-         }
 
-         public async override CTask Close()
 
-         {
 
-             await base.Close();
 
-             UIManager.Instance.DormancyAllGComponent<WidgetItem>(_poolName);
 
-             _callback?.Invoke(_buyMark, currentSelectCount);
 
-         }
 
-     }
 
- }
 
 
  |