作用:SyncPositionHandler获得位置、ClientPeer保存位置
SyncPositionHandler.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Common;
using Common.Tools;
using Photon.SocketServer;
namespace MyGameServer.Handler
{
class SyncPositionHandler:BaseHandler
{
public SyncPositionHandler()
{
OpCode = OperationCode.SyncPosition;//位置
}
public override void OnOperationRequest(OperationRequest operationRequest, SendParameters sendParameters, ClientPeer peer)
{
Vector3Data pos = (Vector3Data)DictTool.GetValue<byte, object>(operationRequest.Parameters, (byte)ParameterCode.Position);//字典
float x = (float)DictTool.GetValue<byte, object>(operationRequest.Parameters, (byte)ParameterCode.X);
float y = (float)DictTool.GetValue<byte, object>(operationRequest.Parameters, (byte)ParameterCode.Y);
float z = (float)DictTool.GetValue<byte, object>(operationRequest.Parameters, (byte)ParameterCode.Z);
//MyGameServer.log.Info(x+y+z);//输出位置
peer.x = x; peer.y = y; peer.z = z;
}
}
}