Files
MinFt/Client/Assets/Scripts/UI/Shop/LackOfTicketPopupPanel.cs
Liubing\LB 3d8d4d18f3 first commit
先修复一下,错误的场景

删除不必要的钓场资产

修复into场景

update:更新meta文件,修复报错

update:修复资源

修复第一章节建造

修复建造第三章

update:删除多余内容

update:更新README.md

update:还原图标

update:更新README

update:更新配置
2026-04-28 02:17:22 +08:00

107 lines
3.9 KiB
C#

using asap.core;
using cfg;
using game;
using GameCore;
using TMPro;
using UnityEngine;
using UnityEngine.UI;
public class LackOfTicketPopupPanel : MonoBehaviour
{
[SerializeField] private RewardItemNew _rewardShown;
[SerializeField] private Button btnBuy, btnMask, btnDiscount;
[SerializeField] private TMP_Text textPrice, textPriceOrigin, textPriceDiscount, textDiscount;
[SerializeField] private GameObject discountTag;
private Tables _tables;
private TbWheelLevel _tableWheelLevel;
private FishingEventData _fishingEventData;
private PlayerItemData _playerItemData;
private int _wheelLvl, _diamondCost;
private ItemData _reward;
private const int LackOfTicketPurchaseCount = -2;
private TbWheelInit _tableWheelInit;
private int PurchaseCount
{
get => _fishingEventData.WheelLevelCount[LackOfTicketPurchaseCount];
set => _fishingEventData.WheelLevelCount[LackOfTicketPurchaseCount] = value;
}
// Start is called before the first frame update
private void Start()
{
btnMask.onClick.AddListener(OnClickContinue);
_tables = GContext.container.Resolve<Tables>();
_tableWheelLevel = _tables.TbWheelLevel;
_tableWheelInit = _tables.TbWheelInit;
_fishingEventData = GContext.container.Resolve<FishingEventData>();
_wheelLvl = _fishingEventData.wheelLevel.Level;
_reward = new ItemData(1004, _tableWheelLevel[_wheelLvl].BuyCount);
SetupPurchaseConfig();
_playerItemData = GContext.container.Resolve<PlayerItemData>();
_rewardShown.SetData(_reward);
btnBuy.onClick.AddListener(OnClickBuy);
btnDiscount.onClick.AddListener(OnClickBuy);
}
private void SetupPurchaseConfig()
{
_diamondCost = _tableWheelLevel[_wheelLvl].Price;
var discountList = _tableWheelInit.DataList[0].Discount;
if (PurchaseCount >= discountList.Count)
{
btnBuy.gameObject.SetActive(true);
btnDiscount.gameObject.SetActive(false);
discountTag.SetActive(false);
textPrice.text = ConvertTools.GetNumberString(_diamondCost);
}
else
{
btnBuy.gameObject.SetActive(false);
btnDiscount.gameObject.SetActive(true);
discountTag.SetActive(true);
textDiscount.text = ConvertTools.GetNumberString3(discountList[PurchaseCount]);
textPriceOrigin.text = ConvertTools.GetNumberString(_diamondCost);
_diamondCost = (int)(_diamondCost * discountList[PurchaseCount]);
int r = _diamondCost % 5;
_diamondCost -= r;
if (r >= 3)
_diamondCost += 5;
textPriceDiscount.text = ConvertTools.GetNumberString(_diamondCost);
}
}
private void OnClickBuy()
{
int diamondCount = (int)_playerItemData.GetItemCount(1005);
if (diamondCount < _diamondCost)
{
UIManager.Instance.ShowUI(UITypes.LackOfResourceConfirmPopupPanel);
}
else
{
_playerItemData.AddItem(_reward, null);
_playerItemData.AddItemCount(1005, -_diamondCost, null);
GContext.Publish(new ShowData(_reward));
GContext.Publish(new ShowData());
PurchaseCount++;
_fishingEventData.UpdateTurnTableData();
#if AGG
using (var e = GEvent.GameEvent("resource_shop"))
{
e.AddContent("cost_diamond_count", _diamondCost)
.AddContent("change_type", 5)
.AddContent("change_num", _reward.count)
.AddContent("item_id", "1004")
.AddContent("change_count", 1);
}
#endif
GContext.Publish(new ResAddEvent(1004));
UIManager.Instance.DestroyUI(UITypes.LackOfTicketPopupPanel);
}
}
private void OnClickContinue()
{
UIManager.Instance.DestroyUI(UITypes.LackOfTicketPopupPanel);
}
}