微信登录

游戏互交1 - 双服SyncPositionHandler-CP保存位置

作用:SyncPositionHandler获得位置、ClientPeer保存位置

  1. SyncPositionHandler.cs
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using Common;
  7. using Common.Tools;
  8. using Photon.SocketServer;
  9. namespace MyGameServer.Handler
  10. {
  11. class SyncPositionHandler:BaseHandler
  12. {
  13. public SyncPositionHandler()
  14. {
  15. OpCode = OperationCode.SyncPosition;//位置
  16. }
  17. public override void OnOperationRequest(OperationRequest operationRequest, SendParameters sendParameters, ClientPeer peer)
  18. {
  19. Vector3Data pos = (Vector3Data)DictTool.GetValue<byte, object>(operationRequest.Parameters, (byte)ParameterCode.Position);//字典
  20. float x = (float)DictTool.GetValue<byte, object>(operationRequest.Parameters, (byte)ParameterCode.X);
  21. float y = (float)DictTool.GetValue<byte, object>(operationRequest.Parameters, (byte)ParameterCode.Y);
  22. float z = (float)DictTool.GetValue<byte, object>(operationRequest.Parameters, (byte)ParameterCode.Z);
  23. //MyGameServer.log.Info(x+y+z);//输出位置
  24. peer.x = x; peer.y = y; peer.z = z;
  25. }
  26. }
  27. }
游戏互交1 - 双服SyncPositionHandler-CP保存位置