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 ActExposureEffect(float exposureTime, float keepTime, float recoverTime, float maxRate) { this._camExposureArg.exposureTime = exposureTime; this._camExposureArg.keepTime = keepTime; this._camExposureArg.recoverTime = recoverTime; this._camExposureArg.maxExposureRate = Mathf.Max(this._camExposureArg.maxExposureRate, maxRate); this._camExposureArg.deltaExposureRate = (maxRate - this._camExposureArg.currentExposureRate) / this._camExposureArg.exposureTime; this._camExposureArg.deltaGlareThresRate = this._camExposureArg.currentGlareThresRate / this._camExposureArg.exposureTime; this._camExposureArg.timer = exposureTime; this._camExposureState = CameraExposureState.Exposure; }
private void UpdateCameraExposure() { float timeScale = Singleton <LevelManager> .Instance.levelEntity.TimeScale; if ((timeScale != 0f) && (this._camExposureState != CameraExposureState.Idle)) { if (this._camExposureState == CameraExposureState.Exposure) { this._camExposureArg.timer -= Time.deltaTime * timeScale; this._camExposureArg.currentExposureRate += (this._camExposureArg.deltaExposureRate * Time.deltaTime) * timeScale; this._camExposureArg.currentGlareThresRate -= (this._camExposureArg.deltaGlareThresRate * Time.deltaTime) * timeScale; if (this._camExposureArg.timer <= 0f) { this._camExposureArg.timer = this._camExposureArg.keepTime; this._camExposureState = CameraExposureState.Keep; } } else if (this._camExposureState == CameraExposureState.Keep) { this._camExposureArg.timer -= Time.deltaTime * timeScale; if (this._camExposureArg.timer <= 0f) { this._camExposureArg.timer = this._camExposureArg.recoverTime; this._camExposureArg.deltaExposureRate = (this._camExposureArg.maxExposureRate - 1f) / this._camExposureArg.recoverTime; this._camExposureArg.deltaGlareThresRate = 1f / this._camExposureArg.recoverTime; this._camExposureState = CameraExposureState.Recover; } } else { this._camExposureArg.timer -= Time.deltaTime * timeScale; this._camExposureArg.currentExposureRate -= (this._camExposureArg.deltaExposureRate * Time.deltaTime) * timeScale; this._camExposureArg.currentGlareThresRate += (this._camExposureArg.deltaGlareThresRate * Time.deltaTime) * timeScale; if (this._camExposureArg.timer <= 0f) { this._camExposureArg.currentExposureRate = 1f; this._camExposureState = CameraExposureState.Idle; } } this._camExposureArg.currentExposureRate = Mathf.Clamp(this._camExposureArg.currentExposureRate, 1f, this._camExposureArg.maxExposureRate); this._camExposureArg.currentGlareThresRate = Mathf.Clamp(this._camExposureArg.currentGlareThresRate, 0f, 1f); base.GetComponent <PostFXBase>().Exposure = this._camExposureArg.currentExposureRate * this._camExposureArg.originalExposure; base.GetComponent <PostFXBase>().glareThreshold = this._camExposureArg.currentGlareThresRate * this._camExposureArg.originalGlareThres; } }