Files
back_cantanBuilding/Assets/Scripts/Duel/UI/DuelChatView.cs
2026-05-26 16:15:54 +08:00

70 lines
1.8 KiB
C#

using asap.core;
using cfg;
using GameCore;
using System.Collections;
using TMPro;
using UniRx;
using UnityEngine;
using UnityEngine.UI;
public class DuelChatView : MonoBehaviour, IDuelChatView
{
public Animation dialogue;
public TMP_Text text_chat;
public Animation emoji;
public Image image_emoji;
IUIService uiService;
protected virtual void Awake()
{
uiService = GContext.container.Resolve<IUIService>();
}
public void SetDuelFishingEvent(int roleID)
{
GContext.OnEvent<DuelChatEvent>().Where(x => x.RoleID == roleID).Subscribe(SetMessage).AddTo(this);
}
void SetMessage(DuelChatEvent duelChatEvent)
{
EventSoloQuickMessage eventSoloQuickMessage = GContext.container.Resolve<Tables>().TbEventSoloQuickMessage.GetOrDefault(duelChatEvent.MessageID);
if (eventSoloQuickMessage != null)
{
switch (eventSoloQuickMessage.Type)
{
case 1:
Emoji(eventSoloQuickMessage.Emoji);
break;
case 2:
Dialogue(eventSoloQuickMessage.Text_l10n_key);
break;
default:
break;
}
}
}
public void Dialogue(string chat)
{
if (this == null)
{
return;
}
emoji.gameObject.SetActive(false);
dialogue.gameObject.SetActive(true);
dialogue.Play();
text_chat.text = LocalizationMgr.GetText(chat);
}
public void Emoji(string chat)
{
if (this == null)
{
return;
}
emoji.gameObject.SetActive(true);
dialogue.gameObject.SetActive(false);
emoji.Play();
uiService.SetImageSprite(image_emoji, chat);
}
}