备份CatanBuilding瘦身独立工程
This commit is contained in:
128
Assets/Scripts/UI/Social/ClubChat/DialogueBase.cs
Normal file
128
Assets/Scripts/UI/Social/ClubChat/DialogueBase.cs
Normal 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;
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/UI/Social/ClubChat/DialogueBase.cs.meta
Normal file
11
Assets/Scripts/UI/Social/ClubChat/DialogueBase.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 27a097add7331be45acb3a7f9ad72dd4
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
14
Assets/Scripts/UI/Social/ClubChat/DialogueEmoji.cs
Normal file
14
Assets/Scripts/UI/Social/ClubChat/DialogueEmoji.cs
Normal 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);
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/UI/Social/ClubChat/DialogueEmoji.cs.meta
Normal file
11
Assets/Scripts/UI/Social/ClubChat/DialogueEmoji.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0d94db00caf59074d9151842a5693452
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
143
Assets/Scripts/UI/Social/ClubChat/DialogueEnergyHelp.cs
Normal file
143
Assets/Scripts/UI/Social/ClubChat/DialogueEnergyHelp.cs
Normal 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;
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/UI/Social/ClubChat/DialogueEnergyHelp.cs.meta
Normal file
11
Assets/Scripts/UI/Social/ClubChat/DialogueEnergyHelp.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b8294be3b2cae9740a8f53b508f2d090
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
132
Assets/Scripts/UI/Social/ClubChat/DialogueHelp.cs
Normal file
132
Assets/Scripts/UI/Social/ClubChat/DialogueHelp.cs
Normal 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/UI/Social/ClubChat/DialogueHelp.cs.meta
Normal file
11
Assets/Scripts/UI/Social/ClubChat/DialogueHelp.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: dd8faf41ba755f0419b56fccc1519e9e
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
14
Assets/Scripts/UI/Social/ClubChat/DialogueLeft.cs
Normal file
14
Assets/Scripts/UI/Social/ClubChat/DialogueLeft.cs
Normal 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);
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/UI/Social/ClubChat/DialogueLeft.cs.meta
Normal file
11
Assets/Scripts/UI/Social/ClubChat/DialogueLeft.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ce8f15260eadc734e82cba7d6d6f5272
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
44
Assets/Scripts/UI/Social/ClubChat/EmojiTips.cs
Normal file
44
Assets/Scripts/UI/Social/ClubChat/EmojiTips.cs
Normal 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);
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/UI/Social/ClubChat/EmojiTips.cs.meta
Normal file
11
Assets/Scripts/UI/Social/ClubChat/EmojiTips.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 06e6777ae9e59b642804e9b6a4340d92
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
89
Assets/Scripts/UI/Social/ClubChat/Prompted.cs
Normal file
89
Assets/Scripts/UI/Social/ClubChat/Prompted.cs
Normal 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;
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/UI/Social/ClubChat/Prompted.cs.meta
Normal file
11
Assets/Scripts/UI/Social/ClubChat/Prompted.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c9816855881f7494fbdc2d5c200f76ea
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
102
Assets/Scripts/UI/Social/ClubChat/PromptedLike.cs
Normal file
102
Assets/Scripts/UI/Social/ClubChat/PromptedLike.cs
Normal 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;
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/UI/Social/ClubChat/PromptedLike.cs.meta
Normal file
11
Assets/Scripts/UI/Social/ClubChat/PromptedLike.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 569c72d7faae53140a0a0cca8eaed680
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user