Example #1
0
        public void OnReplicateMove()
        {
            NCharacterController controller = OwnerController;

            if (controller != null)
            {
                // 发送移动消息
                C2S_Move msg;
                msg.messageId    = C2S_Move.Id;
                msg.Position     = controller.Location;
                msg.Acceleration = controller.Acceleration;
                msg.Yaw          = controller.Rotation.y;
                msg.Flag         = NSavedMove.ControllerToFlags(controller);
                msg.TimeStamp    = NativeEngineHelper.GetTimeSeconds();
                GameFrameManager.SendNetMessage <C2S_Move>(msg);
            }
        }
        public void OnReplicateMove()
        {
            LocalPlayerController controller = OwnerController;

            if (controller != null &&
                GameFrameManager.Instance.CurrentFrameType == GameFrameType.Gaming)
            {
                // 发送移动消息
                C2S_Move msg;
                msg.messageId    = C2S_Move.Id;
                msg.Position     = controller.Location;
                msg.Acceleration = controller.Acceleration;
                msg.Yaw          = Vector3.CalcYaw(controller.Acceleration);
                msg.Flag         = NSavedMove.ControllerToFlags(controller, controller.PressJump ? (Byte)MovementFlag.PressJump : Byte.MinValue);
                msg.TimeStamp    = NativeEngineHelper.GetTimeSeconds();
                GameFrameManager.SendNetMessage <C2S_Move>(msg);

                // 保存到消息队列以便验证
                controller.NetMovementMessages.Add(msg);

                //Debug.WriteLine("Send C2S_Move " + " Position:" + msg.Position + " Acceleration:" + msg.Acceleration + " Flag:" + msg.Flag);
            }
        }