1058 lines
40 KiB
C#
1058 lines
40 KiB
C#
using Thousandto.Code.Center;
|
||
using Thousandto.Plugins.Common;
|
||
using System.Collections;
|
||
using System.Collections.Generic;
|
||
using UnityEngine;
|
||
using Thousandto.Core.RootSystem;
|
||
using Thousandto.Core.Base;
|
||
using System.Text;
|
||
using Thousandto.Code.Global;
|
||
using Thousandto.Cfg.Data;
|
||
using System.IO;
|
||
using Thousandto.Code.Logic.LocalPlayerBT;
|
||
|
||
namespace Thousandto.Code.Logic
|
||
{
|
||
/// <summary>
|
||
/// 聊天节点,跟每一个控件相关
|
||
/// </summary>
|
||
public class ChatNode
|
||
{
|
||
private class MyWords
|
||
{
|
||
public static string Join_now = DeclareMessageString.Get(DeclareMessageString.C_CHATNODE_JOIN_IN);//Thousandto.Cfg.Data.DeclareMessageString.Get(Thousandto.Cfg.Data.DeclareMessageString.C_CHAT_LIJIJIARU);
|
||
}
|
||
|
||
public int Type;
|
||
public string Param1// param --> type
|
||
{
|
||
//写成属性,是为了在Param1修改的时候重置_displayText的值,避免删除操作时_displayText没有变
|
||
get { return _param1; }
|
||
set { _param1 = value; _displayText = null; }
|
||
}
|
||
private string _param1;
|
||
public string Param2;
|
||
public string Param3;
|
||
public string VoiceKey; //如果是语音节点,则需要设置这个key
|
||
public ItemBase ItemParam;
|
||
|
||
public int LabelType; //接收聊天信息后,设置显示的颜色
|
||
public int ChannelID; //频道id, 接收消息后才赋值
|
||
public int Width; //接收消息后赋值
|
||
public int Height; //接收消息后赋值
|
||
public int ImgStartX; //如果是图片类型,这里记录图片应该存放的坐标x起点
|
||
//在第几行
|
||
public int Line;
|
||
public bool IgnoreInPrivateChat; //当前节点不在私聊界面显示
|
||
public bool ShowRedPoint; //显示红点
|
||
public bool IsChannelNode; //是否频道节点
|
||
public string Position; //坐标节点,用来保存坐标值
|
||
|
||
private ChatNode _baseChatNode; //关联的node
|
||
private GameObject _go;
|
||
private static int _playAudioCounter; //录音播放计数器, 全局静态的
|
||
private int _curPlayerAudio; //当前播放录音计数值
|
||
|
||
//逻辑代码使用NGUI内容的中间转换类
|
||
private IChatNodeTool _chatNodeTool;
|
||
private bool _audioCoroRuning; //语音协程正在运行,避免多次点击同一个语音导致播放异常的问题
|
||
|
||
private string _displayText;
|
||
private string _displayBBCodeText;
|
||
public ulong specialId = 0;
|
||
public bool isPrivateChatNode = false;
|
||
public bool IsBeginNode = false;
|
||
public bool IsEndNode = false;
|
||
|
||
//当前节点转化成的ui
|
||
public GameObject GO
|
||
{
|
||
get { return _go; }
|
||
set
|
||
{
|
||
if (_go != null)
|
||
{
|
||
Destory();
|
||
}
|
||
_go = value;
|
||
}
|
||
}
|
||
|
||
public ChatNode BaseChatNode
|
||
{
|
||
get
|
||
{
|
||
return _baseChatNode;
|
||
}
|
||
}
|
||
|
||
public ChatNode()
|
||
{
|
||
Type = (int)TNodeType.Text;
|
||
Param1 = "";
|
||
Param2 = "";
|
||
Param3 = "";
|
||
LabelType = -1;
|
||
ChannelID = -1;
|
||
GO = null;
|
||
Line = 0;
|
||
Width = 0;
|
||
Height = 0;
|
||
VoiceKey = "";
|
||
_displayText = "";
|
||
_displayBBCodeText = "";
|
||
IgnoreInPrivateChat = false;
|
||
IsChannelNode = false;
|
||
ShowRedPoint = true;
|
||
ItemParam = null;
|
||
IsBeginNode = true;
|
||
IsEndNode = true;
|
||
}
|
||
|
||
public ChatNode(ChatNode nd)
|
||
{
|
||
this.Type = nd.Type;
|
||
this.Param1 = nd.Param1;
|
||
this.Param2 = nd.Param2;
|
||
this.Param3 = nd.Param3;
|
||
this.Position = nd.Position;
|
||
this.VoiceKey = nd.VoiceKey;
|
||
this.LabelType = nd.LabelType;
|
||
this.Line = nd.Line;
|
||
this.ChannelID = nd.ChannelID;
|
||
this.ImgStartX = nd.ImgStartX;
|
||
this.Width = nd.Width;
|
||
this.Height = nd.Height;
|
||
this._displayText = "";
|
||
this._displayBBCodeText = "";
|
||
this.IgnoreInPrivateChat = nd.IgnoreInPrivateChat;
|
||
this.IsChannelNode = nd.IsChannelNode;
|
||
this._baseChatNode = nd;
|
||
this.ShowRedPoint = nd.ShowRedPoint;
|
||
this.specialId = nd.specialId;
|
||
this.ItemParam = nd.ItemParam;
|
||
this.IsBeginNode = nd.IsBeginNode;
|
||
this.IsEndNode = nd.IsEndNode;
|
||
}
|
||
|
||
//显示红点
|
||
public void EnableRedPoint(bool show)
|
||
{
|
||
if (show == ShowRedPoint)
|
||
{
|
||
return;
|
||
}
|
||
ShowRedPoint = show;
|
||
if (_baseChatNode != null)
|
||
{
|
||
_baseChatNode.ShowRedPoint = show;
|
||
}
|
||
}
|
||
|
||
//设置转换工具
|
||
public void SetTool(IChatNodeTool tool)
|
||
{
|
||
_chatNodeTool = tool;
|
||
}
|
||
|
||
/// <summary>
|
||
/// 建立gameObject对象,用来显示在界面上
|
||
/// 不同节点类型,生成的GO是不同的
|
||
/// </summary>
|
||
public GameObject GenGO(MonoBehaviour label)
|
||
{
|
||
Destory();
|
||
|
||
if (Type == (int)TNodeType.Image || Type == (int)TNodeType.Audio)
|
||
{
|
||
return null;
|
||
}
|
||
|
||
if (Type == (int)TNodeType.Item || Type == (int)TNodeType.Equipment)
|
||
{
|
||
int color = getItemOrEquipColorId();
|
||
|
||
MonoBehaviour colorLabel = (MonoBehaviour)GameCenter.ChatSystem.GetLabelByColorID(color);
|
||
if (colorLabel != null)
|
||
{
|
||
label = colorLabel;
|
||
}
|
||
else
|
||
{
|
||
//UnityEngine.Debug.LogError("没有找到对应的color label: color=" + color);
|
||
return null;
|
||
}
|
||
}
|
||
|
||
if (Type == (int)TNodeType.Equipment)
|
||
{
|
||
|
||
}
|
||
GO = GameObject.Instantiate(label.transform.gameObject) as GameObject;
|
||
|
||
return GO;
|
||
}
|
||
|
||
/// <summary>
|
||
/// 拷贝属性
|
||
/// </summary>
|
||
/// <param name="from"></param>
|
||
/// <param name="to"></param>
|
||
/// <returns></returns>
|
||
public MonoBehaviour CopyLabelProperty(MonoBehaviour labelSkin, MonoBehaviour to)
|
||
{
|
||
MonoBehaviour from = null;
|
||
if (Type == (int)TNodeType.Item || Type == (int)TNodeType.Equipment)
|
||
{
|
||
int color = getItemOrEquipColorId();
|
||
|
||
MonoBehaviour colorLabel = (MonoBehaviour)GameCenter.ChatSystem.GetLabelByColorID(color);
|
||
if (colorLabel != null)
|
||
{
|
||
from = colorLabel;
|
||
}
|
||
}
|
||
else
|
||
{
|
||
from = labelSkin;
|
||
}
|
||
return _chatNodeTool.CopyLabelProperty(from, to);
|
||
}
|
||
|
||
//获取颜色id
|
||
private int getItemOrEquipColorId()
|
||
{
|
||
int itemId = 0;
|
||
int.TryParse(getItemOrEquipIdStr(Param2), out itemId);
|
||
|
||
switch (Type)
|
||
{
|
||
case (int)TNodeType.Item:
|
||
case (int)TNodeType.Equipment:
|
||
if(ItemParam != null)
|
||
{
|
||
return ItemParam.Quality;
|
||
}
|
||
break;
|
||
}
|
||
|
||
return -1;
|
||
}
|
||
|
||
private string getItemOrEquipIdStr(string param2)
|
||
{
|
||
if (param2.Contains("_"))
|
||
{
|
||
string[] values = param2.Split('_');
|
||
return values[0];
|
||
}
|
||
|
||
return param2;
|
||
}
|
||
|
||
/// <summary>
|
||
/// 对已生成的go对象,添加必要的组件,已经相应点击函数
|
||
/// </summary>
|
||
public void AddCommponentToGO(bool enableClick = true)
|
||
{
|
||
if (_chatNodeTool == null)
|
||
{
|
||
//UnityEngine.Debug.LogError("chatNode工具类为null");
|
||
return;
|
||
}
|
||
|
||
if (ChannelID == (int)ChatChanelType.PERSONAL)
|
||
{
|
||
_chatNodeTool.AddCommponentToGO(this, onClickLabel, enableClick);
|
||
}
|
||
else
|
||
_chatNodeTool.AddCommponentToGO(this, null, enableClick);
|
||
}
|
||
|
||
/// <summary>
|
||
/// 结束动画播放
|
||
/// </summary>
|
||
public void StopPlayAnim()
|
||
{
|
||
if (_chatNodeTool == null)
|
||
{
|
||
//UnityEngine.Debug.LogError("chatNode工具类为null");
|
||
return;
|
||
}
|
||
_chatNodeTool.StopAnim();
|
||
}
|
||
|
||
|
||
/// <summary>
|
||
/// 格式化输入字符串,用于发送消息
|
||
/// </summary>
|
||
/// <returns></returns>
|
||
public string GetTransferText()
|
||
{
|
||
if (Type == (int)TNodeType.Private)
|
||
return string.Format("<t={0}>{1},{2},{3}</t>", Type, Param3, Param2, Param1);
|
||
else if (Type == (int)TNodeType.Text)
|
||
{
|
||
// string tmp = Param1.Replace("<", "<");
|
||
// tmp = tmp.Replace(">", ">");
|
||
return string.Format("<t={0}>{1},{2},{3}</t>", Type, Param3, Param2, Param1);
|
||
}
|
||
else if (Type == (int)TNodeType.CMD)
|
||
{
|
||
return Param1;
|
||
}
|
||
else
|
||
return string.Format("<t={0}>{1},{2},{3}</t>", Type, Param3, Param2, Param1);
|
||
}
|
||
|
||
private string removeColorTag(string text, List<ChatColorFlag> colorflags)
|
||
{
|
||
int start = 0;
|
||
int end = 0;
|
||
Stack<ChatColorFlag> stack = null;
|
||
if (colorflags != null)
|
||
{
|
||
colorflags.Clear();
|
||
stack = new Stack<ChatColorFlag>();
|
||
}
|
||
StringBuilder sb = new StringBuilder();
|
||
end = text.IndexOf("[", start);
|
||
while (end >= 0)
|
||
{
|
||
var nextTag = text.IndexOf("[", end + 1);
|
||
if (nextTag - end == 1)
|
||
{
|
||
end = nextTag;
|
||
continue;
|
||
}
|
||
int offset = text.IndexOf("]", end) - end;
|
||
if (offset < 0)
|
||
{
|
||
break;
|
||
}
|
||
|
||
sb.Append(text.Substring(start, end - start));
|
||
string colorTag = text.Substring(end, offset + 1);
|
||
if (offset == 7)
|
||
{
|
||
//不在颜色区间中
|
||
if (colorTag.CompareTo("[000000]") < 0 || colorTag.CompareTo("[ffffff]") > 0)
|
||
{
|
||
sb.Append(colorTag);
|
||
}
|
||
else
|
||
{
|
||
if (colorflags != null)
|
||
{
|
||
stack.Push(new ChatColorFlag() { ColorText = colorTag, Left = sb.Length });
|
||
}
|
||
}
|
||
}
|
||
else if (offset == 2)
|
||
{
|
||
if (colorTag != "[-]")
|
||
{
|
||
sb.Append(colorTag);
|
||
}
|
||
else
|
||
{
|
||
if (colorflags != null)
|
||
{
|
||
var cr = stack.Pop();
|
||
cr.Right = sb.Length;
|
||
colorflags.Add(cr);
|
||
}
|
||
}
|
||
}
|
||
else
|
||
sb.Append(colorTag);
|
||
|
||
start = end + offset + 1;
|
||
|
||
end = text.IndexOf("[", start);
|
||
}
|
||
|
||
sb.Append(text.Substring(start));
|
||
|
||
if (colorflags != null)
|
||
{
|
||
//说明有些颜色没有结束符--加上他.
|
||
while (stack.Count > 0)
|
||
{
|
||
var cr = stack.Pop();
|
||
cr.Left = sb.Length;
|
||
colorflags.Add(cr);
|
||
}
|
||
}
|
||
|
||
return sb.ToString();
|
||
}
|
||
|
||
/// <summary>
|
||
/// 生成显示在界面上的内容
|
||
/// </summary>
|
||
/// <returns></returns>
|
||
public string GetDisplayText(bool useForCalcWidth = true, bool ignoreUrl = true, List<ChatColorFlag> list = null)
|
||
{
|
||
if (!string.IsNullOrEmpty(_displayText) && useForCalcWidth)
|
||
{
|
||
return _displayText;
|
||
}
|
||
|
||
switch ((TNodeType)Type)
|
||
{
|
||
case TNodeType.CMD:
|
||
case TNodeType.TextEx:
|
||
case TNodeType.Text:
|
||
if (useForCalcWidth)
|
||
{
|
||
_displayText = removeColorTag(Param1, list);
|
||
}
|
||
else
|
||
_displayText = (Param1);
|
||
break;
|
||
|
||
case TNodeType.PlayerEx:
|
||
case TNodeType.Player:
|
||
//以防名字里面有颜色值
|
||
if (Param1 != null && Param1.CompareTo("000000") >= 0 &&
|
||
Param2.CompareTo("FFFFFF") <= 0)
|
||
{
|
||
_displayText = Param1;
|
||
}
|
||
else
|
||
{
|
||
_displayText = string.Format("[{0}]", Param1);
|
||
}
|
||
break;
|
||
|
||
case TNodeType.ImageEx:
|
||
case TNodeType.BigImage:
|
||
case TNodeType.Image:
|
||
_displayText = Param1;
|
||
break;
|
||
|
||
case TNodeType.Position:
|
||
{
|
||
//做了分割,不再加[] 括号
|
||
if (Param1.StartsWith("<"))
|
||
{
|
||
Param1 = Param1.Replace("<", string.Empty);
|
||
_displayText = Param1;
|
||
}
|
||
if (Param1.EndsWith(">"))
|
||
{
|
||
Param1 = Param1.Replace(">", string.Empty);
|
||
_displayText = Param1;
|
||
}
|
||
else
|
||
{
|
||
//if (Param1.Contains("[") && Param1.Contains("]"))
|
||
//{
|
||
// int start = 0;
|
||
// int end = 0;
|
||
// int offset = 0;
|
||
// start = Param1.IndexOf("[", start);
|
||
// offset = Param1.IndexOf("]", end) - start;
|
||
// Param1 = Param1.Substring(start + 1, offset - 1);
|
||
//}
|
||
int mapId = -1;
|
||
if (Param2.IndexOf("_") > 0)
|
||
{
|
||
string[] args = Param2.Split('_');
|
||
int.TryParse(args[0], out mapId);
|
||
}
|
||
else
|
||
int.TryParse(Param2, out mapId);
|
||
DeclareMapsetting map = DeclareMapsetting.Get(mapId);
|
||
if (map != null)
|
||
{
|
||
_displayText = string.Format(Thousandto.Cfg.Data.DeclareMessageString.Get(Thousandto.Cfg.Data.DeclareMessageString.C_CHAT_DIANJICHUANSONG), map.Name, Param1);
|
||
}
|
||
else
|
||
{
|
||
_displayText = string.Format("[{0}]", Param1);
|
||
}
|
||
}
|
||
break;
|
||
}
|
||
case TNodeType.Private:
|
||
_displayText = Param1;
|
||
break;
|
||
case TNodeType.Equipment:
|
||
case TNodeType.Item:
|
||
_displayText = Param1;
|
||
break;
|
||
|
||
case TNodeType.Team:
|
||
_displayText = "";
|
||
break;
|
||
case TNodeType.Audio:
|
||
_displayText = string.Format("[Audio]{0}\'", Param2);
|
||
break;
|
||
case TNodeType.Function:
|
||
var parseType = ParseFuncNode();
|
||
if (parseType == FuncNodeType.Guild_Jion || parseType == FuncNodeType.Tean_Jion || parseType == FuncNodeType.FuDiHelp)
|
||
{
|
||
if (string.IsNullOrEmpty(Param1))
|
||
{
|
||
_displayText = MyWords.Join_now;
|
||
}
|
||
else
|
||
_displayText = Param1;
|
||
|
||
}
|
||
else if (parseType == FuncNodeType.FunctionStartId)
|
||
{
|
||
if (useForCalcWidth || ignoreUrl)
|
||
_displayText = Param1;
|
||
else
|
||
_displayText = string.Format("[url={1}][u]{0}[/u][/url]", Param1, Param2);
|
||
}
|
||
else if (parseType == FuncNodeType.FightSoul)
|
||
{
|
||
//if(string.IsNullOrEmpty(Param1))
|
||
//{
|
||
// int cfgId = int.Parse(Param2);
|
||
// Param1 = "[" + DeclareFightingSoul.Get(cfgId).Name + "]";
|
||
//}
|
||
|
||
//if(useForCalcWidth)
|
||
//{
|
||
// _displayText = Param1;
|
||
//}
|
||
//else
|
||
//{
|
||
// int cfgId = int.Parse(Param2);
|
||
// int qulity = DeclareFightingSoul.Get(cfgId).Quality;
|
||
// var colorStr = ItemBase.GetQualityStrColor((QualityCode)qulity);
|
||
// _displayText = string.Format("[{0}]{1}[-]", colorStr, Param1);
|
||
//}
|
||
}
|
||
else if (parseType == FuncNodeType.OpenUI)
|
||
{
|
||
_displayText = Param1;
|
||
}
|
||
else
|
||
{
|
||
_displayText = "";
|
||
}
|
||
break;
|
||
|
||
default: break;
|
||
}
|
||
return _displayText;
|
||
}
|
||
|
||
public FuncNodeType ParseFuncNode()
|
||
{
|
||
if ((TNodeType)Type != TNodeType.Function)
|
||
{
|
||
return FuncNodeType.Default;
|
||
}
|
||
|
||
int funcNodeType = 0;
|
||
if (int.TryParse(Param3, out funcNodeType))
|
||
{
|
||
FuncNodeType nodeType = (FuncNodeType)funcNodeType;
|
||
return nodeType;
|
||
}
|
||
|
||
return FuncNodeType.Default;
|
||
}
|
||
|
||
public void SetDisplayText(string text)
|
||
{
|
||
switch ((TNodeType)Type)
|
||
{
|
||
case TNodeType.Equipment:
|
||
case TNodeType.Item:
|
||
Param1 = text;
|
||
break;
|
||
case TNodeType.Function:
|
||
var parseType = ParseFuncNode();
|
||
if (parseType == FuncNodeType.Guild_Jion || parseType == FuncNodeType.Tean_Jion)
|
||
{
|
||
Param1 = text;
|
||
}
|
||
break;
|
||
case TNodeType.CMD:
|
||
case TNodeType.TextEx:
|
||
case TNodeType.Text:
|
||
case TNodeType.PlayerEx:
|
||
case TNodeType.Player:
|
||
case TNodeType.ImageEx:
|
||
case TNodeType.BigImage:
|
||
case TNodeType.Image:
|
||
case TNodeType.Position:
|
||
case TNodeType.Private:
|
||
case TNodeType.Team:
|
||
case TNodeType.Audio:
|
||
default:
|
||
Param1 = text;
|
||
break;
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
/// 生成显示在界面上的内容
|
||
/// contentUseDefaultColor: 0 读取配置颜色, 1 固定小聊天窗颜色, 2 固定大聊天窗颜色
|
||
/// </summary>
|
||
/// <returns></returns>
|
||
public string GetDisplayTextBBCode(int contentUseDefaultColor = 1, bool ignoreUrl = false, int realChannelId = -1)
|
||
{
|
||
if (!string.IsNullOrEmpty(_displayBBCodeText))
|
||
{
|
||
return _displayBBCodeText;
|
||
}
|
||
|
||
if (LabelType == -1)
|
||
{
|
||
SetLabelType(ChannelID);
|
||
}
|
||
|
||
//使用固定配置的颜色,大小聊天窗,text文字颜色是固定的,不区分频道
|
||
string color = GameCenter.ChatSystem.GetLabelColor(LabelType);
|
||
//频道节点的颜色要区分频道
|
||
if (!IsChannelNode && (TNodeType)Type == TNodeType.Text)
|
||
{
|
||
color = GameCenter.ChatSystem.GetLabelColor(LabelType, contentUseDefaultColor);
|
||
|
||
//小聊天窗,并且不是系统和招募信息,显示蓝色字体
|
||
if (contentUseDefaultColor == 1 &&
|
||
ChannelID != (int)ChatChanelType.SYSTEM &&
|
||
ChannelID != (int)ChatChanelType.JOINTEAM)
|
||
color = "00f4ff";
|
||
if (contentUseDefaultColor == 2 && realChannelId == (int)ChatChanelType.SYSTEM)
|
||
{
|
||
//如果是系统频道并且 contentUseDefaultColor == 2
|
||
color = "ffffff";//"1f7f1a";
|
||
}
|
||
if (contentUseDefaultColor == 2 && realChannelId == (int)ChatChanelType.ChuanWen)
|
||
{
|
||
color = "f97602";
|
||
}
|
||
}
|
||
//打开跑马灯的超链接
|
||
ignoreUrl = true;
|
||
string text = GetDisplayText(false, ignoreUrl);
|
||
|
||
switch ((TNodeType)Type)
|
||
{
|
||
case TNodeType.Equipment:
|
||
case TNodeType.Item:
|
||
int colorId = getItemOrEquipColorId();
|
||
color = ItemBase.GetQualityStrColor(colorId);
|
||
break;
|
||
case TNodeType.Function:
|
||
int functionType = int.TryParse(Param3, out functionType) ? functionType : -1;
|
||
if (functionType == 7)
|
||
{
|
||
string[] strs = Param2.Split('_');
|
||
if (strs.Length >= 3)
|
||
{
|
||
color = strs[2];
|
||
}
|
||
}
|
||
break;
|
||
}
|
||
|
||
//不加下划线
|
||
|
||
//var parseType = ParseFuncNode();
|
||
//if (parseType == FuncNodeType.Guild_Jion || parseType == FuncNodeType.Tean_Jion)
|
||
//{
|
||
// _displayBBCodeText = string.Format("[{0}][u]{1}[-][-]", color, text);
|
||
//}
|
||
//else
|
||
|
||
//if (text.EndsWith("[-]") == false || text.StartsWith("[") == false)
|
||
if ((TNodeType)Type == TNodeType.Position || (ChannelID == (int)ChatChanelType.JOINTEAM && (TNodeType)Type != TNodeType.Text
|
||
&& (TNodeType)Type != TNodeType.Player))
|
||
{
|
||
_displayBBCodeText = text;
|
||
}
|
||
else
|
||
{
|
||
if(IsBeginNode && IsEndNode)
|
||
{
|
||
_displayBBCodeText = string.Format("[{0}]{1}[-]", color, text);
|
||
}
|
||
else if (IsBeginNode)
|
||
{
|
||
_displayBBCodeText = string.Format("[{0}]{1}", color, text);
|
||
}
|
||
else if (IsEndNode)
|
||
{
|
||
_displayBBCodeText = string.Format("{0}[-]", text);
|
||
}
|
||
else
|
||
{
|
||
_displayBBCodeText = text;
|
||
}
|
||
}
|
||
//else
|
||
//_displayBBCodeText = text;
|
||
|
||
return _displayBBCodeText;
|
||
}
|
||
|
||
|
||
/// <summary>
|
||
/// 设置节点要显示的颜色风格
|
||
/// </summary>
|
||
/// <param name="channelId"></param>
|
||
public void SetLabelType(int channelId)
|
||
{
|
||
if (ChannelID == -1 && channelId != -1)
|
||
{
|
||
ChannelID = channelId;
|
||
}
|
||
|
||
int type = GameCenter.ChatSystem.GetLabelTypeByChannel(ChannelID);
|
||
|
||
//通过节点类型,获取字体类型,变颜色用
|
||
switch ((TNodeType)Type)
|
||
{
|
||
case TNodeType.Position:
|
||
type = (int)TLabelType.Position;
|
||
break;
|
||
case TNodeType.Player:
|
||
//type = (int)TLabelType.Player; // 名字节点颜色随频道颜色
|
||
break;
|
||
case TNodeType.Equipment:
|
||
type = (int)TLabelType.Team;
|
||
break;
|
||
case TNodeType.Item:
|
||
type = (int)TLabelType.Team;
|
||
break;
|
||
case TNodeType.Function:
|
||
type = (int)TLabelType.Position;
|
||
break;
|
||
}
|
||
|
||
LabelType = type;
|
||
}
|
||
|
||
//相应点击事件
|
||
public void TriggerClick(GameObject go)
|
||
{
|
||
onClickLabel(go);
|
||
}
|
||
|
||
IEnumerator playAudioIE(GameObject obj, ChatNode node)
|
||
{
|
||
if (_audioCoroRuning)
|
||
{
|
||
yield break;
|
||
}
|
||
_audioCoroRuning = true;
|
||
int lenght = int.Parse(node.Param2);
|
||
obj.transform.Find("RedPoint").gameObject.SetActive(false);
|
||
//UnityEngine.Debug.LogError("Click audio ID,Length = " + Param1 + "," + Param2);
|
||
GameObject indicateGo = obj.transform.Find("Left").gameObject;
|
||
if (!indicateGo.activeSelf)
|
||
{
|
||
indicateGo = obj.transform.Find("Right").gameObject;
|
||
}
|
||
|
||
bool show = true;
|
||
lenght *= 5;
|
||
while (lenght > 0 && _curPlayerAudio == _playAudioCounter && GameCenter.ChatSystem.IsAudioPlaying())
|
||
{
|
||
show = !show;
|
||
yield return new WaitForSeconds(0.2f);
|
||
lenght--;
|
||
if (node.GO != null)
|
||
{
|
||
indicateGo.SetActive(show);
|
||
}
|
||
}
|
||
|
||
if (node.GO != null)
|
||
{
|
||
indicateGo.SetActive(true);
|
||
}
|
||
|
||
//没有在录音时,恢复背景音乐
|
||
if (!GameCenter.ChatSystem.IsRecording())
|
||
GameCenter.ChatSystem.ResumeAllSound();
|
||
|
||
_audioCoroRuning = false;
|
||
}
|
||
|
||
private void onAudioReceive()
|
||
{
|
||
GameCenter.ChatSystem.Coro.StartCoroutine(playAudioIE(GO, this));
|
||
}
|
||
|
||
private void onClickLabel(GameObject obj)
|
||
{
|
||
int id = 0;
|
||
//UnityEngine.Debug.Log("Trigger click: " + (TNodeType)Type + " -> " + Param1);
|
||
|
||
switch ((TNodeType)Type)
|
||
{
|
||
case TNodeType.Audio:
|
||
if (_audioCoroRuning)
|
||
{
|
||
GameCenter.ChatSystem.StopPlayingAudio();
|
||
return;
|
||
}
|
||
_playAudioCounter++;
|
||
_curPlayerAudio = _playAudioCounter;
|
||
EnableRedPoint(false);
|
||
GameCenter.ChatSystem.ReqVoiceData(VoiceKey, onAudioReceive);
|
||
break;
|
||
case TNodeType.Image:
|
||
case TNodeType.BigImage:
|
||
case TNodeType.Private: //return "[" + Locale.TextManager.Instance.GetText(5, "H") + "]" + Param1 + ":";
|
||
case TNodeType.Text:
|
||
case TNodeType.TextEx:
|
||
break;
|
||
case TNodeType.Position:
|
||
{
|
||
if (GameCenter.GameSceneSystem.GetLocalPlayer().IsDead())
|
||
{
|
||
GameCenter.MsgPromptSystem.ShowPrompt(DeclareMessageString.Get(DeclareMessageString.Die_CanNotOperate));
|
||
return;
|
||
}
|
||
int mapId = int.TryParse(Param2, out mapId) ? mapId : 0;
|
||
if (mapId != 0)
|
||
{
|
||
float x = 0;
|
||
float z = 0;
|
||
int param = 0;
|
||
string[] strs = Position.Split(',');
|
||
if (strs.Length >= 3)
|
||
{
|
||
x = float.TryParse(strs[0], out x) ? x : 0;
|
||
z = float.TryParse(strs[1], out z) ? z : 0;
|
||
param = int.TryParse(strs[2], out param) ? param : 0;
|
||
}
|
||
PlayerBT.crossBD.Write(mapId, new Vector3(x, 0, z), param);
|
||
}
|
||
}
|
||
break;
|
||
case TNodeType.Player: //return string.Format("[{0}]", Param1);
|
||
case TNodeType.PlayerEx:
|
||
{
|
||
//ulong playerID = 0;
|
||
//ulong.TryParse(Param2, out playerID);
|
||
//if (playerID != 0)
|
||
//{
|
||
// // ChatPrivateInfo info = new ChatPrivateInfo();
|
||
// // info.ID = playerID;
|
||
// // info.Name = Param1;
|
||
// //
|
||
// // GameCenter.ChatPrivateSystem.AddChatPlayer(info);
|
||
// // GameCenter.ChatPrivateSystem.Open(playerID);
|
||
|
||
// GameCenter.PopMenuSystem.Open(playerID, Param1);
|
||
//}
|
||
}
|
||
break;
|
||
case TNodeType.Equipment: //return string.Format("[{0}]", Param1);
|
||
{
|
||
if(ItemParam != null)
|
||
{
|
||
GameCenter.LuaSystem.Adaptor.ShowItemTips(ItemParam, obj);
|
||
}
|
||
}
|
||
break;
|
||
case TNodeType.Item: //return string.Format("[{0}]", Param1);
|
||
{
|
||
if (int.TryParse(Param2, out id))
|
||
{
|
||
if (GO == null)
|
||
{
|
||
GameCenter.LuaSystem.Adaptor.ShowItemTips(id, obj, false);
|
||
}
|
||
else
|
||
{
|
||
GameCenter.LuaSystem.Adaptor.ShowItemTips(id, GO, false);
|
||
}
|
||
}
|
||
}
|
||
break;
|
||
case TNodeType.Function: //功能节点
|
||
{
|
||
if (GameCenter.GameSceneSystem.GetLocalPlayer().IsDead())
|
||
{
|
||
GameCenter.MsgPromptSystem.ShowPrompt(DeclareMessageString.Get(DeclareMessageString.Die_CanNotOperate));
|
||
return;
|
||
}
|
||
|
||
int funcType = 0;
|
||
if (int.TryParse(Param3, out funcType))
|
||
{
|
||
if (funcType == (int)FuncNodeType.Guild_Jion)
|
||
{
|
||
//UnityEngine.Debug.Log("快速加入帮会->" + Param2);
|
||
//string[] args = Param2.Split('_');
|
||
ulong guildId = 0;
|
||
if (ulong.TryParse(Param2, out guildId))
|
||
{
|
||
LocalPlayer lp = GameCenter.GameSceneSystem.GetLocalPlayer();
|
||
if (lp != null && lp.GuildID != 0)
|
||
{
|
||
GameCenter.MsgPromptSystem.ShowPrompt(Thousandto.Cfg.Data.DeclareMessageString.Get(Thousandto.Cfg.Data.DeclareMessageString.C_CHAT_YIYOUXIANMENG));
|
||
}
|
||
else
|
||
{
|
||
var info = GameCenter.MainFunctionSystem.GetFunctionInfo(FunctionStartIdCode.Guild);
|
||
if (info != null)
|
||
{
|
||
if (info.IsEnable == false)
|
||
{
|
||
GameCenter.MsgPromptSystem.ShowPrompt(string.Format(DeclareMessageString.Get(DeclareMessageString.C_MAIN_GONGNENGWEIKAIQI), info.Cfg.FunctionName));
|
||
return;
|
||
}
|
||
}
|
||
else
|
||
{
|
||
return;
|
||
}
|
||
MSG_Guild.ReqJoinGuild msg = new MSG_Guild.ReqJoinGuild();
|
||
msg.ids.Add(guildId);
|
||
msg.Send();
|
||
}
|
||
}
|
||
//int level = int.Parse(args[1]);
|
||
|
||
//GameCenter.MsgPromptSystem.ShowPrompt(Thousandto.Cfg.Data.DeclareMessageString.Get(Thousandto.Cfg.Data.DeclareMessageString.C_CHATNODE_APPLY_FINISH));
|
||
}
|
||
if (funcType == (int)FuncNodeType.Tean_Jion)
|
||
{
|
||
ulong teamId = 0;
|
||
if (ulong.TryParse(Param2, out teamId))
|
||
{
|
||
if (GameCenter.LuaSystem.Adaptor.IsTeamExist())
|
||
{
|
||
GameCenter.MsgPromptSystem.ShowPrompt(Thousandto.Cfg.Data.DeclareMessageString.Get(Thousandto.Cfg.Data.DeclareMessageString.TEAM_YOUHAVEDTEAM));
|
||
}
|
||
else
|
||
{
|
||
MSG_Team.ReqApplyEnter msg = new MSG_Team.ReqApplyEnter();
|
||
msg.teamId = (long)teamId;
|
||
msg.Send();
|
||
}
|
||
//GameCenter.MsgPromptSystem.ShowPrompt(DeclareMessageString.Get(DeclareMessageString.C_CHATNODE_APPLY_FINISH));
|
||
}
|
||
}
|
||
if (funcType == (int)FuncNodeType.ToGuildNPC)
|
||
{
|
||
ulong npcId = 0;
|
||
if (ulong.TryParse(Param2, out npcId))
|
||
{
|
||
//GameCenter.GuildSystem.OnEnterGuildMapTalkToNpc((int)npcId);
|
||
}
|
||
}
|
||
if (funcType == (int)FuncNodeType.FuDiHelp)
|
||
{
|
||
//福地支援
|
||
int cfgId = 0;
|
||
if (int.TryParse(Param2, out cfgId))
|
||
{
|
||
LocalPlayer lp = GameCenter.GameSceneSystem.GetLocalPlayer();
|
||
if (lp != null && lp.ID != specialId)
|
||
{
|
||
//发送进入副本消息
|
||
DeclareGuildBattleBoss cfg = DeclareGuildBattleBoss.Get(cfgId);
|
||
if (cfg != null)
|
||
{
|
||
//请求该支援消息是否有效
|
||
var req = new MSG_GuildActivity.ReqFudiCanHelp();
|
||
req.cfgId = cfgId;
|
||
req.Send();
|
||
}
|
||
}
|
||
}
|
||
}
|
||
if (funcType == (int)FuncNodeType.FunctionStartId)
|
||
{
|
||
if (Param2.IndexOf("_") > 0)
|
||
{
|
||
string[] args = Param2.Split('_');
|
||
int functionId = int.Parse(args[0]);
|
||
int argParam = int.Parse(args[1]);
|
||
GameCenter.MainFunctionSystem.DoFunctionCallBack(functionId, argParam);
|
||
|
||
}
|
||
else
|
||
{
|
||
int functionId = int.Parse(Param2);
|
||
|
||
////专门护送
|
||
//if(functionId == 2340000)
|
||
//{
|
||
// GameCenter.HuSongSystem.SearchToNpc();
|
||
// return;
|
||
//}
|
||
|
||
GameCenter.MainFunctionSystem.DoFunctionCallBack(functionId, null);
|
||
}
|
||
}
|
||
if (funcType == (int)FuncNodeType.FightSoul)
|
||
{
|
||
int cfgId = int.Parse(Param2);
|
||
//FightSoulSystem.ShowTempItemTips(cfgId);
|
||
}
|
||
if (funcType == (int)FuncNodeType.OpenUI)
|
||
{
|
||
string[] strs = Param2.Split('_');
|
||
if (strs.Length >= 2)
|
||
{
|
||
int uiID = int.TryParse(strs[1], out uiID) ? uiID : 0;
|
||
long param = long.TryParse(strs[0], out param) ? param : 0;
|
||
if (param == 0)
|
||
{
|
||
GameCenter.MainFunctionSystem.DoFunctionCallBack(uiID);
|
||
}
|
||
else
|
||
{
|
||
GameCenter.MainFunctionSystem.DoFunctionCallBack(uiID, param);
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
break;
|
||
default: break;
|
||
}
|
||
}
|
||
|
||
|
||
public void Destory()
|
||
{
|
||
if (_go == null)
|
||
{
|
||
return;
|
||
}
|
||
GameObject.Destroy(_go);
|
||
_go = null;
|
||
|
||
if (_chatNodeTool != null)
|
||
{
|
||
_chatNodeTool.Destory();
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
/// 如果当前node是动画节点,则开始播放动画
|
||
/// </summary>
|
||
public void PlayAnim()
|
||
{
|
||
if ((Type != (int)TNodeType.Image && Type != (int)TNodeType.BigImage) || GO == null)
|
||
{
|
||
return;
|
||
}
|
||
|
||
if (_chatNodeTool != null)
|
||
{
|
||
_chatNodeTool.PlayAnim(this);
|
||
}
|
||
}
|
||
}
|
||
}
|