コード例 #1
0
        public MStepRes Handle(long playerId, MStepReq message)
        {
            var playerInputs = new List <PlayerInput>();

            foreach (var item in message.GameInput.Commands)
            {
                playerInputs.Add(new PlayerInput(item));
            }
            var input = new Msg_PlayerInput(message.GameInput.Tick, (byte)message.GameInput.ActorId, playerInputs);

#if DEBUG_SHOW_INPUT
            if (input.Commands != null && input.Commands?.Length > 0)
            {
                var cmd         = input.Commands[0];
                var playerInput = new Deserializer(cmd.content).Parse <Lockstep.Game.PlayerInput>();
                if (playerInput.inputUV != LVector2.zero)
                {
                    Debug.Log(
                        $"curTick{Tick} isOutdate{input.Tick < Tick} RecvInput actorID:{input.ActorId}  inputTick:{input.Tick}  move:{playerInput.inputUV}");
                }
            }
#endif
            var        gameId = GameClass.GetGameIdWithPlayerId(playerId);
            IGameClass game   = GameClass.GetGame(gameId);
            game.HandlePlayerInput(input);

            return(new MStepRes {
                ID = message.ID, MsgType = EResType.Pong
            });
        }
コード例 #2
0
        public MStepRes Handle(long playerId, MStepReq message)
        {
            InitGameScene.RemoveWaitingPlayerId(playerId);
            var        gameId = GameClass.GetGameIdWithPlayerId(playerId);
            IGameClass game   = GameClass.GetGame(gameId);

            game.OnPlayerLeave(playerId);
            return(new MStepRes {
                ID = message.ID, MsgType = EResType.Pong
            });
        }