备份CatanBuilding瘦身独立工程
This commit is contained in:
711
Assets/Scripts/UI/Social/Friend/FishingFriendAddPanel.cs
Normal file
711
Assets/Scripts/UI/Social/Friend/FishingFriendAddPanel.cs
Normal file
@@ -0,0 +1,711 @@
|
||||
using asap.core;
|
||||
using cfg;
|
||||
using EnhancedUI.EnhancedScroller;
|
||||
using GameCore;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using UnityNative.Sharing;
|
||||
|
||||
namespace game
|
||||
{
|
||||
public class FishingFriendAddPanel : BasePanel, IEnhancedScrollerDelegate
|
||||
{
|
||||
|
||||
#region 分享
|
||||
Button btn_invite;
|
||||
GameObject icon_gift_invite;
|
||||
#endregion
|
||||
GameObject empty;
|
||||
GameObject loading;
|
||||
Button btn_add;
|
||||
// 好友码相关
|
||||
TMP_Text text_code;
|
||||
Button btn_copy;
|
||||
Button btn_share;
|
||||
// ScrollView相关
|
||||
EnhancedScroller scroller;
|
||||
public FriendInvitedItemTitleBar invitedItemTitleBar;
|
||||
public FriendInvitedItem invitedItem;
|
||||
public FriendRecommendedItemTitleBar recommendedItemTitleBar;
|
||||
public FriendRecommendedItem recommendedItem;
|
||||
|
||||
List<FriendAddItemData> m_DataList = new List<FriendAddItemData>();
|
||||
List<FriendAddItemData> m_InvitedDataList = new List<FriendAddItemData>();
|
||||
FriendRecommendedListData m_RecommendedListData;
|
||||
|
||||
int m_PageNo = 0;
|
||||
|
||||
#region 后台网络处理
|
||||
private List<FriendAddPanelBackendOperation> m_BackendOperationList = new List<FriendAddPanelBackendOperation>();
|
||||
|
||||
#endregion
|
||||
|
||||
private IUnityNativeSharing adapter;
|
||||
|
||||
#region 主页处理 / 空白搜索处理
|
||||
private async Task InitDefault()
|
||||
{
|
||||
m_DataList.Clear();
|
||||
m_InvitedDataList.Clear();
|
||||
if (m_RecommendedListData != null && m_RecommendedListData.RecommendedList != null)
|
||||
{
|
||||
m_RecommendedListData.RecommendedList.Clear();
|
||||
}
|
||||
if (IsExpire())
|
||||
{
|
||||
// 获取HomePage数据
|
||||
string json = await GContext.container.Resolve<FriendService>().GetHomePage(GContext.container.Resolve<IUserService>().UserId, m_PageNo);
|
||||
bool flag = true;
|
||||
if (string.IsNullOrEmpty(json))
|
||||
{
|
||||
flag = false;
|
||||
}
|
||||
GetHomePageResp getHomePageResp = null;
|
||||
if (flag == true)
|
||||
{
|
||||
try
|
||||
{
|
||||
getHomePageResp = Newtonsoft.Json.JsonConvert.DeserializeObject<GetHomePageResp>(json);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
GameDebug.LogError("FishingFriendAddPanel deserialize [GetHomePageResp] data has failed. Exception: " + ex.ToString());
|
||||
flag = false;
|
||||
}
|
||||
}
|
||||
|
||||
m_DataList.Clear();
|
||||
if (flag == false)
|
||||
{
|
||||
scroller.gameObject.SetActive(false);
|
||||
empty.SetActive(true);
|
||||
return;
|
||||
}
|
||||
|
||||
if (getHomePageResp.Code > 0)
|
||||
{
|
||||
List<BFriendInfo> list = new List<BFriendInfo>();
|
||||
if (getHomePageResp.Friends != null)
|
||||
{
|
||||
foreach (var item in getHomePageResp.Friends)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(item))
|
||||
{
|
||||
BFriendInfo info = Newtonsoft.Json.JsonConvert.DeserializeObject<BFriendInfo>(item);
|
||||
FriendHelper.FixBFriendInfoData(info);
|
||||
list.Add(info);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (list.Count > 0)
|
||||
{
|
||||
// InvitedItem TitleBar Data
|
||||
var invitedTitleBarData = new FriendAddItemData()
|
||||
{
|
||||
Type = FriendHelper.Friend_Add_Item_Type_Invited_TitleBar,
|
||||
FriendInfo = null,
|
||||
Extra = 0
|
||||
};
|
||||
m_InvitedDataList.Add(invitedTitleBarData);
|
||||
m_DataList.Add(invitedTitleBarData);
|
||||
|
||||
// InvitedItem Data
|
||||
foreach (var item in list)
|
||||
{
|
||||
var invitedItemData = new FriendAddItemData()
|
||||
{
|
||||
Type = FriendHelper.Friend_Add_Item_Type_Invited_Item,
|
||||
FriendInfo = item,
|
||||
Extra = 0
|
||||
};
|
||||
m_DataList.Add(invitedItemData);
|
||||
m_InvitedDataList.Add(invitedItemData);
|
||||
}
|
||||
}
|
||||
|
||||
if (getHomePageResp.RecommendedList != null && getHomePageResp.RecommendedList.Length > 0)
|
||||
{
|
||||
if (m_RecommendedListData != null && m_RecommendedListData.RecommendedList != null)
|
||||
{
|
||||
m_RecommendedListData.RecommendedList.Clear();
|
||||
}
|
||||
m_RecommendedListData = new FriendRecommendedListData();
|
||||
m_RecommendedListData.RecommendedList = new List<FriendAddItemData>();
|
||||
m_RecommendedListData.ExpirationDate = DateTime.Now.AddDays(3);
|
||||
|
||||
// RecommendedItem TitleBar Data
|
||||
var recommendedTitleBarData = new FriendAddItemData()
|
||||
{
|
||||
Type = FriendHelper.Friend_Add_Item_Type_Recommended_TitleBar,
|
||||
FriendInfo = null,
|
||||
Extra = 0
|
||||
};
|
||||
m_RecommendedListData.RecommendedList.Add(recommendedTitleBarData);
|
||||
m_DataList.Add(recommendedTitleBarData);
|
||||
|
||||
// RecommendedItem Data
|
||||
foreach (var item in getHomePageResp.RecommendedList)
|
||||
{
|
||||
var recommendedItemData = new FriendAddItemData()
|
||||
{
|
||||
Type = FriendHelper.Friend_Add_Item_Type_Recommended_Item,
|
||||
FriendInfo = item,
|
||||
Extra = 0
|
||||
};
|
||||
m_RecommendedListData.RecommendedList.Add(recommendedItemData);
|
||||
m_DataList.Add(recommendedItemData);
|
||||
}
|
||||
SyncRecommendedListData();
|
||||
}
|
||||
}
|
||||
if (m_DataList.Count > 0)
|
||||
{
|
||||
scroller.gameObject.SetActive(true);
|
||||
empty.SetActive(false);
|
||||
scroller.ReloadData();
|
||||
}
|
||||
else
|
||||
{
|
||||
scroller.gameObject.SetActive(false);
|
||||
empty.SetActive(true);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// 获取邀请列表数据,再合并推荐列表数据
|
||||
string json = await GContext.container.Resolve<FriendService>().GetInvitedList();
|
||||
bool flag = true;
|
||||
if (string.IsNullOrEmpty(json))
|
||||
{
|
||||
flag = false;
|
||||
|
||||
}
|
||||
GetInvitedListResp getInvitedListResp = null;
|
||||
if (flag == true)
|
||||
{
|
||||
try
|
||||
{
|
||||
getInvitedListResp = Newtonsoft.Json.JsonConvert.DeserializeObject<GetInvitedListResp>(json);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
GameDebug.LogError("FishingFriendAddPanel deserialize [GetInvitedListResp] data has failed. Exception: " + ex.ToString());
|
||||
flag = false;
|
||||
}
|
||||
}
|
||||
|
||||
m_DataList.Clear();
|
||||
if (flag == false)
|
||||
{
|
||||
scroller.gameObject.SetActive(false);
|
||||
empty.SetActive(true);
|
||||
return;
|
||||
}
|
||||
|
||||
if (getInvitedListResp.Code > 0)
|
||||
{
|
||||
List<BFriendInfo> list = new List<BFriendInfo>();
|
||||
if (getInvitedListResp.Friends != null)
|
||||
{
|
||||
foreach (var item in getInvitedListResp.Friends)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(item))
|
||||
{
|
||||
BFriendInfo info = Newtonsoft.Json.JsonConvert.DeserializeObject<BFriendInfo>(item);
|
||||
FriendHelper.FixBFriendInfoData(info);
|
||||
list.Add(info);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (list.Count > 0)
|
||||
{
|
||||
// InvitedItem TitleBar Data
|
||||
var invitedTitleBarData = new FriendAddItemData()
|
||||
{
|
||||
Type = FriendHelper.Friend_Add_Item_Type_Invited_TitleBar,
|
||||
FriendInfo = null,
|
||||
Extra = 0
|
||||
};
|
||||
m_InvitedDataList.Add(invitedTitleBarData);
|
||||
m_DataList.Add(invitedTitleBarData);
|
||||
|
||||
// InvitedItem Data
|
||||
foreach (var item in list)
|
||||
{
|
||||
var invitedItemData = new FriendAddItemData()
|
||||
{
|
||||
Type = FriendHelper.Friend_Add_Item_Type_Invited_Item,
|
||||
FriendInfo = item,
|
||||
Extra = 0
|
||||
};
|
||||
m_InvitedDataList.Add(invitedItemData);
|
||||
m_DataList.Add(invitedItemData);
|
||||
}
|
||||
}
|
||||
if (m_RecommendedListData != null && m_RecommendedListData.RecommendedList != null)
|
||||
{
|
||||
m_DataList.AddRange(m_RecommendedListData.RecommendedList.ToArray());
|
||||
}
|
||||
}
|
||||
if (m_DataList.Count > 0)
|
||||
{
|
||||
scroller.gameObject.SetActive(true);
|
||||
scroller.ReloadData();
|
||||
empty.SetActive(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
scroller.gameObject.SetActive(false);
|
||||
empty.SetActive(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsExpire()
|
||||
{
|
||||
if (PlayerPrefs.HasKey(FriendHelper.FriendRecommendedListDataKey) == false) return true;
|
||||
string data = PlayerPrefs.GetString(FriendHelper.FriendRecommendedListDataKey);
|
||||
if (string.IsNullOrEmpty(data)) return true;
|
||||
|
||||
m_RecommendedListData = Newtonsoft.Json.JsonConvert.DeserializeObject<FriendRecommendedListData>(data);
|
||||
if (m_RecommendedListData == null) return true;
|
||||
|
||||
if (DateTime.Now < m_RecommendedListData.ExpirationDate) return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public void SyncRecommendedListData()
|
||||
{
|
||||
lock (m_RecommendedListData)
|
||||
{
|
||||
if (m_RecommendedListData == null)
|
||||
{
|
||||
if (PlayerPrefs.HasKey(FriendHelper.FriendRecommendedListDataKey))
|
||||
{
|
||||
PlayerPrefs.DeleteKey(FriendHelper.FriendRecommendedListDataKey);
|
||||
}
|
||||
return;
|
||||
}
|
||||
PlayerPrefs.SetString(FriendHelper.FriendRecommendedListDataKey, Newtonsoft.Json.JsonConvert.SerializeObject(m_RecommendedListData));
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 数据相关
|
||||
List<FriendAddPanelBackendOperation> m_RecommendedBackendOperationList = new List<FriendAddPanelBackendOperation>();
|
||||
public void StartRecommendedInvite(FriendAddItemData data)
|
||||
{
|
||||
var backendOperation = new FriendAddPanelBackendOperation();
|
||||
|
||||
m_RecommendedBackendOperationList.Add(backendOperation);
|
||||
|
||||
backendOperation.StartRecommendedInvite(this, data, ResumeRecommendedData);
|
||||
|
||||
RemoveRecommendedData(data);
|
||||
}
|
||||
public void ResumeRecommendedData(FriendAddItemData data)
|
||||
{
|
||||
if (data == null) return;
|
||||
if (m_RecommendedBackendOperationList == null || m_RecommendedBackendOperationList.Count < 1) return;
|
||||
|
||||
bool flag = false;
|
||||
int count = m_RecommendedBackendOperationList.Count;
|
||||
for (int i = count - 1; i >= 0; --i)
|
||||
{
|
||||
var item = m_RecommendedBackendOperationList[i];
|
||||
if (item != null && item.Data != null && item.Data.EqualsPlayFabId(data))
|
||||
{
|
||||
flag = true;
|
||||
m_RecommendedBackendOperationList.RemoveAt(i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!flag) return;
|
||||
|
||||
if (m_RecommendedListData == null || m_RecommendedListData.RecommendedList == null) return;
|
||||
|
||||
m_RecommendedListData.RecommendedList.Add(data);
|
||||
|
||||
CombineData();
|
||||
|
||||
RedPointManager.Instance.SetRedPointState(RedPointName.Home_Friend_Add, m_InvitedDataList.Count > 0);
|
||||
}
|
||||
public void RemoveRecommendedData(FriendAddItemData data)
|
||||
{
|
||||
if (m_RecommendedListData == null || m_RecommendedListData.RecommendedList == null) return;
|
||||
|
||||
lock (m_RecommendedListData.RecommendedList)
|
||||
{
|
||||
for (int i = m_InvitedDataList.Count - 1; i >= 0; --i)
|
||||
{
|
||||
var tmpData = m_InvitedDataList[i];
|
||||
if (tmpData.EqualsPlayFabId(data))
|
||||
{
|
||||
m_InvitedDataList.RemoveAt(i);
|
||||
}
|
||||
}
|
||||
for (int i = m_RecommendedListData.RecommendedList.Count - 1; i >= 0; --i)
|
||||
{
|
||||
var tmpData = m_RecommendedListData.RecommendedList[i];
|
||||
if (tmpData.EqualsPlayFabId(data))
|
||||
{
|
||||
m_RecommendedListData.RecommendedList.RemoveAt(i);
|
||||
}
|
||||
}
|
||||
|
||||
if (m_InvitedDataList.Count <= 1)
|
||||
{
|
||||
for (int i = m_InvitedDataList.Count - 1; i >= 0; --i)
|
||||
{
|
||||
var tmpData = m_InvitedDataList[i];
|
||||
if (tmpData.Type == FriendHelper.Friend_Add_Item_Type_Invited_TitleBar)
|
||||
{
|
||||
m_InvitedDataList.RemoveAt(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (m_RecommendedListData.RecommendedList.Count <= 1)
|
||||
{
|
||||
for (int i = m_RecommendedListData.RecommendedList.Count - 1; i >= 0; --i)
|
||||
{
|
||||
var tmpData = m_RecommendedListData.RecommendedList[i];
|
||||
if (tmpData.Type == FriendHelper.Friend_Add_Item_Type_Recommended_TitleBar)
|
||||
{
|
||||
m_RecommendedListData.RecommendedList.RemoveAt(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
SyncRecommendedListData();
|
||||
|
||||
CombineData();
|
||||
|
||||
RedPointManager.Instance.SetRedPointState(RedPointName.Home_Friend_Add, m_InvitedDataList.Count > 0);
|
||||
}
|
||||
|
||||
List<FriendAddPanelBackendOperation> m_InvitedBackendOperationList = new List<FriendAddPanelBackendOperation>();
|
||||
public void StartInvitedAccept(FriendAddItemData data)
|
||||
{
|
||||
var backendOperation = new FriendAddPanelBackendOperation();
|
||||
|
||||
m_InvitedBackendOperationList.Add(backendOperation);
|
||||
|
||||
backendOperation.StartInvitedAccept(this, data, ResumeInvitedData);
|
||||
|
||||
RemoveInvitedData(data);
|
||||
}
|
||||
public void StartInvitedIgnore(FriendAddItemData data)
|
||||
{
|
||||
var backendOperation = new FriendAddPanelBackendOperation();
|
||||
|
||||
m_RecommendedBackendOperationList.Add(backendOperation);
|
||||
|
||||
backendOperation.StartInvitedIgnore(this, data, ResumeInvitedData);
|
||||
|
||||
RemoveInvitedData(data);
|
||||
}
|
||||
public void ResumeInvitedData(FriendAddItemData data)
|
||||
{
|
||||
if (data == null) return;
|
||||
if (m_InvitedBackendOperationList == null || m_InvitedBackendOperationList.Count < 1) return;
|
||||
|
||||
bool flag = false;
|
||||
int count = m_InvitedBackendOperationList.Count;
|
||||
for (int i = count - 1; i >= 0; --i)
|
||||
{
|
||||
var item = m_InvitedBackendOperationList[i];
|
||||
if (item != null && item.Data != null && item.Data.EqualsPlayFabId(data))
|
||||
{
|
||||
flag = true;
|
||||
m_InvitedBackendOperationList.RemoveAt(i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!flag) return;
|
||||
|
||||
if (m_InvitedDataList == null) return;
|
||||
|
||||
m_InvitedDataList.Add(data);
|
||||
|
||||
CombineData();
|
||||
|
||||
RedPointManager.Instance.SetRedPointState(RedPointName.Home_Friend_Add, m_InvitedDataList.Count > 0);
|
||||
}
|
||||
public void RemoveInvitedData(FriendAddItemData data)
|
||||
{
|
||||
if (m_InvitedDataList == null) return;
|
||||
|
||||
lock (m_InvitedDataList)
|
||||
{
|
||||
for (int i = m_InvitedDataList.Count - 1; i >= 0; --i)
|
||||
{
|
||||
var tmpData = m_InvitedDataList[i];
|
||||
if (tmpData.EqualsPlayFabId(data))
|
||||
{
|
||||
m_InvitedDataList.RemoveAt(i);
|
||||
}
|
||||
}
|
||||
for (int i = m_RecommendedListData.RecommendedList.Count - 1; i >= 0; --i)
|
||||
{
|
||||
var tmpData = m_RecommendedListData.RecommendedList[i];
|
||||
if (tmpData.EqualsPlayFabId(data))
|
||||
{
|
||||
m_RecommendedListData.RecommendedList.RemoveAt(i);
|
||||
}
|
||||
}
|
||||
|
||||
if (m_InvitedDataList.Count <= 1)
|
||||
{
|
||||
m_InvitedDataList.Clear();
|
||||
}
|
||||
if (m_RecommendedListData.RecommendedList.Count <= 1)
|
||||
{
|
||||
m_RecommendedListData.RecommendedList.Clear();
|
||||
}
|
||||
}
|
||||
|
||||
CombineData();
|
||||
|
||||
GContext.container.Resolve<FriendService>().GetInvitedListCount();
|
||||
RedPointManager.Instance.SetRedPointState(RedPointName.Home_Friend_Add, m_InvitedDataList.Count > 0);
|
||||
}
|
||||
public void CombineData()
|
||||
{
|
||||
lock (m_DataList)
|
||||
{
|
||||
m_DataList.Clear();
|
||||
if (m_InvitedDataList != null && m_InvitedDataList.Count > 1)
|
||||
{
|
||||
m_DataList.AddRange(m_InvitedDataList.ToArray());
|
||||
}
|
||||
if (m_RecommendedListData != null && m_RecommendedListData.RecommendedList != null && m_RecommendedListData.RecommendedList.Count > 1)
|
||||
{
|
||||
m_DataList.AddRange(m_RecommendedListData.RecommendedList.ToArray());
|
||||
}
|
||||
}
|
||||
|
||||
if (m_DataList.Count > 0)
|
||||
{
|
||||
scroller.gameObject.SetActive(true);
|
||||
empty.SetActive(false);
|
||||
var position = scroller.ScrollPosition;
|
||||
scroller.ReloadData();
|
||||
scroller.ScrollPosition = position;
|
||||
}
|
||||
else
|
||||
{
|
||||
scroller.gameObject.SetActive(false);
|
||||
empty.SetActive(true);
|
||||
}
|
||||
}
|
||||
private void UpdateLockAction(float deltaTime)
|
||||
{
|
||||
if (m_LockScrollViewCumulativeTime > 0)
|
||||
{
|
||||
m_LockScrollViewCumulativeTime -= deltaTime;
|
||||
}
|
||||
if (m_LockScrollViewCumulativeTime < 0)
|
||||
{
|
||||
m_LockScrollViewCumulativeTime = 0f;
|
||||
UnlockScrollView();
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region UI相关
|
||||
|
||||
private void OnBtnCopyClick()
|
||||
{
|
||||
GUIUtility.systemCopyBuffer = text_code.text;
|
||||
ToastPanel.Show(LocalizationMgr.GetText("UI_ToastPanel_25"));
|
||||
}
|
||||
|
||||
void OnClickInviteLink()
|
||||
{
|
||||
if (adapter == null)
|
||||
{
|
||||
adapter = UnityNativeSharing.Create();
|
||||
}
|
||||
string invite = LocalizationMgr.GetFormatTextValue("UI_FishingSocialPanel_45", text_code.text);
|
||||
adapter.ShareText(invite);
|
||||
}
|
||||
private string GetInvitationCodeByPlayFabID()
|
||||
{
|
||||
return GContext.container.Resolve<FriendService>().GetInvitationCodeByPlayFabID(GContext.container.Resolve<IUserService>().UserId);
|
||||
}
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
#region EnhancedScroller Handlers
|
||||
private float m_LockScrollViewCumulativeTime = 0.0f;
|
||||
public void StartLockScrollView(float lockTime)
|
||||
{
|
||||
m_LockScrollViewCumulativeTime = lockTime;
|
||||
LockScrollView();
|
||||
}
|
||||
void LockScrollView()
|
||||
{
|
||||
if (scroller == null || scroller.ScrollRect == null) return;
|
||||
if (scroller.ScrollRect.vertical)
|
||||
{
|
||||
scroller.ScrollRect.vertical = false;
|
||||
}
|
||||
}
|
||||
|
||||
void UnlockScrollView()
|
||||
{
|
||||
if (scroller == null || scroller.ScrollRect == null) return;
|
||||
if (!scroller.ScrollRect.vertical)
|
||||
{
|
||||
scroller.ScrollRect.vertical = true;
|
||||
}
|
||||
}
|
||||
|
||||
public int GetNumberOfCells(EnhancedScroller scroller)
|
||||
{
|
||||
return m_DataList.Count;
|
||||
}
|
||||
|
||||
public float GetCellViewSize(EnhancedScroller scroller, int dataIndex)
|
||||
{
|
||||
if (m_DataList[dataIndex].Type == FriendHelper.Friend_Add_Item_Type_Invited_TitleBar)
|
||||
{
|
||||
return 72f;
|
||||
}
|
||||
else if (m_DataList[dataIndex].Type == FriendHelper.Friend_Add_Item_Type_Invited_Item)
|
||||
{
|
||||
return 150f;
|
||||
}
|
||||
else if (m_DataList[dataIndex].Type == FriendHelper.Friend_Add_Item_Type_Recommended_TitleBar)
|
||||
{
|
||||
return 72f;
|
||||
}
|
||||
return 150f;
|
||||
}
|
||||
|
||||
public EnhancedScrollerCellView GetCellView(EnhancedScroller scroller, int dataIndex, int cellIndex)
|
||||
{
|
||||
FriendAddItem cellView;
|
||||
|
||||
if (m_DataList[dataIndex].Type == FriendHelper.Friend_Add_Item_Type_Invited_TitleBar)
|
||||
{
|
||||
cellView = scroller.GetCellView(invitedItemTitleBar) as FriendInvitedItemTitleBar;
|
||||
cellView.name = "[Invited Title Bar]";
|
||||
cellView.SetData(this, m_DataList[dataIndex], RemoveInvitedData);
|
||||
}
|
||||
else if (m_DataList[dataIndex].Type == FriendHelper.Friend_Add_Item_Type_Invited_Item)
|
||||
{
|
||||
cellView = scroller.GetCellView(invitedItem) as FriendInvitedItem;
|
||||
cellView.name = "[Invited Item] " + cellIndex + "-" + dataIndex;
|
||||
cellView.SetData(this, m_DataList[dataIndex], RemoveInvitedData);
|
||||
}
|
||||
else if (m_DataList[dataIndex].Type == FriendHelper.Friend_Add_Item_Type_Recommended_TitleBar)
|
||||
{
|
||||
cellView = scroller.GetCellView(recommendedItemTitleBar) as FriendRecommendedItemTitleBar;
|
||||
cellView.name = "[Recommended Title Bar]";
|
||||
cellView.SetData(this, m_DataList[dataIndex], RemoveRecommendedData);
|
||||
}
|
||||
else
|
||||
{
|
||||
cellView = scroller.GetCellView(recommendedItem) as FriendRecommendedItem;
|
||||
cellView.name = "[Recommended Item] " + cellIndex + "-" + dataIndex;
|
||||
cellView.SetData(this, m_DataList[dataIndex], RemoveRecommendedData);
|
||||
}
|
||||
|
||||
return cellView;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 生命周期
|
||||
void Awake()
|
||||
{
|
||||
loading = transform.Find("loading").gameObject;
|
||||
empty = transform.Find("add").gameObject;
|
||||
empty.SetActive(false);
|
||||
btn_add = transform.Find("friendcode/btn_search").GetComponent<Button>();
|
||||
icon_gift_invite = transform.Find("btn_invite/btn_green/Ani_Container/p_text/icon").gameObject;
|
||||
btn_invite = transform.Find("btn_invite/btn_green").GetComponent<Button>();
|
||||
btn_invite.onClick.AddListener(OnInviteClick);
|
||||
|
||||
btn_add.onClick.AddListener(OnAddClick);
|
||||
btn_share = transform.Find("friendcode/btn_share").GetComponent<Button>();
|
||||
btn_share.onClick.AddListener(OnClickInviteLink);
|
||||
text_code = transform.Find("friendcode/text_code").GetComponent<TMP_Text>();
|
||||
btn_copy = transform.Find("friendcode/btn_copy").GetComponent<Button>();
|
||||
btn_copy.onClick.AddListener(OnBtnCopyClick);
|
||||
text_code.text = GetInvitationCodeByPlayFabID();
|
||||
|
||||
|
||||
scroller = transform.Find("list/ScrollView").GetComponent<EnhancedScroller>();
|
||||
scroller.Delegate = this;
|
||||
|
||||
m_RecommendedBackendOperationList.Clear();
|
||||
m_InvitedBackendOperationList.Clear();
|
||||
}
|
||||
|
||||
void ShowGiftIcon()
|
||||
{
|
||||
List<cfg.Invite> invites = GContext.container.Resolve<Tables>().TbInvite.DataList;
|
||||
//已经领取奖励的数量
|
||||
string receiveRewardCountStr = PlayFabMgr.Instance.GetLocalData(FriendService.InviteLinkRewardCountKey);
|
||||
if (receiveRewardCountStr != null)
|
||||
{
|
||||
int.TryParse(receiveRewardCountStr, out int InviteLinkRewardCount);
|
||||
icon_gift_invite.SetActive(InviteLinkRewardCount < invites.Count);
|
||||
}
|
||||
}
|
||||
|
||||
void OnInviteClick()
|
||||
{
|
||||
_ = UIManager.Instance.ShowUI(UITypes.FishingSocialInviteFriendsPopupPanel);
|
||||
}
|
||||
|
||||
async void OnAddClick()
|
||||
{
|
||||
await UIManager.Instance.ShowUI(UITypes.FishingSocialFriendSearchPanel);
|
||||
}
|
||||
async void OnEnable()
|
||||
{
|
||||
m_PageNo = 0;
|
||||
ShowGiftIcon();
|
||||
//if (scroller != null) scroller.gameObject.SetActive(false);
|
||||
if (empty != null) empty.SetActive(false);
|
||||
loading.SetActive(true);
|
||||
await InitDefault();
|
||||
|
||||
loading.SetActive(false);
|
||||
}
|
||||
private void Update()
|
||||
{
|
||||
UpdateLockAction(Time.deltaTime);
|
||||
}
|
||||
protected override void OnDestroy()
|
||||
{
|
||||
foreach (var item in m_RecommendedBackendOperationList)
|
||||
{
|
||||
item.Clear();
|
||||
}
|
||||
m_RecommendedBackendOperationList.Clear();
|
||||
|
||||
foreach (var item in m_InvitedBackendOperationList)
|
||||
{
|
||||
item.Clear();
|
||||
}
|
||||
m_InvitedBackendOperationList.Clear();
|
||||
|
||||
base.OnDestroy();
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6a7d84757b772e040a5ef262eb8c4ffe
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
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);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f3ef5efb1f4ec0a418dba6b3b95267fa
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,125 @@
|
||||
using asap.core;
|
||||
using game;
|
||||
using GameCore;
|
||||
using System;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class FishingSocialFriendSearchPanel : MonoBehaviour
|
||||
{
|
||||
Button btn_close;
|
||||
TMP_InputField InputField_name;
|
||||
Button btn_search;
|
||||
GameObject btn_searchgo;
|
||||
GameObject btn_search_graygo;
|
||||
|
||||
FishingSocialFriendAddPanel fishingSocialFriendAddPanel;
|
||||
private void Awake()
|
||||
{
|
||||
btn_close = transform.Find("btn_close").GetComponent<Button>();
|
||||
InputField_name = transform.Find("root/InputField_name").GetComponent<TMP_InputField>();
|
||||
InputField_name.onValueChanged.AddListener(OnInputFieldValueChanged);
|
||||
btn_search = transform.Find("root/btn_search/btn_green").GetComponent<Button>();
|
||||
//
|
||||
btn_searchgo = transform.Find("root/btn_search").gameObject;
|
||||
btn_search_graygo = transform.Find("root/btn_search_gray").gameObject;
|
||||
fishingSocialFriendAddPanel = transform.Find("FishingSocialFriendAddPanel").GetComponent<FishingSocialFriendAddPanel>();
|
||||
}
|
||||
void Start()
|
||||
{
|
||||
btn_close.onClick.AddListener(OnClickClose);
|
||||
btn_search.onClick.AddListener(OnBtnSearchClick);
|
||||
}
|
||||
|
||||
|
||||
private string GetPlayFabIDByInvitationCode(string invitationCode)
|
||||
{
|
||||
ulong code = GContext.container.Resolve<FriendService>().DecryptInvitationCodeToUlong(invitationCode);
|
||||
return code.ToString("X");
|
||||
}
|
||||
|
||||
bool m_IsSearching = false;
|
||||
private async void OnBtnSearchClick()
|
||||
{
|
||||
if (m_IsSearching == true) return;
|
||||
|
||||
string invitationCode = InputField_name.text;
|
||||
if (string.IsNullOrEmpty(invitationCode))
|
||||
{
|
||||
m_IsSearching = false;
|
||||
return;
|
||||
}
|
||||
|
||||
invitationCode = invitationCode.ToUpperInvariant();
|
||||
invitationCode = invitationCode.Replace("-", "");
|
||||
string playFabID = GetPlayFabIDByInvitationCode(invitationCode);
|
||||
if (playFabID == GContext.container.Resolve<IUserService>().UserId)
|
||||
{
|
||||
ToastPanel.Show(LocalizationMgr.GetText("UI_ToastPanel_100"));
|
||||
return;
|
||||
}
|
||||
m_IsSearching = true;
|
||||
btn_search_graygo.SetActive(true);
|
||||
btn_searchgo.SetActive(false);
|
||||
string json = await GContext.container.Resolve<FriendService>().SearchFriend(playFabID);
|
||||
|
||||
if (!string.IsNullOrEmpty(json))
|
||||
{
|
||||
try
|
||||
{
|
||||
SearchFriendResp searchFriendResp = Newtonsoft.Json.JsonConvert.DeserializeObject<SearchFriendResp>(json);
|
||||
if (searchFriendResp.Code > 0)
|
||||
{
|
||||
BFriendInfo FriendInfo = searchFriendResp.Info;
|
||||
fishingSocialFriendAddPanel.gameObject.SetActive(true);
|
||||
await fishingSocialFriendAddPanel.SetBFriendInfo(FriendInfo);
|
||||
}
|
||||
else
|
||||
{
|
||||
ToastPanel.Show(LocalizationMgr.GetText("UI_ToastPanel_101"));
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
GameDebug.LogError("FishingFriendAddPanel deserialize [SearchFriendResp] data has failed. Exception: " + ex.ToString());
|
||||
}
|
||||
}
|
||||
m_IsSearching = false;
|
||||
btn_search_graygo.SetActive(false);
|
||||
btn_searchgo.SetActive(true);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void OnInputFieldValueChanged(string input)
|
||||
{
|
||||
string cleanedInput = input.Replace("-", "");
|
||||
|
||||
string formattedInput = FormatWithDashes(cleanedInput);
|
||||
|
||||
formattedInput = formattedInput.ToUpperInvariant();
|
||||
|
||||
InputField_name.text = formattedInput;
|
||||
|
||||
int caretPositoin = formattedInput.Length;
|
||||
|
||||
InputField_name.caretPosition = caretPositoin;
|
||||
InputField_name.selectionStringAnchorPosition = caretPositoin;
|
||||
InputField_name.selectionStringFocusPosition = caretPositoin;
|
||||
}
|
||||
|
||||
string FormatWithDashes(string input)
|
||||
{
|
||||
for (int i = 3; i < input.Length; i += 4)
|
||||
{
|
||||
input = input.Insert(i, "-");
|
||||
}
|
||||
return input;
|
||||
}
|
||||
|
||||
void OnClickClose()
|
||||
{
|
||||
UIManager.Instance.HideUI(UITypes.FishingSocialFriendSearchPanel);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: be9e3bc056bc87840a4173020887d959
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
51
Assets/Scripts/UI/Social/Friend/FriendAddItem.cs
Normal file
51
Assets/Scripts/UI/Social/Friend/FriendAddItem.cs
Normal file
@@ -0,0 +1,51 @@
|
||||
using DG.Tweening;
|
||||
using EnhancedUI.EnhancedScroller;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Events;
|
||||
|
||||
namespace game
|
||||
{
|
||||
public class FriendAddItem : EnhancedScrollerCellView
|
||||
{
|
||||
public Vector2 zoomOut = new Vector2(0.4f, 0.4f);
|
||||
public float zoomOutTime = 0.15f;
|
||||
|
||||
protected Vector3 originalScale = Vector3.one;
|
||||
|
||||
protected FriendAddItemData m_Data;
|
||||
protected FishingFriendAddPanel m_Panel;
|
||||
public UnityAction<FriendAddItemData> Callback = null; // 回调事件
|
||||
public virtual void SetData(FishingFriendAddPanel panel, FriendAddItemData data, UnityAction<FriendAddItemData> callback)
|
||||
{
|
||||
m_Panel = panel;
|
||||
m_Data = data;
|
||||
this.Callback = null;
|
||||
this.Callback = callback;
|
||||
}
|
||||
|
||||
protected void LockScrollView(float lockTime = -1f)
|
||||
{
|
||||
if (m_Panel == null) return;
|
||||
if (lockTime < 0f)
|
||||
{
|
||||
lockTime = zoomOutTime + 0.1f;
|
||||
}
|
||||
m_Panel.StartLockScrollView(lockTime);
|
||||
}
|
||||
|
||||
protected void ResumeScale()
|
||||
{
|
||||
transform.GetComponent<RectTransform>().localScale = originalScale;
|
||||
}
|
||||
|
||||
protected void StartScalingAnimation(TweenCallback onComplete)
|
||||
{
|
||||
transform.DOKill();
|
||||
|
||||
Vector3 targetScale = new Vector3(zoomOut.x, zoomOut.y, originalScale.z);
|
||||
transform.DOScale(targetScale, zoomOutTime).SetEase(Ease.OutQuad).OnComplete(onComplete);
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/UI/Social/Friend/FriendAddItem.cs.meta
Normal file
11
Assets/Scripts/UI/Social/Friend/FriendAddItem.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 14ed860181e85514fa59923a12e378b1
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
40
Assets/Scripts/UI/Social/Friend/FriendAddItemData.cs
Normal file
40
Assets/Scripts/UI/Social/Friend/FriendAddItemData.cs
Normal file
@@ -0,0 +1,40 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace game
|
||||
{
|
||||
public class FriendAddItemData
|
||||
{
|
||||
public int Type = 0;
|
||||
public BFriendInfo FriendInfo = null;
|
||||
public int Extra = 0;
|
||||
|
||||
public bool EqualsPlayFabId(FriendAddItemData data)
|
||||
{
|
||||
if (this.FriendInfo == data.FriendInfo) return true;
|
||||
if (this.FriendInfo != null && data.FriendInfo != null && this.FriendInfo.PlayFabId == data.FriendInfo.PlayFabId)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public bool Equals(FriendAddItemData data)
|
||||
{
|
||||
if (this.Type != data.Type || this.Extra != data.Extra) return false;
|
||||
if (this.FriendInfo == data.FriendInfo) return true;
|
||||
if (this.FriendInfo != null && data.FriendInfo != null)
|
||||
{
|
||||
if (this.FriendInfo.Level == data.FriendInfo.Level && this.FriendInfo.AvatarUrl == data.FriendInfo.AvatarUrl
|
||||
&& this.FriendInfo.DisplayName == data.FriendInfo.DisplayName && this.FriendInfo.PlayFabId == data.FriendInfo.PlayFabId)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/UI/Social/Friend/FriendAddItemData.cs.meta
Normal file
11
Assets/Scripts/UI/Social/Friend/FriendAddItemData.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 73a931db32b44ca4d92785e5d0bb0b8c
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,320 @@
|
||||
using asap.core;
|
||||
using GameCore;
|
||||
using NSubstitute;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Events;
|
||||
|
||||
namespace game
|
||||
{
|
||||
public class FriendAddPanelBackendOperation
|
||||
{
|
||||
FishingFriendAddPanel m_Panel;
|
||||
public UnityAction<FriendAddItemData> m_Callback = null; // 回调事件
|
||||
FriendAddItemData m_Data;
|
||||
FriendAddPanelBackendOperationFromType m_FromType = FriendAddPanelBackendOperationFromType.FromTypeInvalid;
|
||||
|
||||
public UnityAction<FriendAddPanelBackendOperation, string, int> m_CallbackWithStringAndInt = null;
|
||||
|
||||
public FriendAddItemData Data
|
||||
{
|
||||
get { return m_Data; }
|
||||
}
|
||||
|
||||
public async void StartInvite(string playfabID, UnityAction<FriendAddPanelBackendOperation, string, int> Callback)
|
||||
{
|
||||
try
|
||||
{
|
||||
m_CallbackWithStringAndInt = Callback;
|
||||
string json = await GContext.container.Resolve<FriendService>().AddFriend(playfabID);
|
||||
if (!string.IsNullOrEmpty(json))
|
||||
{
|
||||
// code 1:添加好友成功;-1:我的好友已满;-2:对方好友已满;-3:获取对方好友列表失败;-4:我加对方好友失败;-5:对方加我好友失败;2:已经添加过对方好友;
|
||||
AddFriendResp addFriendResp = Newtonsoft.Json.JsonConvert.DeserializeObject<AddFriendResp>(json);
|
||||
if (addFriendResp != null)
|
||||
{
|
||||
#if AGG
|
||||
using (var e = GEvent.GameEvent("friend_send"))
|
||||
{
|
||||
e.AddContent("playfabid", GContext.container.Resolve<IUserService>().UserId)
|
||||
.AddContent("friendplayfabid", playfabID)
|
||||
.AddContent("code", addFriendResp.Code)
|
||||
.AddContent("friendcode", GContext.container.Resolve<FriendService>().GetInvitationCodeByPlayFabID(playfabID));
|
||||
}
|
||||
#endif
|
||||
GContext.Publish(new ResetWaitTime() { waitTime = 10f });
|
||||
switch (addFriendResp.Code)
|
||||
{
|
||||
case FriendHelper.Code_OK:
|
||||
case FriendHelper.Code_AddFriend_HaveAddedBefore_OK:
|
||||
ToastPanel.Show(LocalizationMgr.GetText("UI_ToastPanel_90"));
|
||||
if (m_CallbackWithStringAndInt != null)
|
||||
{
|
||||
m_CallbackWithStringAndInt(this, playfabID, FriendHelper.Code_OK);
|
||||
}
|
||||
break;
|
||||
case FriendHelper.Code_AddFriend_FriendHaveNoLimit:
|
||||
ToastPanel.Show(LocalizationMgr.GetText("UI_ToastPanel_91"));
|
||||
if (m_CallbackWithStringAndInt != null)
|
||||
{
|
||||
m_CallbackWithStringAndInt(this, playfabID, FriendHelper.Code_AddFriend_FriendHaveNoLimit);
|
||||
}
|
||||
break;
|
||||
case FriendHelper.Code_AddFriend_IHaveNoLimit:
|
||||
ToastPanel.Show(LocalizationMgr.GetText("UI_ToastPanel_92"));
|
||||
if (m_CallbackWithStringAndInt != null)
|
||||
{
|
||||
m_CallbackWithStringAndInt(this, playfabID, FriendHelper.Code_AddFriend_IHaveNoLimit);
|
||||
}
|
||||
break;
|
||||
case FriendHelper.Code_AddFriend_GetFriendList_Failed_PlayFabError:
|
||||
case FriendHelper.Code_AddFriend_IAddFriend_Failed_PlayFabError:
|
||||
case FriendHelper.Code_AddFriend_FriendAddMe_Failed_PlayFabError:
|
||||
ToastPanel.Show(LocalizationMgr.GetText("UI_ToastPanel_93"));
|
||||
if (m_CallbackWithStringAndInt != null)
|
||||
{
|
||||
m_CallbackWithStringAndInt(this, playfabID, FriendHelper.Code_AddFriend_GetFriendList_Failed_PlayFabError);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
ToastPanel.Show(LocalizationMgr.GetText("UI_ToastPanel_93"));
|
||||
if (m_CallbackWithStringAndInt != null)
|
||||
{
|
||||
m_CallbackWithStringAndInt(this, playfabID, FriendHelper.Code_AddFriend_GetFriendList_Failed_PlayFabError);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
string msg = "[FriendAddPanelBackendOperation] StartInvite encountered a fatal problem.";
|
||||
Debug.LogError($"{msg}-{ex.Message} \r\n {ex.StackTrace}");
|
||||
}
|
||||
}
|
||||
|
||||
public async void StartRecommendedInvite(FishingFriendAddPanel panel, FriendAddItemData data, UnityAction<FriendAddItemData> failCallback)
|
||||
{
|
||||
m_Panel = panel;
|
||||
m_Data = data;
|
||||
m_Callback = failCallback;
|
||||
m_FromType = FriendAddPanelBackendOperationFromType.FromTypeRecommended;
|
||||
|
||||
string json = await GContext.container.Resolve<FriendService>().AddFriend(m_Data.FriendInfo.PlayFabId);
|
||||
|
||||
if (!string.IsNullOrEmpty(json))
|
||||
{
|
||||
// code 1:添加好友成功;-1:我的好友已满;-2:对方好友已满;-3:获取对方好友列表失败;-4:我加对方好友失败;-5:对方加我好友失败;2:已经添加过对方好友;
|
||||
AddFriendResp addFriendResp = Newtonsoft.Json.JsonConvert.DeserializeObject<AddFriendResp>(json);
|
||||
if (addFriendResp != null)
|
||||
{
|
||||
#if AGG
|
||||
using (var e = GEvent.GameEvent("friend_send"))
|
||||
{
|
||||
e.AddContent("playfabid", GContext.container.Resolve<IUserService>().UserId)
|
||||
.AddContent("friendplayfabid", m_Data.FriendInfo.PlayFabId)
|
||||
.AddContent("code", addFriendResp.Code)
|
||||
.AddContent("friendcode", GContext.container.Resolve<FriendService>().GetInvitationCodeByPlayFabID(m_Data.FriendInfo.PlayFabId));
|
||||
}
|
||||
#endif
|
||||
|
||||
switch (addFriendResp.Code)
|
||||
{
|
||||
case FriendHelper.Code_OK:
|
||||
case FriendHelper.Code_AddFriend_HaveAddedBefore_OK:
|
||||
ToastPanel.Show(LocalizationMgr.GetText("UI_ToastPanel_90"));
|
||||
//if (m_Callback != null)
|
||||
//{
|
||||
// m_Callback(m_Data);
|
||||
//}
|
||||
break;
|
||||
case FriendHelper.Code_AddFriend_FriendHaveNoLimit:
|
||||
ToastPanel.Show(LocalizationMgr.GetText("UI_ToastPanel_91"));
|
||||
if (m_Callback != null)
|
||||
{
|
||||
m_Callback(m_Data);
|
||||
}
|
||||
break;
|
||||
case FriendHelper.Code_AddFriend_IHaveNoLimit:
|
||||
ToastPanel.Show(LocalizationMgr.GetText("UI_ToastPanel_92"));
|
||||
if (m_Callback != null)
|
||||
{
|
||||
m_Callback(m_Data);
|
||||
}
|
||||
break;
|
||||
case FriendHelper.Code_AddFriend_GetFriendList_Failed_PlayFabError:
|
||||
case FriendHelper.Code_AddFriend_IAddFriend_Failed_PlayFabError:
|
||||
case FriendHelper.Code_AddFriend_FriendAddMe_Failed_PlayFabError:
|
||||
ToastPanel.Show(LocalizationMgr.GetText("UI_ToastPanel_93"));
|
||||
if (m_Callback != null)
|
||||
{
|
||||
m_Callback(m_Data);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
ToastPanel.Show(LocalizationMgr.GetText("UI_ToastPanel_93"));
|
||||
if (m_Callback != null)
|
||||
{
|
||||
m_Callback(m_Data);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public async void StartInvitedAccept(FishingFriendAddPanel panel, FriendAddItemData data, UnityAction<FriendAddItemData> callback)
|
||||
{
|
||||
m_Panel = panel;
|
||||
m_Data = data;
|
||||
m_Callback = callback;
|
||||
m_FromType = FriendAddPanelBackendOperationFromType.FromTypeInvited;
|
||||
|
||||
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 (m_Callback != null)
|
||||
//{
|
||||
// m_Callback(m_Data);
|
||||
//}
|
||||
break;
|
||||
case FriendHelper.Code_AddFriend_FriendHaveNoLimit:
|
||||
ToastPanel.Show(LocalizationMgr.GetText("UI_ToastPanel_91"));
|
||||
if (m_Callback != null)
|
||||
{
|
||||
m_Callback(m_Data);
|
||||
}
|
||||
break;
|
||||
case FriendHelper.Code_AddFriend_IHaveNoLimit:
|
||||
ToastPanel.Show(LocalizationMgr.GetText("UI_ToastPanel_92"));
|
||||
if (m_Callback != null)
|
||||
{
|
||||
m_Callback(m_Data);
|
||||
}
|
||||
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"));
|
||||
if (m_Callback != null)
|
||||
{
|
||||
m_Callback(m_Data);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
ToastPanel.Show(LocalizationMgr.GetText("UI_ToastPanel_93"));
|
||||
if (m_Callback != null)
|
||||
{
|
||||
m_Callback(m_Data);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public async void StartInvitedIgnore(FishingFriendAddPanel panel, FriendAddItemData data, UnityAction<FriendAddItemData> callback)
|
||||
{
|
||||
m_Panel = panel;
|
||||
m_Data = data;
|
||||
m_Callback = callback;
|
||||
m_FromType = FriendAddPanelBackendOperationFromType.FromTypeInvited;
|
||||
|
||||
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 (m_Callback != null)
|
||||
//{
|
||||
// m_Callback(m_Data);
|
||||
//}
|
||||
break;
|
||||
case FriendHelper.Code_AddFriend_FriendHaveNoLimit:
|
||||
ToastPanel.Show(LocalizationMgr.GetText("UI_ToastPanel_91"));
|
||||
if (m_Callback != null)
|
||||
{
|
||||
m_Callback(m_Data);
|
||||
}
|
||||
break;
|
||||
case FriendHelper.Code_AddFriend_IHaveNoLimit:
|
||||
ToastPanel.Show(LocalizationMgr.GetText("UI_ToastPanel_92"));
|
||||
if (m_Callback != null)
|
||||
{
|
||||
m_Callback(m_Data);
|
||||
}
|
||||
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"));
|
||||
if (m_Callback != null)
|
||||
{
|
||||
m_Callback(m_Data);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
ToastPanel.Show(LocalizationMgr.GetText("UI_ToastPanel_93"));
|
||||
if (m_Callback != null)
|
||||
{
|
||||
m_Callback(m_Data);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void Clear()
|
||||
{
|
||||
m_Panel = null;
|
||||
m_Data = null;
|
||||
m_Callback = null;
|
||||
m_FromType = FriendAddPanelBackendOperationFromType.FromTypeInvalid;
|
||||
m_CallbackWithStringAndInt = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 09fa0a60ba04d9145b502da5e754efb8
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
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
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/UI/Social/Friend/FriendInvitedItem.cs.meta
Normal file
11
Assets/Scripts/UI/Social/Friend/FriendInvitedItem.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8ebe3e59f8b5eb94596001d0f33c402d
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
11
Assets/Scripts/UI/Social/Friend/FriendInvitedItemTitleBar.cs
Normal file
11
Assets/Scripts/UI/Social/Friend/FriendInvitedItemTitleBar.cs
Normal file
@@ -0,0 +1,11 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace game
|
||||
{
|
||||
public class FriendInvitedItemTitleBar : FriendAddItem
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 14e9851ce9a0ff0449afe2c38ea2b92a
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
254
Assets/Scripts/UI/Social/Friend/FriendRecommendedItem.cs
Normal file
254
Assets/Scripts/UI/Social/Friend/FriendRecommendedItem.cs
Normal file
@@ -0,0 +1,254 @@
|
||||
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 FriendRecommendedItem : FriendAddItem
|
||||
{
|
||||
TMP_Text text_name;
|
||||
Head btn_head;
|
||||
TMP_Text text_num;
|
||||
GameObject btn_invite_root;
|
||||
Button btn_invite;
|
||||
GameObject btn_invite_icon_loading;
|
||||
GameObject btn_invite_p_text;
|
||||
GameObject btn_invite_gray_root;
|
||||
Button btn_invite_gray;
|
||||
Button btn_skip;
|
||||
|
||||
#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;
|
||||
|
||||
if (data.Extra == 1)
|
||||
{
|
||||
btn_skip.gameObject.SetActive(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
btn_skip.gameObject.SetActive(true);
|
||||
}
|
||||
|
||||
string userID = GContext.container.Resolve<IUserService>().UserId;
|
||||
if (userID.Equals(bFriendInfo.PlayFabId) || GContext.container.Resolve<FriendService>().IsFriend(bFriendInfo.PlayFabId))
|
||||
{
|
||||
btn_invite_root.SetActive(false);
|
||||
btn_invite_gray_root.SetActive(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
btn_invite_root.SetActive(true);
|
||||
btn_invite_gray_root.SetActive(false);
|
||||
}
|
||||
|
||||
m_IsSkipping = false;
|
||||
m_IsInviting = false;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region UI
|
||||
bool m_IsSkipping = false;
|
||||
private void OnBtnInviteGrayClickListener()
|
||||
{
|
||||
if (m_Data == null) return;
|
||||
|
||||
ToastPanel.Show(LocalizationMgr.GetText("UI_ToastPanel_94"));
|
||||
}
|
||||
private void OnBtnSkipClick()
|
||||
{
|
||||
if (m_Data == null) return;
|
||||
|
||||
DisableBtn();
|
||||
LockScrollView();
|
||||
|
||||
StartScalingAnimation(() =>
|
||||
{
|
||||
//if (Callback != null)
|
||||
//{
|
||||
// Callback(m_Data);
|
||||
//}
|
||||
if (m_Panel != null)
|
||||
{
|
||||
m_Panel.RemoveRecommendedData(m_Data);
|
||||
}
|
||||
EnableBtn();
|
||||
});
|
||||
|
||||
//if (m_IsSkipping == true) return;
|
||||
//m_IsSkipping = true;
|
||||
//if (Callback != null)
|
||||
//{
|
||||
// Callback(m_Data);
|
||||
//}
|
||||
//m_IsSkipping = false;
|
||||
}
|
||||
|
||||
bool m_IsInviting = false;
|
||||
private void OnBtnInviteClick()
|
||||
{
|
||||
if (m_Data == null) return;
|
||||
|
||||
DisableBtn();
|
||||
LockScrollView();
|
||||
|
||||
StartScalingAnimation(() =>
|
||||
{
|
||||
//if (Callback != null)
|
||||
//{
|
||||
// Callback(m_Data);
|
||||
//}
|
||||
if (m_Panel != null)
|
||||
{
|
||||
m_Panel.StartRecommendedInvite(m_Data);
|
||||
}
|
||||
EnableBtn();
|
||||
});
|
||||
|
||||
// if (m_IsInviting == true) return;
|
||||
|
||||
// m_IsInviting = true;
|
||||
// if (btn_invite_p_text != null)
|
||||
// {
|
||||
// btn_invite_p_text.SetActive(false);
|
||||
// }
|
||||
// if (btn_invite_icon_loading != null)
|
||||
// {
|
||||
// btn_invite_icon_loading.SetActive(true);
|
||||
// }
|
||||
// string json = await GContext.container.Resolve<FriendService>().AddFriend(m_Data.FriendInfo.PlayFabId);
|
||||
|
||||
// if (!string.IsNullOrEmpty(json))
|
||||
// {
|
||||
// // code 1:添加好友成功;-1:我的好友已满;-2:对方好友已满;-3:获取对方好友列表失败;-4:我加对方好友失败;-5:对方加我好友失败;2:已经添加过对方好友;
|
||||
// AddFriendResp addFriendResp = Newtonsoft.Json.JsonConvert.DeserializeObject<AddFriendResp>(json);
|
||||
// if (addFriendResp != null)
|
||||
// {
|
||||
//#if AGG
|
||||
// using (var e = GEvent.GameEvent("friend_send"))
|
||||
// {
|
||||
// e.AddContent("playfabid", GContext.container.Resolve<IUserService>().UserId)
|
||||
// .AddContent("friendplayfabid", m_Data.FriendInfo.PlayFabId)
|
||||
// .AddContent("code", addFriendResp.Code)
|
||||
// .AddContent("friendcode", GContext.container.Resolve<FriendService>().GetInvitationCodeByPlayFabID(m_Data.FriendInfo.PlayFabId));
|
||||
// }
|
||||
//#endif
|
||||
|
||||
// switch (addFriendResp.Code)
|
||||
// {
|
||||
// case FriendHelper.Code_OK:
|
||||
// case FriendHelper.Code_AddFriend_HaveAddedBefore_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_AddFriend_IAddFriend_Failed_PlayFabError:
|
||||
// case FriendHelper.Code_AddFriend_FriendAddMe_Failed_PlayFabError:
|
||||
// ToastPanel.Show(LocalizationMgr.GetText("UI_ToastPanel_93"));
|
||||
// break;
|
||||
// default:
|
||||
// ToastPanel.Show(LocalizationMgr.GetText("UI_ToastPanel_93"));
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
// if (btn_invite_icon_loading != null)
|
||||
// {
|
||||
// btn_invite_icon_loading.SetActive(false);
|
||||
// }
|
||||
// if (btn_invite_p_text != null)
|
||||
// {
|
||||
// btn_invite_p_text.SetActive(true);
|
||||
// }
|
||||
// m_IsInviting = 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_invite_root = transform.Find("btn_invite").gameObject;
|
||||
btn_invite = transform.Find("btn_invite/btn_green_c").GetComponent<Button>();
|
||||
btn_invite_icon_loading = transform.Find("btn_invite/btn_green_c/Ani_Container/icon_loading").gameObject;
|
||||
btn_invite_p_text = transform.Find("btn_invite/btn_green_c/Ani_Container/p_text").gameObject;
|
||||
btn_invite.onClick.AddListener(OnBtnInviteClick);
|
||||
|
||||
btn_invite_gray_root = transform.Find("btn_invite_gray").gameObject;
|
||||
btn_invite_gray = transform.Find("btn_invite_gray/btn_green_c").GetComponent<Button>();
|
||||
btn_invite_gray.onClick.AddListener(OnBtnInviteGrayClickListener);
|
||||
btn_invite_gray_root.SetActive(false);
|
||||
|
||||
btn_skip = transform.Find("btn_skip/btn_green_c").GetComponent<Button>();
|
||||
btn_skip.onClick.AddListener(OnBtnSkipClick);
|
||||
|
||||
m_IsInit = true;
|
||||
}
|
||||
private void DisableBtn()
|
||||
{
|
||||
if (btn_invite != null)
|
||||
{
|
||||
btn_invite.enabled = false;
|
||||
}
|
||||
if (btn_skip != null)
|
||||
{
|
||||
btn_skip.enabled = false;
|
||||
}
|
||||
}
|
||||
private void EnableBtn()
|
||||
{
|
||||
if (btn_invite != null)
|
||||
{
|
||||
btn_invite.enabled = true;
|
||||
}
|
||||
if (btn_skip != null)
|
||||
{
|
||||
btn_skip.enabled = true;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: da38abe9a04d7484a9c8729faf2bfa39
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,14 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Events;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace game
|
||||
{
|
||||
public class FriendRecommendedItemTitleBar : FriendAddItem
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ee9761e8799b68c49a0d18af6a41ace1
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user