public void Init(uint runtimeID) { base.Init(1, runtimeID); this.originalNearClip = this.cameraComponent.nearClipPlane; this.originalFOV = this.cameraComponent.fieldOfView; this.staticState = new MainCameraStaticState(this); this.followState = new MainCameraFollowState(this); this.levelAnimState = new MainCameraLevelAnimState(this); this.avatarAnimState = new MainCameraAvatarAnimState(this); this.cinemaState = new MainCameraCinemaState(this); this.storyState = new MainCameraStoryState(this); this._state = this.staticState; this._state.Enter(); this._camExposureState = CameraExposureState.Idle; CameraExposureArgument argument = new CameraExposureArgument { timer = 0f, exposureTime = 0f, keepTime = 0f, recoverTime = 0f, maxExposureRate = 1f, currentExposureRate = 1f, originalExposure = base.GetComponent <PostFXBase>().Exposure, deltaExposureRate = 0f, currentGlareThresRate = 1f, originalGlareThres = base.GetComponent <PostFXBase>().glareThreshold, deltaGlareThresRate = 0f }; this._camExposureArg = argument; CameraGlareArgument.originalValue = base.GetComponent <PostFXBase>().glareIntensity; Singleton <EventManager> .Instance.CreateActor <MainCameraActor>(this); }
public void TransitWithLerp(BaseMainCameraState to, float transitionLerpSpeedRatio = 1) { if (this.IsInTransitionLerp()) { this.InterruptTransitionLerp(this._nextState); } else { this._nextState = to; this._transitionLerpStep = 0; this._transitionLerpTimer = 0f; this._transitionLerpSpeedRatio = transitionLerpSpeedRatio; this._doingTransitionLerp = true; } }
public void Transit(BaseMainCameraState to) { if (this._nextState != null) { this.ClearNextState(); } if (this._nextState != null) { } if (this.IsInTransitionLerp()) { this.InterruptTransitionLerp(this._nextState); } else { this._nextState = to; } }
public MainCameraLevelAnimState(MonoMainCamera camera) : base(camera) { this._nextState = camera.staticState; this._exitTransitionLerp = false; base.muteCameraShake = false; }
public void SetNextState(BaseMainCameraState nextState, bool exitTransitionLerp) { this._nextState = nextState; this._exitTransitionLerp = exitTransitionLerp; }
private void LateUpdate() { if (this._nextState != null) { if (this._doingTransitionLerp) { if (this._transitionLerpStep == 0) { this._transitionFromPos = this._state.cameraPosition; this._transitionFromForward = this._state.cameraForward; this._transitionFromFov = this._state.cameraFOV; this._state.Exit(); this._state.SetActive(false); this._state = this._nextState; this._state.Enter(); this._state.SetActive(true); this._state.Update(); this._transitionLerpTimer += Time.unscaledDeltaTime * this._transitionLerpSpeedRatio; float t = this._transitionLerpTimer / 0.5f; t *= 2f - t; base.transform.position = Vector3.Lerp(this._transitionFromPos, this._state.cameraPosition, t); base.transform.forward = CameraForwardLerp(this._transitionFromForward, this._state.cameraForward, (Time.deltaTime * 5f) * this._transitionLerpSpeedRatio); this.cameraComponent.fieldOfView = Mathf.Lerp(this._transitionFromFov, this._state.cameraFOV, t); this._transitionLerpStep = 1; } else if (this._transitionLerpStep == 1) { this._state.Update(); this._transitionLerpTimer += Time.unscaledDeltaTime * this._transitionLerpSpeedRatio; float num2 = this._transitionLerpTimer / 0.5f; if (num2 > 1f) { base.transform.position = this._state.cameraPosition; base.transform.forward = this._state.cameraForward; this.cameraComponent.fieldOfView = this._state.cameraFOV; this._nextState = null; this._doingTransitionLerp = false; } else { num2 *= 2f - num2; base.transform.position = Vector3.Lerp(this._transitionFromPos, this._state.cameraPosition, num2); base.transform.forward = CameraForwardLerp(this._transitionFromForward, this._state.cameraForward, num2); this.cameraComponent.fieldOfView = Mathf.Lerp(this._transitionFromFov, this._state.cameraFOV, num2); } } } else { this._state.Exit(); this._state.SetActive(false); this._state = this._nextState; this._state.Enter(); this._state.SetActive(true); this._nextState = null; this._state.Update(); base._cameraTrans.position = this._state.cameraPosition; base._cameraTrans.forward = this._state.cameraForward; this.cameraComponent.fieldOfView = this._state.cameraFOV; } } else { this._state.Update(); base._cameraTrans.position = this._state.cameraPosition; base._cameraTrans.forward = this._state.cameraForward; this.cameraComponent.fieldOfView = this._state.cameraFOV; } float num3 = !this._state.lerpDirectionalLight ? 8f : 1f; if (this._needUpdateDirectionalLight) { this._directionalLightFollowRotation = Quaternion.Slerp(this._directionalLightFollowRotation, base._cameraTrans.rotation, Time.deltaTime * num3); this.directionalLight.transform.rotation = Quaternion.Euler(45f, this._directionalLightFollowRotation.eulerAngles.y, this._directionalLightFollowRotation.eulerAngles.z); } this.UpdateCameraShake(); this.UpdateCameraExposure(); this.UpdateCameraGlare(); this.UpdateCameraDofCustom(); GeometryUtilityUser.CalculateFrustumPlanes(this.cameraComponent, ref this._frustumPlanes); }
public void InterruptTransitionLerp(BaseMainCameraState nextState) { this._doingTransitionLerp = false; this._nextState = null; this.Transit(nextState); }
public void ClearNextState() { this._doingTransitionLerp = false; this._nextState = null; }
public MainCameraAvatarAnimState(MonoMainCamera camera) : base(camera) { this._nextState = base._owner.followState; this._exitTransitionLerp = false; }