Files
ft/Client/Assets/Scripts/UI/Shop/GiftNoticePanel.cs
Liubing\LB 6813da149a feat(upserver): 保存M2客户端KV迁移至本人统计写检查点
保存独立KV用户服务、固定会话存档与原业务接线,以及C3d资料缓存和C3e本人统计写。
保留原PF/AGG路线、业务公式和时序;榜单读取、好友资料、公告、匹配及首场景闸仍待完成。

验证:ServiceHost两条件各33组646断言;Unity CLI Loop编译0错误269警告。
包含相关方案、评审裁决、测试及状态文档。未操作服务器、正式账号或打包。
2026-09-30 19:19:05 +08:00

93 lines
3.0 KiB
C#

using asap.core;
using cfg;
using game;
using GameCore;
using System.Collections.Generic;
using System.Linq;
using Unity.Notifications;
using UnityEngine;
using UnityEngine.UI;
public class GiftNoticePanel : MonoBehaviour
{
Button btn_close;
Button btn_mask;
Button btn_watch1;
Button btn_watch2;
public RewardItemNew[] rewardItemNews;
private Tables _tables;
ILocalNotificationService notificationService;
bool handlingNotification;
private void Awake()
{
_tables = GContext.container.Resolve<Tables>();
notificationService = GContext.container.Resolve<ILocalNotificationService>();
btn_close = transform.Find("btn_close").GetComponent<Button>();
btn_mask = transform.Find("mask").GetComponent<Button>();
btn_watch1 = transform.Find("root/btn_watch1/btn_green").GetComponent<Button>();
btn_watch2 = transform.Find("root/btn_watch2/btn_green").GetComponent<Button>();
}
private void Start()
{
btn_close.onClick.AddListener(OnClose);
btn_mask.onClick.AddListener(OnClose);
btn_watch1.onClick.AddListener(OnClickNO);
btn_watch2.onClick.AddListener(OnClickYES);
int id = GContext.container.Resolve<PlayerData>().priceLevel.DailyGiftDisplay;
Item item = _tables.TbItem.GetOrDefault(id);
var itemDataGift = GContext.container.Resolve<PlayerItemData>().GetItemDataByDropIdAndType(item.RedirectID);
//ItemDropPackage itemDropPackage = _tables.TbItemDropPackage.GetOrDefault(item.RedirectID);
//if (itemDropPackage.ItemDisplay.Count > 0)
//{
// List<string> CountDisplay = GContext.container.Resolve<PlayerItemData>().ShowItemDropPackage(id, itemDropPackage);
for (int i = 0; i < rewardItemNews.Length; i++)
{
if (i < itemDataGift.Count)
{
rewardItemNews[i].SetData(itemDataGift[i]);
}
else
{
rewardItemNews[i].transform.parent.gameObject.SetActive(false);
}
}
//}
}
void OnClickNO()
{
//不再显示此界面
PlayerPrefs.SetInt("GiftNoticePanel", 1);
OnClose();
}
async void OnClickYES()
{
if (this == null || handlingNotification) return;
handlingNotification = true;
try
{
if (notificationService is LocalNotificationService local && local.HasKVPromptOwner)
{
local.RequirePromptOwner();
await local.OpenSettingsAsync();
if (this == null) return;
local.RequirePromptOwner();
}
else
{
OnClose();
notificationService.OpenSettings();
return;
}
OnClose();
}
catch (System.Exception ex) { game.DefaultSettingService.LogPromptFailure(ex); }
finally { handlingNotification = false; }
}
void OnClose()
{
UIManager.Instance.DestroyUI(UITypes.GiftNoticePanel);
}
}