备份CatanBuilding瘦身独立工程
This commit is contained in:
273
Assets/Scripts/UI/Social/Friend/FriendInvitedItem.cs
Normal file
273
Assets/Scripts/UI/Social/Friend/FriendInvitedItem.cs
Normal file
@@ -0,0 +1,273 @@
|
||||
using asap.core;
|
||||
using GameCore;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Events;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace game
|
||||
{
|
||||
public class FriendInvitedItem : FriendAddItem
|
||||
{
|
||||
TMP_Text text_name;
|
||||
Head btn_head;
|
||||
TMP_Text text_num;
|
||||
Button btn_accept;
|
||||
//GameObject accept_icon_loading;
|
||||
//GameObject accept_p_text;
|
||||
Button btn_ignore;
|
||||
//GameObject ignore_icon_loading;
|
||||
//GameObject ignore_p_text;
|
||||
|
||||
#region 数据相关
|
||||
public override void SetData(FishingFriendAddPanel panel, FriendAddItemData data, UnityAction<FriendAddItemData> callback)
|
||||
{
|
||||
m_Panel = panel;
|
||||
if (data == null || data.FriendInfo == null) return;
|
||||
BFriendInfo bFriendInfo = data.FriendInfo;
|
||||
|
||||
base.SetData(panel, data, callback);
|
||||
|
||||
InitUI();
|
||||
|
||||
ResumeScale();
|
||||
|
||||
EnableBtn();
|
||||
|
||||
if (string.IsNullOrEmpty(bFriendInfo.DisplayName))
|
||||
{
|
||||
bFriendInfo.DisplayName = GContext.container.Resolve<game.IUserService>().GetDefaultName(bFriendInfo.PlayFabId);
|
||||
}
|
||||
|
||||
text_name.text = bFriendInfo.DisplayName;
|
||||
|
||||
btn_head.SetData(bFriendInfo.AvatarUrl);
|
||||
text_num.text = "" + bFriendInfo.Level;
|
||||
|
||||
m_IsAccepting = false;
|
||||
m_IsIgnoring = false;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region UI
|
||||
bool m_IsAccepting = false;
|
||||
private void OnBtnAcceptClick()
|
||||
{
|
||||
if (m_Data == null) return;
|
||||
|
||||
DisableBtn();
|
||||
LockScrollView();
|
||||
|
||||
StartScalingAnimation(() =>
|
||||
{
|
||||
if (m_Panel != null)
|
||||
{
|
||||
m_Panel.StartInvitedAccept(m_Data);
|
||||
}
|
||||
EnableBtn();
|
||||
});
|
||||
|
||||
// if (m_IsAccepting == true) return;
|
||||
|
||||
// m_IsAccepting = true;
|
||||
// if (accept_p_text != null)
|
||||
// {
|
||||
// accept_p_text.SetActive(false);
|
||||
// }
|
||||
// if (accept_icon_loading != null)
|
||||
// {
|
||||
// accept_icon_loading.SetActive(true);
|
||||
// }
|
||||
// string json = await GContext.container.Resolve<FriendService>().AcceptFriend(FriendHelper.Accept_Type_Accept,
|
||||
// GContext.container.Resolve<IUserService>().UserId, m_Data.FriendInfo.PlayFabId);
|
||||
|
||||
// if (!string.IsNullOrEmpty(json))
|
||||
// {
|
||||
// AcceptFriendResp acceptFriendResp = Newtonsoft.Json.JsonConvert.DeserializeObject<AcceptFriendResp>(json);
|
||||
// if (acceptFriendResp != null)
|
||||
// {
|
||||
//#if AGG
|
||||
// using (var e = GEvent.GameEvent("friend_request"))
|
||||
// {
|
||||
// e.AddContent("playfabid", GContext.container.Resolve<IUserService>().UserId)
|
||||
// .AddContent("friendplayfabid", m_Data.FriendInfo.PlayFabId)
|
||||
// .AddContent("code", acceptFriendResp.Code)
|
||||
// .AddContent("friendcode", GContext.container.Resolve<FriendService>().GetInvitationCodeByPlayFabID(GContext.container.Resolve<IUserService>().UserId));
|
||||
// }
|
||||
//#endif
|
||||
|
||||
// switch (acceptFriendResp.Code)
|
||||
// {
|
||||
// case FriendHelper.Code_OK:
|
||||
// case FriendHelper.Code_AddFriend_HaveAddedBefore_OK:
|
||||
// ToastPanel.Show(LocalizationMgr.GetText("UI_ToastPanel_95"));
|
||||
// GContext.Publish(new ResetWaitTime() { waitTime = 10f });
|
||||
// if (Callback != null)
|
||||
// {
|
||||
// Callback(m_Data);
|
||||
// }
|
||||
// break;
|
||||
// case FriendHelper.Code_AddFriend_FriendHaveNoLimit:
|
||||
// ToastPanel.Show(LocalizationMgr.GetText("UI_ToastPanel_91"));
|
||||
// break;
|
||||
// case FriendHelper.Code_AddFriend_IHaveNoLimit:
|
||||
// ToastPanel.Show(LocalizationMgr.GetText("UI_ToastPanel_92"));
|
||||
// break;
|
||||
// case FriendHelper.Code_AddFriend_GetFriendList_Failed_PlayFabError:
|
||||
// case FriendHelper.Code_AcceptFriend_IAddFriend_Failed_PlayFabError:
|
||||
// case FriendHelper.Code_AcceptFriend_FriendAddMe_Failed_PlayFabError:
|
||||
// ToastPanel.Show(LocalizationMgr.GetText("UI_ToastPanel_93"));
|
||||
// break;
|
||||
// default:
|
||||
// ToastPanel.Show(LocalizationMgr.GetText("UI_ToastPanel_93"));
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
// if (accept_icon_loading != null)
|
||||
// {
|
||||
// accept_icon_loading.SetActive(false);
|
||||
// }
|
||||
// if (accept_p_text != null)
|
||||
// {
|
||||
// accept_p_text.SetActive(true);
|
||||
// }
|
||||
// m_IsAccepting = false;
|
||||
}
|
||||
|
||||
bool m_IsIgnoring = false;
|
||||
private void OnBtnIgnoreClick()
|
||||
{
|
||||
if (m_Data == null) return;
|
||||
|
||||
DisableBtn();
|
||||
LockScrollView();
|
||||
|
||||
StartScalingAnimation(() =>
|
||||
{
|
||||
if (m_Panel != null)
|
||||
{
|
||||
m_Panel.StartInvitedIgnore(m_Data);
|
||||
}
|
||||
EnableBtn();
|
||||
});
|
||||
|
||||
// if (m_IsIgnoring == true) return;
|
||||
|
||||
// m_IsIgnoring = true;
|
||||
// if (ignore_p_text != null)
|
||||
// {
|
||||
// ignore_p_text.SetActive(false);
|
||||
// }
|
||||
// if (ignore_icon_loading != null)
|
||||
// {
|
||||
// ignore_icon_loading.SetActive(true);
|
||||
// }
|
||||
// string json = await GContext.container.Resolve<FriendService>().AcceptFriend(FriendHelper.Accept_Type_Ignore,
|
||||
// GContext.container.Resolve<IUserService>().UserId, m_Data.FriendInfo.PlayFabId);
|
||||
|
||||
// if (!string.IsNullOrEmpty(json))
|
||||
// {
|
||||
// AcceptFriendResp acceptFriendResp = Newtonsoft.Json.JsonConvert.DeserializeObject<AcceptFriendResp>(json);
|
||||
// if (acceptFriendResp != null)
|
||||
// {
|
||||
//#if AGG
|
||||
// using (var e = GEvent.GameEvent("friend_request"))
|
||||
// {
|
||||
// e.AddContent("playfabid", GContext.container.Resolve<IUserService>().UserId)
|
||||
// .AddContent("friendplayfabid", m_Data.FriendInfo.PlayFabId)
|
||||
// .AddContent("code", acceptFriendResp.Code)
|
||||
// .AddContent("friendcode", GContext.container.Resolve<FriendService>().GetInvitationCodeByPlayFabID(GContext.container.Resolve<IUserService>().UserId));
|
||||
// }
|
||||
//#endif
|
||||
|
||||
// switch (acceptFriendResp.Code)
|
||||
// {
|
||||
// case FriendHelper.Code_OK:
|
||||
// case FriendHelper.Code_AcceptFriend_Ignore_OK:
|
||||
// //ToastPanel.Show(LocalizationMgr.GetText("UI_ToastPanel_90"));
|
||||
// if (Callback != null)
|
||||
// {
|
||||
// Callback(m_Data);
|
||||
// }
|
||||
// break;
|
||||
// case FriendHelper.Code_AddFriend_FriendHaveNoLimit:
|
||||
// ToastPanel.Show(LocalizationMgr.GetText("UI_ToastPanel_91"));
|
||||
// break;
|
||||
// case FriendHelper.Code_AddFriend_IHaveNoLimit:
|
||||
// ToastPanel.Show(LocalizationMgr.GetText("UI_ToastPanel_92"));
|
||||
// break;
|
||||
// case FriendHelper.Code_AddFriend_GetFriendList_Failed_PlayFabError:
|
||||
// case FriendHelper.Code_AcceptFriend_IAddFriend_Failed_PlayFabError:
|
||||
// case FriendHelper.Code_AcceptFriend_FriendAddMe_Failed_PlayFabError:
|
||||
// ToastPanel.Show(LocalizationMgr.GetText("UI_ToastPanel_93"));
|
||||
// break;
|
||||
// default:
|
||||
// ToastPanel.Show(LocalizationMgr.GetText("UI_ToastPanel_93"));
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
// if (ignore_icon_loading != null)
|
||||
// {
|
||||
// ignore_icon_loading.SetActive(false);
|
||||
// }
|
||||
// if (ignore_p_text != null)
|
||||
// {
|
||||
// ignore_p_text.SetActive(true);
|
||||
// }
|
||||
// m_IsIgnoring = false;
|
||||
}
|
||||
|
||||
bool m_IsInit = false;
|
||||
private void InitUI()
|
||||
{
|
||||
if (m_IsInit == true) return;
|
||||
|
||||
RectTransform rectTransform = transform.GetComponent<RectTransform>();
|
||||
originalScale = rectTransform.localScale;
|
||||
|
||||
text_name = transform.Find("text_name").GetComponent<TMP_Text>();
|
||||
btn_head = transform.Find("btn_head").GetComponent<Head>();
|
||||
text_num = transform.Find("icon_rank/icon/text_num").GetComponent<TMP_Text>();
|
||||
btn_accept = transform.Find("btn_accept/btn_green_c").GetComponent<Button>();
|
||||
//accept_icon_loading = transform.Find("btn_accept/btn_green_c/Ani_Container/icon_loading").gameObject;
|
||||
//accept_p_text = transform.Find("btn_accept/btn_green_c/Ani_Container/p_text").gameObject;
|
||||
btn_ignore = transform.Find("btn_ignore/btn_green_c").GetComponent<Button>();
|
||||
//ignore_icon_loading = transform.Find("btn_ignore/btn_green_c/Ani_Container/icon_loading").gameObject;
|
||||
//ignore_p_text = transform.Find("btn_ignore/btn_green_c/Ani_Container/p_text").gameObject;
|
||||
|
||||
btn_accept.onClick.AddListener(OnBtnAcceptClick);
|
||||
btn_ignore.onClick.AddListener(OnBtnIgnoreClick);
|
||||
|
||||
m_IsInit = true;
|
||||
}
|
||||
private void DisableBtn()
|
||||
{
|
||||
if (btn_accept != null)
|
||||
{
|
||||
btn_accept.enabled = false;
|
||||
}
|
||||
if (btn_ignore != null)
|
||||
{
|
||||
btn_ignore.enabled = false;
|
||||
}
|
||||
}
|
||||
private void EnableBtn()
|
||||
{
|
||||
if (btn_accept != null)
|
||||
{
|
||||
btn_accept.enabled = true;
|
||||
}
|
||||
if (btn_ignore != null)
|
||||
{
|
||||
btn_ignore.enabled = true;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user