2024-12-04 15:05:38 +08:00
|
|
|
|
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;
|
|
|
|
|
public class test : MonoBehaviour
|
|
|
|
|
{
|
|
|
|
|
public string token;
|
|
|
|
|
public WEBScriptListener wEBScriptListener;
|
2024-12-12 15:06:30 +08:00
|
|
|
|
|
2024-12-04 15:05:38 +08:00
|
|
|
|
public class auth_login
|
|
|
|
|
{
|
|
|
|
|
public string clientId = "e5cd7e4891bf95d1d19206ce24a7b32e";
|
|
|
|
|
public string grantType = "password";
|
|
|
|
|
public string userType = "company_user";
|
2024-12-12 11:04:48 +08:00
|
|
|
|
public string username = "13006065371";
|
|
|
|
|
public string password = "YYL5371!";
|
2024-12-04 15:05:38 +08:00
|
|
|
|
}
|
|
|
|
|
//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));
|
|
|
|
|
|
|
|
|
|
// // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ص<EFBFBD><D8B5><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
// server serverData = JsonConvert.DeserializeObject<server>(response);
|
|
|
|
|
// token = serverData.data.access_token;
|
|
|
|
|
// //Debug.Log(setverData.msg);
|
|
|
|
|
|
|
|
|
|
//}
|
2024-12-12 11:04:48 +08:00
|
|
|
|
|
2024-12-04 15:05:38 +08:00
|
|
|
|
//<2F><>¼
|
|
|
|
|
void lodingWebSocket()
|
|
|
|
|
{
|
|
|
|
|
LoginRequest data = new LoginRequest();
|
|
|
|
|
data.UserId = "1845037177556934657";
|
|
|
|
|
data.Account = "17311259169";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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("<22><>¼");
|
|
|
|
|
|
|
|
|
|
wEBScriptListener.SendMessageByte(sendData);
|
|
|
|
|
}
|
2024-12-12 11:04:48 +08:00
|
|
|
|
|
|
|
|
|
|
2024-12-04 15:05:38 +08:00
|
|
|
|
//<2F><><EFBFBD>뷿<EFBFBD><EBB7BF>
|
2024-12-12 17:18:12 +08:00
|
|
|
|
public void JoinRoom()
|
2024-12-04 15:05:38 +08:00
|
|
|
|
{
|
|
|
|
|
JoinRoomRequest data = new JoinRoomRequest();
|
|
|
|
|
data.RoomId = "168888";
|
|
|
|
|
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("<22><><EFBFBD>뷿<EFBFBD><EBB7BF>");
|
|
|
|
|
//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("<22><><EFBFBD>뷿<EFBFBD><EBB7BF>");
|
|
|
|
|
// //BroadcastFrameMsg.FramesFieldNumber
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// wEBScriptListener.SendMessageByte(sendData);
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD>
|
|
|
|
|
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);
|
|
|
|
|
// ÿ<><C3BF>ִ<EFBFBD>е<EFBFBD><D0B5><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
Debug.Log("ÿ<><C3BF>ִ<EFBFBD><D6B4>һ<EFBFBD><D2BB>");
|
|
|
|
|
wEBScriptListener.SendMessageByte(sendData);
|
|
|
|
|
|
|
|
|
|
// <20>ȴ<EFBFBD>һ<EFBFBD><D2BB>
|
|
|
|
|
await Task.Delay(1000);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//֡<>洢<EFBFBD><E6B4A2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
//void UpFps()
|
|
|
|
|
//{
|
|
|
|
|
// InputData data = new InputData();
|
|
|
|
|
// data.RoomId = "168888";
|
|
|
|
|
// data.Id = "778899";
|
|
|
|
|
// data.SId = "7";
|
|
|
|
|
// data.X = 7f;
|
|
|
|
|
// data.Y = 5f;
|
|
|
|
|
// data.Z = 4f;
|
|
|
|
|
// data.RoomSeatId = 5;
|
|
|
|
|
// 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("֡<>洢<EFBFBD><E6B4A2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
|
|
|
|
|
// //BroadcastFrameMsg.FramesFieldNumber
|
|
|
|
|
|
|
|
|
|
// wEBScriptListener.SendMessageByte(sendData);
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
//ʰȡ<CAB0><C8A1><EFBFBD><EFBFBD>
|
|
|
|
|
void PickUpProp()
|
|
|
|
|
{
|
|
|
|
|
PropRequest data = new PropRequest();
|
|
|
|
|
data.PropId = 1001;
|
|
|
|
|
data.RoomId = "168888";
|
|
|
|
|
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("ʰȡ<CAB0><C8A1><EFBFBD><EFBFBD>");
|
|
|
|
|
//BroadcastFrameMsg.FramesFieldNumber
|
|
|
|
|
|
|
|
|
|
wEBScriptListener.SendMessageByte(sendData);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//ʹ<>õ<EFBFBD><C3B5><EFBFBD>
|
|
|
|
|
void StartUseProp()
|
|
|
|
|
{
|
|
|
|
|
PropRequest data = new PropRequest();
|
|
|
|
|
data.RoomId = "168888";
|
|
|
|
|
data.PropId = 1001;
|
|
|
|
|
data.Action = 1;
|
|
|
|
|
data.PropServerId = "MTg1OTc5MDMwOTIyODc4OTc2MA==";
|
|
|
|
|
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("ʹ<>õ<EFBFBD><C3B5><EFBFBD>");
|
|
|
|
|
//BroadcastFrameMsg.FramesFieldNumber
|
|
|
|
|
|
|
|
|
|
wEBScriptListener.SendMessageByte(sendData);
|
|
|
|
|
}
|
|
|
|
|
//ֹͣʹ<D6B9>õ<EFBFBD><C3B5><EFBFBD>
|
|
|
|
|
void StopUseProp()
|
|
|
|
|
{
|
|
|
|
|
PropRequest data = new PropRequest();
|
|
|
|
|
data.RoomId = "168888";
|
|
|
|
|
data.PropId = 1001;
|
|
|
|
|
data.PropServerId = "MTg1OTc5MDMwOTIyODc4OTc2MA==";
|
|
|
|
|
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("ֹͣʹ<D6B9>õ<EFBFBD><C3B5><EFBFBD>");
|
|
|
|
|
//BroadcastFrameMsg.FramesFieldNumber
|
|
|
|
|
|
|
|
|
|
wEBScriptListener.SendMessageByte(sendData);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD>NPC ========================<3D><>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD>Ҫ
|
|
|
|
|
//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("<22><><EFBFBD><EFBFBD>NPC");
|
|
|
|
|
// //BroadcastFrameMsg.FramesFieldNumber
|
|
|
|
|
|
|
|
|
|
// wEBScriptListener.SendMessageByte(sendData);
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD>npc<70><63><EFBFBD><EFBFBD><EFBFBD>ҵ<EFBFBD><D2B5><EFBFBD>Ϣ ===============ֻ<><D6BB>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD>Ϣ
|
|
|
|
|
//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("<22><><EFBFBD><EFBFBD>npc<70><63><EFBFBD><EFBFBD><EFBFBD>ҵ<EFBFBD><D2B5><EFBFBD>Ϣ");
|
|
|
|
|
// //BroadcastFrameMsg.FramesFieldNumber
|
|
|
|
|
|
|
|
|
|
// wEBScriptListener.SendMessageByte(sendData);
|
|
|
|
|
//}
|
|
|
|
|
|
2024-12-12 19:49:08 +08:00
|
|
|
|
|
|
|
|
|
//11<31><31><EFBFBD><EFBFBD>ʼ<EFBFBD><CABC>ʱ
|
2024-12-04 15:05:38 +08:00
|
|
|
|
void RoomStartTime()
|
|
|
|
|
{
|
|
|
|
|
JoinRoomRequest data = new JoinRoomRequest();
|
|
|
|
|
data.RoomId = "168888";
|
|
|
|
|
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("<22><><EFBFBD><EFBFBD>npc<70><63><EFBFBD><EFBFBD><EFBFBD>ҵ<EFBFBD><D2B5><EFBFBD>Ϣ");
|
|
|
|
|
//BroadcastFrameMsg.FramesFieldNumber
|
|
|
|
|
|
|
|
|
|
wEBScriptListener.SendMessageByte(sendData);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Location()
|
|
|
|
|
{
|
|
|
|
|
MoveResponse data = new MoveResponse();
|
|
|
|
|
data.RoomId = "168888";
|
|
|
|
|
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("<22><><EFBFBD><EFBFBD>npc<70><63><EFBFBD><EFBFBD><EFBFBD>ҵ<EFBFBD><D2B5><EFBFBD>Ϣ");
|
|
|
|
|
//BroadcastFrameMsg.FramesFieldNumber
|
|
|
|
|
|
|
|
|
|
wEBScriptListener.SendMessageByte(sendData);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2024-12-05 17:38:33 +08:00
|
|
|
|
void TaskTrigger()
|
|
|
|
|
{
|
|
|
|
|
TaskTrigger data = new TaskTrigger();
|
|
|
|
|
data.RoomId = "168888";
|
|
|
|
|
data.TriggerId = "10006";
|
|
|
|
|
data.UserId = "1845037177556934659";
|
|
|
|
|
data.TypeStr = "selector";
|
|
|
|
|
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("==========<3D><><EFBFBD><EFBFBD>");
|
|
|
|
|
//BroadcastFrameMsg.FramesFieldNumber
|
|
|
|
|
|
|
|
|
|
wEBScriptListener.SendMessageByte(sendData);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void TaskUpdateRequest()
|
|
|
|
|
{
|
|
|
|
|
TaskUpdateRequest data = new TaskUpdateRequest();
|
|
|
|
|
data.RoomId = "168888";
|
|
|
|
|
data.TaskId = "d9608224-18b4-4d68-af45-82b3c843e3c3";
|
|
|
|
|
data.UserId = "1845037177556934659";
|
|
|
|
|
data.PropId = "3005";
|
|
|
|
|
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("==========<3D><><EFBFBD><EFBFBD>");
|
|
|
|
|
//BroadcastFrameMsg.FramesFieldNumber
|
|
|
|
|
|
|
|
|
|
wEBScriptListener.SendMessageByte(sendData);
|
|
|
|
|
}
|
|
|
|
|
|
2024-12-12 17:00:17 +08:00
|
|
|
|
public void NpcMove()
|
|
|
|
|
{
|
|
|
|
|
MoveRequest data = new MoveRequest();
|
|
|
|
|
data.RoomId = "168888";
|
|
|
|
|
data.SelectId = 10821;
|
|
|
|
|
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("==========ѡ<><D1A1>·<EFBFBD><C2B7>");
|
|
|
|
|
//BroadcastFrameMsg.FramesFieldNumber
|
|
|
|
|
|
|
|
|
|
wEBScriptListener.SendMessageByte(sendData);
|
|
|
|
|
}
|
2024-12-04 15:05:38 +08:00
|
|
|
|
|
2024-12-12 19:49:08 +08:00
|
|
|
|
//12<31><32><EFBFBD><EFBFBD>Ϣת<CFA2><D7AA>
|
|
|
|
|
public void MessageToUser()
|
|
|
|
|
{
|
|
|
|
|
MessageBroadcastRequest data = new MessageBroadcastRequest();
|
|
|
|
|
data.RoomId = "168888";
|
|
|
|
|
data.Type = 1;
|
|
|
|
|
data.RoleId = "8002";
|
|
|
|
|
data.Cmd = "55";
|
|
|
|
|
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("==========<3D><>Ϣת<CFA2><D7AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
|
|
|
|
|
//BroadcastFrameMsg.FramesFieldNumber
|
2024-12-04 15:05:38 +08:00
|
|
|
|
|
2024-12-12 19:49:08 +08:00
|
|
|
|
wEBScriptListener.SendMessageByte(sendData);
|
|
|
|
|
}
|
2024-12-04 15:05:38 +08:00
|
|
|
|
|
2024-12-13 17:19:27 +08:00
|
|
|
|
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("==========<3D><>Ϣת<CFA2><D7AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
|
|
|
|
|
//BroadcastFrameMsg.FramesFieldNumber
|
|
|
|
|
|
|
|
|
|
wEBScriptListener.SendMessageByte(sendData);
|
|
|
|
|
}
|
2024-12-04 15:05:38 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Start is called before the first frame update
|
|
|
|
|
async void Start()
|
|
|
|
|
{
|
|
|
|
|
//loging();
|
|
|
|
|
wEBScriptListener.ConcatWEBSocket();
|
|
|
|
|
wEBScriptListener.OnCallback += callback;
|
|
|
|
|
if (wEBScriptListener != null)
|
|
|
|
|
{
|
|
|
|
|
lodingWebSocket();
|
2024-12-12 17:07:43 +08:00
|
|
|
|
//JoinRoom();
|
2024-12-12 11:04:48 +08:00
|
|
|
|
Heartbeat();
|
2024-12-04 15:05:38 +08:00
|
|
|
|
//BroadcastMessage();
|
|
|
|
|
//UpFps();
|
|
|
|
|
//PickUpProp();
|
|
|
|
|
//StartUseProp();
|
|
|
|
|
//StopUseProp();
|
|
|
|
|
//RoomStartTime();
|
|
|
|
|
//Location();
|
2024-12-05 17:38:33 +08:00
|
|
|
|
//TaskTrigger();
|
|
|
|
|
//TaskUpdateRequest();
|
2024-12-12 17:07:43 +08:00
|
|
|
|
|
2024-12-04 15:05:38 +08:00
|
|
|
|
}
|
2024-12-12 11:04:48 +08:00
|
|
|
|
//int index = 0;
|
2024-12-04 15:05:38 +08:00
|
|
|
|
//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("<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:"+deinfo.MessageType);
|
|
|
|
|
byte[] bytes = deinfo.Data.ToByteArray();
|
|
|
|
|
switch (deinfo.MessageType)
|
|
|
|
|
{
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD>
|
|
|
|
|
//<2F><>¼
|
|
|
|
|
case "hall.Login":
|
|
|
|
|
Debug.Log("-=====--");
|
|
|
|
|
LoginResponse user = ProtoBufffer.DeSerialize<LoginResponse>(bytes);
|
|
|
|
|
Debug.Log(user);
|
2024-12-12 17:07:43 +08:00
|
|
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>Dz<EFBFBD><C7B2>Խ<D4BD><D7B6>õģ<C3B5><C4A3>ڵ<EFBFBD>¼֮<C2BC><D6AE><EFBFBD><EFBFBD><EFBFBD>ü<EFBFBD><C3BC>뷿<EFBFBD><EBB7BF>,<2C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɾ<EFBFBD><C9BE>
|
2024-12-12 17:18:12 +08:00
|
|
|
|
|
2024-12-04 15:05:38 +08:00
|
|
|
|
break;
|
|
|
|
|
|
2024-12-05 17:38:33 +08:00
|
|
|
|
//<2F><><EFBFBD>뷿<EFBFBD><EBB7BF>
|
2024-12-04 15:05:38 +08:00
|
|
|
|
case "hall.JoinRoom":
|
|
|
|
|
JoinRoomResponse joinRoomResponse = ProtoBufffer.DeSerialize<JoinRoomResponse>(bytes);
|
|
|
|
|
byte[] joinByte = joinRoomResponse.Data.ToByteArray();
|
|
|
|
|
PlayerJoinResponse playerJoinResponse = ProtoBufffer.DeSerialize<PlayerJoinResponse>(joinByte);
|
|
|
|
|
Debug.Log("<22><><EFBFBD>ң<EFBFBD>"+playerJoinResponse.UserName+"<22><><EFBFBD>뷿<EFBFBD><EBB7BF>:"+playerJoinResponse.RoomId.ToString());
|
2024-12-12 17:07:43 +08:00
|
|
|
|
|
|
|
|
|
|
2024-12-04 15:05:38 +08:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
//<2F>㲥
|
|
|
|
|
case "hall.BroadcastMessage":
|
|
|
|
|
UserJoinResponse userJoinResponse = ProtoBufffer.DeSerialize<UserJoinResponse>(bytes);
|
|
|
|
|
|
|
|
|
|
|
2024-12-06 11:29:20 +08:00
|
|
|
|
|
2024-12-06 15:15:30 +08:00
|
|
|
|
//Debug.Log(userJoinResponse.IncidentPosition);
|
2024-12-06 11:29:20 +08:00
|
|
|
|
Debug.Log(userJoinResponse);
|
|
|
|
|
if(userJoinResponse.MessageType == 1)//<2F>û<EFBFBD><C3BB><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
{
|
|
|
|
|
Debug.Log("<22><><EFBFBD><EFBFBD>:" + userJoinResponse.NickName + "<22><><EFBFBD><EFBFBD>");
|
|
|
|
|
}
|
|
|
|
|
if(userJoinResponse.MessageType == 2)//<2F>û<EFBFBD><C3BB><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
{
|
|
|
|
|
Debug.Log("<22><><EFBFBD><EFBFBD>:" + userJoinResponse.NickName + "<22><><EFBFBD><EFBFBD>");
|
|
|
|
|
}
|
|
|
|
|
if(userJoinResponse.MessageType == 3)//<2F><><EFBFBD>뷿<EFBFBD><EBB7BF>
|
|
|
|
|
{
|
|
|
|
|
Debug.Log("<22><><EFBFBD><EFBFBD>" + userJoinResponse.NickName + "<22><><EFBFBD>뷿<EFBFBD><EBB7BF>:" + userJoinResponse.RoomId.ToString() + "<22><><EFBFBD>û<EFBFBD><C3BB><EFBFBD>ɫ" + userJoinResponse.RoleName);
|
|
|
|
|
}
|
|
|
|
|
if(userJoinResponse.MessageType == 4)//<2F>¹ʷ<C2B9><CAB7><EFBFBD>
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
if(userJoinResponse.MessageType == 5)//<2F><><EFBFBD><EFBFBD>
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
if(userJoinResponse.MessageType == 6)//<2F><><EFBFBD><EFBFBD>
|
|
|
|
|
{
|
|
|
|
|
TaskInfoResponse taskInfoResponse = userJoinResponse.TaskResponse;
|
2024-12-06 16:43:56 +08:00
|
|
|
|
if (long.Parse(taskInfoResponse.ToUserId) == userJoinResponse.UserId)//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǵ<EFBFBD>ǰ<EFBFBD><C7B0><EFBFBD>ҵ<EFBFBD><D2B5><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD>
|
2024-12-06 11:29:20 +08:00
|
|
|
|
{
|
2024-12-13 17:19:27 +08:00
|
|
|
|
//TaskPanel.instance.SetInfo(int.Parse(taskInfoResponse.TaskId));
|
2024-12-06 11:29:20 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
2024-12-04 15:05:38 +08:00
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
case "fps.UpFps":
|
|
|
|
|
InputData inputData = ProtoBufffer.DeSerialize<InputData>(bytes);
|
|
|
|
|
Debug.Log("Id<49><64>" + inputData.Id + ",sId :" + inputData.SId + "<22><>X:"+ inputData.X.ToString() + "<22><>Y:" + inputData.Y.ToString() + "<22><>roomSeatId :" + inputData.RoomSeatId + "<22><>z:" + inputData.Z.ToString() + "<22><>roomId:" + inputData.RoomId);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case "prop.PickUpProp":
|
|
|
|
|
PropRequest propRequest = ProtoBufffer.DeSerialize<PropRequest>(bytes);
|
|
|
|
|
Debug.Log("PropId:" + propRequest.PropId);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case "prop.StartUseProp":
|
|
|
|
|
PropResponse useProp = ProtoBufffer.DeSerialize<PropResponse>(bytes);
|
|
|
|
|
|
|
|
|
|
Debug.Log("PropId:" + useProp);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case "prop.StopUseProp":
|
|
|
|
|
PropResponse stopuseProp = ProtoBufffer.DeSerialize<PropResponse>(bytes);
|
|
|
|
|
|
|
|
|
|
Debug.Log("PropId:" + stopuseProp);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case "move.Location":
|
2024-12-14 14:31:48 +08:00
|
|
|
|
//Debug.Log("move.Location<6F><6E><EFBFBD>ܵ<EFBFBD><DCB5><EFBFBD>");
|
2024-12-04 15:05:38 +08:00
|
|
|
|
NpcData npcData = ProtoBufffer.DeSerialize<NpcData>(bytes);
|
2024-12-14 14:31:48 +08:00
|
|
|
|
//Debug.Log(npcData);
|
2024-12-09 11:30:15 +08:00
|
|
|
|
if(npcData.Type == 1)//npc<70><63><EFBFBD><EFBFBD>
|
|
|
|
|
{
|
2024-12-12 15:48:41 +08:00
|
|
|
|
float x = -float.Parse(npcData.X.ToString());
|
2024-12-09 11:30:15 +08:00
|
|
|
|
float y = float.Parse(npcData.Y.ToString());
|
|
|
|
|
float z = float.Parse(npcData.Z.ToString());
|
2024-12-12 16:02:29 +08:00
|
|
|
|
Vector3 position = new Vector3(x, y, z);
|
|
|
|
|
|
2024-12-12 18:51:08 +08:00
|
|
|
|
NPCController.instance.InitNPC(position, npcData);
|
2024-12-09 11:30:15 +08:00
|
|
|
|
}
|
|
|
|
|
if(npcData.Type == 2)//npc<70>ƶ<EFBFBD>
|
|
|
|
|
{
|
2024-12-14 14:42:47 +08:00
|
|
|
|
Vector3 v = new Vector3(-float.Parse(npcData.X.ToString()), float.Parse(npcData.Y.ToString()), float.Parse(npcData.Z.ToString()));
|
2024-12-13 17:19:27 +08:00
|
|
|
|
foreach(RecuseNpc item in NPCController.instance.npcsList)
|
2024-12-12 18:51:08 +08:00
|
|
|
|
{
|
|
|
|
|
if(npcData.UserId == item.npcId)
|
|
|
|
|
{
|
2024-12-14 14:42:47 +08:00
|
|
|
|
Debug.Log("================" + v);
|
2024-12-12 18:51:08 +08:00
|
|
|
|
item.SetNpcDes(v);
|
|
|
|
|
}
|
|
|
|
|
}
|
2024-12-09 11:30:15 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//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;
|
2024-12-04 15:05:38 +08:00
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
2024-12-12 19:49:08 +08:00
|
|
|
|
case "task.InitStart":
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
2024-12-05 17:38:33 +08:00
|
|
|
|
//<2F><><EFBFBD><EFBFBD>
|
|
|
|
|
case "task.TaskTrigger":
|
|
|
|
|
Debug.Log("-----------task.TaskTrigger");
|
|
|
|
|
TaskTrigger taskTrigger = ProtoBufffer.DeSerialize<TaskTrigger>(bytes);
|
|
|
|
|
Debug.Log(taskTrigger);
|
2024-12-06 11:29:20 +08:00
|
|
|
|
|
2024-12-05 17:38:33 +08:00
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
case "task.UpdateTask":
|
|
|
|
|
Debug.Log("-----------task.TaskTrigger");
|
2024-12-12 17:00:17 +08:00
|
|
|
|
MoveRequest taskUpdateRequest = ProtoBufffer.DeSerialize<MoveRequest>(bytes);
|
2024-12-05 17:38:33 +08:00
|
|
|
|
Debug.Log(taskUpdateRequest);
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD><F3B4A5B7><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
case "object.HandleObject":
|
|
|
|
|
Debug.Log("-----------object.HandleObject");
|
|
|
|
|
RequestObject requestObject = ProtoBufffer.DeSerialize<RequestObject>(bytes);
|
|
|
|
|
Debug.Log(requestObject);
|
|
|
|
|
|
|
|
|
|
break;
|
2024-12-12 17:00:17 +08:00
|
|
|
|
//<2F><><EFBFBD><EFBFBD><F3B4A5B7><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
case "move.MoveNpc":
|
|
|
|
|
Debug.Log("-----------move.MoveNpc");
|
|
|
|
|
MoveRequest moveRequest = ProtoBufffer.DeSerialize<MoveRequest>(bytes);
|
|
|
|
|
Debug.Log(moveRequest);
|
|
|
|
|
|
|
|
|
|
break;
|
2024-12-05 17:38:33 +08:00
|
|
|
|
|
2024-12-12 17:00:17 +08:00
|
|
|
|
|
2024-12-05 17:38:33 +08:00
|
|
|
|
|
|
|
|
|
|
2024-12-12 17:00:17 +08:00
|
|
|
|
//case "prop.CreateNpc":
|
|
|
|
|
// MoveResponse moveResponse = ProtoBufffer.DeSerialize<MoveResponse>(bytes);
|
|
|
|
|
// Debug.Log("UserId:" + moveResponse.UserId + "<22><>RoomId:" + moveResponse.RoomId + "<22><>x:" + moveResponse.MoveData);
|
|
|
|
|
// break;
|
2024-12-04 15:05:38 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//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;
|
|
|
|
|
|
|
|
|
|
|
2024-12-05 17:38:33 +08:00
|
|
|
|
|
2024-12-04 15:05:38 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|