feat(upserver): 保存M2客户端KV迁移至本人统计写检查点
保存独立KV用户服务、固定会话存档与原业务接线,以及C3d资料缓存和C3e本人统计写。 保留原PF/AGG路线、业务公式和时序;榜单读取、好友资料、公告、匹配及首场景闸仍待完成。 验证:ServiceHost两条件各33组646断言;Unity CLI Loop编译0错误269警告。 包含相关方案、评审裁决、测试及状态文档。未操作服务器、正式账号或打包。
This commit is contained in:
@@ -0,0 +1,268 @@
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using asap.core;
|
||||
using cfg;
|
||||
using game;
|
||||
using GameCore;
|
||||
using TMPro;
|
||||
using tysdk;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class BindAccountPopupPanel : MonoBehaviour
|
||||
{
|
||||
game.PlayerDataStorage.IPlayerSaveStore saveStore;
|
||||
|
||||
IUserService userService;
|
||||
Button btn_close;
|
||||
Button btn_close1;
|
||||
|
||||
public BindAccountBtn bind_facebookbtn;
|
||||
|
||||
public BindAccountBtn bind_googlebtn;
|
||||
|
||||
public BindAccountBtn bind_applebtn;
|
||||
|
||||
public BindAccountBtn bind_vkbtn;
|
||||
|
||||
int rewardID;
|
||||
ItemData itemData;
|
||||
private void Awake()
|
||||
{
|
||||
saveStore = GContext.container.Resolve<game.PlayerDataStorage.IPlayerSaveStore>();
|
||||
userService = GContext.container.Resolve<IUserService>();
|
||||
btn_close1 = transform.Find("btn_close").GetComponent<Button>();
|
||||
btn_close = transform.Find("mask").GetComponent<Button>();
|
||||
|
||||
bind_googlebtn = transform.Find("root/layout/btn_google").GetComponent<BindAccountBtn>();
|
||||
bind_facebookbtn = transform.Find("root/layout/btn_facebook").GetComponent<BindAccountBtn>();
|
||||
bind_applebtn = transform.Find("root/layout/btn_apple").GetComponent<BindAccountBtn>();
|
||||
bind_vkbtn = transform.Find("root/layout/btn_vk").GetComponent<BindAccountBtn>();
|
||||
|
||||
#if UNITY_IOS
|
||||
bind_googlebtn.gameObject.SetActive(false);
|
||||
bind_vkbtn.gameObject.SetActive(false);
|
||||
bind_applebtn.gameObject.SetActive(true);
|
||||
bind_facebookbtn.gameObject.SetActive(true);
|
||||
#else
|
||||
bind_googlebtn.gameObject.SetActive(ChannelManager.IsGooglePlay);
|
||||
bind_facebookbtn.gameObject.SetActive(ChannelManager.IsGooglePlay);
|
||||
bind_vkbtn.gameObject.SetActive(ChannelManager.IsRustoreStore);
|
||||
bind_applebtn.gameObject.SetActive(false);
|
||||
#endif
|
||||
}
|
||||
private void Start()
|
||||
{
|
||||
rewardID = GContext.container.Resolve<Tables>().TbGlobalConfig.AccountLinkReward;
|
||||
itemData = GContext.container.Resolve<PlayerItemData>().GetItemDataOne(rewardID);
|
||||
btn_close.onClick.AddListener(OnClose);
|
||||
btn_close1.onClick.AddListener(OnClose);
|
||||
|
||||
bind_facebookbtn.btn.interactable = false;
|
||||
bind_facebookbtn.rewardPanel.SetActive(false);
|
||||
bind_facebookbtn.btn.onClick.AddListener(OnBtnFacebook);
|
||||
|
||||
bind_googlebtn.btn.interactable = false;
|
||||
bind_googlebtn.rewardPanel.SetActive(false);
|
||||
bind_googlebtn.btn.onClick.AddListener(OnBtnGoogle);
|
||||
|
||||
bind_applebtn.btn.interactable = false;
|
||||
bind_applebtn.rewardPanel.SetActive(false);
|
||||
bind_applebtn.btn.onClick.AddListener(OnBtnApple);
|
||||
|
||||
bind_vkbtn.btn.interactable = false;
|
||||
bind_vkbtn.rewardPanel.SetActive(false);
|
||||
bind_vkbtn.btn.onClick.AddListener(OnBtnVK);
|
||||
SetMaterial();
|
||||
}
|
||||
|
||||
void SetMaterial()
|
||||
{
|
||||
bool isLinkGoogle = false;
|
||||
bool isLinkFacebook = false;
|
||||
bool isLinkApple = false;
|
||||
bool isLinkVk = false;
|
||||
|
||||
if (TYSdkFacade.TYAccountInfo != null)
|
||||
{
|
||||
isLinkGoogle = TYSdkFacade.TYAccountInfo.linkedAccout.Contains(EAccoutType.hwGoogle);
|
||||
isLinkFacebook = TYSdkFacade.TYAccountInfo.linkedAccout.Contains(EAccoutType.hwFacebook);
|
||||
isLinkApple = TYSdkFacade.TYAccountInfo.linkedAccout.Contains(EAccoutType.Apple);
|
||||
isLinkVk = TYSdkFacade.TYAccountInfo.linkedAccout.Contains(EAccoutType.hwVkid);
|
||||
}
|
||||
|
||||
Item item = GContext.container.Resolve<Tables>().TbItem.GetOrDefault(itemData.id);
|
||||
|
||||
IUIService uIService = GContext.container.Resolve<IUIService>();
|
||||
if (!isLinkGoogle)
|
||||
{
|
||||
bind_googlebtn.rewardText.text = itemData.count.ToString();
|
||||
uIService.SetImageSprite(bind_googlebtn.p_icon, item.Icon, BasePanel.PanelName);
|
||||
}
|
||||
if (!isLinkFacebook)
|
||||
{
|
||||
bind_facebookbtn.rewardText.text = itemData.count.ToString();
|
||||
uIService.SetImageSprite(bind_facebookbtn.p_icon, item.Icon, BasePanel.PanelName);
|
||||
}
|
||||
|
||||
if (!isLinkApple)
|
||||
{
|
||||
bind_applebtn.rewardText.text = itemData.count.ToString();
|
||||
uIService.SetImageSprite(bind_applebtn.p_icon, item.Icon, BasePanel.PanelName);
|
||||
}
|
||||
|
||||
if (!isLinkVk)
|
||||
{
|
||||
bind_vkbtn.rewardText.text = itemData.count.ToString();
|
||||
uIService.SetImageSprite(bind_vkbtn.p_icon, item.Icon, BasePanel.PanelName);
|
||||
}
|
||||
|
||||
bind_googlebtn.btn.interactable = !isLinkGoogle;
|
||||
bind_facebookbtn.btn.interactable = !isLinkFacebook;
|
||||
bind_applebtn.btn.interactable = !isLinkApple;
|
||||
bind_vkbtn.btn.interactable = !isLinkVk;
|
||||
|
||||
// bind_googlebtn.rewardPanel.SetActive(!isLinkGoogle);
|
||||
// bind_facebookbtn.rewardPanel.SetActive(!isLinkFacebook);
|
||||
// bind_applebtn.rewardPanel.SetActive(!isLinkApple);
|
||||
// bind_vkbtn.rewardPanel.SetActive(!isLinkVk);
|
||||
bind_googlebtn.rewardPanel.SetActive(false);
|
||||
bind_facebookbtn.rewardPanel.SetActive(false);
|
||||
bind_applebtn.rewardPanel.SetActive(false);
|
||||
bind_vkbtn.rewardPanel.SetActive(false);
|
||||
}
|
||||
|
||||
async void OnBtnGoogle()
|
||||
{
|
||||
try
|
||||
{
|
||||
if (await OnLinkSns(EAccoutType.hwGoogle))
|
||||
{
|
||||
bind_googlebtn.btn.interactable = false;
|
||||
bind_googlebtn.rewardPanel.SetActive(false);
|
||||
GetReward();
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Debug.LogWarning(e);
|
||||
}
|
||||
}
|
||||
|
||||
async void OnBtnFacebook()
|
||||
{
|
||||
try
|
||||
{
|
||||
if (await OnLinkSns(EAccoutType.hwFacebook))
|
||||
{
|
||||
bind_facebookbtn.btn.interactable = false;
|
||||
bind_facebookbtn.rewardPanel.SetActive(false);
|
||||
GetReward();
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Debug.LogWarning(e);
|
||||
}
|
||||
}
|
||||
|
||||
async void OnBtnApple()
|
||||
{
|
||||
try
|
||||
{
|
||||
if (await OnLinkSns(EAccoutType.Apple))
|
||||
{
|
||||
bind_applebtn.btn.interactable = false;
|
||||
bind_applebtn.rewardPanel.SetActive(false);
|
||||
GetReward();
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Debug.LogWarning(e);
|
||||
}
|
||||
}
|
||||
|
||||
async void OnBtnVK()
|
||||
{
|
||||
try
|
||||
{
|
||||
if (await OnLinkSns(EAccoutType.hwVkid))
|
||||
{
|
||||
bind_vkbtn.btn.interactable = false;
|
||||
bind_vkbtn.rewardPanel.SetActive(false);
|
||||
GetReward();
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Debug.LogWarning(e);
|
||||
}
|
||||
}
|
||||
|
||||
async Task<bool> OnLinkSns(EAccoutType accountType)
|
||||
{
|
||||
try
|
||||
{
|
||||
UIManager.ShowWaitingBlock("BindAccountPopupPanel::OnlinkSns");
|
||||
var (code, userid) = await userService.LinkAccount(accountType);
|
||||
if (this == null || !saveStore.IsCurrent) return false;
|
||||
|
||||
if (code == 0)
|
||||
{
|
||||
saveStore.Write(accountType.ToString(), "1").RequireAccepted();
|
||||
ToastPanel.Show(LocalizationMgr.GetText("UI_BindAccountPopupPanel_101007"));
|
||||
}
|
||||
else if (code == -1 && userid != int.Parse(userService.CustomId))
|
||||
{
|
||||
var config = GContext.container.Resolve<IConfig>();
|
||||
var titleId = config.Get<string>(GConstant.K_PlayFab_Title, GConstant.V_Debug_PF_Title);
|
||||
var info = await PlayFabTools.GetPFPlayerInfoBySDKId(userid, titleId);
|
||||
if (this == null || !saveStore.IsCurrent) return false;
|
||||
if (!info.IsAccountValid || !info.IsDataValid)
|
||||
{
|
||||
Debug.LogWarning(
|
||||
$"BindAccountPopupPanel: Get Account Info Failed, isAccountValid: {info.IsAccountValid}, isDataValid: {info.IsDataValid}");
|
||||
var msg = LocalizationMgr.GetText("UI_BindAccountPopupPanel_101008");
|
||||
ToastPanel.Show($"{msg} [{code}]");
|
||||
}
|
||||
|
||||
var switchPanelGo = await UIManager.Instance.GetUIAsync(UITypes.AccountSwitchPopupPanel);
|
||||
if (this == null || !saveStore.IsCurrent) return false;
|
||||
switchPanelGo.GetComponent<AccountSwitchPopupPanel>()
|
||||
.SetData(info.DisplayName, info.Avatar, info.Level, userid, accountType);
|
||||
UIManager.Instance.DestroyUI(UITypes.BindAccountPopupPanel);
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogWarning($"BindAccountPopupPanel: Link Account Failed, code: {code}");
|
||||
var msg = LocalizationMgr.GetText("UI_BindAccountPopupPanel_101008");
|
||||
ToastPanel.Show($"{msg} [{code}]");
|
||||
}
|
||||
|
||||
return code == 0;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
var msg = LocalizationMgr.GetText("UI_BindAccountPopupPanel_101008");
|
||||
ToastPanel.Show($"{msg} [{e.Message}]");
|
||||
return false;
|
||||
}
|
||||
finally
|
||||
{
|
||||
UIManager.HideWaitingBlock("BindAccountPopupPanel::OnlinkSns");
|
||||
}
|
||||
}
|
||||
|
||||
void GetReward()
|
||||
{
|
||||
// GContext.container.Resolve<PlayerItemData>().AddItem(itemData, null);
|
||||
// GContext.Publish(new ShowData(itemData));
|
||||
// GContext.Publish(new ShowData());
|
||||
// GContext.container.Resolve<PlayerShopData>().GetSKUs();
|
||||
}
|
||||
protected virtual void OnClose()
|
||||
{
|
||||
UIManager.Instance.DestroyUI(UITypes.BindAccountPopupPanel);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user