657 lines
24 KiB
C#
657 lines
24 KiB
C#
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();
|
|
}
|
|
}
|