Files
MinFt/Client/Assets/Scripts/UI/Shop/CommerceNoviceGiftPopupPanel.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

192 lines
6.3 KiB
C#

using asap.core;
using cfg;
using DG.Tweening;
using game;
using GameCore;
using System.Collections;
using System.Collections.Generic;
using TMPro;
using UnityEngine;
using UnityEngine.UI;
public class CommerceNoviceGiftPopupPanel : MonoBehaviour
{
public int rodID;
#region Field&&Property
private RewardItemNew[] rewardItems;
[SerializeField]
private TMP_Text
//txt_detail,
txt_title,
txt_buy,
txt_remainder,
//txt_rebate,
txt_timer;
[SerializeField]
private Button
btn_close,
btn_buy;
[SerializeField]
private List<Perk> perkList = new List<Perk>();
[SerializeField]
List<Button> peark_btns = new List<Button>();
public IconRodRoot iconRod;
public RawImage rawImageRod;
private TriggerPackBuyData _noticeGift;
private IAPItemList _iapItem;
private Pack _pack;
private List<ItemData> _itemDatas;
#endregion
RodData config;
#region Function
protected void Start()
{
iconRod.SetRawImage(rawImageRod);
rewardItems = transform.Find("root/reward_3").GetComponentsInChildren<RewardItemNew>();
btn_buy.onClick.AddListener(OnBuy);
btn_close.onClick.AddListener(Close);
RefreshView();
SetRod();
}
void SetRod()
{
var tables = GContext.container.Resolve<Tables>();
config = tables.TbRodData.GetOrDefault(rodID);
RodSkinData skin = tables.TbRodSkinData.GetOrDefault(rodID);
RodAscend curRodAscend = tables.TbRodAscend.GetOrDefault(config.AscendID);
int perkIDListCount = curRodAscend.PerkIDList.Count;
for (int i = 0; i < perkList.Count; i++)
{
if (i < perkIDListCount)
{
perkList[i].gameObject.SetActive(true);
perkList[i].SetData(curRodAscend.PerkIDList[i], 1, config.Quality);
}
else
{
perkList[i].gameObject.SetActive(false);
}
}
for (int i = 0; i < peark_btns.Count; i++)
{
int index = i;
peark_btns[i].onClick.AddListener(() =>
{
ShowPeark(index);
});
}
//rod.transform.localPosition = new Vector3(skin.DisplayPosition[0], skin.DisplayPosition[1], skin.DisplayPosition[2]);
//rod.transform.localScale = Vector3.one * skin.DisplayScale;
//rod.rod.GetComponent<Animator>().Play("Show01");
StartDoRotate();
}
async void ShowPeark(int index)
{
item_tips _item_tips = await item_tips.Show();
if (_item_tips == null)
{
return;
}
_item_tips.ShowPerk(config.ID, index, peark_btns[index].transform.position);
}
void RefreshView()
{
var triggerPackData = GContext.container.Resolve<TriggerPackData>();
var noticeGifts = triggerPackData.GetTriggerPackList(2);
if (noticeGifts == null || noticeGifts.Count == 0)
{
Close();
return;
}
_noticeGift = noticeGifts[0];
var triggerPack = GContext.container.Resolve<Tables>().TbTriggerPackManager.GetOrDefault(_noticeGift.ID);
int packID = triggerPack.VIPPackList[triggerPackData.GetVIPLevel(2)][_noticeGift.index];
_pack = GContext.container.Resolve<Tables>().TbPack.DataMap[packID];
_iapItem = GContext.container.Resolve<Tables>().TbIAPItemList.GetOrDefault(_pack.IAPID);
_itemDatas = GContext.container.Resolve<PlayerItemData>().GetItemDataByDropIdLureInflation(null, _pack.DropID);
txt_remainder.text = LocalizationMgr.GetFormatTextValue("UI_FishingShopPanel_1", 1, 1);
for (int i = 0; i < rewardItems.Length; i++)
{
if (i < _itemDatas.Count)
{
rewardItems[i].SetData(_itemDatas[i]);
}
else
{
rewardItems[i].gameObject.SetActive(false);
}
}
txt_title.text = LocalizationMgr.GetFormatTextValue(_pack.Title_l10n_key);
//txt_detail.text = LocalizationMgr.GetFormatTextValue(_pack.Desc_l10n_key);
// txt_rebate.text = LocalizationMgr.GetFormatTextValue("UI_CommerceWelfarePopupPanel_2", _pack.Value);
SKUDetailDataEvent sKUDetailDataEvent = new SKUDetailDataEvent(_iapItem);
GContext.Publish(sKUDetailDataEvent);
txt_buy.text = sKUDetailDataEvent.price;
StopAllCoroutines();
StartCoroutine(SetTimer());
}
async void OnBuy()
{
btn_buy.onClick.RemoveAllListeners();
ShopBuyTypeData shopBuyTypeData = new ShopBuyTypeData();
shopBuyTypeData.type = ShopBuyType.TriggerPack;
shopBuyTypeData.ID = _noticeGift.ID;
bool Result = await GContext.container.Resolve<PlayerShopData>().OnBuy(_pack.DropID, shopBuyTypeData, _iapItem, _itemDatas);
if (Result)
{
OnBuySuccess();
Close();
}
btn_buy.onClick.AddListener(OnBuy);
}
async void OnBuySuccess()
{
//GContext.container.Resolve<TriggerPackData>().AddTriggerPackCount(_noticeGift.ID);
var triggerPackData = GContext.container.Resolve<TriggerPackData>();
var noticeGifts = triggerPackData.GetTriggerPackList(2);
if (noticeGifts == null || noticeGifts.Count == 0)
{
return;
}
// CommerceNoviceGiftPopupPanel 已禁用,不再重新添加拍脸
}
void Close()
{
UIManager.Instance.DestroyUI(UITypes.CommerceNoviceGiftPopupPanel);
}
IEnumerator SetTimer()
{
while (true)
{
var now = GContext.container.Resolve<TriggerPackData>().GetCurTriggerPackEndTime(_noticeGift);
if (now.TotalSeconds < 0)
{
RefreshView();
yield break;
}
txt_timer.text = ConvertTools.ConvertTime2(now.Days, now.Hours, now.Minutes, now.Seconds);
yield return new WaitForSeconds(1);
}
}
public Transform rotateTarget;
void StartDoRotate()
{
var endRotation = rotateTarget.localRotation.eulerAngles + new Vector3(0, 360, 0);
rotateTarget.DOKill();
rotateTarget.DOLocalRotate(endRotation, 10f, DG.Tweening.RotateMode.FastBeyond360).SetEase(Ease.Linear).SetLoops(-1);
}
#endregion
}