public void GameMapMoveReq(Player player, byte[] byteArray) { GameMapMoveReqPayload.ParsePayload(byteArray, out var moveAction); var ackCode = GameMapAck.Success; if (!GameMapsDict.TryGetValue(player.PlayerData.MapSeed, out var gameMap)) { Console.WriteLine("不存在的地圖"); ackCode = GameMapAck.NoExistMapSeed; } //檢查面向,依照面向的位置往前後左右移動,然後再計算有沒有超界 if (!isBorder(gameMap, player, moveAction)) { Console.WriteLine("超越地圖邊界、不存在的動作"); ackCode = GameMapAck.OverBorder; } var payload = GameMapMoveRespPayload.CreatePayload(ackCode, player.PlayerData.PosX, player.PlayerData.PosY, player.PlayerData.PlayeyFace); Send(player, PacketBuilder.BuildPacket((int)SystemCategory.GameMapSystem, (int)GameMapCommand.MoveResp, payload)); }
public void OnMoveReq(GameMapAction.MoveAction moveAction) { //封包只傳往前後左右的動作 var payload = PacketBuilder.BuildPacket((int)SystemCategory.GameMapSystem, (int)GameMapCommand.MoveReq, GameMapMoveReqPayload.CreatePayload(moveAction)); SocketClientManager.Instance.Send(payload); }