376 lines
11 KiB
C#
376 lines
11 KiB
C#
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
using System;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using Games.GlobeDefine;
|
|
using Games.ChatHistory;
|
|
using Games.Item;
|
|
using GCGame.Table;
|
|
using GCGame;
|
|
using Module.Log;
|
|
using Google.ProtocolBuffers;
|
|
|
|
public class ChatInfoLogic : UIControllerBase<ChatInfoLogic>
|
|
{
|
|
#region
|
|
|
|
public enum CHANNEL_TYPE
|
|
{
|
|
CHANNEL_TYPE_INVALID = -1,
|
|
CHAT_TYPE_WORLD = 0, // 世界频道
|
|
CHAT_TYPE_TELL, // 密聊频道
|
|
CHAT_TYPE_NORMAL, // 附近频道
|
|
CHAT_TYPE_TEAM, // 队伍频道
|
|
CHAT_TYPE_GUILD, // 帮会频道
|
|
CHAT_TYPE_MASTER, // 师门频道
|
|
CHAT_TYPE_FRIEND, // 好友频道
|
|
CHAT_TYPE_SYSTEM, // 系统频道
|
|
CHAT_TYPE_BATTLE, // 战斗频道
|
|
CHAT_TYPE_NUM,
|
|
}
|
|
|
|
public enum LINK_TYPE
|
|
{
|
|
LINK_TYPE_INVALID1 = -1,
|
|
LINK_TYPE_INVALID = 0,
|
|
LINK_TYPE_ITEM = 1, // 物品链接
|
|
LINK_TYPE_EQUIP = 2, // 装备链接
|
|
LINK_TYPE_COPYTEAM = 3, //副本组队
|
|
LINK_TYPE_GUILD = 7, // 帮会链接
|
|
}
|
|
|
|
|
|
private CHANNEL_TYPE m_eCurChannelType = CHANNEL_TYPE.CHAT_TYPE_WORLD; // 当前频道
|
|
public CHANNEL_TYPE CurChannelType
|
|
{
|
|
get { return m_eCurChannelType; }
|
|
set { m_eCurChannelType = value; }
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
private void Start()
|
|
{
|
|
InitCannel();
|
|
}
|
|
|
|
void OnEnable()
|
|
{
|
|
SetInstance(this);
|
|
|
|
ShowAnim();
|
|
|
|
_ChatHistory.ShowHistory(_SelectedCannel);
|
|
|
|
CheckShowQuestion();
|
|
|
|
UpdateVoiceAnim();
|
|
|
|
if (_ShowRedPacket)
|
|
{
|
|
ShowRedPacketEffect();
|
|
}
|
|
else
|
|
{
|
|
ShowRedPacketImg();
|
|
}
|
|
}
|
|
|
|
void OnDisable()
|
|
{
|
|
SetInstance(null);
|
|
_ChatQuestion.gameObject.SetActive(false);
|
|
}
|
|
|
|
public void Close()
|
|
{
|
|
StartCoroutine(HideAnim());
|
|
}
|
|
|
|
public void DestoryUI()
|
|
{
|
|
StartCoroutine(DestoryAnim());
|
|
}
|
|
|
|
#region function
|
|
|
|
public void OnFriendClick()
|
|
{
|
|
UIManager.ShowUI(UIInfo.FriendAndMail);
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region show anim
|
|
|
|
public Animator _ShowAnim;
|
|
|
|
public void ShowAnim()
|
|
{
|
|
_ShowAnim.Play("Show");
|
|
}
|
|
|
|
public IEnumerator HideAnim()
|
|
{
|
|
_ShowAnim.Play("Hide");
|
|
yield return new WaitForSeconds(0.4f);
|
|
UIManager.CloseUI(UIInfo.ChatInfoRoot);
|
|
}
|
|
|
|
public IEnumerator DestoryAnim()
|
|
{
|
|
_ShowAnim.Play("Hide");
|
|
yield return new WaitForSeconds(0.4f);
|
|
GameObject.Destroy(gameObject);
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region cannel
|
|
|
|
//public UIStateBtn _UseSoundState;
|
|
public Toggle _UseSoundState;
|
|
public UISubScollMenu _ChatCannels;
|
|
public ChatInputLogic _ChatInputLogic;
|
|
public ChatHistoryLogic _ChatHistory;
|
|
public ChatQuestion _ChatQuestion;
|
|
public Text _WarningText;
|
|
|
|
private List<string> _CannelNames;
|
|
private int _SelectedCannel = (int)CG_CHAT.CHATTYPE.CHAT_TYPE_WORLD;
|
|
private Dictionary<string, int> _CannelDict;
|
|
|
|
public void InitCannel()
|
|
{
|
|
|
|
_CannelNames = new List<string>()
|
|
{
|
|
StrDictionary.GetClientDictionaryString("#{4336}"),
|
|
StrDictionary.GetClientDictionaryString("#{4342}"),
|
|
StrDictionary.GetClientDictionaryString("#{4346}"),
|
|
StrDictionary.GetClientDictionaryString("#{4345}"),
|
|
StrDictionary.GetClientDictionaryString("#{4648}"),
|
|
StrDictionary.GetClientDictionaryString("#{4715}"),
|
|
StrDictionary.GetClientDictionaryString("#{4716}"),
|
|
|
|
};
|
|
|
|
if (_CannelDict == null)
|
|
{
|
|
_CannelDict = new Dictionary<string, int>();
|
|
_CannelDict.Add(StrDictionary.GetClientDictionaryString("#{4715}"), (int)CG_CHAT.CHATTYPE.CHAT_TYPE_NORMAL);
|
|
_CannelDict.Add(StrDictionary.GetClientDictionaryString("#{4345}"), (int)CG_CHAT.CHATTYPE.CHAT_TYPE_TEAM);
|
|
_CannelDict.Add(StrDictionary.GetClientDictionaryString("#{4346}"), (int)CG_CHAT.CHATTYPE.CHAT_TYPE_GUILD);
|
|
_CannelDict.Add(StrDictionary.GetClientDictionaryString("#{4342}"), (int)CG_CHAT.CHATTYPE.CHAT_TYPE_WORLD);
|
|
_CannelDict.Add(StrDictionary.GetClientDictionaryString("#{4716}"), (int)CG_CHAT.CHATTYPE.CHAT_TYPE_BATTLE);
|
|
_CannelDict.Add(StrDictionary.GetClientDictionaryString("#{4336}"), (int)CG_CHAT.CHATTYPE.CHAT_TYPE_SYSTEM);
|
|
_CannelDict.Add(StrDictionary.GetClientDictionaryString("#{4648}"), (int)CG_CHAT.CHATTYPE.CHAT_TYPE_TEAM_INVITE);
|
|
}
|
|
|
|
_ChatCannels.Clear();
|
|
|
|
foreach (var classStr in _CannelNames)
|
|
{
|
|
_ChatCannels.PushMenu(classStr);
|
|
}
|
|
//_ChatCannels.ShowDefaultFirst();
|
|
var objParam = StrDictionary.GetClientDictionaryString("#{4342}");
|
|
_ChatCannels.ShowMenu(objParam);
|
|
}
|
|
|
|
public void OnAutoVoiceState(bool state)
|
|
{
|
|
ChatVoice.Instance()._IsAutoVoice = (state);
|
|
LogModule.DebugLog("_IsAutoVoice:" + ChatVoice.Instance()._IsAutoVoice);
|
|
|
|
if ((GC_CHAT.CHATTYPE)_SelectedCannel == GC_CHAT.CHATTYPE.CHAT_TYPE_WORLD)
|
|
{
|
|
PlayerPreferenceData.SystemAutoVoiceWorld = (state);
|
|
}
|
|
else if ((GC_CHAT.CHATTYPE)_SelectedCannel == GC_CHAT.CHATTYPE.CHAT_TYPE_GUILD)
|
|
{
|
|
PlayerPreferenceData.SystemAutoVoiceGuild = (state);
|
|
}
|
|
else if ((GC_CHAT.CHATTYPE)_SelectedCannel == GC_CHAT.CHATTYPE.CHAT_TYPE_TEAM)
|
|
{
|
|
PlayerPreferenceData.SystemAutoVoiceTeam = (state);
|
|
}
|
|
else if ((GC_CHAT.CHATTYPE)_SelectedCannel == GC_CHAT.CHATTYPE.CHAT_TYPE_NORMAL)
|
|
{
|
|
PlayerPreferenceData.SystemAutoVoiceNearBy = (state);
|
|
}
|
|
}
|
|
|
|
public void RefreshAutoVoiceState()
|
|
{
|
|
if ((GC_CHAT.CHATTYPE)_SelectedCannel == GC_CHAT.CHATTYPE.CHAT_TYPE_WORLD)
|
|
{
|
|
_UseSoundState.isOn = PlayerPreferenceData.SystemAutoVoiceWorld;
|
|
}
|
|
else if ((GC_CHAT.CHATTYPE)_SelectedCannel == GC_CHAT.CHATTYPE.CHAT_TYPE_GUILD)
|
|
{
|
|
_UseSoundState.isOn = PlayerPreferenceData.SystemAutoVoiceGuild;
|
|
}
|
|
else if ((GC_CHAT.CHATTYPE)_SelectedCannel == GC_CHAT.CHATTYPE.CHAT_TYPE_TEAM)
|
|
{
|
|
_UseSoundState.isOn = PlayerPreferenceData.SystemAutoVoiceTeam;
|
|
}
|
|
else if ((GC_CHAT.CHATTYPE)_SelectedCannel == GC_CHAT.CHATTYPE.CHAT_TYPE_NORMAL)
|
|
{
|
|
_UseSoundState.isOn = PlayerPreferenceData.SystemAutoVoiceNearBy;
|
|
}
|
|
else
|
|
{
|
|
_UseSoundState.isOn = false;
|
|
}
|
|
}
|
|
|
|
public void OnReceiveChat()
|
|
{
|
|
//int HistoryCount = GameManager.gameManager.PlayerDataPool.ChatHistory.ChatHistoryList.Count;
|
|
//ChatHistoryItem LastHistory = GameManager.gameManager.PlayerDataPool.ChatHistory.ChatHistoryList[HistoryCount - 1];
|
|
//if ((int)LastHistory.EChannel == _SelectedCannel)
|
|
_ChatHistory.OnReceiveChat();
|
|
}
|
|
|
|
//public void Force()
|
|
//{
|
|
// Canvas.ForceUpdateCanvases();
|
|
//}
|
|
|
|
public void OnCannelSelect(object cannelObj)
|
|
{
|
|
string cannel = cannelObj as string;
|
|
_SelectedCannel = GetCurChannelType(cannel);
|
|
_ChatHistory.ShowHistory(_SelectedCannel);
|
|
_ChatQuestion.gameObject.SetActive(false);
|
|
_ChatInputLogic.SetCurChannelType(_SelectedCannel);
|
|
|
|
if (_SelectedCannel == (int)GC_CHAT.CHATTYPE.CHAT_TYPE_BATTLE
|
|
|| _SelectedCannel == (int)GC_CHAT.CHATTYPE.CHAT_TYPE_SYSTEM
|
|
|| _SelectedCannel == (int)GC_CHAT.CHATTYPE.CHAT_TYPE_TEAM_INVITE)
|
|
{
|
|
_ChatInputLogic.gameObject.SetActive(false);
|
|
}
|
|
else
|
|
{
|
|
_ChatInputLogic.gameObject.SetActive(true);
|
|
}
|
|
|
|
switch(_SelectedCannel)
|
|
{
|
|
case (int)GC_CHAT.CHATTYPE.CHAT_TYPE_WORLD:
|
|
_WarningText.text = StrDictionary.GetClientDictionaryString("#{79210}");
|
|
break;
|
|
case (int)GC_CHAT.CHATTYPE.CHAT_TYPE_GUILD:
|
|
_WarningText.text = StrDictionary.GetClientDictionaryString("#{79211}");
|
|
break;
|
|
case (int)GC_CHAT.CHATTYPE.CHAT_TYPE_TEAM:
|
|
_WarningText.text = StrDictionary.GetClientDictionaryString("#{79212}");
|
|
break;
|
|
case (int)GC_CHAT.CHATTYPE.CHAT_TYPE_NORMAL:
|
|
_WarningText.text = StrDictionary.GetClientDictionaryString("#{79213}");
|
|
break;
|
|
case (int)GC_CHAT.CHATTYPE.CHAT_TYPE_BATTLE:
|
|
_WarningText.text = StrDictionary.GetClientDictionaryString("#{79214}");
|
|
break;
|
|
case (int)GC_CHAT.CHATTYPE.CHAT_TYPE_SYSTEM:
|
|
case (int)GC_CHAT.CHATTYPE.CHAT_TYPE_TEAM_INVITE:
|
|
_WarningText.text = StrDictionary.GetClientDictionaryString("#{79215}");
|
|
break;
|
|
}
|
|
|
|
_ChatCannels.HightLightMenu(cannel);
|
|
|
|
CheckShowQuestion();
|
|
RefreshAutoVoiceState();
|
|
}
|
|
|
|
public void CheckShowQuestion()
|
|
{
|
|
if(_SelectedCannel == (int)GC_CHAT.CHATTYPE.CHAT_TYPE_GUILD)
|
|
{
|
|
CG_ASK_FOR_QUESTION send = (CG_ASK_FOR_QUESTION)PacketDistributed.CreatePacket(MessageID.PACKET_CG_ASK_FOR_QUESTION);
|
|
send.SetChannel(_SelectedCannel);
|
|
send.SendPacket();
|
|
}
|
|
}
|
|
|
|
public int GetCurChannelType(string canelStr)
|
|
{
|
|
if (_CannelDict.ContainsKey(canelStr))
|
|
return _CannelDict[canelStr];
|
|
return -1;
|
|
}
|
|
|
|
public int GetCurChannelType()
|
|
{
|
|
return _SelectedCannel;
|
|
}
|
|
|
|
public void UpdateVoiceAnim()
|
|
{
|
|
_ChatHistory.UpdateVoiceAnim();
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region red packet
|
|
|
|
public GameObject _RedPacketImg;
|
|
public GameObject _RedPacketEffect;
|
|
|
|
public static bool _ShowRedPacket = false;
|
|
|
|
public static void ShowRedPacket(bool isShowRedPacket)
|
|
{
|
|
_ShowRedPacket = isShowRedPacket;
|
|
if (Instance() != null)
|
|
{
|
|
if (_ShowRedPacket)
|
|
{
|
|
Instance().ShowRedPacketEffect();
|
|
}
|
|
else
|
|
{
|
|
Instance().ShowRedPacketImg();
|
|
}
|
|
}
|
|
}
|
|
|
|
public void ShowRedPacketEffect()
|
|
{
|
|
_RedPacketEffect.SetActive(true);
|
|
_RedPacketImg.SetActive(false);
|
|
}
|
|
|
|
public void ShowRedPacketImg()
|
|
{
|
|
_RedPacketEffect.SetActive(false);
|
|
_RedPacketImg.SetActive(true);
|
|
}
|
|
|
|
public void OnRedPacketSend()
|
|
{
|
|
if (_ShowRedPacket)
|
|
{
|
|
if (ActiveBtns.Instance())
|
|
{
|
|
ActiveBtns.Instance().OnRedPacketClick();
|
|
}
|
|
}
|
|
else
|
|
{
|
|
UIManager.ShowUI(UIInfo.RedPacketRecvRoot);
|
|
}
|
|
|
|
|
|
}
|
|
|
|
#endregion
|
|
|
|
}
|