备份CatanBuilding瘦身独立工程
This commit is contained in:
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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user