作用:服务器和Unity共用的请求响应码
解决方案资源管理器—解决方案“MyGameServer”—右键—添加—新建项—类库
命名为:
解决方案“MyGameServer”里
与MyGameServer并排
common
解决方案资源管理器—MyGameServer—引用—右键—添加引用—项目—解决方案—common—确定
common.dll就可以和MyGameServer一起生成在:
C:\Photon-OnPremise-Server-SDK_v4-0-29-11263\deploy\MyGameServer\bin
新生成的common.cs复制到Unity的Assest-pulgins
│ EventCode.cs-------------------#单向事件码
│ OperationCode.cs--------------#双向事件码
│ ParameterCode.cs-------------#数据参数接收码
│ PlayerData.cs-------------------#玩家数据
│ ReturnCode.cs------------------#返回码
│ Vector3Data.cs------------------#位置数据
namespace Common
{
public enum EventCode:byte //区分服务器向客户端发送的事件的类型
{
NewPlayer,//新的玩家
SyncPosition//打包位置信息
}
}
namespace Common
{
public enum OperationCode:byte //区分请求和响应的类型
{
Login,
Register,
Default,
SyncPosition,
SyncPlayer
}
}
namespace Common
{
public enum ParameterCode:byte //区分传送数据的时候,参数的类型
{
Username,
Password,
Position,
X,Y,Z,
UsernameList,
PlayerDataList
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Common
{
[Serializable]
public class PlayerData
{
public Vector3Data Pos { get; set; }
public string Username { get; set; }
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Common
{
public enum ReturnCode:short
{
Success,
Failed
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
//接收方向
namespace Common
{
[Serializable]
public class Vector3Data
{
public float x { get; set; }
public float y { get; set; }
public float z { get; set; }
}
}