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 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().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().AcceptFriend(FriendHelper.Accept_Type_Accept, // GContext.container.Resolve().UserId, m_Data.FriendInfo.PlayFabId); // if (!string.IsNullOrEmpty(json)) // { // AcceptFriendResp acceptFriendResp = Newtonsoft.Json.JsonConvert.DeserializeObject(json); // if (acceptFriendResp != null) // { //#if AGG // using (var e = GEvent.GameEvent("friend_request")) // { // e.AddContent("playfabid", GContext.container.Resolve().UserId) // .AddContent("friendplayfabid", m_Data.FriendInfo.PlayFabId) // .AddContent("code", acceptFriendResp.Code) // .AddContent("friendcode", GContext.container.Resolve().GetInvitationCodeByPlayFabID(GContext.container.Resolve().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().AcceptFriend(FriendHelper.Accept_Type_Ignore, // GContext.container.Resolve().UserId, m_Data.FriendInfo.PlayFabId); // if (!string.IsNullOrEmpty(json)) // { // AcceptFriendResp acceptFriendResp = Newtonsoft.Json.JsonConvert.DeserializeObject(json); // if (acceptFriendResp != null) // { //#if AGG // using (var e = GEvent.GameEvent("friend_request")) // { // e.AddContent("playfabid", GContext.container.Resolve().UserId) // .AddContent("friendplayfabid", m_Data.FriendInfo.PlayFabId) // .AddContent("code", acceptFriendResp.Code) // .AddContent("friendcode", GContext.container.Resolve().GetInvitationCodeByPlayFabID(GContext.container.Resolve().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(); originalScale = rectTransform.localScale; text_name = transform.Find("text_name").GetComponent(); btn_head = transform.Find("btn_head").GetComponent(); text_num = transform.Find("icon_rank/icon/text_num").GetComponent(); btn_accept = transform.Find("btn_accept/btn_green_c").GetComponent