Exemplo n.º 1
0
        private void CalcFinalOutput(PlayerEntity player, DummyCameraMotorInput input,
                                     CameraStateOutputNewComponent finalOutput, DummyCameraMotorState state)
        {
            player.cameraConfigNow.Config     = state.GetMainConfig();
            player.cameraConfigNow.PeekConfig = SingletonManager.Get <CameraConfigManager>().Config.PeekConfig;
            player.cameraConfigNow.DeadConfig = SingletonManager.Get <CameraConfigManager>().Config.DeadConfig;
            _output.Init();
            _output.ArchorPosition =
                player.cameraArchor.ArchorPosition +
                player.cameraArchor.ArchorTransitionOffsetPosition;
            _output.ArchorEulerAngle = player.cameraArchor.ArchorEulerAngle;

            for (int i = 0; i < (int)SubCameraMotorType.End; i++)
            {
                var type = (SubCameraMotorType)i;
                _output.Append(CalcSubFinalCamera(player, input, state, _motors.GetDict(type), state.Get(type),
                                                  player.time.ClientTime));
            }

            finalOutput.ArchorPosition   = _output.ArchorPosition;
            finalOutput.ArchorEulerAngle = _output.ArchorEulerAngle;
            finalOutput.ArchorOffset     = _output.ArchorOffset;
            finalOutput.ArchorPostOffset = _output.ArchorPostOffset;
            finalOutput.EulerAngle       = _output.EulerAngle;
            finalOutput.Offset           = _output.Offset;
            finalOutput.PostOffset       = _output.PostOffset;
            finalOutput.Fov  = _output.Fov;
            finalOutput.Far  = _output.Far;
            finalOutput.Near = _output.Near;

            SmoothFov(player);
        }
Exemplo n.º 2
0
        private void CalcuForNormal(IUserCmd cmd, PlayerEntity player, Vector3 archotRotation,
                                    CameraStateOutputNewComponent result)
        {
            DummyCameraMotorState.Convert(player.cameraStateNew, _state);

            DummyCameraMotorInput _input = (DummyCameraMotorInput)player.cameraStateNew.CameraMotorInput;

            _input.Generate(_context, player, cmd, archotRotation.y, archotRotation.x);

            for (int i = 0; i < (int)SubCameraMotorType.End; i++)
            {
                var type = (SubCameraMotorType)i;
                SetNextMotor(player, type, _state, _input);
            }

            CameraActionManager.OnAction(player, _state);

            player.cameraStateUpload.EnterActionCode = CameraActionManager.GetActionCode(CameraActionType.Enter);
            player.cameraStateUpload.LeaveActionCode = CameraActionManager.GetActionCode(CameraActionType.Leave);
            CameraActionManager.ClearActionCode();

            player.cameraStateNew.CameraMotorInput     = player.cameraStateNew.LastCameraMotorInput;
            player.cameraStateNew.LastCameraMotorInput = _input;

            CalcFinalOutput(player, (DummyCameraMotorInput)player.cameraStateNew.LastCameraMotorInput,
                            result, _state);
        }
Exemplo n.º 3
0
        protected override void ExecWhenObserving(PlayerEntity player, IUserCmd cmd)
        {
            var observedPlayer = player.observeCamera.ObservedPlayer;

            if (observedPlayer != null)
            {
                DummyCameraMotorInput _input = (DummyCameraMotorInput)observedPlayer.cameraStateNew.CameraMotorInput;
                if (_input == null)
                {
                    _input = new DummyCameraMotorInput();
                }
                _input.FakeForObserve(observedPlayer);

                DummyCameraMotorState.Convert(observedPlayer.cameraStateNew, _state);

                observedPlayer.cameraStateNew.CameraMotorInput     = observedPlayer.cameraStateNew.LastCameraMotorInput;
                observedPlayer.cameraStateNew.LastCameraMotorInput = _input;

                var result = observedPlayer.cameraStateOutputNew;
                CalcFinalOutput(observedPlayer, (DummyCameraMotorInput)observedPlayer.cameraStateNew.LastCameraMotorInput,
                                result, _state);

                DummyCameraMotorState.Convert(_state, observedPlayer.cameraStateNew);
            }

            RestoreSelfPlayer(player);
        }
Exemplo n.º 4
0
        private void CalcFinalOutput(PlayerEntity player, DummyCameraMotorInput input,
                                     CameraStateOutputNewComponent finalOutput, DummyCameraMotorState state)
        {
            _output.Init();
            _output.ArchorPosition =
                player.cameraArchor.ArchorPosition +
                player.cameraArchor.ArchorTransitionOffsetPosition;
            _output.ArchorEulerAngle = player.cameraArchor.ArchorEulerAngle;

            for (int i = 0; i < (int)SubCameraMotorType.End; i++)
            {
                var type = (SubCameraMotorType)i;
                _output.Append(CalcSubFinalCamera(player, input, state, _motors.GetDict(type), state.Get(type),
                                                  player.time.ClientTime));
            }

            finalOutput.ArchorPosition   = _output.ArchorPosition;
            finalOutput.ArchorEulerAngle = _output.ArchorEulerAngle;
            finalOutput.ArchorOffset     = _output.ArchorOffset;
            finalOutput.ArchorPostOffset = _output.ArchorPostOffset;
            finalOutput.EulerAngle       = _output.EulerAngle;
            finalOutput.Offset           = _output.Offset;
            finalOutput.PostOffset       = _output.PostOffset;
            finalOutput.Fov  = _output.Fov;
            finalOutput.Far  = _output.Far;
            finalOutput.Near = _output.Near;
            finalOutput.NeedDetectDistance = !_output.ForbidDetect;

            SmoothFov(player, input.GetViewConfig());
        }
Exemplo n.º 5
0
        private ICameraNewMotor SetNextMotor(PlayerEntity player, SubCameraMotorType type,
                                             ICameraMotorState stat, DummyCameraMotorInput input
                                             )
        {
            var dict     = _motors.GetDict(type);
            var subState = _state.Get(type);

            if (!dict.ContainsKey(subState.NowMode))
            {
                return(null);
            }
            var oldMotor = dict[subState.NowMode];

            var excludes  = oldMotor.ExcludeNextMotor();
            var nextMotor = oldMotor;
            var orderId   = int.MinValue;

            foreach (var motor in dict.Values)
            {
                if (excludes.Contains(motor.ModeId))
                {
                    continue;
                }
                if (motor.IsActive(input, stat))
                {
                    if (motor.Order > orderId)
                    {
                        nextMotor = motor;
                        orderId   = motor.Order;
                    }
                }
            }

            if (nextMotor.ModeId != oldMotor.ModeId || subState.ModeTime == 0)
            {
                Logger.DebugFormat("{0} Levae :{1} To {2} with input{3}", _cmdSeq, oldMotor.ModeId, nextMotor.ModeId,
                                   input);

                CameraActionManager.SetActionCode(CameraActionType.Leave, type, oldMotor.ModeId);
                CameraActionManager.SetActionCode(CameraActionType.Enter, type, nextMotor.ModeId);

                subState.NowMode  = (byte)nextMotor.ModeId;
                subState.ModeTime = player.time.ClientTime;
                subState.LastMode = (byte)oldMotor.ModeId;
            }

            if (type == SubCameraMotorType.View)
            {
                if (CanChangeViewMotor(input))
                {
                    UpdateOrderViewMode(player, nextMotor.ModeId);
                }
            }

            return(oldMotor);
        }
Exemplo n.º 6
0
        private void CalcuForObserving(IUserCmd cmd, PlayerEntity player, Vector3 archotRotation,
                                       CameraStateOutputNewComponent result)
        {
            DummyCameraMotorState.Convert(player.cameraStateNew, _dummyState);
            _dummyState.Dict[(int)SubCameraMotorType.View].NowMode  = (byte)ECameraViewMode.ThirdPerson;
            _dummyState.Dict[(int)SubCameraMotorType.View].LastMode = (byte)ECameraViewMode.FirstPerson;
            DummyCameraMotorInput _input = (DummyCameraMotorInput)player.cameraStateNew.CameraMotorInput;

            _input.Generate(_context, player, cmd, archotRotation.y, archotRotation.x);
            CalcFinalOutput(player, _input, result, _dummyState);
            result.ArchorPosition = player.thirdPersonDataForObserving.ThirdPersonArchorPosition;
        }
Exemplo n.º 7
0
        public void ExecuteUserCmd(IUserCmdOwner owner, IUserCmd cmd)
        {
            _cmdSeq = cmd.Seq;
            PlayerEntity player = owner.OwnerEntity as PlayerEntity;

            if (!player.hasCameraStateNew)
            {
                return;
            }
            if (!player.hasCameraStateOutputNew)
            {
                return;
            }

            DummyCameraMotorState.Convert(player.cameraStateNew, _state);
            DummyCameraMotorInput _input = (DummyCameraMotorInput)player.cameraStateNew.CameraMotorInput;
            var archotRotation           = player.cameraArchor.ArchorEulerAngle;

            _input.Generate(player, cmd, archotRotation.y, archotRotation.x);

            //if (_input.IsChange(player.cameraStateNew.LastCameraMotorInput))
            {
                foreach (SubCameraMotorType i in _subCameraMotorTypeArray)
                {
                    var type = i;
                    SetNextMotor(player, type, _state, _input);
                }
            }

            CameraActionManager.OnAction(player, _state);

            player.cameraStateUpload.EnterActionCode = CameraActionManager.GetActionCode(CameraActionType.Enter);
            player.cameraStateUpload.LeaveActionCode = CameraActionManager.GetActionCode(CameraActionType.Leave);
            CameraActionManager.ClearActionCode();

            player.cameraStateNew.CameraMotorInput     = player.cameraStateNew.LastCameraMotorInput;
            player.cameraStateNew.LastCameraMotorInput = _input;

            CalcFinalOutput(player, (DummyCameraMotorInput)player.cameraStateNew.LastCameraMotorInput,
                            player.cameraStateOutputNew);
            DummyCameraMotorState.Convert(_state, player.cameraStateNew);

            CopyStateToUploadComponent(player.cameraStateNew, player.cameraStateUpload);
            player.cameraStateUpload.ArchorType = (Byte)player.cameraArchor.ArchorType;
        }
Exemplo n.º 8
0
        private void CalcuForNormal(IUserCmd cmd, PlayerEntity player, CameraStateOutputNewComponent result)
        {
            DummyCameraMotorState.Convert(player.cameraStateNew, _state);

            DummyCameraMotorInput _input = (DummyCameraMotorInput)player.cameraStateNew.CameraMotorInput;

            _input.Generate(player, cmd, _state, LockView);

            if (!HasConfigInitialed(_input))
            {
                return;
            }

            for (int i = 0; i < (int)SubCameraMotorType.End; i++)
            {
                var type = (SubCameraMotorType)i;
                SetNextMotor(player, type, _state, _input);
            }

            HandleAction(player);

            _motors.ActionManager.ClearActionCode();

            player.cameraStateNew.CameraMotorInput     = player.cameraStateNew.LastCameraMotorInput;
            player.cameraStateNew.LastCameraMotorInput = _input;

            player.cameraConfigNow.Config     = _input.GetPoseConfig(_state.GetMainMotor().NowMode);
            player.cameraConfigNow.PeekConfig = _input.GetPeekConfig();
            player.cameraConfigNow.DeadConfig = _input.GetDeadConfig();

            CalcFinalOutput(player, (DummyCameraMotorInput)player.cameraStateNew.LastCameraMotorInput,
                            result, _state);

            DummyCameraMotorState.Convert(_state, player.cameraStateNew);
            player.cameraStateNew.CanFire =
                !_state.IsFree() && _input.GetPoseConfig(player.cameraStateNew.MainNowMode).CanFire;
        }
Exemplo n.º 9
0
 private bool HasConfigInitialed(DummyCameraMotorInput input)
 {
     return(input.GetPoseConfig(0) != null);
 }