备份CatanBuilding瘦身独立工程

This commit is contained in:
JSD\13999
2026-05-26 16:15:54 +08:00
commit 2d0e6a61b7
12001 changed files with 2431925 additions and 0 deletions

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 1ac6a3385ed6d634eb52a49088516082
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,90 @@
using asap.core;
using cfg;
using GameCore;
using TMPro;
using UnityEngine;
using UnityEngine.UI;
public class ChestRewardItem : PanelItemBase<ChestRewardItemData>
{
GameObject bar_root;
Image bar;
GameObject bg_normal;
GameObject bg_gray;
GameObject bg_next;
RewardItemNew[] rewardItems;
TMP_Text text_grade;
Image icon_chest;
TMP_Text text_point;
private void Awake()
{
bar_root = transform.Find("bg_bar").gameObject;
bar = transform.Find("bg_bar/bar").GetComponent<Image>();
bg_normal = transform.Find("bg_normal").gameObject;
bg_gray = transform.Find("bg_gray").gameObject;
bg_next = transform.Find("bg_next").gameObject;
rewardItems = transform.Find("reward").GetComponentsInChildren<RewardItemNew>();
icon_chest = transform.Find("icon_chest").GetComponent<Image>();
text_grade = transform.Find("bg_grade/text_grade").GetComponent<TMP_Text>();
text_point = transform.Find("text_point").GetComponent<TMP_Text>();
}
public void SetData(Account account)
{
text_grade.text = account.ID.ToString();
var itemDatas = GContext.container.Resolve<PlayerItemData>().GetItemDataByDropId(account.Rewards);
int len = 0;
if (itemDatas != null)
{
len = itemDatas.Count;
for (int i = 0; i < itemDatas.Count; i++)
{
if (i >= rewardItems.Length)
{
break;
}
rewardItems[i].SetData(itemDatas[i]);
}
}
for (int i = len; i < rewardItems.Length; i++)
{
rewardItems[i].gameObject.SetActive(false);
}
bg_next.SetActive(data.next);
//此处 等级相关转为工会积分相关
if (GContext.container.Resolve<PlayerData>().lv >= account.ID)
{
bar.fillAmount = 1;
bg_gray.SetActive(true);
bg_normal.SetActive(false);
}
else
{
bar.fillAmount = 0;
bg_gray.SetActive(false);
bg_normal.SetActive(!data.next);
}
for (int i = 0; i < rewardItems.Length; i++)
{
rewardItems[i].SetReceived(GContext.container.Resolve<PlayerData>().lv >= account.ID);
}
if (data.nextIndex - 1 == index)
{
bar.fillAmount = data.fillAmount;
}
bar_root.SetActive(data.bar);
}
public override void OnInit()
{
SetData(data.account);
}
}
public class ChestRewardItemData
{
public Account account;
public int nextIndex;
public float fillAmount;
public bool next;
public bool bar = true;
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 2e84dc6c0bd00124bb54200aa26d20dd
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,20 @@
using GameCore;
using UnityEngine;
using UnityEngine.UI;
public class ChestSettlementChes : MonoBehaviour
{
Button btn_continue;
private void Awake()
{
btn_continue = transform.Find("btn_continue/btn_green").GetComponent<Button>();
}
private void Start()
{
btn_continue.onClick.AddListener(() =>
{
UIManager.Instance.DestroyUI(UITypes.ClubChestSettlementPanel);
});
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 58d7bc528c335424a9d889051982e442
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,20 @@
using GameCore;
using UnityEngine;
using UnityEngine.UI;
public class ChestSettlementChestNone : MonoBehaviour
{
Button btn_continue;
private void Awake()
{
btn_continue = transform.Find("btn_continue/btn_green").GetComponent<Button>();
}
private void Start()
{
btn_continue.onClick.AddListener(() =>
{
UIManager.Instance.DestroyUI(UITypes.ClubChestSettlementPanel);
});
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 6026464c8f10ee5459339018e09ace14
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,20 @@
using GameCore;
using UnityEngine;
using UnityEngine.UI;
public class ChestSettlementPlayer : MonoBehaviour
{
Button btn_continue;
private void Awake()
{
btn_continue = transform.Find("btn_continue/btn_green").GetComponent<Button>();
}
private void Start()
{
btn_continue.onClick.AddListener(() =>
{
UIManager.Instance.DestroyUI(UITypes.ClubChestSettlementPanel);
});
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 65871b9d2ebfd0f42b0049210ef34a9f
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,20 @@
using GameCore;
using UnityEngine;
using UnityEngine.UI;
public class ChestSettlementRank : MonoBehaviour
{
Button btn_continue;
private void Awake()
{
btn_continue = transform.Find("btn_continue/btn_green").GetComponent<Button>();
}
private void Start()
{
btn_continue.onClick.AddListener(() =>
{
UIManager.Instance.DestroyUI(UITypes.ClubChestSettlementPanel);
});
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 487f124fe0324be4e942829079778407
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,19 @@
using GameCore;
using UnityEngine;
using UnityEngine.UI;
public class ClubBannerTarget : MonoBehaviour
{
Button btn_questionmark;
private void Awake()
{
btn_questionmark = transform.Find("btn_questionmark").GetComponent<Button>();
}
private void Start()
{
btn_questionmark.onClick.AddListener(() =>
{
UIManager.Instance.ShowUI(UITypes.ClubChestSettlementPanel);
});
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 2fcc2ac1d2ab8584bac1635ee128312c
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,70 @@
using asap.core;
using cfg;
using GameCore;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class ClubChestPopupPanel : MonoBehaviour
{
Button btn_close;
PanelScroll scrollRect;
Image bar;
GameObject gradeItem;
List<ChestRewardItemData> gradeDatas = new List<ChestRewardItemData>();
float itemHigh = 250;
private void Awake()
{
btn_close = transform.Find("btn_close").GetComponent<Button>();
bar = transform.Find("root/root_reward/ScrollView/Viewport/Content/bg_bar/bar").GetComponent<Image>();
scrollRect = transform.Find("root/root_reward/ScrollView").GetComponent<PanelScroll>();
gradeItem = transform.Find("root/root_reward/ScrollView/Viewport/Content/item").gameObject;
gradeItem.SetActive(false);
itemHigh = gradeItem.GetComponent<RectTransform>().sizeDelta.y;
scrollRect.isReversal = true;
}
private void Start()
{
//btn_close.onClick.AddListener(() =>
//{
// UIManager.Instance.DestroyUI(UITypes.ClubChestPopupPanel);
//});
//gradeDatas.Clear();
////等级相关转为工会积分Todo
//var account = GContext.container.Resolve<Tables>().TbAccount.DataList;
//int nextIndex = account.Count - 1;
//for (int i = 0; i < account.Count; i++)
//{
// if (GContext.container.Resolve<PlayerData>().lv < account[i].ID)
// {
// nextIndex = i;
// break;
// }
//}
//bar.fillAmount = GContext.container.Resolve<PlayerData>().lv / (float)account[0].ID;
//int showCount = nextIndex + 10;
//if (showCount > account.Count)
//{
// showCount = account.Count;
//}
//for (int i = 0; i < showCount; i++)
//{
// gradeDatas.Add(new ChestRewardItemData() { account = account[i], nextIndex = nextIndex });
//}
//if (nextIndex > 0)
//{
// int startLv = account[nextIndex - 1].ID;
// var nextAccountData = account[nextIndex];
// gradeDatas[nextIndex - 1].fillAmount = (GContext.container.Resolve<PlayerData>().lv - startLv) / (float)(nextAccountData.ID - startLv);
// gradeDatas[nextIndex].next = true;
// nextIndex--;
//}
//else if (GContext.container.Resolve<PlayerData>().lv < account[0].ID)
//{
// gradeDatas[0].next = true;
//}
//gradeDatas[^1].bar = false;
//scrollRect.Init<ChestRewardItem, ChestRewardItemData>(itemHigh, gradeItem, null, gradeDatas, _currentIndex: nextIndex, _minShowAdd: 3);
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 1fbcd429e0eb4314f8e44a02a76d0cff
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,19 @@
using GameCore;
using UnityEngine;
using UnityEngine.UI;
public class ClubChestSettlementPanel : MonoBehaviour
{
Button btn_mask;
private void Awake()
{
btn_mask = transform.Find("btn_mask").GetComponent<Button>();
}
private void Start()
{
btn_mask.onClick.AddListener(() =>
{
UIManager.Instance.DestroyUI(UITypes.ClubChestSettlementPanel);
});
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: e4385f74e941fae48ad1287319ef8932
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,19 @@
using GameCore;
using UnityEngine;
using UnityEngine.UI;
public class ClubRankPopupPanel : MonoBehaviour
{
Button btn_close;
private void Awake()
{
btn_close = transform.Find("btn_close").GetComponent<Button>();
}
private void Start()
{
btn_close.onClick.AddListener(() =>
{
UIManager.Instance.DestroyUI(UITypes.ClubRankPopupPanel);
});
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 0148056dba84eaa43bac4a051590aadb
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,156 @@
using asap.core;
using game;
using GameCore;
using System;
using TMPro;
using UniRx;
using UnityEngine;
using UnityEngine.UI;
public class ClubApplyPopupPanel : MonoBehaviour
{
public Button btn_mask;
public Button btn_close;
public Button btn_ignore;
public Transform content;
public GameObject contentPrefab;
GameObject emply;
bool isHas = false;
private void Awake()
{
btn_mask = transform.Find("mask").GetComponent<Button>();
btn_close = transform.Find("btn_close").GetComponent<Button>();
btn_ignore = transform.Find("root/btn_ignore/btn_green").GetComponent<Button>();
content = transform.Find("root/ScrollView/Viewport/Content");
contentPrefab = transform.Find("root/ScrollView/Viewport/Content/Item").gameObject;
emply = transform.Find("root/text_emply").gameObject;
}
private void OnStart()
{
var datas = GContext.container.Resolve<ClubService>().clubPlayerInfos;
if (datas != null && datas.Count > 0)
{
IUserService userService = GContext.container.Resolve<IUserService>();
for (int i = 0; i < datas.Count; i++)
{
SocialInfoItemData clubPlayerInfoData = datas[i];
GameObject go = Instantiate(contentPrefab, content);
go.SetActive(true);
ApplyItem applyItem = go.AddComponent<ApplyItem>();
applyItem.SetData(clubPlayerInfoData);
}
isHas = true;
}
emply.SetActive(datas == null || datas.Count == 0);
//btn_ignore.gameObject.SetActive(datas != null && datas.Count > 0);
}
public void Start()
{
OnStart();
btn_mask.onClick.AddListener(OnClose);
btn_close.onClick.AddListener(OnClose);
btn_ignore.onClick.AddListener(() =>
{
if (isHas)
{
GContext.container.Resolve<ClubService>().HandleApply(false, "");
}
OnClose();
});
}
private void OnClose()
{
UIManager.Instance.DestroyUI(UITypes.ClubApplyPopupPanel);
}
}
class ApplyItem : MonoBehaviour
{
TMP_Text text_name;
Head head;
TMP_Text text_count;
Button btn_accept;
Button btn_ignore;
string playFabId;
//string entityKey;
SocialInfoItemData data;
IDisposable disposable;
private void Awake()
{
disposable = GContext.OnEvent<GetClubPlayInfoEvent>().Where(x => x.id == playFabId).Subscribe(SetAvatar);
text_name = transform.Find("text_name").GetComponent<TMP_Text>();
head = transform.Find("btn_head").GetComponent<Head>();
text_count = transform.Find("icon_rank/text_num").GetComponent<TMP_Text>();
btn_accept = transform.Find("btn_accept").GetComponent<Button>();
btn_ignore = transform.Find("btn_ignore").GetComponent<Button>();
}
private void Start()
{
btn_accept.onClick.AddListener(OnAccept);
btn_ignore.onClick.AddListener(OnIgnore);
}
public void SetData(SocialInfoItemData data)
{
this.data = data;
playFabId = data.playFabId;
//entityKey = data.entityKey;
//head.SetData(data.avatarUrl);
IUserService userService = GContext.container.Resolve<IUserService>();
if (data.playFabId == userService.UserId)
{
text_name.text = userService.DisplayName;
head.SetData(userService.AvatarUrl);
text_count.text = GContext.container.Resolve<PlayerData>().lv.ToString();
}
else
{
text_count.text = data.lv.ToString();
PlayInfo clubPlayInfo = userService.GetPlayInfo(playFabId);
if (clubPlayInfo != null)
{
text_name.text = clubPlayInfo.name;
head.SetData(clubPlayInfo.avatarUrl);
}
if (data.lv <= 1)
{
SetLv(data, userService);
}
}
}
async void SetLv(SocialInfoItemData curData, IUserService userService)
{
var (playId, lv) = await userService.GetPlayLv(playFabId);
curData.lv = lv;
if (playId == playFabId)
{
text_count.text = lv.ToString();
}
}
void SetAvatar(GetClubPlayInfoEvent getClubPlayInfoEvent)
{
if (getClubPlayInfoEvent.id == playFabId)
{
text_name.text = getClubPlayInfoEvent.name;
head.SetData(getClubPlayInfoEvent.avatarUrl);
}
}
private void OnDestroy()
{
disposable?.Dispose();
disposable = null;
}
void OnAccept()
{
//同意
GContext.container.Resolve<ClubService>().HandleApply(true, playFabId);
Destroy(gameObject);
}
void OnIgnore()
{
//忽略
GContext.container.Resolve<ClubService>().HandleApply(false, playFabId);
Destroy(gameObject);
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 3a609688e66da124a921b1a64364511e
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 347058ee68c0d634ea64bddeeb6c6ef1
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,128 @@
using asap.core;
using game;
using GameCore;
using System;
using TMPro;
using UniRx;
using UnityEngine;
using UnityEngine.UI;
public class DialogueBase : MonoBehaviour
{
protected IUserService userService;
public Head head;
public GameObject player_info;
public TMP_Text text_name;
public TMP_Text text_time;
public Button btn_head;
public Transform tips_dock_trans;
public Vector2 tips_dock_offset = Vector2.zero;
protected string playFabId = null;
protected string displayName = null;
protected string avatarUrl = null;
IDisposable disposable;
#if UNITY_EDITOR
private void Reset()
{
text_name = transform.Find("player_info/text_name")?.GetComponent<TMP_Text>();
text_time = transform.Find("player_info/text_time").GetComponent<TMP_Text>();
head = transform.Find("btn_head").GetComponent<Head>();
player_info = transform.Find("player_info").gameObject;
}
#endif
protected virtual void Awake()
{
userService = GContext.container.Resolve<IUserService>();
disposable = GContext.OnEvent<GetClubPlayInfoEvent>().Where(x => x.id == playFabId).Subscribe(SetAvatar);
}
protected void Init(DateTime timeSpan, bool isSame)
{
if (isSame)
{
head.gameObject.SetActive(false);
player_info.gameObject.SetActive(false);
disposable?.Dispose();
disposable = null;
return;
}
text_time.text = timeSpan.ToString();
if (playFabId == userService.UserId)
{
if (text_name != null)
text_name.text = userService.DisplayName;
head.SetData(userService.AvatarUrl);
displayName = userService.DisplayName;
avatarUrl = userService.AvatarUrl;
}
else
{
if (playFabId == null)
{
playFabId = "";
}
PlayInfo clubPlayInfo = userService.GetPlayInfo(playFabId);
if (clubPlayInfo != null)
{
if (text_name != null)
text_name.text = clubPlayInfo.name;
head.SetData(clubPlayInfo.avatarUrl);
displayName = clubPlayInfo.name;
avatarUrl = clubPlayInfo.avatarUrl;
}
}
if (btn_head != null)
{
btn_head.onClick.RemoveAllListeners();
btn_head.onClick.AddListener(OnBtnHeadClickListener);
}
}
private async void OnBtnHeadClickListener()
{
if (tips_dock_trans == null) return;
PlayInfo clubPlayInfo = userService.GetPlayInfo(playFabId);
if (clubPlayInfo == null) return;
GameObject go = await UIManager.Instance.ShowUI(UITypes.SocialClubPlayerTips);
if (go == null) return;
BFriendInfo friendInfo = new BFriendInfo()
{
PlayFabId = playFabId,
DisplayName = displayName,
AvatarUrl = avatarUrl,
Level = -1
};
SocialClubPlayerTips tips = go.GetComponent<SocialClubPlayerTips>();
tips.SetData(tips_dock_trans, tips_dock_offset, friendInfo);
}
void SetAvatar(GetClubPlayInfoEvent getClubPlayInfoEvent)
{
if (getClubPlayInfoEvent.id == playFabId)
{
if (text_name != null)
text_name.text = getClubPlayInfoEvent.name;
head.SetData(getClubPlayInfoEvent.avatarUrl);
displayName = getClubPlayInfoEvent.name;
avatarUrl = getClubPlayInfoEvent.avatarUrl;
}
}
private void OnDestroy()
{
disposable?.Dispose();
disposable = null;
playFabId = null;
displayName = null;
avatarUrl = null;
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 27a097add7331be45acb3a7f9ad72dd4
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,14 @@
using asap.core;
using System;
using UnityEngine.UI;
public class DialogueEmoji : DialogueBase
{
public Image emoji;
public void Init(string message, string userID, DateTime timeSpan, bool isSame)
{
playFabId = userID;
GContext.container.Resolve<IUIService>().SetImageSprite(emoji, message);
Init(timeSpan, isSame);
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 0d94db00caf59074d9151842a5693452
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,143 @@
using asap.core;
using cfg;
using DG.Tweening;
using game;
using GameCore;
using System;
using TMPro;
using UniRx;
using UnityEngine;
using UnityEngine.UI;
public class DialogueEnergyHelp : DialogueBase
{
ClubService clubService;
public Button btn_donate;
public Button btn_donate_gray;
public GameObject done;
public TMP_Text text_progress;
public Image bar;
public Animation ani;
long cursorId;
int count;
int ClubLureRequestCount = 5;
int ClubLureDonateLimit = 50;
string content;
bool hasHelped;
Tables tables;
bool isEnable = true;
protected override void Awake()
{
tables = GContext.container.Resolve<cfg.Tables>();
ClubLureRequestCount = tables.TbGlobalConfig.ClubLureRequestCount;
ClubLureDonateLimit = tables.TbGlobalConfig.ClubLureDonateLimit;
base.Awake();
clubService = GContext.container.Resolve<ClubService>();
btn_donate.onClick.AddListener(OnClickDonate);
btn_donate_gray.onClick.AddListener(OnClickDonate);
}
async void OnClickDonate()
{
if (playFabId == userService.UserId)
{
ToastPanel.Show(LocalizationMgr.GetText("UI_ToastPanel_68"));
InitHelpState();
return;
}
if (hasHelped)
{
ToastPanel.Show(LocalizationMgr.GetText("UI_ToastPanel_67"));
return;
}
if (clubService.ClubLureDonateCount >= ClubLureDonateLimit)
{
return;
}
btn_donate.gameObject.SetActive(false);
hasHelped = true;
//捐赠成功
count++;
SetHelpState(count);
AddProgress();
content = await clubService.SendHelpOthersEnergy(playFabId, cursorId);
if (!string.IsNullOrEmpty(content))
{
hasHelped = content.Contains(userService.UserId);
count = content.Split("#").Length;
}
ToastPanel.Show(LocalizationMgr.GetText("UI_ToastPanel_69"));
}
async void AddProgress()
{
if (count > ClubLureRequestCount)
{
count = ClubLureRequestCount;
}
text_progress.text = $"{count}/{ClubLureRequestCount}";
bar.DOFillAmount((float)count / ClubLureRequestCount, 0.5f);
if (count >= ClubLureRequestCount)
{
await Awaiters.Seconds(0.5f);
ani.Play();
}
}
public void Init(string userID, long cursorId, string message, DateTime timeSpan, bool isSame)
{
isSame = false;
playFabId = userID;
this.cursorId = cursorId;
done.gameObject.SetActive(false);
btn_donate_gray.gameObject.SetActive(false);
btn_donate.gameObject.SetActive(false);
hasHelped = true;
text_progress.text = $"{0}/{ClubLureRequestCount}";
bar.fillAmount = 0;
InitHelpState();
Init(timeSpan, isSame);
}
async void InitHelpState()
{
content = await clubService.GetHelpEnergyState(cursorId);
if (!isEnable)
{
return;
}
if (!string.IsNullOrEmpty(content))
{
hasHelped = content.Contains(userService.UserId);
count = content.Split("#").Length;
}
else
{
hasHelped = false;
}
if (count > ClubLureRequestCount)
{
count = ClubLureRequestCount;
}
SetHelpState(count);
text_progress.text = $"{count}/{ClubLureRequestCount}";
bar.fillAmount = (float)count / ClubLureRequestCount;
}
void SetHelpState(int curCount)
{
if (curCount < ClubLureRequestCount)
{
bool isGray = playFabId == userService.UserId || hasHelped || clubService.ClubLureDonateCount >= ClubLureDonateLimit;
btn_donate_gray.gameObject.SetActive(isGray);
btn_donate.gameObject.SetActive(!isGray);
done.gameObject.SetActive(false);
}
else
{
btn_donate_gray.gameObject.SetActive(false);
btn_donate.gameObject.SetActive(false);
done.gameObject.SetActive(true);
}
}
private void OnDestroy()
{
isEnable = false;
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: b8294be3b2cae9740a8f53b508f2d090
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,132 @@
using asap.core;
using cfg;
using game;
using GameCore;
using System;
using TMPro;
using UniRx;
using UnityEngine;
using UnityEngine.UI;
public class DialogueHelp : DialogueBase
{
ClubService clubService;
public Button btn_donate;
public Button btn_donate_gray;
public GameObject done;
public TMP_Text text_donor;
public TMP_Text text_photo_name;
public TMP_Text text_help;
long cursorId;
int count = 0;
int pictureID;
string curDonateId;
IDisposable disposable;
protected override void Awake()
{
base.Awake();
clubService = GContext.container.Resolve<ClubService>();
//btn_donate.onClick.AddListener(OnClickDonate);
//btn_donate_gray.onClick.AddListener(OnClickDonate);
}
async void OnClickDonate()
{
if (playFabId == userService.UserId)
{
ToastPanel.Show(LocalizationMgr.GetText("UI_ToastPanel_35"));
return;
}
count = GContext.container.Resolve<AlbumData>().GetPictureProgress(pictureID);
if (count <= 1)
{
ToastPanel.Show(LocalizationMgr.GetText("UI_ToastPanel_34"));
}
else
{
btn_donate.gameObject.SetActive(false);
//捐赠成功
var donateId = await clubService.SendDonatePhoto(playFabId, cursorId, pictureID);
if (string.IsNullOrEmpty(donateId))
{
donateId = userService.UserId;
}
SetPhotoState(donateId);
}
}
public void Init(string userID, long cursorId, string message, DateTime timeSpan, bool isSame)
{
playFabId = userID;
this.cursorId = cursorId;
var picture = GContext.container.Resolve<Tables>().TbPicture.GetOrDefault(int.Parse(message));
done.gameObject.SetActive(false);
if (picture != null)
{
btn_donate_gray.gameObject.SetActive(false);
btn_donate.gameObject.SetActive(false);
pictureID = picture.ID;
count = GContext.container.Resolve<AlbumData>().GetPictureProgress(picture.ID);
InitPhotoState();
text_photo_name.text = LocalizationMgr.GetText(picture.Title_l10n_key);
}
else
{
btn_donate_gray.gameObject.SetActive(true);
btn_donate.gameObject.SetActive(false);
}
Init(timeSpan, isSame);
}
async void InitPhotoState()
{
var donateId = await clubService.GetPhotoState(playFabId, cursorId);
SetPhotoState(donateId);
}
void SetPhotoState(string donateId)
{
if (string.IsNullOrEmpty(donateId))
{
curDonateId = "";
//未捐赠
//btn_donate_gray.gameObject.SetActive(count <= 1);
//btn_donate.gameObject.SetActive(count > 1);
btn_donate_gray.gameObject.SetActive(true);
btn_donate.gameObject.SetActive(false);
done.gameObject.SetActive(false);
}
else
{
//已捐赠
btn_donate.gameObject.SetActive(false);
btn_donate_gray.gameObject.SetActive(false);
done.gameObject.SetActive(true);
//展示捐赠人名称和对勾
//donateId
curDonateId = donateId;
if (userService.UserId == curDonateId)
{
text_donor.text = userService.DisplayName;
}
else
{
if (disposable == null)
{
disposable = GContext.OnEvent<GetClubPlayInfoEvent>().Where(x => x.id == curDonateId).Subscribe(SetAvatar);
}
PlayInfo clubPlayInfo = userService.GetPlayInfo(curDonateId);
if (clubPlayInfo != null)
{
text_donor.text = clubPlayInfo.name;
}
}
}
}
void SetAvatar(GetClubPlayInfoEvent getClubPlayInfoEvent)
{
if (getClubPlayInfoEvent.id == curDonateId)
{
text_donor.text = getClubPlayInfoEvent.name;
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: dd8faf41ba755f0419b56fccc1519e9e
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,14 @@
using System;
using TMPro;
public class DialogueLeft : DialogueBase
{
public TMP_Text text_content;
public void Init(string message, string userID, DateTime timeSpan, bool isSame)
{
playFabId = userID;
text_content.text = message;
Init(timeSpan, isSame);
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: ce8f15260eadc734e82cba7d6d6f5272
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,44 @@
using asap.core;
using cfg;
using game;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class EmojiTips : MonoBehaviour
{
GameObject item;
Button btn_close;
IChatService chatService;
private void Awake()
{
chatService = GContext.container.Resolve<IChatService>();
btn_close = transform.Find("btn_close").GetComponent<Button>();
item = transform.Find("emoji1").gameObject;
item.SetActive(false);
}
private void Start()
{
btn_close.onClick.AddListener(OnClose);
List<ClubEmoji> clubEmojis = GContext.container.Resolve<Tables>().TbClubEmoji.DataList;
Image icon;
IUIService uIService = GContext.container.Resolve<IUIService>();
foreach (var emoji in clubEmojis)
{
GameObject go = Instantiate(item, transform);
go.SetActive(true);
icon = go.transform.Find("icon").GetComponent<Image>();
uIService.SetImageSprite(icon, emoji.Frame, BasePanel.PanelName);
go.GetComponent<Button>().onClick.AddListener(() => OnClick(emoji.Frame));
}
}
void OnClick(string icon)
{
chatService.SendEmoji(icon);
OnClose();
}
void OnClose()
{
gameObject.SetActive(false);
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 06e6777ae9e59b642804e9b6a4340d92
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,89 @@
using asap.core;
using game;
using GameCore;
using System;
using TMPro;
using UniRx;
using UnityEngine;
public class Prompted : MonoBehaviour
{
public TMP_Text text_prompted;
IUserService userService;
string playFabId;
IDisposable disposable;
string multilingual;
string roleStr = "";
private void Awake()
{
userService = GContext.container.Resolve<IUserService>();
disposable = GContext.OnEvent<GetClubPlayInfoEvent>().Where(x => x.id == playFabId).Subscribe(SetAvatar);
}
public void Init(string message)
{
roleStr = "";
var messageArray = message.Split('_');
playFabId = messageArray[1];
multilingual = messageArray[0];
switch (multilingual)
{
case MessageChatType.IN:
multilingual = LocalizationMgr.GetText("UI_FishingSocialPanel_23");
break;
case MessageChatType.OUT:
multilingual = LocalizationMgr.GetText("UI_FishingSocialPanel_24");
break;
case MessageChatType.SI:
multilingual = LocalizationMgr.GetText("UI_FishingSocialPanel_26");
break;
case MessageChatType.DEMOTE:
multilingual = LocalizationMgr.GetText("UI_ClubInfoPopupPanel_17");
break;
case MessageChatType.PROMOTE:
roleStr = messageArray[2];
if (messageArray[2] == EMemberRole.Owner.ToString())
{
roleStr = LocalizationMgr.GetText("UI_ClubInfoPopupPanel_2");
}
else if (messageArray[2] == EMemberRole.Vice.ToString())
{
roleStr = LocalizationMgr.GetText("UI_ClubInfoPopupPanel_3");
}
else if (messageArray[2] == EMemberRole.Elder.ToString())
{
roleStr = LocalizationMgr.GetText("UI_ClubInfoPopupPanel_4");
}
multilingual = LocalizationMgr.GetText("UI_ClubInfoPopupPanel_16");
break;
default:
multilingual = "Player {0} ";
break;
}
if (playFabId == userService.UserId)
{
text_prompted.text = multilingual.SafeFormat(userService.DisplayName, roleStr);
}
else
{
PlayInfo clubPlayInfo = userService.GetPlayInfo(playFabId);
if (clubPlayInfo != null)
{
text_prompted.text = multilingual.SafeFormat(clubPlayInfo.name, roleStr);
}
}
}
void SetAvatar(GetClubPlayInfoEvent getClubPlayInfoEvent)
{
if (getClubPlayInfoEvent.id == playFabId)
{
text_prompted.text = multilingual.SafeFormat(getClubPlayInfoEvent.name, roleStr);
}
}
private void OnDestroy()
{
disposable?.Dispose();
disposable = null;
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: c9816855881f7494fbdc2d5c200f76ea
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,102 @@
using asap.core;
using cfg;
using game;
using GameCore;
using System;
using TMPro;
using UniRx;
using UnityEngine;
using UnityEngine.UI;
public class PromptedLike : MonoBehaviour
{
public TMP_Text text_prompted;
public Button btn_like;
public GameObject icon;
public GameObject icon_done;
public TMP_Text text_num;
IUserService userService;
string playFabId;
IDisposable disposable;
string multilingual;
string mapName;
ClubService clubService;
long cursorId;
int num;
bool isEnable = true;
private void Awake()
{
userService = GContext.container.Resolve<IUserService>();
disposable = GContext.OnEvent<GetClubPlayInfoEvent>().Where(x => x.id == playFabId).Subscribe(SetAvatar);
}
private void Start()
{
icon.SetActive(true);
icon_done.SetActive(false);
btn_like.onClick.AddListener(() =>
{
SetBtnState(true);
num++;
text_num.text = num.ToString();
clubService.SendLike(cursorId);
});
}
void SetBtnState(bool like)
{
btn_like.enabled = !like;
icon.SetActive(!like);
icon_done.SetActive(like);
}
public void Init(long cursorId, string message, ClubService clubService)
{
btn_like.enabled = false;
this.cursorId = cursorId;
string[] str = message.Split('_');
playFabId = str[0];
int mapIndex = int.Parse(str[1]);
var data = GContext.container.Resolve<Tables>().TbMapData.DataList[mapIndex];
mapName = $"{mapIndex + 1}.{LocalizationMgr.GetText(data.Name_l10n_key)}";
multilingual = LocalizationMgr.GetText("UI_FishingSocialPanel_25");
if (playFabId == userService.UserId)
{
text_prompted.text = multilingual.SafeFormat(userService.DisplayName, mapName);
}
else
{
PlayInfo clubPlayInfo = userService.GetPlayInfo(playFabId);
if (clubPlayInfo != null)
{
text_prompted.text = multilingual.SafeFormat(clubPlayInfo.name, mapName);
}
}
this.clubService = clubService;
//点赞
SetLike();
}
async void SetLike()
{
(bool islike, int likeNum) = await clubService.GetLikeCount(cursorId);
if (!isEnable)
{
return;
}
num = likeNum;
text_num.text = likeNum.ToString();
SetBtnState(islike);
}
void SetAvatar(GetClubPlayInfoEvent getClubPlayInfoEvent)
{
if (getClubPlayInfoEvent.id == playFabId)
{
text_prompted.text = multilingual.SafeFormat(getClubPlayInfoEvent.name, mapName);
}
}
private void OnDestroy()
{
isEnable = false;
disposable?.Dispose();
disposable = null;
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 569c72d7faae53140a0a0cca8eaed680
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,166 @@
using asap.core;
using game;
using GameCore;
using System;
using System.Collections;
using System.Collections.Generic;
using TMPro;
using UniRx;
using UnityEngine;
using UnityEngine.UI;
public class ClubChooseHeirPopupPanel : MonoBehaviour
{
Button btn_close;
Button btn_sure;
public Transform content;
public GameObject contentPrefab;
ClubService clubService;
string selectId = "0";
List<HeirItem> heirItems = new List<HeirItem>();
HeirItem curHeirItem;
bool isEnable = true;
private void Awake()
{
clubService = GContext.container.Resolve<ClubService>();
btn_close = transform.Find("btn_close").GetComponent<Button>();
btn_sure = transform.Find("root/btn_sure/btn_green").GetComponent<Button>();
content = transform.Find("root/panel_list/ScrollView/Viewport/Content");
contentPrefab = transform.Find("root/panel_list/ScrollView/Viewport/Content/Item").gameObject;
contentPrefab.SetActive(false);
}
private void OnDestroy()
{
isEnable = false;
}
private void Start()
{
btn_sure.onClick.AddListener(OnSure);
btn_close.onClick.AddListener(ClosePanel);
btn_sure.gameObject.SetActive(false);
OnStart();
}
async void OnStart()
{
var datas = await GContext.container.Resolve<ClubService>().GetClubDetails(clubService.myClubInfo.id);
if (!isEnable)
{
return;
}
if (datas != null && datas.Count > 0)
{
IUserService userService = GContext.container.Resolve<IUserService>();
for (int i = 0; i < datas.Count; i++)
{
SocialInfoItemData clubPlayerInfoData = datas[i];
if (clubPlayerInfoData.playFabId == userService.UserId)
{
continue;
}
GameObject go = Instantiate(contentPrefab, content);
go.SetActive(true);
HeirItem HeirItem = go.AddComponent<HeirItem>();
HeirItem.OnClick = OnClickHeirItem;
HeirItem.SetData(clubPlayerInfoData);
heirItems.Add(HeirItem);
}
if (datas.Count > 1)
{
OnClickHeirItem(heirItems[0]);
}
}
btn_sure.gameObject.SetActive(true);
}
private void OnSure()
{
clubService.QuitClub(selectId);
ClosePanel();
}
void ClosePanel()
{
UIManager.Instance.DestroyUI(UITypes.ClubChooseHeirPopupPanel);
}
void OnClickHeirItem(HeirItem heir)
{
if (curHeirItem != null)
{
curHeirItem.SetSelect(false);
}
curHeirItem = heir;
curHeirItem.SetSelect(true);
selectId = heir.playFabId;
}
}
class HeirItem : MonoBehaviour
{
TMP_Text text_name;
Head head;
TMP_Text text_count;
Button btn_accept;
public string playFabId;
IDisposable disposable;
public Action<HeirItem> OnClick;
GameObject Checkmark;
private void Awake()
{
disposable = GContext.OnEvent<GetClubPlayInfoEvent>().Where(x => x.id == playFabId).Subscribe(SetAvatar);
btn_accept = transform.GetComponent<Button>();
text_name = transform.Find("text_name").GetComponent<TMP_Text>();
head = transform.Find("btn_head").GetComponent<Head>();
text_count = transform.Find("icon_rank/text_num").GetComponent<TMP_Text>();
Checkmark = transform.Find("btn_cherk/Ani_Container/Checkmark").gameObject;
SetSelect(false);
}
private void Start()
{
btn_accept.onClick.AddListener(() =>
{
OnClick?.Invoke(this);
});
}
public void SetSelect(bool active)
{
Checkmark.SetActive(active);
}
public void SetData(SocialInfoItemData data)
{
playFabId = data.playFabId;
IUserService userService = GContext.container.Resolve<IUserService>();
text_count.text = data.lv.ToString();
PlayInfo clubPlayInfo = userService.GetPlayInfo(playFabId);
if (clubPlayInfo != null)
{
text_name.text = clubPlayInfo.name;
head.SetData(clubPlayInfo.avatarUrl);
}
if (data.lv <= 1)
{
SetLv(data, userService);
}
}
async void SetLv(SocialInfoItemData curData, IUserService userService)
{
var (playId, lv) = await userService.GetPlayLv(playFabId);
curData.lv = lv;
if (playId == playFabId)
{
text_count.text = lv.ToString();
}
}
void SetAvatar(GetClubPlayInfoEvent getClubPlayInfoEvent)
{
if (getClubPlayInfoEvent.id == playFabId)
{
text_name.text = getClubPlayInfoEvent.name;
head.SetData(getClubPlayInfoEvent.avatarUrl);
}
}
private void OnDestroy()
{
playFabId = null;
disposable?.Dispose();
disposable = null;
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: be333813d0976da49ae7f1959ffc564f
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,213 @@
using asap.core;
using cfg;
using game;
using GameCore;
using TMPro;
using UnityEngine;
using UnityEngine.UI;
public class ClubCreatePopupPanel : MonoBehaviour
{
public Button btn_mask;
public Button btn_close;
public Button btn_head;
public ClubHead club_head;
public TMP_InputField inputField_name;
public TMP_InputField inputField_desc;
public Button btn_left_type;
public TMP_Text text_type;
public Button btn_right_type;
public Button btn_left_required;
public TMP_Text text_required;
public Button btn_right_required;
public Button btn_create;
TMP_Text text_create;
public Button btn_save;
public TMP_Text text_title;
int typeIndex = 0;
int requiredLv;
ClubSettingData curGroupSettingData;
string iconUrl;
int ClubCreationCashCost;
private void Awake()
{
btn_mask = transform.Find("mask").GetComponent<Button>();
btn_close = transform.Find("btn_close").GetComponent<Button>();
btn_head = transform.Find("root/btn_head").GetComponent<Button>();
club_head = transform.Find("root/btn_head").GetComponent<ClubHead>();
inputField_name = transform.Find("root/info/name/InputField_name").GetComponent<TMP_InputField>();
inputField_desc = transform.Find("root/info/description/InputField_description").GetComponent<TMP_InputField>();
btn_left_type = transform.Find("root/info/type/bg_type/btn_left").GetComponent<Button>();
text_type = transform.Find("root/info/type/bg_type/text").GetComponent<TMP_Text>();
btn_right_type = transform.Find("root/info/type/bg_type/btn_right").GetComponent<Button>();
btn_left_required = transform.Find("root/info/required/bg_grade/btn_left").GetComponent<Button>();
text_required = transform.Find("root/info/required/bg_grade/text").GetComponent<TMP_Text>();
btn_right_required = transform.Find("root/info/required/bg_grade/btn_right").GetComponent<Button>();
btn_create = transform.Find("root/btn_creat/btn_green").GetComponent<Button>();
text_create = transform.Find("root/btn_creat/btn_green/Ani_Container/content_cost/cost/p_text_num").GetComponent<TMP_Text>();
btn_save = transform.Find("root/btn_save/btn_green").GetComponent<Button>();
text_title = transform.Find("root/text_title").GetComponent<TMP_Text>();
}
private void Start()
{
ClubCreationCashCost = GContext.container.Resolve<Tables>().TbGlobalConfig.ClubCreationCashCost;
text_create.text = ClubCreationCashCost.ToString();
btn_mask.onClick.AddListener(OnClose);
btn_close.onClick.AddListener(OnClose);
btn_create.onClick.AddListener(OnCreate);
btn_save.onClick.AddListener(OnSave);
btn_left_type.onClick.AddListener(OnLeftType);
btn_right_type.onClick.AddListener(OnRightType);
btn_left_required.onClick.AddListener(OnLeftRequired);
btn_right_required.onClick.AddListener(OnRightRequired);
//设置字数限制
inputField_name.characterLimit = GContext.container.Resolve<Tables>().TbGlobalConfig.ClubNameMaxChar;
inputField_desc.characterLimit = GContext.container.Resolve<Tables>().TbGlobalConfig.ClubNoticeMaxChar;
btn_head.onClick.AddListener(OpenAvatarPanel);
//添加事件,当头像改变时,更新头像
}
private void OnEnable()
{
int id = GContext.container.Resolve<Tables>().TbGlobalConfig.ClubInitAvatar;
int frameId = GContext.container.Resolve<Tables>().TbGlobalConfig.ClubInitFrame;
iconUrl = string.Format("{0}#{1}",
GContext.container.Resolve<Tables>().TbClubAvatar[id].Avatar,
GContext.container.Resolve<Tables>().TbClubFrame[frameId].Frame);
btn_save.gameObject.SetActive(GContext.container.Resolve<ClubService>().IsClubJoined());
btn_create.gameObject.SetActive(!GContext.container.Resolve<ClubService>().IsClubJoined());
if (GContext.container.Resolve<ClubService>().IsClubJoined())
{
curGroupSettingData = GContext.container.Resolve<ClubService>().myClubInfo.clubSettingData;
inputField_name.text = curGroupSettingData.clubName;
inputField_desc.text = curGroupSettingData.description;
text_type.text = LocalizationMgr.GetText(((EClubType)curGroupSettingData.type).ToString());
text_required.text = curGroupSettingData.gradeReq.ToString();
typeIndex = curGroupSettingData.type;
text_title.text = LocalizationMgr.GetText("UI_ClubCreatePopupPanel_8");
if (curGroupSettingData != null && !string.IsNullOrEmpty(curGroupSettingData.icon))
{
iconUrl = curGroupSettingData.icon;
}
}
else
{
text_type.text = LocalizationMgr.GetText(((EClubType)typeIndex).ToString());
text_title.text = LocalizationMgr.GetText("UI_ClubCreatePopupPanel_1");
}
club_head.SetData(iconUrl);
}
void OnClose()
{
UIManager.Instance.DestroyUI(UITypes.ClubCreatePopupPanel);
}
async void OpenAvatarPanel()
{
var panel = await UIManager.Instance.ShowUI(UITypes.ClubHeadPopupPanel);
ClubHeadPopupPanel clubHeadPopupPanel = panel.GetComponent<ClubHeadPopupPanel>();
clubHeadPopupPanel.OnChange = ChangeAvatar;
}
void ChangeAvatar(string avatar)
{
iconUrl = avatar;
club_head.SetData(avatar);
}
async void OnCreate()
{
//判断消耗品是否足够
PlayerData playerData = GContext.container.Resolve<PlayerData>();
if (playerData.gold < (ulong)ClubCreationCashCost)
{
//int required = 100;
//GContext.Publish(new SetLackOfResourceEvent(5, required));
ToastPanel.Show(LocalizationMgr.GetText("UI_CampPanel_8"));
return;
}
ClubSettingData groupSettingData = NewClubSettingData();
if (groupSettingData == null)
{
return;
}
btn_create.enabled = false;
var Result = await GContext.container.Resolve<ClubService>().CreateClub(groupSettingData);
if (Result != null)
{
playerData.SetGold(playerData.gold - (ulong)ClubCreationCashCost);
ToastPanel.Show(LocalizationMgr.GetText("UI_ToastPanel_38"));
UIManager.Instance.DestroyUI(UITypes.ClubCreatePopupPanel);
}
else
{
btn_create.enabled = true;
}
}
async void OnSave()
{
ClubSettingData groupSettingData = NewClubSettingData();
if (groupSettingData == null)
{
return;
}
btn_save.enabled = false;
bool result = await GContext.container.Resolve<ClubService>().UpdateClub(groupSettingData);
if (result)
{
ToastPanel.Show(LocalizationMgr.GetText("UI_ToastPanel_36"));
}
UIManager.Instance.DestroyUI(UITypes.ClubCreatePopupPanel);
}
ClubSettingData NewClubSettingData()
{
string clubName = inputField_name.text;
string desc = inputField_desc.text;
EClubType type = (EClubType)typeIndex;
if (string.IsNullOrEmpty(clubName))
{
//TODO
ToastPanel.Show(LocalizationMgr.GetText("UI_ToastPanel_47"));
return null;
}
return new ClubSettingData { clubName = clubName, type = (int)type, gradeReq = requiredLv, description = desc, icon = iconUrl };
}
void OnLeftType()
{
typeIndex--;
if (typeIndex < 0)
{
typeIndex = (int)EClubType.UI_ClubCreatePopupPanel_13;
}
text_type.text = LocalizationMgr.GetText(((EClubType)typeIndex).ToString());
}
void OnRightType()
{
typeIndex++;
if (typeIndex > (int)EClubType.UI_ClubCreatePopupPanel_13)
{
typeIndex = 0;
}
text_type.text = LocalizationMgr.GetText(((EClubType)typeIndex).ToString());
}
void OnLeftRequired()
{
requiredLv -= 100;
if (requiredLv < 0)
{
requiredLv = 1000;
}
text_required.text = requiredLv.ToString();
}
void OnRightRequired()
{
requiredLv += 100;
if (requiredLv > 1000)
{
requiredLv = 0;
}
text_required.text = requiredLv.ToString();
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 2081f83e09d3bc740b77df7e3d025fb8
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,48 @@
using asap.core;
using cfg;
using UnityEngine;
using UnityEngine.UI;
public class ClubHead : MonoBehaviour
{
public Image bg_head;
public Image icon_head;
#if UNITY_EDITOR
private void Reset()
{
Awake();
}
#endif
private void Awake()
{
bg_head = transform.Find("bg_head").GetComponent<Image>();
icon_head = transform.Find("icon_head").GetComponent<Image>();
}
public void SetData(string avatars)
{
if (string.IsNullOrEmpty(avatars) || !avatars.Contains('#'))
{
int id = GContext.container.Resolve<Tables>().TbGlobalConfig.ClubInitAvatar;
int frameId = GContext.container.Resolve<Tables>().TbGlobalConfig.ClubInitFrame;
avatars = $"{GContext.container.Resolve<Tables>().TbClubAvatar[id].Avatar}#{GContext.container.Resolve<Tables>().TbClubFrame[frameId].Frame}";
}
string[] icon_frame = avatars.Split('#');
string avatar = icon_frame[0];
string frame = icon_frame[1];
GContext.container.Resolve<IUIService>().SetImageSprite(icon_head, avatar);
GContext.container.Resolve<IUIService>().SetImageSprite(bg_head, frame);
//GetSpriteEvent getSpriteEvent = new GetSpriteEvent(avatar);
//icon_head.sprite = getSpriteEvent.sprite;
}
public void SetIcon(string avatar)
{
GContext.container.Resolve<IUIService>().SetImageSprite(icon_head, avatar);
}
public void SetFrame(string frame)
{
GContext.container.Resolve<IUIService>().SetImageSprite(bg_head, frame);
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 17dab006f3afb134a8d40a484c0de6e9
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,166 @@
using asap.core;
using cfg;
using game;
using GameCore;
using System;
using System.Collections.Generic;
using TMPro;
using UnityEngine;
using UnityEngine.UI;
public class ClubHeadPopupPanel : MonoBehaviour
{
public Action<string> OnChange;
Button btn_close;
Button btn_mask;
Button btn_save;
ClubHead club_head;
TMP_Text text_title;
Transform iconContent;
Transform frameContent;
GameObject iconItem;
GameObject frameItem;
string iconUrl;
string frameUrl;
List<GameObject> iconSelecteds = new List<GameObject>();
List<GameObject> frameSelecteds = new List<GameObject>();
IUIService uIService;
List<ClubAvatar> avatars;
List<ClubFrame> frames;
int iconIndex;
int frameIndex;
private void Awake()
{
uIService = GContext.container.Resolve<IUIService>();
btn_close = transform.Find("btn_close").GetComponent<Button>();
btn_mask = transform.Find("mask").GetComponent<Button>();
btn_save = transform.Find("root/btn_save/btn_green").GetComponent<Button>();
club_head = transform.Find("root/btn_head").GetComponent<ClubHead>();
text_title = transform.Find("root/text_title").GetComponent<TMP_Text>();
iconContent = transform.Find("root/ScrollView1/Viewport/Content");
frameContent = transform.Find("root/ScrollView2/Viewport/Content");
iconItem = transform.Find("root/ScrollView1/Viewport/Content/icon").gameObject;
frameItem = transform.Find("root/ScrollView2/Viewport/Content/frame").gameObject;
iconItem.SetActive(false);
frameItem.SetActive(false);
}
private void Start()
{
btn_close.onClick.AddListener(OnClose);
btn_mask.onClick.AddListener(OnClose);
btn_save.onClick.AddListener(OnClickSave);
int id = GContext.container.Resolve<Tables>().TbGlobalConfig.ClubInitAvatar;
int frameId = GContext.container.Resolve<Tables>().TbGlobalConfig.ClubInitFrame;
iconUrl = GContext.container.Resolve<Tables>().TbClubAvatar[id].Avatar;
frameUrl = GContext.container.Resolve<Tables>().TbClubFrame[frameId].Frame;
if (GContext.container.Resolve<ClubService>().IsClubJoined())
{
var curGroupSettingData = GContext.container.Resolve<ClubService>().myClubInfo.clubSettingData;
text_title.text = LocalizationMgr.GetText("UI_ClubCreatePopupPanel_8");
if (curGroupSettingData != null && !string.IsNullOrEmpty(curGroupSettingData.icon))
{
var icon = curGroupSettingData.icon.Split('#');
iconUrl = icon[0];
frameUrl = icon[1];
}
}
else
{
text_title.text = LocalizationMgr.GetText("UI_ClubCreatePopupPanel_1");
}
SetScrollView();
club_head.SetIcon(iconUrl);
club_head.SetFrame(frameUrl);
}
void SetScrollView()
{
avatars = GContext.container.Resolve<Tables>().TbClubAvatar.DataList;
frames = GContext.container.Resolve<Tables>().TbClubFrame.DataList;
Image image;
GameObject select;
ClubAvatar avatar;
for (int i = 0; i < avatars.Count; i++)
{
int ii = i;
avatar = avatars[i];
var item = Instantiate(iconItem, iconContent);
item.SetActive(true);
image = item.transform.Find("icon").GetComponent<Image>();
uIService.SetImageSprite(image, avatar.Avatar);
select = item.transform.Find("selected").gameObject;
select.SetActive(avatar.Avatar == iconUrl);
if (avatar.Avatar == iconUrl)
{
iconIndex = ii;
}
iconSelecteds.Add(select);
item.GetComponent<Button>().onClick.AddListener(() =>
{
ChangeIcon(ii);
});
}
ClubFrame frame;
for (int i = 0; i < frames.Count; i++)
{
int ii = i;
frame = frames[i];
var item = Instantiate(frameItem, frameContent);
item.SetActive(true);
image = item.transform.Find("icon").GetComponent<Image>();
uIService.SetImageSprite(image, frame.Frame);
select = item.transform.Find("selected").gameObject;
select.SetActive(frame.Frame == frameUrl);
if (frame.Frame == frameUrl)
{
frameIndex = ii;
}
frameSelecteds.Add(select);
item.GetComponent<Button>().onClick.AddListener(() =>
{
ChangeFrame(ii);
});
}
}
void ChangeIcon(int index)
{
iconSelecteds[iconIndex].SetActive(false);
iconIndex = index;
iconSelecteds[iconIndex].SetActive(true);
iconUrl = avatars[index].Avatar;
club_head.SetIcon(iconUrl);
}
void ChangeFrame(int index)
{
frameSelecteds[frameIndex].SetActive(false);
frameIndex = index;
frameSelecteds[frameIndex].SetActive(true);
frameUrl = frames[index].Frame;
club_head.SetFrame(frameUrl);
}
async void OnClickSave()
{
btn_save.enabled = false;
string newAvatar = $"{iconUrl}#{frameUrl}";
OnChange?.Invoke(newAvatar);
OnClose();
if (GContext.container.Resolve<ClubService>().IsClubJoined())
{
ClubSettingData groupSettingData = GContext.container.Resolve<ClubService>().myClubInfo.clubSettingData;
if (newAvatar != groupSettingData.icon)
{
groupSettingData.icon = newAvatar;
bool result = await GContext.container.Resolve<ClubService>().UpdateClub(groupSettingData);
if (result)
{
ToastPanel.Show(LocalizationMgr.GetText("UI_ToastPanel_39"));
}
}
}
}
void OnClose()
{
UIManager.Instance.DestroyUI(UITypes.ClubHeadPopupPanel);
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 931eda62d4c8c1c4bbb1fbf58524a485
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,310 @@
using asap.core;
using game;
using GameCore;
using System.Collections.Generic;
using TMPro;
using UnityEngine;
using UnityEngine.UI;
using UniRx;
using System.Linq;
public class ClubInfoPopupPanel : MonoBehaviour
{
ClubService _socialData;
Button btn_close;
Button btn_mask;
Button btn_apply;
Button btn_apply_gray;
TMP_Text text_name;
TMP_Text text_desc;
TMP_Text text_country;
TMP_Text text_type;
TMP_Text text_required;
ClubHead icon_club;
TMP_Text text_people_num;
TMP_Text text_club_trophy;
GameObject item;
PanelScroll scrollRect;
GameObject club_info;
GameObject club_apply;
GameObject item_apply;
PanelScroll scrollRect_apply;
GameObject more_tips;
Button more_buttonClose;
Button btn_demote;
Button btn_promote;
Button btn_leave;
Button btn_kickout;
float itemHigh;
List<SocialInfoItemData> data;
SocialInfoItemData curSocialInfoItemData;
int dataCount;
bool isEnable = true;
private void Awake()
{
_socialData = GContext.container.Resolve<ClubService>();
btn_close = transform.Find("btn_close").GetComponent<Button>();
btn_mask = transform.Find("mask").GetComponent<Button>();
btn_apply = transform.Find("root/club_apply/btn_apply/btn_green").GetComponent<Button>();
btn_apply_gray = transform.Find("root/club_apply/btn_apply_gray/btn_green").GetComponent<Button>();
text_name = transform.Find("root/text_title").GetComponent<TMP_Text>();
text_desc = transform.Find("root/description/text").GetComponent<TMP_Text>();
text_country = transform.Find("root/head/country/text").GetComponent<TMP_Text>();
text_type = transform.Find("root/head/type/text").GetComponent<TMP_Text>();
text_required = transform.Find("root/head/required/text").GetComponent<TMP_Text>();
icon_club = transform.Find("root/head/btn_head").GetComponent<ClubHead>();
text_people_num = transform.Find("root/info/text_people_num").GetComponent<TMP_Text>();
text_club_trophy = transform.Find("root/info/text_club_trophy").GetComponent<TMP_Text>();
club_info = transform.Find("root/club_info").gameObject;
club_apply = transform.Find("root/club_apply").gameObject;
item = transform.Find("root/club_info/ScrollView/Viewport/Content/Item").gameObject;
item_apply = transform.Find("root/club_apply/ScrollView/Viewport/Content/Item").gameObject;
scrollRect = transform.Find("root/club_info/ScrollView").GetComponent<PanelScroll>();
scrollRect_apply = transform.Find("root/club_apply/ScrollView").GetComponent<PanelScroll>();
more_tips = transform.Find("root/more_tips").gameObject;
more_buttonClose = transform.Find("root/more_tips/ButtonClose").GetComponent<Button>();
btn_demote = transform.Find("root/more_tips/bg/btn_demote/btn_green_c").GetComponent<Button>();
btn_promote = transform.Find("root/more_tips/bg/btn_promote/btn_green_c").GetComponent<Button>();
btn_leave = transform.Find("root/more_tips/bg/btn_leave/btn_green_c").GetComponent<Button>();
btn_kickout = transform.Find("root/more_tips/bg/btn_kickout/btn_green_c").GetComponent<Button>();
GContext.OnEvent<ClubStateChangeEvent>().Subscribe(OnChangeJoinedState).AddTo(this);
}
private async void Start()
{
more_buttonClose.onClick.AddListener(() =>
{
more_tips.SetActive(false);
});
btn_leave.onClick.AddListener(OnClickLeave);
btn_kickout.onClick.AddListener(OnClickKickout);
btn_demote.onClick.AddListener(OnClickDemote);
btn_promote.onClick.AddListener(OnClickPromote);
btn_close.onClick.AddListener(Close);
btn_mask.onClick.AddListener(Close);
btn_apply.onClick.AddListener(OnClickApply);
btn_apply_gray.onClick.AddListener(() => ToastPanel.Show(LocalizationMgr.GetText("UI_ToastPanel_44")));
scrollRect.loop = false;
itemHigh = item.GetComponent<RectTransform>().sizeDelta.y;
item.SetActive(false);
item_apply.SetActive(false);
text_name.text = _socialData.ClubItemData.name;
bool descNull = string.IsNullOrEmpty(_socialData.ClubItemData.desc);
text_desc.text = descNull ? LocalizationMgr.GetText("UI_FishingSocialPanel_27") : _socialData.ClubItemData.desc;//
text_type.text = LocalizationMgr.GetText(_socialData.ClubItemData.type.ToString());
text_required.text = _socialData.ClubItemData.required.ToString();
text_people_num.text = $"{_socialData.ClubItemData.memberCount}/{_socialData.ClubItemData.memberLimit}";
text_club_trophy.text = _socialData.ClubItemData.trophy.ToString();
icon_club.SetData(_socialData.ClubItemData.icon);
bool joined = _socialData.IsClubJoined();
club_info.SetActive(joined);
club_apply.SetActive(!joined);
btn_apply.gameObject.SetActive(false);
btn_apply_gray.gameObject.SetActive(false);
data = await _socialData.GetClubDetails(_socialData.ClubItemData.id, !joined);
if (isEnable)
{
ShowPanel();
}
}
void ShowPanel()
{
bool joined = _socialData.IsClubJoined();
if (!joined)
{
btn_apply.gameObject.SetActive(!_socialData.ApplyState);
btn_apply_gray.gameObject.SetActive(_socialData.ApplyState);
}
if (data == null || data.Count == 0)
{
return;
}
bool showMore = joined && _socialData.CanAccepted && _socialData.ClubItemData.id == _socialData.myClubInfo.id;
IUserService userService = GContext.container.Resolve<IUserService>();
for (int i = 0; i < data.Count; i++)
{
bool isMore = showMore;
if (data[i].playFabId != userService.UserId)
{
if (_socialData.memberRole == EMemberRole.Vice)
{
isMore &= data[i].role == EMemberRole.Elder || data[i].role == EMemberRole.Member;
}
else if (_socialData.memberRole == EMemberRole.Elder)
{
isMore &= data[i].role == EMemberRole.Member;
}
}
data[i].showMore = isMore;
data[i].rank = i + 1;
}
if (joined)
{
scrollRect.Init<SocialInfoItem, SocialInfoItemData>(itemHigh, item, OnClickItem, data);
}
else
{
scrollRect_apply.Init<SocialInfoItem, SocialInfoItemData>(itemHigh, item_apply, OnClickItem, data);
}
}
public bool IsInClub(string playfabID)
{
if (data == null || data.Count < 1) return false;
foreach(var item in data)
{
if (item.playFabId.Equals(playfabID))
{
return true;
}
}
return false;
}
public void OnClickItem(SocialInfoItem memberItem)
{
curSocialInfoItemData = memberItem.data;
IUserService userService = GContext.container.Resolve<IUserService>();
//TODO
more_tips.transform.position = memberItem.btn_more.transform.position;
more_tips.SetActive(true);
btn_leave.transform.parent.gameObject.SetActive(curSocialInfoItemData.playFabId == userService.UserId);
bool iskickout = curSocialInfoItemData.playFabId != userService.UserId;/*_socialData.ClubItemData.id == _socialData.myClubInfo.id*/;
bool isPromote = false;
bool isDemote = false;
EMemberRole role = curSocialInfoItemData.role;
if (_socialData.memberRole == EMemberRole.Owner)
{
isDemote |= role == EMemberRole.Vice || role == EMemberRole.Elder;
isPromote |= role == EMemberRole.Elder || role == EMemberRole.Member;
}
else if (_socialData.memberRole == EMemberRole.Vice)
{
iskickout &= role == EMemberRole.Elder || role == EMemberRole.Member;
isDemote |= role == EMemberRole.Elder;
isPromote |= role == EMemberRole.Member;
}
else if (_socialData.memberRole == EMemberRole.Elder)
{
iskickout &= role == EMemberRole.Member;
}
btn_kickout.transform.parent.gameObject.SetActive(iskickout);
btn_promote.transform.parent.gameObject.SetActive(isPromote);
btn_demote.transform.parent.gameObject.SetActive(isDemote);
}
public async void OnClickApply()
{
//申请加入
if (GContext.container.Resolve<PlayerData>().lv < _socialData.ClubItemData.required)
{
//等级不够
ToastPanel.Show(LocalizationMgr.GetText("UI_ToastPanel_40"));
return;
}
btn_apply.gameObject.SetActive(false);
btn_apply_gray.gameObject.SetActive(true);
await _socialData.ApplyClub(_socialData.ClubItemData.id);
}
void OnChangeJoinedState(ClubStateChangeEvent stateData)
{
int state = stateData.state;
if (state == 0)
{
Close();
}
}
async void OnClickLeave()
{
await UIManager.Instance.ShowUI(UITypes.ClubQuitNoticePopupPanel);
more_tips.SetActive(false);
}
async void OnClickDemote()
{
//降职
more_tips.SetActive(false);
if (curSocialInfoItemData.role == EMemberRole.Vice || curSocialInfoItemData.role == EMemberRole.Elder)
{
GameObject go = await UIManager.Instance.ShowUI(UITypes.NoticeConfirmPopupPanel);
var NoticeConfirmPopupPanel = go.GetComponent<NoticeConfirmPopupPanel>();
string roleStr = "";
if (curSocialInfoItemData.role == EMemberRole.Vice)
{
roleStr = LocalizationMgr.GetText("UI_ClubInfoPopupPanel_3");
}
else if (curSocialInfoItemData.role == EMemberRole.Elder)
{
roleStr = LocalizationMgr.GetText("UI_ClubInfoPopupPanel_4");
}
IUserService userService = GContext.container.Resolve<IUserService>();
PlayInfo clubPlayInfo = userService.GetPlayInfo(curSocialInfoItemData.playFabId);
string info = LocalizationMgr.GetFormatTextValue("UI_ClubInfoPopupPanel_15", clubPlayInfo.name, roleStr);
string title = LocalizationMgr.GetText("UI_ClubInfoPopupPanel_7");
NoticeConfirmPopupPanel.Init(2, title, info, onClickRight: Demote, btn_left_text: LocalizationMgr.GetText("UI_COMMON_cancel"), btn_right_text: LocalizationMgr.GetText("UI_COMMON_confirm"));
}
}
void Demote()
{
ToastPanel.Show(LocalizationMgr.GetText("UI_ToastPanel_82"));
_socialData.Demote(curSocialInfoItemData.playFabId);
curSocialInfoItemData.role = EMemberRole.Member;
scrollRect.Refresh();
}
async void OnClickPromote()
{
//升职
more_tips.SetActive(false);
if (curSocialInfoItemData.role == EMemberRole.Member || curSocialInfoItemData.role == EMemberRole.Elder)
{
GameObject go = await UIManager.Instance.ShowUI(UITypes.ClubPromotePopupPanel);
var ClubPromotePopupPanel = go.GetComponent<ClubPromotePopupPanel>();
int elderCount = data.Count((x) => x.role == EMemberRole.Elder);
int viceCount = data.Count((x) => x.role == EMemberRole.Vice);
ClubPromotePopupPanel.Init(Promote, curSocialInfoItemData, elderCount, viceCount);
}
}
void Promote(EMemberRole role)
{
if (curSocialInfoItemData.role != role)
{
ToastPanel.Show(LocalizationMgr.GetText("UI_ToastPanel_82"));
_socialData.Promote(curSocialInfoItemData.playFabId, role);
curSocialInfoItemData.role = role;
scrollRect.Refresh();
}
}
async void OnClickKickout()
{
//踢出
more_tips.SetActive(false);
GameObject go = await UIManager.Instance.ShowUI(UITypes.NoticeConfirmPopupPanel);
var NoticeConfirmPopupPanel = go.GetComponent<NoticeConfirmPopupPanel>();
string info = LocalizationMgr.GetText("UI_FishingSocialPanel_34");
NoticeConfirmPopupPanel.Init(2,"", info, onClickRight: Kickout, btn_left_text: LocalizationMgr.GetText("UI_COMMON_cancel"), btn_right_text: LocalizationMgr.GetText("UI_COMMON_confirm"));
}
void Kickout()
{
_socialData.ClubItemData.memberCount--;
text_people_num.text = $"{_socialData.ClubItemData.memberCount}/{_socialData.ClubItemData.memberLimit}";
data.Remove(curSocialInfoItemData);
for (int i = 0; i < data.Count; i++)
{
data[i].rank = i + 1;
}
scrollRect.Init<SocialInfoItem, SocialInfoItemData>(itemHigh, item, OnClickItem, data);
_socialData.Kickout(curSocialInfoItemData.playFabId);
PlayInfo clubPlayInfo = GContext.container.Resolve<IUserService>().GetPlayInfo(curSocialInfoItemData.playFabId);
ToastPanel.Show(LocalizationMgr.GetFormatTextValue("UI_ToastPanel_73", clubPlayInfo.name));
}
void Close()
{
UIManager.Instance.DestroyUI(UITypes.ClubInfoPopupPanel);
}
private void OnDestroy()
{
isEnable = false;
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 2c4cb8bc9a69e1047ad5548fa0563710
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,36 @@
using GameCore;
using TMPro;
using UnityEngine.UI;
public class ClubItem : PanelItemBase<ClubItemData>
{
//public GameObject bg_myself;
public TMP_Text text_name;
public TMP_Text text_stage;
public ClubHead head;
public TMP_Text text_people_num;
public TMP_Text text_club_trophy;
public Button btn_click;
private void Awake()
{
//bg_myself = transform.Find("bg_myself").gameObject;
text_name = transform.Find("text_name").GetComponent<TMP_Text>();
text_stage = transform.Find("text_stage").GetComponent<TMP_Text>();
head = transform.Find("btn_head").GetComponent<ClubHead>();
text_people_num = transform.Find("info/text_people_num").GetComponent<TMP_Text>();
text_club_trophy = transform.Find("info/text_club_trophy").GetComponent<TMP_Text>();
btn_click = transform.GetComponent<Button>();
}
private void Start()
{
btn_click.onClick.AddListener(OnBtnItem);
}
public override void OnInit()
{
text_name.text = data.name;
text_stage.text = LocalizationMgr.GetText(data.type.ToString());
head.SetData(data.icon);
text_people_num.text = $"{data.memberCount}/{data.memberLimit}";
text_club_trophy.text = data.trophy.ToString();
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 3361c589918ce6842b0bc233c03d0221
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,57 @@
using asap.core;
using game;
using GameCore;
using System.Collections;
using System.Collections.Generic;
using TMPro;
using UnityEngine;
using UnityEngine.UI;
public class ClubPromoteNoticePopupPanel : MonoBehaviour
{
Button btn_close;
Button btn_promote;
TMP_Text text_tips;
GameObject leader_1;
GameObject leader_2;
GameObject leader_3;
private void Awake()
{
btn_close = transform.Find("btn_close").GetComponent<Button>();
text_tips = transform.Find("root/text_tips").GetComponent<TMP_Text>();
btn_promote = transform.Find("root/btn_promote/btn_green").GetComponent<Button>();
leader_1 = transform.Find("root/leader_1").gameObject;
leader_2 = transform.Find("root/leader_2").gameObject;
leader_3 = transform.Find("root/leader_3").gameObject;
}
private void Start()
{
btn_promote.onClick.AddListener(ClosePanel);
btn_close.onClick.AddListener(ClosePanel);
}
public void SetRole(EMemberRole role)
{
leader_1.SetActive(role == EMemberRole.Elder);
leader_2.SetActive(role == EMemberRole.Vice);
leader_3.SetActive(role == EMemberRole.Owner);
string roleStr = role.ToString();
if (role == EMemberRole.Owner)
{
roleStr = LocalizationMgr.GetText("UI_ClubInfoPopupPanel_2");
}
else if (role == EMemberRole.Vice)
{
roleStr = LocalizationMgr.GetText("UI_ClubInfoPopupPanel_3");
}
else if (role == EMemberRole.Elder)
{
roleStr = LocalizationMgr.GetText("UI_ClubInfoPopupPanel_4");
}
//UI_ClubInfoPopupPanel_14
text_tips.text = LocalizationMgr.GetFormatTextValue("UI_ClubInfoPopupPanel_14", roleStr);
}
void ClosePanel()
{
UIManager.Instance.DestroyUI(UITypes.ClubPromoteNoticePopupPanel);
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 549f5136074994643b01f3086add4fe9
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,99 @@
using asap.core;
using cfg;
using game;
using GameCore;
using System;
using TMPro;
using UnityEngine;
using UnityEngine.UI;
public class ClubPromotePopupPanel : MonoBehaviour
{
// 当剩余席位不足时按钮置灰点击弹toast提示UI_ToastPanel_80 剩余席位不足 Insufficient remaining seats
//当副会长没有权限任命副会长时按钮置灰点击弹toast提示UI_ToastPanel_81 您没有权限 You don't have permission
Action<EMemberRole> OnClickPromote;
TMP_Text text_remaining1;
TMP_Text text_remaining2;
Button btn_promote1;
Button btn_promote2;
Button btn_close;
Button btn_promote_gray1;
Button btn_promote_gray2;
SocialInfoItemData socialInfoItemData;
ClubService _socialData;
int allViceCount = 3;
int allElderCount = 6;
private void Awake()
{
_socialData = GContext.container.Resolve<ClubService>();
text_remaining1 = transform.Find("root/info1/text_remaining").GetComponent<TMP_Text>();
text_remaining2 = transform.Find("root/info2/text_remaining").GetComponent<TMP_Text>();
btn_promote1 = transform.Find("root/info1/btn_promote/btn_green").GetComponent<Button>();
btn_promote2 = transform.Find("root/info2/btn_promote/btn_green").GetComponent<Button>();
btn_close = transform.Find("btn_close").GetComponent<Button>();
btn_promote_gray1 = transform.Find("root/info1/btn_promote_gray/btn_green").GetComponent<Button>();
btn_promote_gray2 = transform.Find("root/info2/btn_promote_gray/btn_green").GetComponent<Button>();
allViceCount = GContext.container.Resolve<Tables>().TbGlobalConfig.ClubMaxCoLeaderCount;
allElderCount = GContext.container.Resolve<Tables>().TbGlobalConfig.ClubMaxElderCount;
}
private void Start()
{
btn_promote1.onClick.AddListener(OnClickPromote1);
btn_promote2.onClick.AddListener(OnClickPromote2);
btn_close.onClick.AddListener(OnClickClose);
btn_promote_gray1.onClick.AddListener(OnClickPromotegray1);
btn_promote_gray2.onClick.AddListener(OnClickPromotegray2);
}
public void Init(Action<EMemberRole> onClickPromote, SocialInfoItemData socialInfoItemData, int elderCount, int viceCount)
{
this.socialInfoItemData = socialInfoItemData;
OnClickPromote = onClickPromote;
btn_promote1.gameObject.SetActive(_socialData.memberRole == EMemberRole.Owner && viceCount < allViceCount);
btn_promote_gray1.gameObject.SetActive(_socialData.memberRole != EMemberRole.Owner || viceCount >= allViceCount);
text_remaining1.text = LocalizationMgr.GetFormatTextValue("UI_ClubInfoPopupPanel_12", viceCount, allViceCount);
btn_promote2.gameObject.SetActive(socialInfoItemData.role == EMemberRole.Member && elderCount < allElderCount);
btn_promote_gray2.gameObject.SetActive(socialInfoItemData.role != EMemberRole.Member || elderCount >= allElderCount);
text_remaining2.text = LocalizationMgr.GetFormatTextValue("UI_ClubInfoPopupPanel_12", elderCount, allElderCount);
}
void OnClickPromote1()
{
OnClickPromote?.Invoke(EMemberRole.Vice);
OnClickClose();
}
void OnClickPromote2()
{
OnClickPromote?.Invoke(EMemberRole.Elder);
OnClickClose();
}
void OnClickPromotegray1()
{
if (_socialData.memberRole == EMemberRole.Owner)
{
ToastPanel.Show(LocalizationMgr.GetText("UI_ToastPanel_80"));
}
else
{
ToastPanel.Show(LocalizationMgr.GetText("UI_ToastPanel_81"));
}
}
void OnClickPromotegray2()
{
if (socialInfoItemData.role == EMemberRole.Member)
{
ToastPanel.Show(LocalizationMgr.GetText("UI_ToastPanel_80"));
}
else
{
//用户已经是 长老 等待提示多语言
ToastPanel.Show(LocalizationMgr.GetText("UI_ToastPanel_81"));
}
}
void OnClickClose()
{
UIManager.Instance.DestroyUI(UITypes.ClubPromotePopupPanel);
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 8a21fefc0238dda43a5231a390e0a5ac
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,47 @@
using asap.core;
using game;
using GameCore;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class ClubQuitNoticePopupPanel : MonoBehaviour
{
Button btn_close;
Button btn_leave;
Button btn_choose;
ClubService clubService;
private void Awake()
{
btn_close = transform.Find("btn_close").GetComponent<Button>();
btn_leave = transform.Find("root/btn_leave/btn_green").GetComponent<Button>();
btn_choose = transform.Find("root/btn_choose/btn_green").GetComponent<Button>();
}
private void Start()
{
clubService = GContext.container.Resolve<ClubService>();
btn_leave.onClick.AddListener(OnLeave);
btn_choose.onClick.AddListener(OnChoose);
btn_close.onClick.AddListener(ClosePanel);
bool showChoose = clubService.memberRole == EMemberRole.Owner && clubService.myClubInfo.curMembers > 1;
btn_leave.gameObject.SetActive(!showChoose);
btn_choose.gameObject.SetActive(showChoose);
}
void OnLeave()
{
btn_leave.enabled = false;
clubService.QuitClub();
ClosePanel();
}
async void OnChoose()
{
btn_close.enabled = false;
ClosePanel();
await UIManager.Instance.ShowUI(UITypes.ClubChooseHeirPopupPanel);
}
void ClosePanel()
{
UIManager.Instance.DestroyUI(UITypes.ClubQuitNoticePopupPanel);
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: c531dea1505c3e34da5b7e2e4447685d
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,23 @@
using GameCore;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class FishingLeaderboardPanel : MonoBehaviour
{
Button btn_close;
SocialLeadboard leadboard;
private void Awake()
{
btn_close = transform.Find("root/btn_close").GetComponent<Button>();
leadboard = transform.Find("root/leaderboard").GetComponent<SocialLeadboard>();
}
private void Start()
{
btn_close.onClick.AddListener(() =>
{
UIManager.Instance.DestroyUI(UITypes.FishingLeaderboardPanel);
});
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 480ea0f22e756b541b2ccc2c4c99e9fc
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,197 @@
using asap.core;
using UniRx;
using game;
using GameCore;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class FishingSocialPanel : BasePanel
{
ClubService _socialData;
public Button btn_close;
List<Toggle> toggleList = new List<Toggle>();
List<GameObject> selected_tab = new List<GameObject>();
SocialFriends friends;
SocialLeadboard leaderboard;
GameObject clubOb;
SocialClubApplication clubApplication;
SocialClubJoined clubJoined;
private void Awake()
{
_socialData = GContext.container.Resolve<ClubService>();
btn_close = transform.Find("root/btn_close").GetComponent<Button>();
for (int i = 1; i <= 3; i++)
{
toggleList.Add(transform.Find($"root/tab/text_tab{i}").GetComponent<Toggle>());
selected_tab.Add(transform.Find($"root/tab/selected_tab{i}").gameObject);
}
friends = transform.Find("root/friends").GetComponent<SocialFriends>();
friends.InitUI();
leaderboard = transform.Find("root/leaderboard").GetComponent<SocialLeadboard>();
clubOb = transform.Find("root/club").gameObject;
clubApplication = transform.Find("root/club/club_application").GetComponent<SocialClubApplication>();
clubJoined = transform.Find("root/club/club_joined").GetComponent<SocialClubJoined>();
GContext.container.Resolve<GuideDataCenter>().InspectTriggerGuide("FishingSocialPanel");
}
protected override void Start()
{
base.Start();
GContext.OnEvent<ClubStateChangeEvent>().Subscribe(OnChangeJoinedState).AddTo(disposables);
GContext.OnEvent<SocialFriendListChangedData>().Subscribe(OnChangeFriendListData).AddTo(disposables);
clubOb.gameObject.SetActive(false);
friends.gameObject.SetActive(false);
leaderboard.gameObject.SetActive(false);
btn_close.onClick.AddListener(() =>
{
UIManager.Instance.DestroyUI(UITypes.FishingSocialFriendSearchPanel);
UIManager.Instance.DestroyUI(UITypes.FishingSocialPanel);
});
selected_tab[0].SetActive(false);
selected_tab[1].SetActive(false);
selected_tab[2].SetActive(false);
toggleList[0].onValueChanged.AddListener(OnToggleClub);
toggleList[1].onValueChanged.AddListener(OnToggleFriends);
toggleList[2].onValueChanged.AddListener(OnToggleLeaderboard);
OnToggle();
_socialData.GetSelfClub();
_socialData.SetOpenClubRed();
EventPopupData eventPopup = GContext.container.Resolve<ClubService>().eventPopupDataClub;
if (eventPopup != null && !eventPopup.IsRead)
{
eventPopup.IsRead = true;
_socialData.ReadClubEvent();
switch (eventPopup.redirectID)
{
case 1:
KickedOut();
break;
case 2:
KickedOutMaster();
break;
case 3:
case 4:
Promote(eventPopup.content);
break;
default:
break;
}
}
}
//玩家被踢出首次进入俱乐部打开提示弹窗:
// 您被会长踢出了俱乐部 You have been kicked out of the club by the club master
void KickedOut()
{
string info = LocalizationMgr.GetText("UI_FishingSocialPanel_35");
ShowTips(info);
}
//会长长时间不活跃被踢出后首次进入俱乐部打开提示弹窗:
//由于长时间不活跃,您已被踢出俱乐部,会长已自动移交给他人
//Due to inactivity, you have been kicked out of the club ,
//the club master has been automatically transferred
void KickedOutMaster()
{
string info = LocalizationMgr.GetText("UI_FishingSocialPanel_36");
ShowTips(info);
}
//由于前任会长不活跃被踢出,被转让会长身份的玩家首次进入俱乐部打开的提示弹窗:
//由于前任会长长时间不活跃,您已被任命成新的俱乐部会长
//Due to the inactivity of the previous club master, you have been appointed as the new club master
void BeenAppointed()
{
string info = LocalizationMgr.GetText("UI_FishingSocialPanel_37");
ShowTips(info);
}
//升职
void Promote(string content)
{
_socialData.ShowPromote();
}
async void ShowTips(string info)
{
GameObject go = await UIManager.Instance.ShowUI(UITypes.NoticeConfirmPopupPanel);
var NoticeConfirmPopupPanel = go.GetComponent<NoticeConfirmPopupPanel>();
NoticeConfirmPopupPanel.Init(1, "", info);
}
void OnToggle()
{
if (_socialData.OpenPanelType == 2)
{
selected_tab[3].SetActive(true);
toggleList[3].isOn = true;
OnToggleLeaderboard(true);
}
else if (_socialData.OpenPanelType == 1)
{
selected_tab[1].SetActive(true);
toggleList[1].isOn = true;
OnToggleFriends(true);
}
else
{
selected_tab[0].SetActive(true);
toggleList[0].isOn = true;
OnToggleClub(true);
}
}
void OnToggleClub(bool isOn)
{
selected_tab[0].SetActive(isOn);
clubOb.gameObject.SetActive(isOn);
if (isOn)
{
clubApplication.gameObject.SetActive(!_socialData.IsClubJoined());
clubJoined.gameObject.SetActive(_socialData.IsClubJoined());
}
}
void OnToggleFriends(bool isOn)
{
friends.gameObject.SetActive(isOn);
selected_tab[1].SetActive(isOn);
}
void OnToggleLeaderboard(bool isOn)
{
leaderboard.gameObject.SetActive(isOn);
selected_tab[2].SetActive(isOn);
}
void OnChangeFriendListData(SocialFriendListChangedData data)
{
if (friends == null) return;
friends.SetScroll();
}
void OnChangeJoinedState(ClubStateChangeEvent stateData)
{
int state = stateData.state;
if (state == 0)
{
clubApplication.gameObject.SetActive(!_socialData.IsClubJoined());
clubJoined.gameObject.SetActive(_socialData.IsClubJoined());
}
else
{
//加入公会之后的搜索和返回
clubApplication.gameObject.SetActive(state == 1);
clubJoined.gameObject.SetActive(state == 2);
}
}
private void OnDisable()
{
RestartShowHomeUIEvent restartShowHomeUIEvent = new RestartShowHomeUIEvent();
GContext.Publish(restartShowHomeUIEvent);
}
protected override void OnDestroy()
{
base.OnDestroy();
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 6868173a8eba0364fa87111eeef82166
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: cebdcc93fbc5eda42b09ec34bd3a1041
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View 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
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 6a7d84757b772e040a5ef262eb8c4ffe
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View 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);
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: f3ef5efb1f4ec0a418dba6b3b95267fa
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -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);
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: be9e3bc056bc87840a4173020887d959
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View 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);
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 14ed860181e85514fa59923a12e378b1
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View 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;
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 73a931db32b44ca4d92785e5d0bb0b8c
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -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;
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 09fa0a60ba04d9145b502da5e754efb8
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View 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
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 8ebe3e59f8b5eb94596001d0f33c402d
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,11 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace game
{
public class FriendInvitedItemTitleBar : FriendAddItem
{
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 14e9851ce9a0ff0449afe2c38ea2b92a
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View 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
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: da38abe9a04d7484a9c8729faf2bfa39
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -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
{
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: ee9761e8799b68c49a0d18af6a41ace1
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,24 @@
using asap.core;
using game;
public class ScocialReportPanel : ReportPopupPanel
{
private void Awake()
{
clubService = GContext.container.Resolve<ClubService>();
text_empty = transform.Find("empty").gameObject;
panelScroll = transform.Find("rank/ScrollView").gameObject;
eventReportPopupItem = transform.Find("rank/ScrollView/Viewport/Content/Item").gameObject;
Content = transform.Find("rank/ScrollView/Viewport/Content");
eventReportPopupItem.SetActive(false);
//SetH();
}
//赠送礼物
//void SetH()
//{
// RectTransform rectTransform = panelScroll.transform.GetComponent<RectTransform>();
// //Rect rect = rectTransform.rect;
// //rect.yMax = 1550;350
// rectTransform.offsetMin = new Vector2(0, 500);//350
//}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 1bc8cfdd896135a48b30c523d9789259
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,162 @@
using asap.core;
using game;
using GameCore;
using System.Collections.Generic;
using TMPro;
using UnityEngine;
using UnityEngine.UI;
public class SocialClubApplication : MonoBehaviour
{
ClubService _socialData;
public TMP_InputField inputField;
public Button btn_search;
public Button btn_delete;
public Button btn_refresh;
public Button btn_create;
public GameObject empty;
public GameObject loading;
public GameObject item;
public PanelScroll scrollRect;
public TMP_Text btn_name;
float itemHigh;
List<ClubItemData> itemDatas = new List<ClubItemData>();
private void Awake()
{
_socialData = GContext.container.Resolve<ClubService>();
inputField = transform.Find("InputField_name").GetComponent<TMP_InputField>();
btn_search = transform.Find("btn_search").GetComponent<Button>();
btn_delete = transform.Find("InputField_name/Text Area/Text/btn_delete").GetComponent<Button>();
btn_refresh = transform.Find("bg_recommened/btn_refresh").GetComponent<Button>();
btn_create = transform.Find("rank/btn_enter/btn_green").GetComponent<Button>();
empty = transform.Find("rank/empty").gameObject;
loading = transform.Find("rank/loading").gameObject;
item = transform.Find("rank/Item").gameObject;
scrollRect = transform.Find("rank/ScrollView").GetComponent<PanelScroll>();
btn_name = transform.Find("rank/btn_enter/btn_green/Ani_Container/p_text").GetComponent<TMP_Text>();
}
private void Start()
{
scrollRect.loop = false;
itemHigh = item.GetComponent<RectTransform>().sizeDelta.y;
item.SetActive(false);
btn_search.onClick.AddListener(OnSearch);
btn_delete.onClick.AddListener(OnDelete);
btn_refresh.onClick.AddListener(OnRefresh);
btn_create.onClick.AddListener(OnCreate);
inputField.onValueChanged.AddListener((str) =>
{
btn_delete.gameObject.SetActive(!string.IsNullOrEmpty(str));
});
}
void OnEnable()
{
loading.SetActive(true);
empty.SetActive(false);
scrollRect.gameObject.SetActive(false);
OnRefresh();
btn_name.text = _socialData.IsClubJoined() ? LocalizationMgr.GetText("UI_FishingSocialPanel_18") : LocalizationMgr.GetText("UI_FishingSocialPanel_17");
}
async void OnSearch()
{
string name = inputField.text;
if (string.IsNullOrEmpty(name))
{
return;
}
//搜索俱乐部
var group = await _socialData.GetClubs(name);
OnRefreshList(group);
}
void OnDelete()
{
inputField.text = "";
btn_delete.gameObject.SetActive(false);
OnRefresh();
}
async void OnRefresh()
{
var group = await _socialData.GetClubs("");
OnRefreshList(group);
}
void OnRefreshList(List<ClubInfo> clubInfos)
{
if (this == null || !enabled)
{
return;
}
itemDatas.Clear();
if (clubInfos != null)
{
foreach (var item in clubInfos)
{
ClubItemData data = new ClubItemData();
data.name = item.clubSettingData.clubName;
data.id = item.id;
data.icon = item.clubSettingData.icon;
data.desc = item.clubSettingData.description;
data.trophy = item.points;
data.memberCount = item.curMembers;
data.memberLimit = item.maxMembers;
data.type = (EClubType)item.clubSettingData.type;
data.required = item.clubSettingData.gradeReq;
itemDatas.Add(data);
}
}
loading.SetActive(false);
bool isShow = itemDatas.Count > 0;
//empty.SetActive(!isShow);
if (!isShow)
{
inputField.text = "";
ToastPanel.Show(LocalizationMgr.GetText("UI_ToastPanel_107"));
}
scrollRect.gameObject.SetActive(isShow);
if (isShow)
{
scrollRect.Init<ClubItem, ClubItemData>(itemHigh, item, OnClickItem, itemDatas);
}
}
bool isLoadClubInfoPopupPanel = false;
async void OnClickItem(ClubItem item)
{
if (isLoadClubInfoPopupPanel)
{
return;
}
isLoadClubInfoPopupPanel = true;
//俱乐部详情
_socialData.ClubItemData = item.data;
await UIManager.Instance.ShowUI(UITypes.ClubInfoPopupPanel);
isLoadClubInfoPopupPanel = false;
}
async void OnCreate()
{
btn_create.enabled = false;
if (_socialData.IsClubJoined())
{
//已经加入俱乐部
GContext.Publish(new ClubStateChangeEvent() { state = 2 });
}
else
{
//创建俱乐部窗口
await UIManager.Instance.ShowUI(UITypes.ClubCreatePopupPanel);
}
btn_create.enabled = true;
}
}
public class ClubItemData
{
public string name;
public ulong id;
public string icon;
public string desc;
public int trophy = 0;
public int memberCount = 0;
public int memberLimit = 10;
public EClubType type;
public int required;
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 1847b4cbe101bd74a88e14deb8595060
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,656 @@
using asap.core;
using cfg;
using game;
using GameCore;
using System;
using System.Collections.Generic;
using TMPro;
using UniRx;
using UnityEngine;
using UnityEngine.UI;
public class SocialClubJoined : MonoBehaviour
{
ClubService _socialData;
IChatService _chatService;
IUserService userService;
//public Button btn_head;
ClubHead clubHead;
GameObject sign_cd;
TMP_Text text_sign_cd;
Button btn_sign_cd;
public Button btn_sign;
public Button btn_more;
public TMP_Text text_name;
public Image icon_club;
public TMP_Text text_people_num;
public TMP_Text text_club_trophy;
public TMP_Text text_people_online;
public GameObject more_tips;
Button btn_more_close;
public Button btn_details;
public Button btn_apply;
public Button btn_settings;
public Button btn_search;
public Button btn_leave;
//聊天相关
GameObject chatEmpty;
ScrollRect scrollRect;
RectTransform chatContent;
RectTransform NextContent;
GameObject prompted;
GameObject prompted_like;
GameObject dialogue_left;
GameObject dialogue_right;
GameObject dialogue_emoji_left;
GameObject dialogue_emoji_right;
GameObject dialogue_help_left;
GameObject dialogue_help_right;
List<GameObject> chatItemList = new List<GameObject>();
TMP_InputField InputField_chat;
Button btn_help;
Button btn_help_gray;
TMP_Text text_time_help_gray;
Button btn_send;
Button btn_emoji;
GameObject emojio_tips;
protected IDisposable disposable;
IDisposable chatDisposable;
long lastId;
long cursorId;
long cursorUserID = -1;
bool isSame = false;
bool canNextpage = true;
public ulong id { get; set; }
private void Awake()
{
userService = GContext.container.Resolve<IUserService>();
_socialData = GContext.container.Resolve<ClubService>();
_chatService = GContext.container.Resolve<IChatService>();
//btn_head = transform.Find("head/btn_head").GetComponent<Button>();
clubHead = transform.Find("head/btn_head").GetComponent<ClubHead>();
sign_cd = transform.Find("head/sign_cd").gameObject;
text_sign_cd = transform.Find("head/sign_cd/text_time").GetComponent<TMP_Text>();
btn_sign_cd = transform.Find("head/sign_cd/btn_sign/btn_green_c").GetComponent<Button>();
btn_sign = transform.Find("head/btn_sign/btn_green_c").GetComponent<Button>();
btn_more = transform.Find("head/text_name/btn_more").GetComponent<Button>();
text_name = transform.Find("head/text_name").GetComponent<TMP_Text>();
icon_club = transform.Find("head/btn_head/icon_head").GetComponent<Image>();
text_people_num = transform.Find("head/info/text_people_num").GetComponent<TMP_Text>();
text_club_trophy = transform.Find("head/info/text_club_trophy").GetComponent<TMP_Text>();
text_people_online = transform.Find("head/info/text_people_online").GetComponent<TMP_Text>();
more_tips = transform.Find("more_tips").gameObject;
btn_more_close = transform.Find("more_tips/ButtonClose").GetComponent<Button>();
btn_details = transform.Find("more_tips/bg/btn_details").GetComponent<Button>();
btn_apply = transform.Find("more_tips/bg/btn_apply").GetComponent<Button>();
btn_settings = transform.Find("more_tips/bg/btn_setting").GetComponent<Button>();
btn_search = transform.Find("more_tips/bg/btn_search").GetComponent<Button>();
btn_leave = transform.Find("more_tips/bg/btn_leave").GetComponent<Button>();
chatEmpty = transform.Find("chat/empty").gameObject;
scrollRect = transform.Find("chat/ScrollView").GetComponent<ScrollRect>();
chatContent = transform.Find("chat/ScrollView/Viewport/Content").GetComponent<RectTransform>();
NextContent = transform.Find("chat/ScrollView/Viewport/Content/NextContent").GetComponent<RectTransform>();
prompted = transform.Find("chat/ScrollView/Viewport/Content/prompted").gameObject;
prompted_like = transform.Find("chat/ScrollView/Viewport/Content/prompted_like").gameObject;
dialogue_left = transform.Find("chat/ScrollView/Viewport/Content/dialogue_left").gameObject;
dialogue_emoji_left = transform.Find("chat/ScrollView/Viewport/Content/dialogue_emoji_left").gameObject;
dialogue_emoji_right = transform.Find("chat/ScrollView/Viewport/Content/dialogue_emoji_right").gameObject;
dialogue_right = transform.Find("chat/ScrollView/Viewport/Content/dialogue_right").gameObject;
dialogue_help_left = transform.Find("chat/ScrollView/Viewport/Content/dialogue_help_left").gameObject;
dialogue_help_right = transform.Find("chat/ScrollView/Viewport/Content/dialogue_help_right").gameObject;
InputField_chat = transform.Find("InputField_chat").GetComponent<TMP_InputField>();
btn_help = transform.Find("btn_help").GetComponent<Button>();
btn_help_gray = transform.Find("btn_help_gray").GetComponent<Button>();
text_time_help_gray = transform.Find("btn_help_gray/text_time").GetComponent<TMP_Text>();
btn_send = transform.Find("btn_send").GetComponent<Button>();
btn_emoji = transform.Find("btn_emoji").GetComponent<Button>();
emojio_tips = transform.Find("emoji_tips").gameObject;
}
private void Start()
{
btn_sign.onClick.AddListener(OnSign);
btn_sign_cd.onClick.AddListener(OnSignCD);
btn_more.onClick.AddListener(OnMore);
btn_details.onClick.AddListener(OnDetails);
btn_apply.onClick.AddListener(OnApply);
btn_settings.onClick.AddListener(OnSettings);
btn_search.onClick.AddListener(OnSearch);
btn_leave.onClick.AddListener(OnLeave);
btn_emoji.onClick.AddListener(OnClickEmoji);
btn_send.onClick.AddListener(Send);
scrollRect.onValueChanged.AddListener(OnValueChanged);
//if (_socialData.myClubInfo != null)
//{
// ChatChangeEvent();
//}
btn_more_close.onClick.AddListener(() =>
{
more_tips.SetActive(false);
});
btn_help.onClick.AddListener(SendHelpEnergy);
btn_help_gray.onClick.AddListener(ClickHelpEnergyGray);
}
private void OnEnable()
{
if (_socialData.myClubInfo != null)
{
_socialData.RefreshLureDonate();
SetChatContent(false);
if (id != _socialData.myClubInfo.id)
{
InitData();
}
id = _socialData.myClubInfo.id;
btn_apply.gameObject.SetActive(_socialData.CanAccepted);
btn_settings.gameObject.SetActive(_socialData.CanSetting);
text_name.text = _socialData.myClubInfo.clubSettingData.clubName;
text_people_num.text = $"{_socialData.myClubInfo.curMembers}/{_socialData.myClubInfo.maxMembers}";
text_club_trophy.text = _socialData.myClubInfo.points.ToString();
SetSignCD();
SetHelpCD();
clubHead.SetData(_socialData.myClubInfo.clubSettingData.icon);
SetOnLineCount();
if (_socialData.CanAccepted)
{
GContext.container.Resolve<ClubService>().GetApplyList();
}
else
{
RedPointManager.Instance.SetRedPointState(RedPointName.ApplyList, false);
}
ChatChangeEvent();
}
chatDisposable = GContext.OnEvent<ChatChangeEvent>().Subscribe(ChatChangeEvent);
disposable = GContext.OnEvent<ClubSttingUpdateEvent>().Subscribe(ClubSttingUpdate);
more_tips.SetActive(false);
}
void SetSignCD()
{
var timer = ZZTimeHelper.UtcNow().UtcNowOffset();
btn_sign.gameObject.SetActive(_socialData.signTime?.DayOfYear != timer.DayOfYear);
sign_cd.SetActive(_socialData.signTime?.DayOfYear == timer.DayOfYear);
if (_socialData.signTime?.DayOfYear == timer.DayOfYear)
{
StartTimer();
}
}
async void StartTimer()
{
DateTime now = ZZTimeHelper.UtcNow().UtcNowOffset().Date.AddDays(1);
TimeSpan timeSpan = now - ZZTimeHelper.UtcNow().UtcNowOffset();
text_sign_cd.text = ConvertTools.ConvertTime2(timeSpan.Days, timeSpan.Hours, timeSpan.Minutes, timeSpan.Seconds);
while (true)
{
await Awaiters.Seconds(1);
if (this == null || this.enabled == false)
{
return;
}
timeSpan = now - ZZTimeHelper.UtcNow().UtcNowOffset();
text_sign_cd.text = ConvertTools.ConvertTime2(timeSpan.Days, timeSpan.Hours, timeSpan.Minutes, timeSpan.Seconds);
if (timeSpan.TotalSeconds < 0)
{
SetSignCD();
return;
}
}
}
void SetHelpCD()
{
bool isGray = _socialData.ClubLureRequestCDEnd >= ZZTimeHelper.UtcNow().UtcNowOffset();
btn_help.gameObject.SetActive(!isGray);
btn_help_gray.gameObject.SetActive(isGray);
if (isGray)
{
StartHelpTimer();
}
}
async void StartHelpTimer()
{
TimeSpan timeSpan = _socialData.ClubLureRequestCDEnd - ZZTimeHelper.UtcNow().UtcNowOffset();
text_time_help_gray.text = ConvertTools.ConvertTime2(timeSpan);
while (true)
{
await Awaiters.Seconds(1);
if (this == null || this.enabled == false)
{
return;
}
timeSpan = _socialData.ClubLureRequestCDEnd - ZZTimeHelper.UtcNow().UtcNowOffset();
text_time_help_gray.text = ConvertTools.ConvertTime2(timeSpan);
if (timeSpan.TotalSeconds < 0)
{
SetHelpCD();
return;
}
}
}
void InitData()
{
for (int i = 0; i < chatItemList.Count; i++)
{
Destroy(chatItemList[i]);
}
chatItemList.Clear();
lastId = 0;
cursorId = 0;
cursorUserID = 0;
isSame = false;
canNextpage = true;
}
async void SetOnLineCount()
{
text_people_online.text = "1";
int count = await _socialData.GetOnlineUsers();
if (chatDisposable != null)
{
text_people_online.text = count.ToString();
}
}
void OnClickEmoji()
{
emojio_tips.SetActive(!emojio_tips.activeSelf);
}
void OnSign()
{
//签到
_socialData.ClubSingin();
SetSignCD();
}
void ClickHelpEnergyGray()
{
var curTime = ZZTimeHelper.UtcNow().UtcNowOffset();
var timer = _socialData.ClubLureRequestCDEnd - curTime;
ToastPanel.Show(LocalizationMgr.GetFormatTextValue("UI_ToastPanel_70", ConvertTools.ConvertTime2(timer)));
}
async void SendHelpEnergy()
{
btn_help.enabled = false;
//社交求助帖
bool resut = await _socialData.SendHelpEnergy();
if (resut)
{
SetHelpCD();
}
btn_help.enabled = true;
}
void OnSignCD()
{
ToastPanel.Show(LocalizationMgr.GetText("UI_ToastPanel_1"));
}
void OnMore()
{
more_tips.SetActive(true);
}
async void OnDetails()
{
more_tips.SetActive(false);
//btn_details.enabled = false;
//俱乐部详情
ClubItemData data = new ClubItemData();
data.name = _socialData.myClubInfo.clubSettingData.clubName;
data.id = _socialData.myClubInfo.id;
data.icon = _socialData.myClubInfo.clubSettingData.icon;
data.desc = _socialData.myClubInfo.clubSettingData.description;
data.trophy = _socialData.myClubInfo.points;
data.memberCount = _socialData.myClubInfo.curMembers;
data.memberLimit = _socialData.myClubInfo.maxMembers;
data.type = (EClubType)_socialData.myClubInfo.clubSettingData.type;
data.required = _socialData.myClubInfo.clubSettingData.gradeReq;
_socialData.ClubItemData = data;
await UIManager.Instance.ShowUI(UITypes.ClubInfoPopupPanel);
//btn_details.enabled = true;
}
async void OnApply()
{
more_tips.SetActive(false);
//申请列表
//btn_apply.enabled = false;
await UIManager.Instance.ShowUI(UITypes.ClubApplyPopupPanel);
//btn_apply.enabled = true;
}
async void OnSettings()
{
more_tips.SetActive(false);
//设置
//btn_settings.enabled = false;
await UIManager.Instance.ShowUI(UITypes.ClubCreatePopupPanel);
//btn_settings.enabled = true;
}
void OnSearch()
{
more_tips.SetActive(false);
GContext.Publish(new ClubStateChangeEvent() { state = 1 });
}
async void OnLeave()
{
more_tips.SetActive(false);
//离开
await UIManager.Instance.ShowUI(UITypes.ClubQuitNoticePopupPanel);
}
void ClubSttingUpdate(ClubSttingUpdateEvent data)
{
text_name.text = _socialData.myClubInfo.clubSettingData.clubName;
text_people_num.text = $"{_socialData.myClubInfo.curMembers}/{_socialData.myClubInfo.maxMembers}";
text_club_trophy.text = _socialData.myClubInfo.points.ToString();
clubHead.SetData(_socialData.myClubInfo.clubSettingData.icon);
}
void Send()
{
if (string.IsNullOrEmpty(InputField_chat.text))
{
ToastPanel.Show(LocalizationMgr.GetText("UI_ToastPanel_32"));
return;
}
_chatService.SendTxTMessage(InputField_chat.text);
InputField_chat.text = "";
}
void ChatChangeEvent(ChatChangeEvent chatChangeEvent = null)
{
ChatChatData chatChatData = _chatService.GetGroupChat();
List<ChatMessage> messageList = null;
if (chatChatData != null)
{
messageList = chatChatData.messageList;
}
if (messageList == null || messageList.Count == 0)
{
chatEmpty.SetActive(true);
scrollRect.gameObject.SetActive(false);
return;
}
chatEmpty.SetActive(false);
scrollRect.gameObject.SetActive(true);
if (chatChangeEvent != null && chatChangeEvent.nextContent)
{
NextChatChangeEvent(messageList);
}
else
{
AddChatChangeEvent(messageList, chatChangeEvent != null && chatChangeEvent.push);
}
}
void NextChatChangeEvent(List<ChatMessage> messageList)
{
if (messageList[0].cursorId < lastId)
{
SetChatContent(true);
for (int i = messageList.Count - 1; i >= 0; i--)
{
if (messageList[i].cursorId < lastId)
{
isSame = false;
if (i > 0)
{
var arr = _chatService.ParseChat(messageList[i - 1].message);
int typeInt;
if (arr.Length == 3)
{
int.TryParse(arr[1], out typeInt);
}
else
{
int.TryParse(arr[0], out typeInt);
}
ChatType type = (ChatType)typeInt;
switch (type)
{
case ChatType.Text:
case ChatType.Emoji:
isSame = messageList[i].fromUid == messageList[i - 1].fromUid;
break;
default:
break;
}
}
SetChatItem(messageList[i], NextContent);
}
}
}
}
/// <summary>
/// ChatContent 无感向上向下增加聊天内容做准备
/// </summary>
/// <param name="up"></param>
void SetChatContent(bool up)
{
Vector2 vector2 = chatContent.anchoredPosition;
float height = chatContent.rect.height;
var pivot = chatContent.pivot;
if (up && pivot.y > 0.5f)
{
chatContent.pivot = new Vector2(0, 0);
chatContent.anchoredPosition = new Vector2(0, vector2.y - height);
}
else if (!up && pivot.y < 0.5f)
{
chatContent.pivot = new Vector2(0, 1);
chatContent.anchoredPosition = new Vector2(0, vector2.y + height);
}
}
async void AddChatChangeEvent(List<ChatMessage> messageList, bool push)
{
if (messageList[^1].cursorId > cursorId)
{
SetChatContent(false);
for (int i = 0; i < messageList.Count; i++)
{
if (messageList[i].cursorId > cursorId)
{
isSame = messageList[i].fromUid == cursorUserID;
isSame = SetChatItem(messageList[i], chatContent);
cursorId = messageList[i].cursorId;
if (isSame)
{
cursorUserID = messageList[i].fromUid;
}
else
{
cursorUserID = -1;
}
}
}
//chatContent 拉到最下面(自己发送的消息才拉到最下面)
if (!push)
{
await Observable.NextFrame();
scrollRect.verticalNormalizedPosition = 0;
}
}
}
void OnValueChanged(Vector2 vector2)
{
if (scrollRect.verticalNormalizedPosition >= 1)
{
ChatChatData chatChatData = _chatService.GetGroupChat();
if (chatChatData != null && lastId != chatChatData.lastId && canNextpage)
{
canNextpage = false;
lastId = chatChatData.lastId;
SetCanNextPage();
}
}
}
async void SetCanNextPage()
{
_chatService.NextPage();
await Awaiters.Seconds(1);
canNextpage = true;
}
bool SetChatItem(ChatMessage chatMessage, Transform content)
{
string userID = _socialData.internalIdToPlayerId.GetValueOrDefault(chatMessage.fromUid);// .fromUid.ToString("X");
string chat = chatMessage.message;
//毫秒时间戳转时间
DateTime timeSpan = DateTimeOffset.FromUnixTimeMilliseconds(chatMessage.mtime).DateTime.ToLocalTime();// DateTime(messageList[i].mtime);
var arr = _chatService.ParseChat(chat);
int typeInt;
string message;
if (arr.Length == 3)
{
userID = arr[0];
int.TryParse(arr[1], out typeInt);
message = arr[2];
}
else
{
int.TryParse(arr[0], out typeInt);
message = arr[1];
}
ChatType type = (ChatType)typeInt;
bool _isSame = true;
if (string.IsNullOrEmpty(message))
{
return false;
}
switch (type)
{
case ChatType.Text:
if (string.IsNullOrEmpty(userID))
{
Debug.Log($"chatMessage.fromUid ==> internalId : {chatMessage.fromUid} chatMessage.message {chatMessage.message} Not");
return false;
}
SetDialogue(userID, message, timeSpan, content);
break;
case ChatType.System:
SetPrompted(message, content);
_isSame = false;
break;
case ChatType.System2:
SetPromptedLike(chatMessage.cursorId, message, content);
_isSame = false;
break;
//case ChatType.Help:
// SetHelp(userID, chatMessage.cursorId, message, timeSpan, content);
//break;
case ChatType.Emoji:
if (string.IsNullOrEmpty(userID))
{
Debug.Log($"chatMessage.fromUid ==> internalId : {chatMessage.fromUid} chatMessage.message {chatMessage.message} Not");
return false;
}
SetEmoji(userID, message, timeSpan, content);
break;
case ChatType.HelpEnergy:
if (string.IsNullOrEmpty(userID))
{
Debug.Log($"chatMessage.fromUid ==> internalId : {chatMessage.fromUid} chatMessage.message {chatMessage.message} Not");
return false;
}
var curTime = ZZTimeHelper.UtcNow().ToLocalTime();
if ((curTime - timeSpan).TotalHours < GContext.container.Resolve<cfg.Tables>().TbGlobalConfig.ClubLureRequestCd + 24)
HelpEnergy(userID, chatMessage.cursorId, message, timeSpan, content);
_isSame = false;
break;
default:
_isSame = false;
break;
}
return _isSame;
}
void ChatItemAdd(GameObject chatItem)
{
chatItem.SetActive(true);
chatItemList.Add(chatItem);
}
void SetPrompted(string message, Transform content)
{
var chatItem = Instantiate(prompted, content);
ChatItemAdd(chatItem);
Prompted promptedM = chatItem.GetComponent<Prompted>();
promptedM.Init(message);
}
void SetPromptedLike(long cursorId, string message, Transform content)
{
var chatItem = Instantiate(prompted_like, content);
ChatItemAdd(chatItem);
PromptedLike promptedLike = chatItem.GetComponent<PromptedLike>();
promptedLike.Init(cursorId, message, _socialData);
}
void SetDialogue(string userID, string message, DateTime timeSpan, Transform content)
{
GameObject chatItem;
if (userID == userService.UserId)
{
chatItem = Instantiate(dialogue_right, content);
}
else
{
chatItem = Instantiate(dialogue_left, content);
}
ChatItemAdd(chatItem);
DialogueLeft dialogueLeft = chatItem.GetComponent<DialogueLeft>();
dialogueLeft.Init(message, userID, timeSpan, isSame);
}
void HelpEnergy(string userID, long cursorId, string message, DateTime timeSpan, Transform content)
{
GameObject chatItem;
if (userID == userService.UserId)
{
chatItem = Instantiate(dialogue_help_right, content);
}
else
{
chatItem = Instantiate(dialogue_help_left, content);
}
ChatItemAdd(chatItem);
DialogueEnergyHelp dialogueHelp = chatItem.GetComponent<DialogueEnergyHelp>();
dialogueHelp.Init(userID, cursorId, message, timeSpan, isSame);
}
void SetHelp(string userID, long cursorId, string message, DateTime timeSpan, Transform content)
{
GameObject chatItem;
if (userID == userService.UserId)
{
chatItem = Instantiate(dialogue_help_right, content);
}
else
{
chatItem = Instantiate(dialogue_help_left, content);
}
ChatItemAdd(chatItem);
DialogueHelp dialogueHelp = chatItem.GetComponent<DialogueHelp>();
dialogueHelp.Init(userID, cursorId, message, timeSpan, isSame);
}
void SetEmoji(string userID, string message, DateTime timeSpan, Transform content)
{
GameObject chatItem;
if (userID == userService.UserId)
{
chatItem = Instantiate(dialogue_emoji_right, content);
}
else
{
chatItem = Instantiate(dialogue_emoji_left, content);
}
ChatItemAdd(chatItem);
DialogueEmoji dialogueEmojiLeft = chatItem.GetComponent<DialogueEmoji>();
dialogueEmojiLeft.Init(message, userID, timeSpan, isSame);
}
private void OnDisable()
{
disposable?.Dispose();
disposable = null;
chatDisposable?.Dispose();
chatDisposable = null;
}
private void OnDestroy()
{
_chatService.InitChatData();
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: ad898dfaf7e5c194395fa91305f2b16a
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,209 @@
using asap.core;
using GameCore;
using System;
using System.Collections;
using System.Collections.Generic;
using TMPro;
using UnityEngine;
using UnityEngine.UI;
namespace game
{
public class SocialClubPlayerTips : BasePanel
{
BFriendInfo m_FriendInfo;
#region UI
public Button ButtonClose;
public RectTransform tips_root;
public TMP_Text text_name;
public TMP_Text grade_text_num;
public GameObject icon_skyscraper;
public TMP_Text skyscraper_text_num;
public GameObject btn_add_root;
public Button btn_add;
public GameObject btn_add_gray_root;
public Button btn_add_gray;
public void SetData(Transform dockTransform, Vector2 offset, BFriendInfo friendInfo)
{
if (dockTransform == null || friendInfo == null) return;
m_FriendInfo = friendInfo;
tips_root.position = dockTransform.position + new Vector3(offset.x, offset.y, 0);
if (text_name != null)
{
if (string.IsNullOrEmpty(m_FriendInfo.DisplayName))
{
text_name.text = GContext.container.Resolve<game.IUserService>().GetDefaultName(m_FriendInfo.PlayFabId);
}
else
{
text_name.text = m_FriendInfo.DisplayName;
}
}
//int level = friendInfo.Level / LeadboardData.LV_MODELING;
//int infiniteBuildingLevel = friendInfo.Level % LeadboardData.LV_MODELING;
//if (grade_text_num != null)
//{
// grade_text_num.text = "" + level;
//}
//if (infiniteBuildingLevel > 0)
//{
// icon_skyscraper.SetActive(true);
// skyscraper_text_num.text = "" + infiniteBuildingLevel;
//}
//else
//{
// icon_skyscraper.SetActive(false);
//}
IUserService userService = GContext.container.Resolve<IUserService>();
if (userService != null && userService.UserId.Equals(m_FriendInfo.PlayFabId))
{
btn_add_root.SetActive(false);
btn_add_gray_root.SetActive(false);
icon_skyscraper.SetActive(false);
if (grade_text_num != null)
{
grade_text_num.text = "" + GContext.container.Resolve<PlayerData>().lv;
}
this.gameObject.SetActive(true);
}
else
{
btn_add_root.SetActive(false);
btn_add_gray_root.SetActive(false);
bool isFriend = GContext.container.Resolve<FriendService>().IsFriend(m_FriendInfo.PlayFabId);
if (isFriend)
{
this.gameObject.SetActive(true);
}
else
{
IsFriendWaitingForAccept();
}
SetLv(m_FriendInfo.PlayFabId);
}
tips_root.gameObject.SetActive(true);
}
private async void IsFriendWaitingForAccept()
{
if (m_FriendInfo == null || string.IsNullOrEmpty(m_FriendInfo.PlayFabId)) return;
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;
this.gameObject.SetActive(true);
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);
}
}
public async void SetLv(string playFabId)
{
icon_skyscraper.SetActive(false);
var (playId, lv) = await GContext.container.Resolve<IUserService>().GetPlayLv(playFabId);
if (grade_text_num != null)
{
grade_text_num.text = "" + lv;
}
//if (infiniteBuildingLevel > 0)
//{
// icon_skyscraper.SetActive(true);
// skyscraper_text_num.text = "" + infiniteBuildingLevel;
//}
//else
//{
// icon_skyscraper.SetActive(false);
//}
}
#endregion
#region
protected override void Start()
{
base.Start();
if (ButtonClose != null)
{
ButtonClose.onClick.RemoveAllListeners();
ButtonClose.onClick.AddListener(OnBtnCloseClickListener);
}
if (btn_add != null)
{
btn_add.onClick.RemoveAllListeners();
btn_add.onClick.AddListener(OnBtnAddClickListener);
}
if (btn_add_gray != null)
{
btn_add_gray.onClick.RemoveAllListeners();
btn_add_gray.onClick.AddListener(OnBtnAddGrayClickListener);
}
tips_root.gameObject.SetActive(false);
this.gameObject.SetActive(false);
}
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);
UIManager.Instance.DestroyUI(UITypes.SocialClubPlayerTips);
}
private void OnBtnCloseClickListener()
{
UIManager.Instance.DestroyUI(UITypes.SocialClubPlayerTips);
}
#endregion
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 1ed222be00fbf0441b32a395eaf518f0
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,83 @@
using asap.core;
using game;
using System.Collections.Generic;
using TMPro;
using UnityEngine;
public class SocialFriendItem : PanelItemBase<SocialFriendItemData>
{
public GameObject bg_myself;
List<GameObject> rank = new List<GameObject>();
public TMP_Text text_rank;
public TMP_Text text_name;
public Head head;
public TMP_Text lv_text_count;
public TMP_Text infiniteBuildingLevel_text_count;
public GameObject icon_skyscraper;
string playFabId;
bool isInit;
void InitPanel()
{
bg_myself = transform.Find("bg_myself").gameObject;
text_rank = transform.Find("rank/rank/text_rank").GetComponent<TMP_Text>();
text_name = transform.Find("text_name").GetComponent<TMP_Text>();
head = transform.Find("btn_head").GetComponent<Head>();
//reward_panel = transform.Find("reward_panel").gameObject;
lv_text_count = transform.Find("icon_rank/text_num").GetComponent<TMP_Text>();
infiniteBuildingLevel_text_count = transform.Find("icon_skyscraper/text_num").GetComponent<TMP_Text>();
icon_skyscraper = transform.Find("icon_skyscraper").gameObject;
Transform rank_panel = transform.Find("rank");
rank.Clear();
for (int i = 0; i < rank_panel.childCount; i++)
{
rank.Add(rank_panel.GetChild(i).gameObject);
}
isInit = true;
}
public override void OnInit()
{
if (!isInit)
{
InitPanel();
}
IUserService userService = GContext.container.Resolve<IUserService>();
playFabId = data.playFabId;
bg_myself.SetActive(data.playFabId == userService.UserId);
for (int i = 0; i < rank.Count - 1; i++)
{
rank[i].SetActive(data.rank == i + 1);
}
rank[^1].SetActive(data.rank >= rank.Count);
text_rank.text = data.rank.ToString();
lv_text_count.text = data.lv.ToString();
infiniteBuildingLevel_text_count.text = data.infiniteBuildingLevel.ToString();
if (data.infiniteBuildingLevel > 0)
{
if (icon_skyscraper != null)
{
icon_skyscraper.SetActive(true);
}
}
else
{
if (icon_skyscraper != null)
{
icon_skyscraper.SetActive(false);
}
}
text_name.text = data.displayName;
head.SetData(data.avatarUrl);
}
}
public class SocialFriendItemData
{
public int rank;
public int lv = 1;
public int infiniteBuildingLevel = 0;
public string playFabId;
public string displayName;
public string avatarUrl;
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 3ca6342e1ed43dd4ba890ff6c02afe7b
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,147 @@
using asap.core;
using game;
using GameCore;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class SocialFriends : MonoBehaviour
{
List<Toggle> toggleList = new List<Toggle>();
List<GameObject> selected_tab = new List<GameObject>();
FishingFriendAddPanel addfriends;
GameObject addfriendsOb;
GameObject listOb;
GameObject timelineOb;
#region
//Button btn_event;
#endregion
#region
public GameObject item;
public PanelScroll scrollRect;
GameObject empty;
float itemHigh;
public int curSelfRank;
SocialFriendItem selfItem;
Button btn_add;
#endregion
public void InitUI()
{
for (int i = 1; i <= 3; i++)
{
toggleList.Add(transform.Find($"tab/text_tab{i}").GetComponent<Toggle>());
selected_tab.Add(transform.Find($"tab/selected_tab{i}").gameObject);
}
addfriendsOb = transform.Find("addfriends").gameObject;
listOb = transform.Find("list").gameObject;
timelineOb = transform.Find("timeline").gameObject;
//btn_event = transform.Find("btn_event").GetComponent<Button>();
empty = transform.Find("list/empty").gameObject;
btn_add = transform.Find("list/empty/btn_add/btn_green").GetComponent<Button>();
scrollRect = transform.Find("list/rank/ScrollView").GetComponent<PanelScroll>();
item = transform.Find("list/rank/ScrollView/Viewport/Content/Item").gameObject;
selfItem = transform.Find("list/rank/ScrollView/Viewport/Item").GetComponent<SocialFriendItem>();
itemHigh = item.GetComponent<RectTransform>().sizeDelta.y;
scrollRect.loop = false;
}
private void Start()
{
//btn_event.onClick.AddListener(OnEventClick);
btn_add.onClick.AddListener(OnAddClick);
SetScroll();
selected_tab[0].SetActive(true);
selected_tab[1].SetActive(false);
selected_tab[2].SetActive(false);
toggleList[0].onValueChanged.AddListener(OnToggleAddFriends);
toggleList[1].onValueChanged.AddListener(OnToggleList);
toggleList[2].onValueChanged.AddListener(OnToggleTimeLine);
toggleList[0].isOn = true;
OnToggleAddFriends(true);
}
void OnToggleAddFriends(bool isOn)
{
addfriendsOb.SetActive(isOn);
selected_tab[0].SetActive(isOn);
}
void OnToggleList(bool isOn)
{
listOb.SetActive(isOn);
selected_tab[1].SetActive(isOn);
}
void OnToggleTimeLine(bool isOn)
{
timelineOb.SetActive(isOn);
selected_tab[2].SetActive(isOn);
}
public void SetScroll()
{
curSelfRank = -1;
var friendList = new List<SocialFriendItemData>();
var LeadboardDataList = GContext.container.Resolve<FriendService>().FriendList;
for (int i = 0; i < LeadboardDataList.Count; i++)
{
friendList.Add(new SocialFriendItemData()
{
rank = LeadboardDataList[i].rank,
lv = LeadboardDataList[i].value / LeadboardData.LV_MODELING,
infiniteBuildingLevel = LeadboardDataList[i].value % LeadboardData.LV_MODELING,
playFabId = LeadboardDataList[i].playFabId,
displayName = LeadboardDataList[i].displayName,
avatarUrl = LeadboardDataList[i].avatarUrl
});
}
empty.SetActive(friendList.Count == 0);
for (int i = 0; i < friendList.Count; i++)
{
if (friendList[i].playFabId == GContext.container.Resolve<IUserService>().UserId)
{
curSelfRank = i;
selfItem.data = friendList[i];
break;
}
}
scrollRect.Init<SocialFriendItem, SocialFriendItemData>(itemHigh, item, null, friendList);
SetSelfItem();
}
void SetSelfItem()
{
if (curSelfRank >= 0)
{
float selfPos = itemHigh * curSelfRank - scrollRect.viewport.rect.height + itemHigh;
selfItem.gameObject.SetActive(scrollRect.content.anchoredPosition.y < selfPos);
selfItem.OnInit();
scrollRect.onValueChanged.AddListener((Vector2 v2) =>
{
selfItem.gameObject.SetActive(scrollRect.content.anchoredPosition.y < selfPos);
});
}
else
{
selfItem.gameObject.SetActive(false);
}
}
async void OnEventClick()
{
await UIManager.Instance.ShowUI(UITypes.EventReportPopupPanel);
}
async void OnAddClick()
{
await UIManager.Instance.ShowUI(UITypes.FishingSocialFriendSearchPanel);
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 66b2a7b9c460d1b408bebedf15dd58de
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,198 @@
using asap.core;
using cfg;
using game;
using GameCore;
using System;
using System.Collections.Generic;
using TMPro;
using UniRx;
using UnityEngine;
using UnityEngine.UI;
public class SocialInfoItem : PanelItemBase<SocialInfoItemData>
{
public GameObject bg_myself;
List<GameObject> rank = new List<GameObject>();
public TMP_Text text_rank;
public TMP_Text text_name;
public TMP_Text text_time;
public Head head;
public Button btn_more;
GameObject icon_leader1;
GameObject icon_leader2;
GameObject icon_leader3;
public TMP_Text text_count;
public Button btn_head;
public Transform tips_dock_trans;
public Vector2 tips_dock_offset = Vector2.zero;
string playFabId;
IDisposable disposable;
private void Awake()
{
disposable = GContext.OnEvent<GetClubPlayInfoEvent>().Where(x => x.id == playFabId).Subscribe(SetAvatar);
bg_myself = transform.Find("bg_myself").gameObject;
text_rank = transform.Find("rank/rank/text_rank").GetComponent<TMP_Text>();
text_name = transform.Find("text_name").GetComponent<TMP_Text>();
text_time = transform.Find("text_time").GetComponent<TMP_Text>();
head = transform.Find("btn_head").GetComponent<Head>();
icon_leader1 = transform.Find("btn_head/leader_1").gameObject;
icon_leader2 = transform.Find("btn_head/leader_2").gameObject;
icon_leader3 = transform.Find("btn_head/leader_3").gameObject;
btn_more = transform.Find("btn_more").GetComponent<Button>();
btn_more.onClick.AddListener(OnBtnItem);
//reward_panel = transform.Find("reward_panel").gameObject;
text_count = transform.Find("icon_rank/text_num").GetComponent<TMP_Text>();
Transform rank_panel = transform.Find("rank");
for (int i = 0; i < rank_panel.childCount; i++)
{
rank.Add(rank_panel.GetChild(i).gameObject);
}
btn_head = transform.Find("btn_head").GetComponent<Button>();
if (btn_head != null)
{
btn_head.onClick.RemoveAllListeners();
btn_head.onClick.AddListener(OnBtnHeadClickListener);
}
}
public async void OnBtnHeadClickListener()
{
if (data == null || !GContext.container.Resolve<ClubService>().IsClubJoined()) return;
var clubInfoPopupPanelNode = UIManager.Instance.GetContainedUI(UITypes.ClubInfoPopupPanel);
if (clubInfoPopupPanelNode == null) return;
var clubInfoPopupPanel = clubInfoPopupPanelNode.GetComponent<ClubInfoPopupPanel>();
if (clubInfoPopupPanel == null) return;
IUserService userService = GContext.container.Resolve<IUserService>();
bool isInClub = clubInfoPopupPanel.IsInClub(userService.UserId);
if (!isInClub) return;
GameObject go = await UIManager.Instance.ShowUI(UITypes.SocialClubPlayerTips);
if (go == null) return;
PlayInfo clubPlayInfo = userService.GetPlayInfo(playFabId);
if (clubPlayInfo == null)
{
return;
}
BFriendInfo friendInfo = new BFriendInfo()
{
PlayFabId = data.playFabId,
DisplayName = clubPlayInfo.name,
AvatarUrl = clubPlayInfo.avatarUrl,
Level = data.lv
};
SocialClubPlayerTips tips = go.GetComponent<SocialClubPlayerTips>();
tips.SetData(tips_dock_trans, tips_dock_offset, friendInfo);
}
string ConvertTime2(int d, int h, int m, int s)
{
if (d > 0)
{
return $"{d}d";
}
if (h > 0)
{
return $"{h}h";
}
if (m > 0)
{
return $"{m}m";
}
return $"{s}s";
}
public override void OnInit()
{
IUserService userService = GContext.container.Resolve<IUserService>();
playFabId = data.playFabId;
bg_myself.SetActive(data.playFabId == userService.UserId);
icon_leader1.SetActive(data.role == EMemberRole.Elder);
icon_leader2.SetActive(data.role == EMemberRole.Vice);
icon_leader3.SetActive(data.role == EMemberRole.Owner);
btn_more.gameObject.SetActive(data.showMore);
if (data.isOnline)
{
text_time.text = LocalizationMgr.GetText("UI_FishingSocialPanel_32");
}
else
{
int ClubMaxRecentActiveTime = GContext.container.Resolve<Tables>().TbGlobalConfig.ClubMaxRecentActiveTime;
DateTime dateTime = ZZTimeHelper.UtcNow();
var now = dateTime - data.lastLoginTime;
int days = now.Days;
if (days >= ClubMaxRecentActiveTime)
{
days = ClubMaxRecentActiveTime;
}
text_time.text = LocalizationMgr.GetFormatTextValue("UI_FishingSocialPanel_33",
ConvertTime2(days, now.Hours, now.Minutes, now.Seconds));
}
for (int i = 0; i < rank.Count - 1; i++)
{
rank[i].SetActive(data.rank == i + 1);
}
rank[^1].SetActive(data.rank >= rank.Count);
text_rank.text = data.rank.ToString();
if (data.playFabId == userService.UserId)
{
text_name.text = userService.DisplayName;
head.SetData(userService.AvatarUrl);
text_count.text = GContext.container.Resolve<PlayerData>().lv.ToString();
}
else
{
text_count.text = data.lv.ToString();
PlayInfo clubPlayInfo = userService.GetPlayInfo(playFabId);
if (clubPlayInfo != null)
{
text_name.text = clubPlayInfo.name;
head.SetData(clubPlayInfo.avatarUrl);
}
if (data.lv <= 1)
{
SetLv(data, userService);
}
}
}
async void SetLv(SocialInfoItemData curData, IUserService userService)
{
var (playId, lv) = await userService.GetPlayLv(playFabId);
curData.lv = lv;
if (playId == playFabId)
{
text_count.text = lv.ToString();
}
}
void SetAvatar(GetClubPlayInfoEvent getClubPlayInfoEvent)
{
if (getClubPlayInfoEvent.id == playFabId)
{
text_name.text = getClubPlayInfoEvent.name;
head.SetData(getClubPlayInfoEvent.avatarUrl);
}
}
private void OnDestroy()
{
disposable?.Dispose();
disposable = null;
}
}
public class SocialInfoItemData
{
public int rank;
public int lv = 1;
//public string entityKey;
public string playFabId;
public string displayName;
public string avatarUrl;
public bool isOnline;
public EMemberRole role;
public bool showMore;
//最后登录时间
public DateTime lastLoginTime;
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 2ba47283d57dc1a488de5aeddc5c7ced
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,140 @@
using asap.core;
using game;
using GameCore;
using System;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using UniRx;
public class SocialLeadboard : MonoBehaviour
{
LeadboardData _leadboardData;
List<Toggle> toggleList = new List<Toggle>();
List<GameObject> selected_tab = new List<GameObject>();
public GameObject item;
public PanelScroll scrollRect;
float itemHigh;
public int curSelfRank;
SocialLeadboardItem selfItem;
IDisposable disposable;
private void Awake()
{
_leadboardData = GContext.container.Resolve<LeadboardData>();
scrollRect = transform.Find("rank/ScrollView").GetComponent<PanelScroll>();
item = transform.Find("rank/ScrollView/Viewport/Content/Item").gameObject;
selfItem = transform.Find("rank/ScrollView/Viewport/Item").GetComponent<SocialLeadboardItem>();
for (int i = 1; i <= 2; i++)
{
toggleList.Add(transform.Find($"tab/text_tab{i}").GetComponent<Toggle>());
selected_tab.Add(transform.Find($"tab/selected_tab{i}").gameObject);
}
itemHigh = item.GetComponent<RectTransform>().sizeDelta.y;
toggleList[0].isOn = true;
toggleList[1].isOn = false;
scrollRect.loop = false;
}
private void Start()
{
toggleList[0].onValueChanged.AddListener(Global);
toggleList[1].onValueChanged.AddListener(Locals);
//SetScroll();
}
private void OnEnable()
{
disposable = GContext.OnEvent<PFRankDataEvent>().Subscribe((data) =>
{
if (!data.isLocal && toggleList[0].isOn)
{
SetScroll();
}
else if (data.isLocal && toggleList[1].isOn)
{
SetLocalScroll();
}
});
selected_tab[0].SetActive(toggleList[0].isOn);
selected_tab[1].SetActive(toggleList[1].isOn);
if (toggleList[0].isOn)
{
Global(true);
}
else
{
Locals(true);
}
}
//void OnClickItem(SocialLeadboardItem item)
//{
//}
void SetScroll()
{
curSelfRank = -1;
for (int i = 0; i < _leadboardData.LeadboardDataList.Count; i++)
{
if (_leadboardData.LeadboardDataList[i].playFabId == GContext.container.Resolve<IUserService>().UserId)
{
curSelfRank = i;
selfItem.data = _leadboardData.LeadboardDataList[i];
break;
}
}
scrollRect.Init<SocialLeadboardItem, LeadboardItemData>(itemHigh, item, null, _leadboardData.LeadboardDataList);
SetSelfItem();
}
void SetSelfItem()
{
if (curSelfRank >= 0)
{
float selfPos = itemHigh * curSelfRank - scrollRect.viewport.rect.height + itemHigh;
selfItem.gameObject.SetActive(scrollRect.content.anchoredPosition.y < selfPos);
selfItem.OnInit();
scrollRect.onValueChanged.AddListener((Vector2 v2) =>
{
selfItem.gameObject.SetActive(scrollRect.content.anchoredPosition.y < selfPos);
});
}
else
{
selfItem.gameObject.SetActive(false);
}
}
void Global(bool isOn)
{
selected_tab[0].SetActive(isOn);
if (isOn)
{
SetScroll();
}
}
void Locals(bool isOn)
{
selected_tab[1].SetActive(isOn);
if (isOn)
{
SetLocalScroll();
}
}
void SetLocalScroll()
{
curSelfRank = -1;
for (int i = 0; i < _leadboardData.LeadboardContinentDataList.Count; i++)
{
if (_leadboardData.LeadboardContinentDataList[i].playFabId == GContext.container.Resolve<IUserService>().UserId)
{
curSelfRank = i;
selfItem.data = _leadboardData.LeadboardContinentDataList[i];
break;
}
}
scrollRect.Init<SocialLeadboardItem, LeadboardItemData>(itemHigh, item, null, _leadboardData.LeadboardContinentDataList);
SetSelfItem();
}
private void OnDisable()
{
disposable?.Dispose();
disposable = null;
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 061700dadb13f2e4c946e516aab2d6aa
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,101 @@
using System;
using asap.core;
using game;
using GameCore;
using PlayFab.ClientModels;
using System.Collections.Generic;
using TMPro;
using UnityEngine;
public class SocialLeadboardItem : PanelItemBase<LeadboardItemData>
{
public GameObject bg_myself;
List<GameObject> rank = new List<GameObject>();
public TMP_Text text_rank;
public TMP_Text text_name;
public Head head;
public TMP_Text text_count;
public TMP_Text text_count_skyscraper;
string playFabId;
bool isInit;
GameObject skyscraper;
//private void Awake()
//{
// if (!isInit)
// {
// InitPanel();
// }
//}
void InitPanel()
{
skyscraper = transform.Find("icon_skyscraper").gameObject;
bg_myself = transform.Find("bg_myself").gameObject;
text_rank = transform.Find("rank/rank/text_rank").GetComponent<TMP_Text>();
text_name = transform.Find("text_name").GetComponent<TMP_Text>();
head = transform.Find("btn_head").GetComponent<Head>();
//reward_panel = transform.Find("reward_panel").gameObject;
text_count = transform.Find("icon_rank/text_num").GetComponent<TMP_Text>();
text_count_skyscraper = transform.Find("icon_skyscraper/text_num").GetComponent<TMP_Text>();
Transform rank_panel = transform.Find("rank");
rank.Clear();
for (int i = 0; i < rank_panel.childCount; i++)
{
rank.Add(rank_panel.GetChild(i).gameObject);
}
isInit = true;
}
public override void OnInit()
{
if (!isInit)
{
InitPanel();
}
IUserService userService = GContext.container.Resolve<IUserService>();
playFabId = data.playFabId;
bg_myself.SetActive(data.playFabId == userService.UserId);
for (int i = 0; i < rank.Count - 1; i++)
{
rank[i].SetActive(data.rank == i + 1);
}
rank[^1].SetActive(data.rank >= rank.Count);
text_rank.text = data.rank.ToString();
int level = data.value / LeadboardData.LV_MODELING;
int level2 = data.value % LeadboardData.LV_MODELING;
if (level > 0)
{
text_count.text = level.ToString();
text_count_skyscraper.text = level2.ToString();
}
else
{
text_count_skyscraper.text = "0";
text_count.text = data.value.ToString();
}
skyscraper.SetActive(level2 > 0);
text_name.text = data.displayName;
head.SetData(data.avatarUrl);
}
}
public class LeadboardItemData
{
public int position;
public int rank;
public int value = 1;
//public string entityKey;
public string playFabId;
public string displayName;
public string avatarUrl;
public DateTime? LastLogin;
public void SetData(PlayerLeaderboardEntry data)
{
playFabId = data.PlayFabId;
position = data.Position;
rank = data.Position + 1;
value = data.StatValue;
displayName = data.Profile.DisplayName;
avatarUrl = data.Profile.AvatarUrl;
LastLogin = data.Profile.LastLogin;
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 4c25417d9906b3c4898a9b4dac7908dc
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: