Files
ft/CodexOutput/upserver/B3BatchMigration/M2/C2d修改前快照/093-SurveyPanel.cs.txt
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

73 lines
2.4 KiB
Plaintext

using asap.core;
using GameCore;
using System;
using UnityEngine;
using UnityEngine.UI;
public class SurveyPanel : MonoBehaviour
{
Button btn_close;
RectTransform RectPos;
WebView webView;
int left; int top; int right; int bottom;
DateTime startTime;
SurveyService surveyService;
cfg.SurveyData survey;
bool closing;
private void Awake()
{
webView = GetComponent<WebView>();
btn_close = transform.Find("root/btn_close").GetComponent<Button>();
RectPos = transform.Find("content").GetComponent<RectTransform>();
}
private void Start()
{
surveyService = GContext.container.Resolve<SurveyService>();
survey = surveyService.tableData;
startTime = ZZTimeHelper.UtcNow();
UIManager.Instance.DestroyUI(UITypes.FishingMorePanel);
#if UNITY_EDITOR
string Url = surveyService.GetSurveyAnswer();
Application.OpenURL(Url);
#else
Vector2 anchoredPosition1 = GetComponent<RectTransform>().anchoredPosition;
Vector2 anchoredPosition = anchoredPosition1 + RectPos.anchoredPosition;
var rect = RectPos.rect;
var rectparent = UIManager.Instance.RectTrans.rect;
int width = (int)rectparent.width / 2;
int height = (int)rectparent.height / 2;
left = width + (int)(rect.xMin + anchoredPosition.x);
right = width - (int)(rect.xMax + anchoredPosition.x);
top = height - (int)(rect.yMax + anchoredPosition.y);
bottom = height + (int)(rect.yMin + anchoredPosition.y);
string Url = surveyService.GetSurveyAnswer();
webView.OnOpen(Url, left, top, right, bottom);
#endif
btn_close.onClick.AddListener(Close);
}
async void Close()
{
if (closing) return;
closing = true;
btn_close.interactable = false;
try
{
if ((ZZTimeHelper.UtcNow() - startTime).TotalSeconds >= 10)
await surveyService.GetSurveyCheckAnswer(survey);
if (this != null && surveyService.IsCurrent) UIManager.Instance.DestroyUI(UITypes.SurveyPanel);
}
catch (Exception e)
{
Debug.LogException(e);
// Close without replaying a reward whose save outcome is uncertain.
if (this != null && surveyService.IsCurrent) UIManager.Instance.DestroyUI(UITypes.SurveyPanel);
}
}
private void OnDisable()
{
webView.OnClose();
}
}