215 lines
8.0 KiB
C#
215 lines
8.0 KiB
C#
using System;
|
|
using System.Threading.Tasks;
|
|
using asap.core;
|
|
using cfg;
|
|
using game;
|
|
using GameCore;
|
|
using TMPro;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
public class BindAccountPopupPanel : MonoBehaviour
|
|
{
|
|
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()
|
|
{
|
|
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;
|
|
|
|
// tysdk removed - account link status unavailable, buttons default to interactable
|
|
// 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()
|
|
{
|
|
// OnLinkSns removed with SDK
|
|
}
|
|
|
|
async void OnBtnFacebook()
|
|
{
|
|
// OnLinkSns removed with SDK
|
|
}
|
|
|
|
async void OnBtnApple()
|
|
{
|
|
// OnLinkSns removed with SDK
|
|
}
|
|
|
|
async void OnBtnVK()
|
|
{
|
|
// OnLinkSns removed with SDK
|
|
}
|
|
|
|
// async Task<bool> OnLinkSns(EAccoutType accountType)
|
|
// {
|
|
// try
|
|
// {
|
|
// UIManager.ShowWaitingBlock("BindAccountPopupPanel::OnlinkSns");
|
|
// var (code, userid) = await userService.LinkAccount(accountType);
|
|
//
|
|
// if (code == 0)
|
|
// {
|
|
// PlayFabMgr.Instance.UpdateUserDataValue(accountType.ToString(), "1");
|
|
// 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 (!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);
|
|
// 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);
|
|
}
|
|
}
|