备份CatanBuilding瘦身独立工程
This commit is contained in:
126
Assets/Scripts/UI/Social/Friend/FishingSocialFriendAddPanel.cs
Normal file
126
Assets/Scripts/UI/Social/Friend/FishingSocialFriendAddPanel.cs
Normal file
@@ -0,0 +1,126 @@
|
||||
using asap.core;
|
||||
using game;
|
||||
using GameCore;
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class FishingSocialFriendAddPanel : MonoBehaviour
|
||||
{
|
||||
BFriendInfo m_FriendInfo;
|
||||
|
||||
Button btn_close;
|
||||
TMP_Text text_name;
|
||||
Head btn_head;
|
||||
TMP_Text text_num;
|
||||
|
||||
GameObject btn_add_root;
|
||||
Button btn_add;
|
||||
GameObject btn_add_gray_root;
|
||||
Button btn_add_gray;
|
||||
GameObject btn_confirm_root;
|
||||
Button btn_confirm;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
btn_add_root = transform.Find("root/btn_add").gameObject;
|
||||
btn_add_gray_root = transform.Find("root/btn_requested").gameObject;
|
||||
btn_confirm_root = transform.Find("root/btn_confirm").gameObject;
|
||||
|
||||
btn_add = transform.Find("root/btn_add/btn_green").GetComponent<Button>();
|
||||
btn_add_gray = transform.Find("root/btn_requested/btn_green").GetComponent<Button>();
|
||||
btn_confirm = transform.Find("root/btn_confirm/btn_green").GetComponent<Button>();
|
||||
|
||||
btn_close = transform.Find("btn_close").GetComponent<Button>();
|
||||
text_name = transform.Find("root/bg_name/text_name").GetComponent<TMP_Text>();
|
||||
text_num = transform.Find("root/player_info/icon_grade/text_num").GetComponent<TMP_Text>();
|
||||
btn_head = transform.Find("root/btn_head").GetComponent<Head>();
|
||||
}
|
||||
private void Start()
|
||||
{
|
||||
btn_add_gray.onClick.AddListener(OnBtnAddGrayClickListener);
|
||||
btn_add.onClick.AddListener(OnBtnAddClickListener);
|
||||
btn_close.onClick.AddListener(HideUI);
|
||||
btn_confirm.onClick.AddListener(HideUI);
|
||||
}
|
||||
|
||||
private void OnBtnAddGrayClickListener()
|
||||
{
|
||||
ToastPanel.Show(LocalizationMgr.GetText("UI_ToastPanel_98"));
|
||||
UIManager.Instance.DestroyUI(UITypes.SocialClubPlayerTips);
|
||||
}
|
||||
|
||||
private void OnBtnAddClickListener()
|
||||
{
|
||||
if (m_FriendInfo == null) return;
|
||||
|
||||
btn_add_root.SetActive(false);
|
||||
btn_add_gray_root.SetActive(true);
|
||||
|
||||
GContext.container.Resolve<FriendService>().StartInvite(m_FriendInfo.PlayFabId);
|
||||
|
||||
gameObject.SetActive(false);
|
||||
}
|
||||
|
||||
public async Task SetBFriendInfo(BFriendInfo bFriendInfo)
|
||||
{
|
||||
m_FriendInfo = bFriendInfo;
|
||||
text_name.text = bFriendInfo.DisplayName;
|
||||
|
||||
btn_head.SetData(bFriendInfo.AvatarUrl);
|
||||
text_num.text = "" + bFriendInfo.Level;
|
||||
btn_add_root.SetActive(false);
|
||||
btn_add_gray_root.SetActive(false);
|
||||
btn_confirm_root.SetActive(false);
|
||||
bool isFriend = GContext.container.Resolve<FriendService>().IsFriend(m_FriendInfo.PlayFabId);
|
||||
if (isFriend)
|
||||
{
|
||||
btn_confirm_root.SetActive(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
await IsFriendWaitingForAccept();
|
||||
}
|
||||
}
|
||||
|
||||
private async Task IsFriendWaitingForAccept()
|
||||
{
|
||||
try
|
||||
{
|
||||
string json = await GContext.container.Resolve<FriendService>().IsFriendWaitingForAccept(GContext.container.Resolve<IUserService>().UserId, m_FriendInfo.PlayFabId);
|
||||
|
||||
if (string.IsNullOrEmpty(json))
|
||||
return;
|
||||
|
||||
IsFriendWaitingForAcceptResp resp = Newtonsoft.Json.JsonConvert.DeserializeObject<IsFriendWaitingForAcceptResp>(json);
|
||||
if (resp == null)
|
||||
return;
|
||||
|
||||
if (resp.Code > 0)
|
||||
{
|
||||
btn_add_root.SetActive(false);
|
||||
btn_add_gray_root.SetActive(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
btn_add_root.SetActive(true);
|
||||
btn_add_gray_root.SetActive(false);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
string msg = "[SocialClubPlayerTips] IsFriendWaitingForAccept encountered a fatal problem.";
|
||||
Debug.LogError($"{msg}-{ex.Message} \r\n {ex.StackTrace}");
|
||||
|
||||
btn_add_root.SetActive(false);
|
||||
btn_add_gray_root.SetActive(false);
|
||||
}
|
||||
}
|
||||
|
||||
void HideUI()
|
||||
{
|
||||
gameObject.SetActive(false);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user