151 lines
4.6 KiB
C#
151 lines
4.6 KiB
C#
//----------------------------------------------
|
|
// NGUI: Next-Gen UI kit
|
|
// Copyright © 2011-2014 Tasharen Entertainment
|
|
//----------------------------------------------
|
|
|
|
#if !UNITY_3_5 && !UNITY_FLASH
|
|
#define DYNAMIC_FONT
|
|
#endif
|
|
|
|
using UnityEngine;
|
|
using UnityEditor;
|
|
using System.Collections.Generic;
|
|
using Thousandto.DIY;
|
|
using System.IO;
|
|
using Thousandto.Code.Center;
|
|
using MSG_Map;
|
|
using System;
|
|
|
|
/// <summary>
|
|
/// Inspector class used to edit UILabels.
|
|
/// </summary>
|
|
[CustomEditor(typeof(Thousandto.GameUI.Form.UIMainChat), true)]
|
|
public partial class UIChatMainformInspector : Editor
|
|
{
|
|
private string _text = "";
|
|
private int _channel = 0;
|
|
private string _targetName = "";
|
|
private long _targetId = 0;
|
|
private int _sendCount = 1;
|
|
private float _interval = 0;
|
|
private float _setInterval = 0.1f;
|
|
private int _sendChatCount = 0;
|
|
|
|
private bool _sendChatByUpdate = false;
|
|
void OnInspectorUpdate()
|
|
{
|
|
if (!_sendChatByUpdate)
|
|
EditorApplication.update -= OnInspectorUpdate;
|
|
|
|
if (!_sendChatByUpdate)
|
|
return;
|
|
_interval += Time.deltaTime;
|
|
|
|
if(_interval >= _setInterval)
|
|
{
|
|
_interval = 0;
|
|
_sendChatCount++;
|
|
MSG_Chat.ChatResInfo myChat = new MSG_Chat.ChatResInfo();
|
|
myChat.chatchannel = (int)_channel;
|
|
myChat.condition = _text;
|
|
if (_sendChatCount % 3 == 0)
|
|
{
|
|
myChat.chater = GameCenter.GameSceneSystem.GetLocalPlayerID();
|
|
myChat.chatername = GameCenter.GameSceneSystem.GetLocalPlayer().Name;
|
|
}
|
|
|
|
GameCenter.ChatSystem.GS2U_ChatResSC(myChat);
|
|
}
|
|
}
|
|
|
|
public override void OnInspectorGUI()
|
|
{
|
|
base.OnInspectorGUI();
|
|
string channelStr = "";
|
|
for(int i = 0; i < (int)Thousandto.Code.Logic.ChatChanelType.COUNT; ++i)
|
|
{
|
|
if (i > 0 && i % 3 == 0)
|
|
channelStr += '\n';
|
|
channelStr += ((Thousandto.Code.Logic.ChatChanelType)i).ToString() + ": " + i + "|";
|
|
}
|
|
GUILayout.Label(channelStr);
|
|
_channel = EditorGUILayout.IntField("聊天频道", _channel);
|
|
_text = EditorGUILayout.TextField(_text);
|
|
_targetName = EditorGUILayout.TextField(_targetName);
|
|
_targetId = EditorGUILayout.LongField(_targetId);
|
|
|
|
|
|
GUILayout.Label("发送次数");
|
|
_sendCount = EditorGUILayout.IntField(_sendCount);
|
|
|
|
//GUILayout.BeginHorizontal();
|
|
if (GUILayout.Button("SendChat"))
|
|
{
|
|
if (_sendCount <= 0)
|
|
_sendCount = 1;
|
|
|
|
for(int i = 0; i < _sendCount; ++i)
|
|
{
|
|
MSG_Chat.ChatResInfo myChat = new MSG_Chat.ChatResInfo();
|
|
myChat.chatchannel = (int)_channel;
|
|
myChat.condition = _text;
|
|
if(i % 3 == 0)
|
|
{
|
|
myChat.chater = GameCenter.GameSceneSystem.GetLocalPlayerID();
|
|
myChat.chatername = GameCenter.GameSceneSystem.GetLocalPlayer().Name;
|
|
}
|
|
|
|
GameCenter.ChatSystem.GS2U_ChatResSC(myChat);
|
|
}
|
|
}
|
|
|
|
if(GUILayout.Button("私聊"))
|
|
{
|
|
MSG_Chat.ChatResInfo myChat = new MSG_Chat.ChatResInfo();
|
|
myChat.chatchannel = (int)Thousandto.Code.Logic.ChatChanelType.PERSONAL;
|
|
myChat.condition = _text;
|
|
myChat.chater = (ulong)_targetId;
|
|
myChat.chatername = _targetName;
|
|
GameCenter.ChatSystem.GS2U_ChatResSC(myChat);
|
|
}
|
|
//GUILayout.EndHorizontal();
|
|
|
|
if(GUILayout.Button("断线"))
|
|
{
|
|
GameCenter.Networker.TextCloseForReconnect();
|
|
}
|
|
|
|
if (GUILayout.Button("发送剧情传送"))
|
|
{
|
|
ReqCineMatic req = new ReqCineMatic();
|
|
req.plotId = int.Parse(_targetName);
|
|
req.Send();
|
|
}
|
|
|
|
GUILayout.BeginHorizontal();
|
|
GUILayout.Label("SetInterval:", GUILayout.MaxWidth(100));
|
|
_setInterval = EditorGUILayout.FloatField(_setInterval, GUILayout.MaxWidth(50));
|
|
|
|
if (GUILayout.Button("开启或关闭自动发送消息"))
|
|
{
|
|
_sendChatByUpdate = !_sendChatByUpdate;
|
|
if(_sendChatByUpdate)
|
|
EditorApplication.update += OnInspectorUpdate;
|
|
else
|
|
EditorApplication.update -= OnInspectorUpdate;
|
|
|
|
}
|
|
GUILayout.EndHorizontal();
|
|
}
|
|
|
|
private void GUILayoutHorizontal(params Action[] actions)
|
|
{
|
|
GUILayout.BeginHorizontal();
|
|
for(int i = 0; i < actions.Length; ++i)
|
|
{
|
|
actions[i]();
|
|
}
|
|
GUILayout.EndHorizontal();
|
|
}
|
|
}
|