您最多选择25个主题
主题必须以中文或者字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
134 行
3.7 KiB
134 行
3.7 KiB
using MetaCity.Core.Common;
|
|
using UnityEngine;
|
|
using Newtonsoft.Json;
|
|
|
|
namespace MetaCity.Core.Messages
|
|
{
|
|
public class Message
|
|
{
|
|
public MessageType type { get; set; }
|
|
|
|
public string body { get; set; }
|
|
|
|
public Message(MessageType type, string body)
|
|
{
|
|
this.type = type;
|
|
this.body = body;
|
|
}
|
|
}
|
|
|
|
public enum MessageType
|
|
{
|
|
GameError = -1, // Optional. Unity to Platform
|
|
// General purpose, starts from 0
|
|
GameReady = 0, // Required. Unity to Platform
|
|
LevelReady = 1, // Reserved
|
|
ServerReady = 2, // Platform to Unity.
|
|
PlayerReady = 3, // Required if DS enabled. Unity to Platform
|
|
LauncherReady = 4, // Reserved
|
|
|
|
// Player related, starts from 100
|
|
Move = 101,
|
|
Animate = 102,
|
|
JoinMeeting = 110, // Required if Social feature enabled. Unity to Platform
|
|
InteractionChoice = 120,
|
|
StopInteraction = 121,
|
|
|
|
// UpdateRoomLayout = 200,
|
|
LoadSpace = 500, // Reserved
|
|
|
|
|
|
ApplicationFocus = 1000, // Reserved
|
|
LoadLevel = 1001,
|
|
|
|
PlayerJoins = 1101, // Platform to Unity
|
|
PlayerExits = 1102, // Platform to Unity
|
|
PlayerMoves = 1103,
|
|
PlayerAnimates = 1104,
|
|
ChooseInteraction = 1110,
|
|
UpdateItems = 1111,
|
|
|
|
// MapMaker related, starts from 1200
|
|
// BuildRoom = 1200,
|
|
// BuildRoomItem = 1201,
|
|
// AcceptRoom = 1202,
|
|
// SaveRoomLayout = 1203,
|
|
// CancelRoom = 1204,
|
|
|
|
ApplicationQuit = 1500, // Reserved
|
|
|
|
// Development purpose, starts from 2000
|
|
EnableConsole = 2000, // Reserved
|
|
}
|
|
|
|
public class PlayerInfo
|
|
{
|
|
public string userId { get; set; }
|
|
public int encId { get; set; }
|
|
public bool local { get; set; }
|
|
public string name { get; set; }
|
|
public string sex { get; set; }
|
|
|
|
[JsonConverter(typeof(VectorConverter))]
|
|
public Vector3 position { get; set; }
|
|
|
|
[JsonConverter(typeof(VectorConverter))]
|
|
public Vector3 rotation { get; set; }
|
|
public string animator { get; set; }
|
|
public string outfitString { get; set; }
|
|
|
|
public int avatarId { get; set; }
|
|
}
|
|
|
|
public class SyncTransform {
|
|
public int encId { get; set; }
|
|
public Vector3 pos { get; set; }
|
|
public Vector3 rot { get; set; }
|
|
}
|
|
|
|
public class SyncAnimation
|
|
{
|
|
public int encId { get; set; }
|
|
public string parameters { get; set; }
|
|
}
|
|
|
|
public class Interaction
|
|
{
|
|
public string itemId { get; set; }
|
|
public int capacity { get; set; }
|
|
public string name { get; set; }
|
|
public int index { get; set; }
|
|
public bool start { get; set; }
|
|
}
|
|
|
|
public class InteractionList
|
|
{
|
|
public Interaction[] interactions;
|
|
}
|
|
|
|
public class ItemProperty
|
|
{
|
|
public string id;
|
|
public int[] occupiedBy;
|
|
public bool unavailable;
|
|
}
|
|
|
|
public class UpdatePlayerMessage
|
|
{
|
|
private Vector3 position;
|
|
private Vector3 rotation;
|
|
|
|
public UpdatePlayerMessage(Transform transform)
|
|
{
|
|
position = transform.position;
|
|
rotation = transform.rotation.eulerAngles;
|
|
}
|
|
|
|
public float[] ToFloatArray()
|
|
{
|
|
float[] arr = {position.x, position.y, position.z, rotation.x, rotation.y, rotation.z};
|
|
return arr;
|
|
}
|
|
}
|
|
|
|
}
|