1251 lines
46 KiB
C#
1251 lines
46 KiB
C#
using System.Collections;
|
||
using System.Collections.Generic;
|
||
using UnityEngine;
|
||
using Newtonsoft.Json;
|
||
using System.Net.Sockets;
|
||
using UnityWebSocket;
|
||
using System.Text;
|
||
using Google.Protobuf;
|
||
using System.Net.WebSockets;
|
||
using System;
|
||
using System.Threading.Tasks;
|
||
using UnityEngine.Networking.Types;
|
||
|
||
public class test : MonoBehaviour
|
||
{
|
||
public string token;
|
||
public WEBScriptListener wEBScriptListener;
|
||
|
||
public class auth_login
|
||
{
|
||
public string clientId = "e5cd7e4891bf95d1d19206ce24a7b32e";
|
||
public string grantType = "password";
|
||
public string userType = "company_user";
|
||
public string username = "13006065371";
|
||
public string password = "YYL5371!";
|
||
}
|
||
//public async void loging()
|
||
//{
|
||
// auth_login auth_Login = new auth_login();
|
||
// string response = await web.SendRequest(web.URL + "/auth/login", "POST", JsonUtility.ToJson(auth_Login));
|
||
|
||
// // 解析服务器返回的数据
|
||
// server serverData = JsonConvert.DeserializeObject<server>(response);
|
||
// token = serverData.data.access_token;
|
||
// //Debug.Log(setverData.msg);
|
||
|
||
//}
|
||
|
||
//登录
|
||
public void lodingWebSocket(string str)
|
||
{
|
||
LoginRequest data = new LoginRequest();
|
||
data.UserId = GlobalData.ServerData.data.userId ;
|
||
data.Account = str;
|
||
|
||
WSMessage msg = new WSMessage();
|
||
msg.Module = "hall";
|
||
msg.ServiceName = "Login";
|
||
msg.Data = ByteString.CopyFrom(ProtoBufffer.Serialize(data));
|
||
byte[] sendData = ProtoBufffer.Serialize(msg);
|
||
WSMessage deinfo = ProtoBufffer.DeSerialize<WSMessage>(sendData);
|
||
LoginRequest login = ProtoBufffer.DeSerialize<LoginRequest>(deinfo.Data.ToByteArray());
|
||
Debug.Log(login);
|
||
Debug.Log("dddddddddddddddddddd");
|
||
wEBScriptListener.SendMessageByte(sendData);
|
||
}
|
||
|
||
|
||
//加入房间
|
||
public void JoinRoom(string roomid)
|
||
{
|
||
JoinRoomRequest data = new JoinRoomRequest();
|
||
|
||
data.RoomId = roomid;
|
||
WSMessage msg = new WSMessage();
|
||
msg.Module = "hall";
|
||
msg.ServiceName = "JoinRoom";
|
||
msg.Data = ByteString.CopyFrom(ProtoBufffer.Serialize(data));
|
||
byte[] sendData = ProtoBufffer.Serialize(msg);
|
||
WSMessage deinfo = ProtoBufffer.DeSerialize<WSMessage>(sendData);
|
||
JoinRoomRequest login = ProtoBufffer.DeSerialize<JoinRoomRequest>(deinfo.Data.ToByteArray());
|
||
Debug.Log("加入房间");
|
||
//BroadcastFrameMsg.FramesFieldNumber
|
||
|
||
|
||
wEBScriptListener.SendMessageByte(sendData);
|
||
}
|
||
|
||
//void BroadcastMessage()
|
||
//{
|
||
// WSMessage msg = new WSMessage();
|
||
// msg.Module = "hall";
|
||
// msg.ServiceName = "BroadcastMessage";
|
||
// //msg.Data = ByteString.CopyFrom(ProtoBufffer.Serialize(data));
|
||
// byte[] sendData = ProtoBufffer.Serialize(msg);
|
||
// WSMessage deinfo = ProtoBufffer.DeSerialize<WSMessage>(sendData);
|
||
// JoinRoomRequest login = ProtoBufffer.DeSerialize<JoinRoomRequest>(deinfo.Data.ToByteArray());
|
||
// Debug.Log("加入房间");
|
||
// //BroadcastFrameMsg.FramesFieldNumber
|
||
|
||
|
||
// wEBScriptListener.SendMessageByte(sendData);
|
||
//}
|
||
|
||
//心跳
|
||
async void Heartbeat()
|
||
{
|
||
//WSMessage msg = new WSMessage();
|
||
//msg.Data = ByteString.CopyFrom(new byte[] { 1 });
|
||
//byte[] sendData = ProtoBufffer.Serialize(msg);
|
||
//Debug.Log("");
|
||
while (true)
|
||
{
|
||
WSMessage msg = new WSMessage();
|
||
msg.Module = "ping";
|
||
//msg.Data = ByteString.CopyFrom(new byte[] { 1 });
|
||
byte[] sendData = ProtoBufffer.Serialize(msg);
|
||
// 每秒执行的任务
|
||
Debug.Log("每秒执行一次");
|
||
wEBScriptListener.SendMessageByte(sendData);
|
||
|
||
// 等待2秒
|
||
await Task.Delay(2000);
|
||
}
|
||
}
|
||
|
||
//帧存储操作输入
|
||
public void UpFps(string id,string sid,float x,float y,int roomseatid,float z,string roomid)
|
||
{
|
||
InputData data = new InputData();
|
||
data.Id = id;
|
||
data.SId = sid;
|
||
data.X = x;
|
||
data.Y = y;
|
||
data.RoomSeatId = roomseatid;
|
||
data.Z = z;
|
||
data.RoomId = roomid;
|
||
WSMessage msg = new WSMessage();
|
||
msg.Module = "fps";
|
||
msg.ServiceName = "UpFps";
|
||
msg.Data = ByteString.CopyFrom(ProtoBufffer.Serialize(data));
|
||
byte[] sendData = ProtoBufffer.Serialize(msg);
|
||
WSMessage deinfo = ProtoBufffer.DeSerialize<WSMessage>(sendData);
|
||
InputData login = ProtoBufffer.DeSerialize<InputData>(deinfo.Data.ToByteArray());
|
||
Debug.Log("帧存储操作输入");
|
||
//BroadcastFrameMsg.FramesFieldNumber
|
||
|
||
wEBScriptListener.SendMessageByte(sendData);
|
||
}
|
||
|
||
//拾取道具
|
||
void PickUpProp(int propid,int action,string propserverid,string roomid)
|
||
{
|
||
PropRequest data = new PropRequest();
|
||
data.PropId = propid;
|
||
data.Action = action;
|
||
data.PropServerId = propserverid;
|
||
data.RoomId = roomid;
|
||
WSMessage msg = new WSMessage();
|
||
msg.Module = "prop";
|
||
msg.ServiceName = "PickUpProp";
|
||
msg.Data = ByteString.CopyFrom(ProtoBufffer.Serialize(data));
|
||
byte[] sendData = ProtoBufffer.Serialize(msg);
|
||
WSMessage deinfo = ProtoBufffer.DeSerialize<WSMessage>(sendData);
|
||
PropRequest login = ProtoBufffer.DeSerialize<PropRequest>(deinfo.Data.ToByteArray());
|
||
Debug.Log("拾取道具");
|
||
//BroadcastFrameMsg.FramesFieldNumber
|
||
|
||
wEBScriptListener.SendMessageByte(sendData);
|
||
}
|
||
|
||
//使用道具
|
||
void StartUseProp(int propid, int action, string propserverid, string roomid)
|
||
{
|
||
PropRequest data = new PropRequest();
|
||
data.PropId = propid;
|
||
data.Action = action;
|
||
data.PropServerId = propserverid;
|
||
data.RoomId = roomid;
|
||
WSMessage msg = new WSMessage();
|
||
msg.Module = "prop";
|
||
msg.ServiceName = "StartUseProp";
|
||
msg.Data = ByteString.CopyFrom(ProtoBufffer.Serialize(data));
|
||
byte[] sendData = ProtoBufffer.Serialize(msg);
|
||
WSMessage deinfo = ProtoBufffer.DeSerialize<WSMessage>(sendData);
|
||
PropRequest login = ProtoBufffer.DeSerialize<PropRequest>(deinfo.Data.ToByteArray());
|
||
Debug.Log("使用道具");
|
||
//BroadcastFrameMsg.FramesFieldNumber
|
||
|
||
wEBScriptListener.SendMessageByte(sendData);
|
||
}
|
||
|
||
//停止使用道具
|
||
void StopUseProp(int propid, int action, string propserverid, string roomid)
|
||
{
|
||
PropRequest data = new PropRequest();
|
||
data.RoomId = roomid;
|
||
data.PropId = propid;
|
||
data.PropServerId = propserverid;
|
||
data.Action = action;
|
||
WSMessage msg = new WSMessage();
|
||
msg.Module = "prop";
|
||
msg.ServiceName = "StopUseProp";
|
||
msg.Data = ByteString.CopyFrom(ProtoBufffer.Serialize(data));
|
||
byte[] sendData = ProtoBufffer.Serialize(msg);
|
||
WSMessage deinfo = ProtoBufffer.DeSerialize<WSMessage>(sendData);
|
||
PropRequest login = ProtoBufffer.DeSerialize<PropRequest>(deinfo.Data.ToByteArray());
|
||
Debug.Log("停止使用道具");
|
||
//BroadcastFrameMsg.FramesFieldNumber
|
||
|
||
wEBScriptListener.SendMessageByte(sendData);
|
||
}
|
||
|
||
//创建NPC ========================暂时不需要
|
||
//void CreateNpc()
|
||
//{
|
||
// PropRequest data = new PropRequest();
|
||
// data.RoomId = "168888";
|
||
// WSMessage msg = new WSMessage();
|
||
// msg.Module = "move";
|
||
// msg.ServiceName = "CreateNpc";
|
||
// msg.Data = ByteString.CopyFrom(ProtoBufffer.Serialize(data));
|
||
// byte[] sendData = ProtoBufffer.Serialize(msg);
|
||
// WSMessage deinfo = ProtoBufffer.DeSerialize<WSMessage>(sendData);
|
||
// PropRequest login = ProtoBufffer.DeSerialize<PropRequest>(deinfo.Data.ToByteArray());
|
||
// Debug.Log("创建NPC");
|
||
// //BroadcastFrameMsg.FramesFieldNumber
|
||
|
||
// wEBScriptListener.SendMessageByte(sendData);
|
||
//}
|
||
|
||
//推送npc和玩家的信息 ===============只需要收消息
|
||
//void Location()
|
||
//{
|
||
// PropRequest data = new PropRequest();
|
||
// data.RoomId = "168888";
|
||
// WSMessage msg = new WSMessage();
|
||
// msg.Module = "prop";
|
||
// msg.ServiceName = "CreateNpc";
|
||
// msg.Data = ByteString.CopyFrom(ProtoBufffer.Serialize(data));
|
||
// byte[] sendData = ProtoBufffer.Serialize(msg);
|
||
// WSMessage deinfo = ProtoBufffer.DeSerialize<WSMessage>(sendData);
|
||
// PropRequest login = ProtoBufffer.DeSerialize<PropRequest>(deinfo.Data.ToByteArray());
|
||
// Debug.Log("推送npc和玩家的信息");
|
||
// //BroadcastFrameMsg.FramesFieldNumber
|
||
|
||
// wEBScriptListener.SendMessageByte(sendData);
|
||
//}
|
||
|
||
|
||
|
||
|
||
//推送npc和玩家的信息
|
||
void Location(string userId = "2", string roomId = "3")
|
||
{
|
||
MoveResponse data = new MoveResponse();
|
||
data.RoomId = roomId;
|
||
data.UserId = userId;
|
||
|
||
|
||
|
||
WSMessage msg = new WSMessage();
|
||
msg.Module = "move";
|
||
msg.ServiceName = "Location";
|
||
msg.Data = ByteString.CopyFrom(ProtoBufffer.Serialize(data));
|
||
byte[] sendData = ProtoBufffer.Serialize(msg);
|
||
WSMessage deinfo = ProtoBufffer.DeSerialize<WSMessage>(sendData);
|
||
MoveResponse login = ProtoBufffer.DeSerialize<MoveResponse>(deinfo.Data.ToByteArray());
|
||
Debug.Log("推送npc和玩家的信息");
|
||
//BroadcastFrameMsg.FramesFieldNumber
|
||
|
||
wEBScriptListener.SendMessageByte(sendData);
|
||
}
|
||
|
||
|
||
//(1) 开始演练后需要执行的任务(当动画播放完成后调用)
|
||
public void InitStart(string roomid)
|
||
{
|
||
TaskTrigger data = new TaskTrigger();
|
||
data.RoomId = roomid;
|
||
|
||
WSMessage msg = new WSMessage();
|
||
msg.Module = "task";
|
||
msg.ServiceName = "InitStart";
|
||
msg.Data = ByteString.CopyFrom(ProtoBufffer.Serialize(data));
|
||
byte[] sendData = ProtoBufffer.Serialize(msg);
|
||
WSMessage deinfo = ProtoBufffer.DeSerialize<WSMessage>(sendData);
|
||
TaskTrigger login = ProtoBufffer.DeSerialize<TaskTrigger>(deinfo.Data.ToByteArray());
|
||
Debug.Log("==========任务触发");
|
||
//BroadcastFrameMsg.FramesFieldNumber
|
||
|
||
wEBScriptListener.SendMessageByte(sendData);
|
||
}
|
||
|
||
//(2) 任务触发
|
||
public void TaskTrigger(string userid,string roomid,string triggerid,string typestr,string targetid,string taskid,string roleid)
|
||
{
|
||
TaskTrigger data = new TaskTrigger();
|
||
data.RoomId = roomid;
|
||
data.TriggerId = triggerid;
|
||
data.UserId = userid;
|
||
data.TypeStr = typestr;
|
||
data.TargetId = targetid;
|
||
data.TaskId = taskid;
|
||
data.RoleId = roleid;
|
||
WSMessage msg = new WSMessage();
|
||
msg.Module = "task";
|
||
msg.ServiceName = "TaskTrigger";
|
||
msg.Data = ByteString.CopyFrom(ProtoBufffer.Serialize(data));
|
||
byte[] sendData = ProtoBufffer.Serialize(msg);
|
||
WSMessage deinfo = ProtoBufffer.DeSerialize<WSMessage>(sendData);
|
||
TaskTrigger login = ProtoBufffer.DeSerialize<TaskTrigger>(deinfo.Data.ToByteArray());
|
||
Debug.Log("==========任务触发");
|
||
//BroadcastFrameMsg.FramesFieldNumber
|
||
|
||
wEBScriptListener.SendMessageByte(sendData);
|
||
}
|
||
|
||
|
||
|
||
//(3) 更新任务状态
|
||
void TaskUpdateRequest(TaskUpdateRequest taskUpdateRequest)
|
||
{
|
||
//TaskUpdateRequest的数据在下面注释
|
||
/*
|
||
message TaskUpdateRequesti
|
||
string RoomId =1;//房间id
|
||
tring TaskId =2; // 任务id
|
||
string UserId =3;// 用户id
|
||
string SelectId =4;// 选项ID 界面按钮
|
||
string ToUserId =5;// 目标用户id
|
||
string UserName =6;//用户名
|
||
string PropId =7;//道具id
|
||
string PropName =8;//道具名称
|
||
int32 InputNum =9;//道具数量
|
||
string status =10;// 任务状态
|
||
string HandleButtoncallId=11;//处理按钮调用idstring TargetType =12;// 任务完成类型
|
||
*/
|
||
TaskUpdateRequest data = new TaskUpdateRequest();
|
||
data = taskUpdateRequest;
|
||
WSMessage msg = new WSMessage();
|
||
msg.Module = "task";
|
||
msg.ServiceName = "UpdateTask";
|
||
msg.Data = ByteString.CopyFrom(ProtoBufffer.Serialize(data));
|
||
byte[] sendData = ProtoBufffer.Serialize(msg);
|
||
WSMessage deinfo = ProtoBufffer.DeSerialize<WSMessage>(sendData);
|
||
TaskUpdateRequest login = ProtoBufffer.DeSerialize<TaskUpdateRequest>(deinfo.Data.ToByteArray());
|
||
Debug.Log("==========任务触发");
|
||
//BroadcastFrameMsg.FramesFieldNumber
|
||
|
||
wEBScriptListener.SendMessageByte(sendData);
|
||
}
|
||
|
||
//NPC路线选择
|
||
public void NpcMove(string roomId, int moveType, int selectId)
|
||
{
|
||
MoveRequest data = new MoveRequest();
|
||
data.RoomId = roomId;
|
||
data.MoveType = moveType;
|
||
data.SelectId = selectId;
|
||
|
||
WSMessage msg = new WSMessage();
|
||
msg.Module = "move";
|
||
msg.ServiceName = "MoveNpc";
|
||
msg.Data = ByteString.CopyFrom(ProtoBufffer.Serialize(data));
|
||
byte[] sendData = ProtoBufffer.Serialize(msg);
|
||
WSMessage deinfo = ProtoBufffer.DeSerialize<WSMessage>(sendData);
|
||
MoveRequest login = ProtoBufffer.DeSerialize<MoveRequest>(deinfo.Data.ToByteArray());
|
||
Debug.Log("==========选择路线");
|
||
//BroadcastFrameMsg.FramesFieldNumber
|
||
|
||
wEBScriptListener.SendMessageByte(sendData);
|
||
}
|
||
|
||
//11.开始计时
|
||
void RoomStartTime(string rooid)
|
||
{
|
||
JoinRoomRequest data = new JoinRoomRequest();
|
||
data.RoomId = rooid;
|
||
WSMessage msg = new WSMessage();
|
||
msg.Module = "hall";
|
||
msg.ServiceName = "RoomStartTime";
|
||
msg.Data = ByteString.CopyFrom(ProtoBufffer.Serialize(data));
|
||
byte[] sendData = ProtoBufffer.Serialize(msg);
|
||
WSMessage deinfo = ProtoBufffer.DeSerialize<WSMessage>(sendData);
|
||
JoinRoomRequest login = ProtoBufffer.DeSerialize<JoinRoomRequest>(deinfo.Data.ToByteArray());
|
||
Debug.Log("推送npc和玩家的信息");
|
||
//BroadcastFrameMsg.FramesFieldNumber
|
||
|
||
wEBScriptListener.SendMessageByte(sendData);
|
||
}
|
||
|
||
//12.消息转发
|
||
public void MessageToUser(string roomid, int type, string roleid, string cmd)
|
||
{
|
||
MessageBroadcastRequest data = new MessageBroadcastRequest();
|
||
data.RoomId = roomid;
|
||
data.Type = type;
|
||
data.RoleId = roleid;
|
||
data.Cmd = cmd;
|
||
WSMessage msg = new WSMessage();
|
||
msg.Module = "hall";
|
||
msg.ServiceName = "MessageToUser";
|
||
msg.Data = ByteString.CopyFrom(ProtoBufffer.Serialize(data));
|
||
byte[] sendData = ProtoBufffer.Serialize(msg);
|
||
WSMessage deinfo = ProtoBufffer.DeSerialize<WSMessage>(sendData);
|
||
MessageBroadcastRequest login = ProtoBufffer.DeSerialize<MessageBroadcastRequest>(deinfo.Data.ToByteArray());
|
||
Debug.Log("==========消息转发函数调用");
|
||
//BroadcastFrameMsg.FramesFieldNumber
|
||
|
||
wEBScriptListener.SendMessageByte(sendData);
|
||
}
|
||
|
||
//14.对象触发操作
|
||
public void HandleObject(RequestObject requestObject)
|
||
{
|
||
RequestObject data = new RequestObject();
|
||
|
||
WSMessage msg = new WSMessage();
|
||
msg.Module = "object";
|
||
msg.ServiceName = "HandleObject";
|
||
msg.Data = ByteString.CopyFrom(ProtoBufffer.Serialize(data));
|
||
byte[] sendData = ProtoBufffer.Serialize(msg);
|
||
WSMessage deinfo = ProtoBufffer.DeSerialize<WSMessage>(sendData);
|
||
MessageBroadcastRequest login = ProtoBufffer.DeSerialize<MessageBroadcastRequest>(deinfo.Data.ToByteArray());
|
||
Debug.Log("==========消息转发函数调用");
|
||
//BroadcastFrameMsg.FramesFieldNumber
|
||
|
||
wEBScriptListener.SendMessageByte(sendData);
|
||
}
|
||
|
||
|
||
public void CreateNpcHandler()
|
||
{
|
||
NpcCreateRequest data = new NpcCreateRequest();
|
||
data.RoomId = "168888";
|
||
data.SceneId = "9003";
|
||
data.TemplateId = 2;
|
||
WSMessage msg = new WSMessage();
|
||
msg.Module = "move";
|
||
msg.ServiceName = "CreateNpcHandler";
|
||
msg.Data = ByteString.CopyFrom(ProtoBufffer.Serialize(data));
|
||
byte[] sendData = ProtoBufffer.Serialize(msg);
|
||
WSMessage deinfo = ProtoBufffer.DeSerialize<WSMessage>(sendData);
|
||
NpcCreateRequest login = ProtoBufffer.DeSerialize<NpcCreateRequest>(deinfo.Data.ToByteArray());
|
||
Debug.Log("==========消息转发函数调用");
|
||
//BroadcastFrameMsg.FramesFieldNumber
|
||
|
||
wEBScriptListener.SendMessageByte(sendData);
|
||
}
|
||
|
||
//17.创建语音频道
|
||
public void RtcTokenHandler(VoiceRequest voiceRequest)
|
||
{
|
||
/*
|
||
VoiceRequest
|
||
uint32 uid =1;// 用户id
|
||
string channelName=2;//频道名称
|
||
Channelrype=5;//频道类型string
|
||
string roomId=8://游戏房间id
|
||
string role=6;//需要通知的角色 例如:1,2,3,4 You,Moments
|
||
*/
|
||
VoiceRequest data = new VoiceRequest();
|
||
data = voiceRequest;
|
||
|
||
WSMessage msg = new WSMessage();
|
||
msg.Module = "voice";
|
||
msg.ServiceName = "RtcTokenHandler";
|
||
msg.Data = ByteString.CopyFrom(ProtoBufffer.Serialize(data));
|
||
byte[] sendData = ProtoBufffer.Serialize(msg);
|
||
WSMessage deinfo = ProtoBufffer.DeSerialize<WSMessage>(sendData);
|
||
VoiceRequest login = ProtoBufffer.DeSerialize<VoiceRequest>(deinfo.Data.ToByteArray());
|
||
Debug.Log("==========消息转发函数调用");
|
||
//BroadcastFrameMsg.FramesFieldNumber
|
||
|
||
wEBScriptListener.SendMessageByte(sendData);
|
||
}
|
||
|
||
//18.NPC是否进入烟雾区域
|
||
public void EnterFogArea(string[] npclist,string roomid,int action)
|
||
{
|
||
npcRequest data = new npcRequest();
|
||
data.RoomId = roomid;
|
||
data.Action = action;
|
||
|
||
|
||
WSMessage msg = new WSMessage();
|
||
msg.Module = "voice";
|
||
msg.ServiceName = "RtcTokenHandler";
|
||
msg.Data = ByteString.CopyFrom(ProtoBufffer.Serialize(data));
|
||
byte[] sendData = ProtoBufffer.Serialize(msg);
|
||
WSMessage deinfo = ProtoBufffer.DeSerialize<WSMessage>(sendData);
|
||
npcRequest login = ProtoBufffer.DeSerialize<npcRequest>(deinfo.Data.ToByteArray());
|
||
Debug.Log("==========消息转发函数调用");
|
||
//BroadcastFrameMsg.FramesFieldNumber
|
||
|
||
wEBScriptListener.SendMessageByte(sendData);
|
||
}
|
||
|
||
|
||
//19.界面选项操作
|
||
public void SelectTrigger(SelectRequest selectRequest)
|
||
{
|
||
SelectRequest data = new SelectRequest();
|
||
data = selectRequest;
|
||
|
||
|
||
WSMessage msg = new WSMessage();
|
||
msg.Module = "select";
|
||
msg.ServiceName = "SelectTrigger";
|
||
msg.Data = ByteString.CopyFrom(ProtoBufffer.Serialize(data));
|
||
byte[] sendData = ProtoBufffer.Serialize(msg);
|
||
WSMessage deinfo = ProtoBufffer.DeSerialize<WSMessage>(sendData);
|
||
SelectRequest login = ProtoBufffer.DeSerialize<SelectRequest>(deinfo.Data.ToByteArray());
|
||
Debug.Log("==========消息转发函数调用");
|
||
//BroadcastFrameMsg.FramesFieldNumber
|
||
|
||
wEBScriptListener.SendMessageByte(sendData);
|
||
}
|
||
|
||
|
||
//20.选项操作记录
|
||
public void GetSelectHistoryList(string selectid,string userid,string roomid)
|
||
{
|
||
SelectHistoryRequest data = new SelectHistoryRequest();
|
||
data.SelectId = selectid;
|
||
data.UserId = userid;
|
||
data.RoomId = roomid;
|
||
|
||
|
||
|
||
WSMessage msg = new WSMessage();
|
||
msg.Module = "select";
|
||
msg.ServiceName = "GetSelectHistoryList";
|
||
msg.Data = ByteString.CopyFrom(ProtoBufffer.Serialize(data));
|
||
byte[] sendData = ProtoBufffer.Serialize(msg);
|
||
WSMessage deinfo = ProtoBufffer.DeSerialize<WSMessage>(sendData);
|
||
SelectHistoryRequest login = ProtoBufffer.DeSerialize<SelectHistoryRequest>(deinfo.Data.ToByteArray());
|
||
Debug.Log("==========消息转发函数调用");
|
||
//BroadcastFrameMsg.FramesFieldNumber
|
||
|
||
wEBScriptListener.SendMessageByte(sendData);
|
||
}
|
||
|
||
//16.获取任务列表
|
||
public void GetTaskList(TaskTrigger taskTrigger)
|
||
{
|
||
TaskTrigger data = new TaskTrigger();
|
||
data = taskTrigger;
|
||
|
||
|
||
|
||
WSMessage msg = new WSMessage();
|
||
msg.Module = "select";
|
||
msg.ServiceName = "GetSelectHistoryList";
|
||
msg.Data = ByteString.CopyFrom(ProtoBufffer.Serialize(data));
|
||
byte[] sendData = ProtoBufffer.Serialize(msg);
|
||
WSMessage deinfo = ProtoBufffer.DeSerialize<WSMessage>(sendData);
|
||
TaskTrigger login = ProtoBufffer.DeSerialize<TaskTrigger>(deinfo.Data.ToByteArray());
|
||
Debug.Log("==========消息转发函数调用");
|
||
//BroadcastFrameMsg.FramesFieldNumber
|
||
|
||
wEBScriptListener.SendMessageByte(sendData);
|
||
}
|
||
|
||
//15.推送玩家信息
|
||
public void ThatUser(PlayerJoinResponse player)
|
||
{
|
||
PlayerJoinResponse data = new PlayerJoinResponse();
|
||
data = player;
|
||
|
||
|
||
WSMessage msg = new WSMessage();
|
||
msg.Module = "select";
|
||
msg.ServiceName = "GetSelectHistoryList";
|
||
msg.Data = ByteString.CopyFrom(ProtoBufffer.Serialize(data));
|
||
byte[] sendData = ProtoBufffer.Serialize(msg);
|
||
WSMessage deinfo = ProtoBufffer.DeSerialize<WSMessage>(sendData);
|
||
PlayerJoinResponse login = ProtoBufffer.DeSerialize<PlayerJoinResponse>(deinfo.Data.ToByteArray());
|
||
Debug.Log("==========消息转发函数调用");
|
||
//BroadcastFrameMsg.FramesFieldNumber
|
||
|
||
wEBScriptListener.SendMessageByte(sendData);
|
||
}
|
||
|
||
|
||
public void TriggerNpcArrive()
|
||
{
|
||
MoveRoomAoiRequest data = new MoveRoomAoiRequest();
|
||
data.RoomId = "1";
|
||
data.UserId = 2;
|
||
data.X = 3f;
|
||
data.Y = 4f;
|
||
data.Z = 5f;
|
||
data.SceneId = "6";
|
||
data.NpcId = "7";
|
||
data.Action = 8;
|
||
|
||
|
||
WSMessage msg = new WSMessage();
|
||
msg.Module = "select";
|
||
msg.ServiceName = "GetSelectHistoryList";
|
||
msg.Data = ByteString.CopyFrom(ProtoBufffer.Serialize(data));
|
||
byte[] sendData = ProtoBufffer.Serialize(msg);
|
||
WSMessage deinfo = ProtoBufffer.DeSerialize<WSMessage>(sendData);
|
||
MoveRoomAoiRequest login = ProtoBufffer.DeSerialize<MoveRoomAoiRequest>(deinfo.Data.ToByteArray());
|
||
Debug.Log("==========消息转发函数调用");
|
||
//BroadcastFrameMsg.FramesFieldNumber
|
||
|
||
wEBScriptListener.SendMessageByte(sendData);
|
||
}
|
||
|
||
//21.玩家准备
|
||
public void PlayerReady(string roomId,bool isready)
|
||
{
|
||
PlayerReadyRequest data = new PlayerReadyRequest();
|
||
data.RoomId = roomId;
|
||
data.IsReady = isready;
|
||
|
||
Debug.Log("==========玩家准备,,,,,,,,,,,,,,");
|
||
WSMessage msg = new WSMessage();
|
||
msg.Module = "hall";
|
||
msg.ServiceName = "PlayerReady";
|
||
msg.Data = ByteString.CopyFrom(ProtoBufffer.Serialize(data));
|
||
byte[] sendData = ProtoBufffer.Serialize(msg);
|
||
WSMessage deinfo = ProtoBufffer.DeSerialize<WSMessage>(sendData);
|
||
PlayerReadyRequest login = ProtoBufffer.DeSerialize<PlayerReadyRequest>(deinfo.Data.ToByteArray());
|
||
Debug.Log("==========消息转发函数调用");
|
||
//BroadcastFrameMsg.FramesFieldNumber
|
||
|
||
wEBScriptListener.SendMessageByte(sendData);
|
||
}
|
||
|
||
//22.开始演练
|
||
public void StartGameDrill(string roomId)
|
||
{
|
||
JoinRoomRequest data = new JoinRoomRequest();
|
||
data.RoomId = roomId;
|
||
|
||
|
||
|
||
WSMessage msg = new WSMessage();
|
||
msg.Module = "hall";
|
||
msg.ServiceName = "StartGameDrill";
|
||
msg.Data = ByteString.CopyFrom(ProtoBufffer.Serialize(data));
|
||
byte[] sendData = ProtoBufffer.Serialize(msg);
|
||
WSMessage deinfo = ProtoBufffer.DeSerialize<WSMessage>(sendData);
|
||
JoinRoomRequest login = ProtoBufffer.DeSerialize<JoinRoomRequest>(deinfo.Data.ToByteArray());
|
||
Debug.Log("==========消息转发函数调用");
|
||
//BroadcastFrameMsg.FramesFieldNumber
|
||
|
||
wEBScriptListener.SendMessageByte(sendData);
|
||
}
|
||
|
||
//24.提交着火点 2024.12.30
|
||
public void PlayerSituation(FirePointRequest firePointRequest)
|
||
{
|
||
FirePointRequest data = new FirePointRequest();
|
||
data = firePointRequest;
|
||
|
||
|
||
Debug.Log("==========------------------用");
|
||
WSMessage msg = new WSMessage();
|
||
msg.Module = "hall";
|
||
msg.ServiceName = "SubmitFirePoint";
|
||
msg.Data = ByteString.CopyFrom(ProtoBufffer.Serialize(data));
|
||
byte[] sendData = ProtoBufffer.Serialize(msg);
|
||
WSMessage deinfo = ProtoBufffer.DeSerialize<WSMessage>(sendData);
|
||
FirePointRequest login = ProtoBufffer.DeSerialize<FirePointRequest>(deinfo.Data.ToByteArray());
|
||
Debug.Log("==========消息转发函数调用");
|
||
//BroadcastFrameMsg.FramesFieldNumber
|
||
|
||
wEBScriptListener.SendMessageByte(sendData);
|
||
}//23.玩家到位情况 2024.12.30
|
||
public void PlayerSituation(string roomId)
|
||
{
|
||
JoinRoomRequest data = new JoinRoomRequest();
|
||
data.RoomId = roomId;
|
||
|
||
|
||
Debug.Log("==========------------------用");
|
||
WSMessage msg = new WSMessage();
|
||
msg.Module = "hall";
|
||
msg.ServiceName = "PlayerSituation";
|
||
msg.Data = ByteString.CopyFrom(ProtoBufffer.Serialize(data));
|
||
byte[] sendData = ProtoBufffer.Serialize(msg);
|
||
WSMessage deinfo = ProtoBufffer.DeSerialize<WSMessage>(sendData);
|
||
JoinRoomRequest login = ProtoBufffer.DeSerialize<JoinRoomRequest>(deinfo.Data.ToByteArray());
|
||
Debug.Log("==========消息转发函数调用");
|
||
//BroadcastFrameMsg.FramesFieldNumber
|
||
|
||
wEBScriptListener.SendMessageByte(sendData);
|
||
}
|
||
|
||
|
||
|
||
// Start is called before the first frame update
|
||
async void Start()
|
||
{
|
||
//loging();
|
||
wEBScriptListener.ConcatWEBSocket();
|
||
wEBScriptListener.OnCallback += callback;
|
||
if (wEBScriptListener != null)
|
||
{
|
||
//lodingWebSocket(ReadRoom.instance.ID);
|
||
//JoinRoom();
|
||
Heartbeat();
|
||
//BroadcastMessage();
|
||
//UpFps();
|
||
//PickUpProp();
|
||
//StartUseProp();
|
||
//StopUseProp();
|
||
//RoomStartTime();
|
||
//Location();
|
||
//TaskTrigger();
|
||
//TaskUpdateRequest();
|
||
|
||
}
|
||
//int index = 0;
|
||
//while (true)
|
||
//{
|
||
// index++;
|
||
// NpcData moveData = new NpcData();
|
||
// moveData.X = index;
|
||
// moveData.Y = 1;
|
||
// moveData.Z = 1;
|
||
|
||
// MoveResponse data = new MoveResponse();
|
||
// data.MoveData.Add(moveData);
|
||
|
||
|
||
// WSResponse ws = new WSResponse();
|
||
// ws.MessageType = "move.Location";
|
||
// ws.Data = ByteString.CopyFrom(data.ToByteArray());
|
||
|
||
|
||
// callback(ProtoBufffer.Serialize(ws));
|
||
|
||
|
||
|
||
// //PlayerJoinResponse pj = new PlayerJoinResponse();
|
||
// //pj.UserName = "abc";
|
||
// //pj.RoomId = "2";
|
||
// //pj.Status = 0;
|
||
// //pj.RoleName = "ABC";
|
||
// //pj.IsLeadingNPC = 5;
|
||
// //pj.Online = true;
|
||
// //pj.RoleId = 7;
|
||
// //pj.GroupLeader = 0;
|
||
// //pj.ActionMode = 2;
|
||
// //pj.Group = -1;
|
||
// //pj.X = 11;
|
||
// //pj.Y = 12;
|
||
// //pj.Z = 13;
|
||
// //pj.OverseeCond = "14";
|
||
// //pj.SendFrameCount = 15;
|
||
// //pj.MoveSpeedFirst = 16;
|
||
// //pj.MoveSpeedSecond = 17;
|
||
// //pj.MoveSpeedThird = 18;
|
||
// //pj.BearLoad = 19;
|
||
// //pj.Protection = 20;
|
||
// //pj.Health = 21;
|
||
// //pj.RoleStatus = 22;
|
||
// //pj.UserId = 23;
|
||
|
||
|
||
// //JoinRoomResponse data = new JoinRoomResponse();
|
||
// //data.Data = pj;
|
||
|
||
// //WSResponse ws = new WSResponse();
|
||
// //ws.MessageType = "hall.JoinRoom";
|
||
// //ws.Data = ByteString.CopyFrom(data.ToByteArray());
|
||
|
||
// //callback(ProtoBufffer.Serialize(ws));
|
||
|
||
// await Task.Delay(1000);
|
||
//}
|
||
}
|
||
|
||
void callback(byte[] data)
|
||
{
|
||
WSResponse deinfo = ProtoBufffer.DeSerialize<WSResponse>(data);
|
||
Debug.Log("返回数据类型:" + deinfo.MessageType);
|
||
byte[] bytes = deinfo.Data.ToByteArray();
|
||
switch (deinfo.MessageType)
|
||
{
|
||
//监听
|
||
//登录
|
||
case "hall.Login":
|
||
Debug.Log("-=====--");
|
||
LoginResponse user = ProtoBufffer.DeSerialize<LoginResponse>(bytes);
|
||
Debug.Log(user);
|
||
//这里是测试阶段用的,在登录之后调用加入房间,后续会删掉
|
||
|
||
break;
|
||
|
||
//进入房间
|
||
case "hall.JoinRoom":
|
||
JoinRoomResponse joinRoomResponse = ProtoBufffer.DeSerialize<JoinRoomResponse>(bytes);
|
||
byte[] joinByte = joinRoomResponse.Data.ToByteArray();
|
||
PlayerJoinResponse playerJoinResponse = ProtoBufffer.DeSerialize<PlayerJoinResponse>(joinByte);
|
||
Debug.Log("玩家:" + playerJoinResponse.UserName + "加入房间:" + playerJoinResponse.RoomId.ToString());
|
||
GameObject.Find("player").transform.position = new Vector3((float)playerJoinResponse.X, (float)playerJoinResponse.Y, (float)playerJoinResponse.Z);
|
||
Debug.Log(playerJoinResponse.IsReady);//是否准备的判断
|
||
|
||
Debug.Log("玩家位置");
|
||
|
||
break;
|
||
|
||
//广播
|
||
case "hall.BroadcastMessage":
|
||
UserJoinResponse userJoinResponse = ProtoBufffer.DeSerialize<UserJoinResponse>(bytes);
|
||
/*
|
||
这里是userJoinResponse带的数据信息
|
||
int64 userId =1;//用户id
|
||
string nickName=2;//用户名
|
||
string roleName=3;//用户角色
|
||
string roomId=4;//房间号
|
||
bool online =5;//状态 接收这个用户是不是掉线了
|
||
事件状态 1 用户上线 2用户下线 3 用户加入房间 4 事故发生 5 火势6 任务7 对象操作 8 NPc 属性更新 9 语音信息、 10 用户信息更新 11 房间开始
|
||
int32 messageType = 6;
|
||
string cmd =7;//操作指令
|
||
string incidentPosition=8://事件发生位置
|
||
float fireRadius =9;//火势半径
|
||
int32 firevalue = 10;//火势值
|
||
TaskInfoResponse taskResponse=11;//任务信息
|
||
0bjectInfoResponse objectResponse=12;//对象信息
|
||
NpcInfoResponse npcResponse=13;//npc信息
|
||
VoiceTransportResponse voiceResponse =14;//语音信息
|
||
PlayerJoinResponse playerResponse=15;//玩家信息
|
||
*/
|
||
//Debug.Log(userJoinResponse);
|
||
if (userJoinResponse.MessageType == 1)//用户上线
|
||
{
|
||
Debug.Log("玩家:" + userJoinResponse.NickName + "上线");
|
||
}
|
||
if (userJoinResponse.MessageType == 2)//用户下线
|
||
{
|
||
Debug.Log("玩家:" + userJoinResponse.NickName + "下线");
|
||
}
|
||
if (userJoinResponse.MessageType == 3)//加入房间
|
||
{
|
||
Debug.Log("玩家" + userJoinResponse.NickName + "加入房间:" + userJoinResponse.RoomId.ToString() + ",用户角色" + userJoinResponse.RoleName);
|
||
}
|
||
if (userJoinResponse.MessageType == 4)//事故发生
|
||
{
|
||
|
||
}
|
||
if (userJoinResponse.MessageType == 5)//火势
|
||
{
|
||
//这里写更新火势的信息 半径userJoinResponse.FireRadius 位置userJoinResponse.IncidentPosition 火势值userJoinResponse.FireValue
|
||
|
||
|
||
}
|
||
if (userJoinResponse.MessageType == 6)//任务
|
||
{
|
||
//解析出任务信息到taskInfoResponse 里面有TaskId 状态Status 房间id 坐标x,y,z 类型Type 时间限制Timelimit 描述Des 触发条件Trigger 下一步任务NextTask 目标类型TargetType 奖励Reward 备注Note 创建时间CreatTime 更新时间UpdateTime 目标用户id ToUserId 基础任务的id BaseTaskid
|
||
TaskInfoResponse taskInfoResponse = userJoinResponse.TaskResponse;
|
||
if (long.Parse(taskInfoResponse.ToUserId) == userJoinResponse.UserId)//当这个任务是当前玩家的任务时显示任务
|
||
{
|
||
TaskPanel.instance.Taskad(int.Parse(taskInfoResponse.TaskId));
|
||
}
|
||
}
|
||
if (userJoinResponse.MessageType == 7)//对象操作
|
||
{
|
||
//解析出的对象信息objectInfoResponse里面有
|
||
/*
|
||
string RoomId=1;//对象id
|
||
string Id=2://ID
|
||
string objectId=3;//对象ID
|
||
string Note =4;//状态
|
||
string Type =5;// 对象类型lilubing,2024/11/2716:37·对象物体及任务:Changes
|
||
|
||
|
||
string Name=6;//对象文本Id
|
||
int64 Nameshowoffset=7;//对象文本显示偏移量
|
||
int64 showRadius=8;//对象显示半径
|
||
string Icon =9;//对象图标
|
||
string Role =10;//对象角色
|
||
string ItemDepend =11;//依赖物品
|
||
int64 Takerime = 12;// 交互、读条时间 -1 立即执行
|
||
string Needplayers = 13;// 判定范围,玩家数量,是否可操作(当人数不满足时)
|
||
string Taskstatus=14;//对应事件ID
|
||
string selectList=15;//选择列表
|
||
int64 onoff =16;// 操作状态 0不可操作1 可操作
|
||
|
||
string status=17;//状态
|
||
string ResChange =18;//资源变化
|
||
|
||
int64 ParallelControl=19;//是否支持多人操作
|
||
string ExtraValue=20;//额外参数
|
||
string UserIds = 21;// 玩家id列表 逗号分隔
|
||
|
||
string Createrime =22;//创建时间
|
||
|
||
string Updaterime =23;//更新时间
|
||
|
||
*/
|
||
ObjectInfoResponse objectInfoResponse = userJoinResponse.ObjectResponse;
|
||
}
|
||
if (userJoinResponse.MessageType == 8)//NPC属性更新
|
||
{
|
||
|
||
}
|
||
if (userJoinResponse.MessageType == 9)//语音信息
|
||
{
|
||
//解析出的语音信息voiceTransportResponse里面有 应用id AppId 用户id channelName
|
||
VoiceTransportResponse voiceTransportResponse = userJoinResponse.VoiceResponse;
|
||
}
|
||
if (userJoinResponse.MessageType == 10)//用户信息更新
|
||
{
|
||
//
|
||
|
||
}
|
||
if (userJoinResponse.MessageType == 11)//房间开始
|
||
{
|
||
Debug.LogWarning("房间开始");
|
||
test111.instance.Oppanel();
|
||
}
|
||
if (userJoinResponse.MessageType == 12)//玩家准备
|
||
{
|
||
if (userJoinResponse.IsAllReady)
|
||
{
|
||
Debug.Log("服务器给准备好消息");
|
||
GameObject.Find("HostCanvas").GetComponent<Starthost>().start.interactable = true;
|
||
GameObject.Find("HostCanvas").GetComponent<Starthost>().isSatisfy = true;
|
||
}
|
||
|
||
}
|
||
|
||
break;
|
||
|
||
//帧数据
|
||
case "fps.UpFps":
|
||
InputData inputData = ProtoBufffer.DeSerialize<InputData>(bytes);
|
||
Debug.Log("Id:" + inputData.Id + ",sId :" + inputData.SId + ",X:" + inputData.X.ToString() + ",Y:" + inputData.Y.ToString() + ",roomSeatId :" + inputData.RoomSeatId + ",z:" + inputData.Z.ToString() + ",roomId:" + inputData.RoomId);
|
||
break;
|
||
|
||
//拾取道具监听返回
|
||
case "prop.PickUpProp":
|
||
PropResponse PropResponse = ProtoBufffer.DeSerialize<PropResponse>(bytes);
|
||
//道具id propId 服务端ID propServerId 道具名称name 道具编码code 道具提示信息message
|
||
Debug.Log("PropId:" + PropResponse.PropId);
|
||
|
||
break;
|
||
|
||
//开始使用道具监听返回
|
||
case "prop.StartUseProp":
|
||
PropResponse useProp = ProtoBufffer.DeSerialize<PropResponse>(bytes);
|
||
//道具id propId 服务端ID propServerId 道具名称name 道具编码code 道具提示信息message
|
||
Debug.Log("PropId:" + useProp);
|
||
break;
|
||
|
||
case "prop.StopUseProp":
|
||
PropResponse stopuseProp = ProtoBufffer.DeSerialize<PropResponse>(bytes);
|
||
//道具id propId 服务端ID propServerId 道具名称name 道具编码code 道具提示信息message
|
||
Debug.Log("PropId:" + stopuseProp);
|
||
break;
|
||
|
||
case "move.Location":
|
||
//Debug.Log("move.Location接受到了");
|
||
MoveResponse playermove = ProtoBufffer.DeSerialize<MoveResponse>(bytes);
|
||
|
||
NpcData npcData = ProtoBufffer.DeSerialize<NpcData>(bytes);
|
||
//Debug.Log(npcData);
|
||
if (npcData.Type == 1)//npc创建
|
||
{
|
||
float x = -float.Parse(npcData.X.ToString());
|
||
float y = float.Parse(npcData.Y.ToString());
|
||
float z = float.Parse(npcData.Z.ToString());
|
||
Vector3 position = new Vector3(x, y, z);
|
||
|
||
NPCController.instance.InitNPC(position, npcData);
|
||
|
||
}
|
||
if (npcData.Type == 2)//npc移动
|
||
{
|
||
Vector3 v = new Vector3(float.Parse(npcData.X.ToString()), float.Parse(npcData.Y.ToString()) + 0.5f, float.Parse(npcData.Z.ToString()));
|
||
//NPCController.instance.npcposition.Add(v);
|
||
//foreach (RecuseNpc item in NPCController.instance.npcsList)
|
||
//{
|
||
// if (npcData.UserId == item.npcId)
|
||
// {
|
||
// //Debug.Log("================" + v);
|
||
// item.SetNpcDes(v);
|
||
// }
|
||
//}
|
||
foreach (var npcDict in NPCController.instance.npcsList)
|
||
{
|
||
foreach (var kvp in npcDict)
|
||
{
|
||
RecuseNpc npc = kvp.Key; // 获取 NPC 脚本(键)
|
||
Vector3 position = kvp.Value; // 获取 NPC 的位置(值)
|
||
|
||
if (npcData.UserId == npc.npcId)
|
||
{
|
||
npc.SetNpcDes(v);
|
||
Debug.Log($"NPCID{npcData.UserId}NPCPOSITION{v}");
|
||
}
|
||
|
||
|
||
}
|
||
}
|
||
}
|
||
|
||
//npc.transform.name = npcData.UserId;
|
||
//npc.transform.localScale = new Vector3(0.5f, 0.5f, 0.5f);
|
||
//npc.transform.position = new Vector3(x, y + 0.25f, z);
|
||
//npc.transform.parent = GameObject.Find("schoo103").transform;
|
||
|
||
break;
|
||
|
||
case "task.InitStart":
|
||
|
||
|
||
break;
|
||
|
||
|
||
//13(1)任务触发
|
||
case "task.TaskTrigger":
|
||
Debug.Log("-----------task.TaskTrigger");
|
||
TaskTrigger taskTrigger = ProtoBufffer.DeSerialize<TaskTrigger>(bytes);
|
||
Debug.Log(taskTrigger);
|
||
|
||
|
||
break;
|
||
//13(2)更新任务
|
||
case "task.UpdateTask":
|
||
Debug.Log("-----------task.TaskTrigger");
|
||
MoveRequest taskUpdateRequest = ProtoBufffer.DeSerialize<MoveRequest>(bytes);
|
||
Debug.Log(taskUpdateRequest);
|
||
|
||
|
||
break;
|
||
|
||
//对象触发操作
|
||
case "object.HandleObject":
|
||
Debug.Log("-----------object.HandleObject");
|
||
RequestObject requestObject = ProtoBufffer.DeSerialize<RequestObject>(bytes);
|
||
Debug.Log(requestObject);
|
||
|
||
break;
|
||
//
|
||
case "move.MoveNpc":
|
||
Debug.Log("-----------move.MoveNpc");
|
||
MoveRequest moveRequest = ProtoBufffer.DeSerialize<MoveRequest>(bytes);
|
||
Debug.Log(moveRequest);
|
||
|
||
break;
|
||
|
||
|
||
|
||
//15.对象触发操作
|
||
case "hall.ThatUser":
|
||
Debug.Log("-----------move.MoveNpc");
|
||
PlayerJoinResponse PlayerJoinResponse = ProtoBufffer.DeSerialize<PlayerJoinResponse>(bytes);
|
||
Debug.Log(PlayerJoinResponse);
|
||
|
||
break;
|
||
|
||
//16.获取任务列表
|
||
case "hall.GetTaskList":
|
||
/*
|
||
TaskListResponsetmessage
|
||
repeated TaskResponse tasks =1;//任务列表
|
||
|
||
message TaskResponsef
|
||
string TaskId =1;//任务id
|
||
string status =2;//状态
|
||
string RoomId =3;//房间id
|
||
float X=4;//x坐标
|
||
float Y=5;// y坐标
|
||
float z=6;// z坐标
|
||
string Type = 7;//类型
|
||
int64 TimeLimit =8;//时间限制
|
||
string Desc=9;//描述
|
||
string Trigger =10;//触发条件
|
||
string NextTasks =11;//下一步任务
|
||
string TargetType =12;//日标类型
|
||
string Reward =13;//奖励
|
||
string Note =14;//备注
|
||
string CreateTime =15;//创建时间
|
||
string UpdateTime =16;//更新时间
|
||
string ToUserId =17;//日标用户id
|
||
string BaseTaskId =18;//基础任务id
|
||
*/
|
||
Debug.Log("-----------move.MoveNpc");
|
||
TaskListResponse TaskListResponse = ProtoBufffer.DeSerialize<TaskListResponse>(bytes);
|
||
foreach (var task in TaskListResponse.Tasks)
|
||
{
|
||
Debug.Log(task.TaskId);
|
||
}
|
||
|
||
break;
|
||
|
||
//17.语音频道v
|
||
case "voice.RtcTokenHandler":
|
||
/*
|
||
uint32 uid =1;// 用户id
|
||
ChannelName=2;//频道名称string
|
||
ChannelId=3;//频道idstring
|
||
string Token =4://语音token
|
||
Channelrype=5;//频道类型string
|
||
string appId =7;// 需要通知的角色
|
||
*/
|
||
Debug.Log("-----------move.MoveNpc");
|
||
VoiceResponse voiceResponse = ProtoBufffer.DeSerialize<VoiceResponse>(bytes);
|
||
Debug.Log(voiceResponse);
|
||
|
||
break;
|
||
|
||
//19. 界面选项操作
|
||
case "select.SelectTrigger":
|
||
|
||
/*
|
||
tring Id =1;// 选择的ID
|
||
string BaseId =2;//选项表基础ID
|
||
string Note =3;// 选项说明
|
||
string Group =4;// 选项分组
|
||
string UnDisplay =5;// 是否隐藏 1 只显示一次 2 可重复显示
|
||
string ShowText =6;//显示文本
|
||
string Icon =7;// 图标
|
||
string Preconditions=8;//前置条件
|
||
string Exclusive =9;//是否独占
|
||
string TaskTime =10;// 任务时间
|
||
int64 TimeLimit = 11;// 时间限制
|
||
string NextSelect =12;//下一个选项
|
||
string TaskLink = 13;// 任务链接
|
||
string TaskLinkDetails = 14;// 任务链接详情
|
||
string callMode = 15;// 呼叫方式
|
||
string callRecipient =16;//呼叫接收者
|
||
string Correctoption=17;//正确选项
|
||
string Reward =18;//奖励
|
||
string Result=19;//结果
|
||
string Route =20;//路由
|
||
string TimingChange = 21;//是否允许定时修改
|
||
string ApplieduI = 22;// 是否已应用UI
|
||
string UIDetails = 23;// UI详情
|
||
string Seq = 24;// 执行时的序列帧
|
||
string PlayScript = 25;// JSON格式的播放脚本
|
||
string RoomId=26;//房间ID
|
||
string CreateTime =27;//创建时间
|
||
string UpdateTime =28;//更新时间
|
||
string UserId =29;//创建人ID
|
||
string RoleId =30;//角色ID
|
||
*/
|
||
Debug.Log("select.SelectTrigger");
|
||
SelectResponse selectRequest = ProtoBufffer.DeSerialize<SelectResponse>(bytes);
|
||
Debug.Log(selectRequest);
|
||
|
||
break;
|
||
|
||
//20. 选项操作记录
|
||
case "select.GetSelectHistoryList":
|
||
/*
|
||
message SelectHistoryResponse
|
||
meated selectResponse selects= 1;// 选择历史列表
|
||
|
||
message SelectResponse
|
||
string Id =1;// 选择的ID
|
||
string BaseId =2;//选项表基础ID
|
||
string Note =3;//选项说明
|
||
string Group =4;//选项分组
|
||
string UnDisplay =5;// 是否隐藏 1 只显示一次 2 可重复显示
|
||
string ShowText =6;// 显示文本
|
||
string Icon =7;// 图标
|
||
string Preconditions=8;//前置条件
|
||
string Exclusive =9;// 是否独占
|
||
string TaskTime =10;// 任务时间
|
||
int64 TimeLimit = 11;// 时问限制
|
||
string NextSelect=12;//下一个选项
|
||
string TaskLink=13;//任务链接
|
||
string TaskLinkDetails=14;//任务链接详情
|
||
string callMode =15;//呼叫方式
|
||
string callRecipient =16;//呼叫接收者
|
||
string Correctoption=17;//正确选项
|
||
string Reward =18;// 奖励
|
||
string Result = 19;// 结果
|
||
string Route =20;//路由
|
||
string Timingchange =21;//是否允许定时修改
|
||
string ApplieduI=22;//是否已应用UI
|
||
string UIDetails=23;//UI详情
|
||
string Seq=24;// 执行时的序列帧
|
||
string PlayScript=25;//JSON格式的播放脚本
|
||
string RoomId=26;//房问ID
|
||
string CreateTime=27;//创建时问
|
||
string UpdateTime =28;// 更新时间
|
||
string UserId =29;//创建人ID
|
||
string RoleId =30://角色ID
|
||
repeated UserList SelectUserList =31;//选择的用户ID
|
||
repeated string SelectRoleList=32;//选择的角色ID
|
||
message UserList{
|
||
string UserId =1://用户ID
|
||
string RoleId=2;//角色ID
|
||
*/
|
||
Debug.Log("select.GetSelectHistoryList");
|
||
SelectHistoryResponse selectHistoryResponse = ProtoBufffer.DeSerialize<SelectHistoryResponse>(bytes);
|
||
foreach (var selectRes in selectHistoryResponse.Selects)
|
||
{
|
||
Debug.Log(selectRes.Id);
|
||
}
|
||
break;
|
||
|
||
//21.NPC是否被扛起
|
||
case "hall.PlayerReady":
|
||
//SelectResponse selectResponse = ProtoBufffer.DeSerialize<SelectResponse>(bytes);
|
||
|
||
|
||
break;
|
||
|
||
//23.玩家到位情况 2024.12.30
|
||
//case "hall.PlayerSituation":
|
||
// //SelectResponse selectResponse = ProtoBufffer.DeSerialize<SelectResponse>(bytes);
|
||
// PlayerStatisticsResponse playerStatisticsResponse1 = ProtoBufffer.DeSerialize<PlayerStatisticsResponse>(bytes);
|
||
// foreach(var item in playerStatisticsResponse1.Data)
|
||
// {
|
||
// Debug.Log(item.UserId);
|
||
// }
|
||
// break;
|
||
|
||
//23.玩家到位情况 2024.12.30 之前后端让改的
|
||
case "hall.PlayerSituation":
|
||
Debug.LogError("玩家状态11111111111111111");
|
||
PlayerStatisticsResponse playerStatisticsResponse = ProtoBufffer.DeSerialize<PlayerStatisticsResponse>(bytes);
|
||
Debug.LogError(playerStatisticsResponse.Data.Count);
|
||
foreach (var item in playerStatisticsResponse.Data)
|
||
{
|
||
Debug.Log(item.RoleId);
|
||
Debug.Log(item.IsReady);
|
||
}
|
||
Personnelpreparation.instance.playerStatisticsResponse = playerStatisticsResponse;
|
||
Personnelpreparation.instance.UpdateSubObjectList();
|
||
break;
|
||
|
||
//25.监听用户是否登录
|
||
case "user.UnOnlineByUser":
|
||
|
||
|
||
|
||
break;
|
||
|
||
|
||
|
||
|
||
|
||
//case "hall.RoomStartTime":
|
||
// JoinRoomRequest joinRoomRequest = ProtoBufffer.DeSerialize<JoinRoomRequest>(bytes);
|
||
// Debug.Log("PropId:" + joinRoomRequest.RoomId);
|
||
// break;
|
||
//case " hall.MessageToUser":
|
||
// //JoinRoomRequest joinRoomRequest = ProtoBufffer.DeSerialize<JoinRoomRequest>(bytes);
|
||
// //Debug.Log("PropId:" + joinRoomRequest.RoomId);
|
||
// break;
|
||
|
||
|
||
|
||
}
|
||
}
|
||
|
||
}
|