예제 #1
0
        private void HandleInput()
        {
            ObjectController playerController = _objects.Find(obj => obj.ObjectId.Equals(_playerObjectId));

            if (playerController != null && playerController.ObjectType.Equals(ObjectEnum.Player))
            {
                Dictionary <InputEnum, bool> inputMap = InputMapper.ExtractInput();
                float      mouseX              = Input.GetAxisRaw("Mouse X");
                float      timeStamp           = _timeManager.GetCurrentTime();
                Quaternion rotation            = ((PlayerController)playerController).GetRotation();
                bool       isSameInputAsBefore = InputMapper.CompareInputs(inputMap, _lastInputSent);
                if (!isSameInputAsBefore)
                {
                    //Debug.Log("Send input" + InputMapper.InputMapToInt(inputMap));
                    _eventManager.SendEventAction(new MovementAction(timeStamp, inputMap, rotation), _serverId);
                    _lastInputSent = inputMap;
                }
                if (Prediction)
                {
                    ((PlayerController)playerController).ApplyInputPrediction(inputMap, mouseX, timeStamp);
                }
                if (Math.Abs(mouseX) > 0.1f)
                {
                    ((PlayerController)playerController).ApplyMouseInput(mouseX);

                    //_eventManager.SendEventAction(new RotationAction(rotation), _serverId);
                }
            }
        }