1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204 |
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using System.IO;
- using UnityEngine;
- public class CameraMain : MonoBehaviour
- {
- private int CurrentScreenWidth
- {
- get
- {
- return (int)((float)Screen.width);
- }
- }
- private int CurrentScreenHeight
- {
- get
- {
- return (int)((float)Screen.height);
- }
- }
- private int CurrentAntialias
- {
- get
- {
- return QualitySettings.antiAliasing;
- }
- set
- {
- QualitySettings.antiAliasing = value;
- }
- }
- private bool CurrentFullScreen
- {
- get
- {
- return Screen.fullScreen;
- }
- }
- public virtual bool IsBloomEnabled
- {
- get
- {
- return this.m_gcBloom.enabled;
- }
- }
- public virtual bool IsFallThrough
- {
- get
- {
- return this.m_bFallThrough;
- }
- }
- protected virtual void Awake()
- {
- this.m_nBackCullingMask = this.camera.cullingMask;
- this.back_screen_size_.width = this.CurrentScreenWidth;
- this.back_screen_size_.height = this.CurrentScreenHeight;
- this.back_antialias_ = this.CurrentAntialias;
- this.back_full_screen_ = this.CurrentFullScreen;
- this.m_UOCamera = base.GetComponent<UltimateOrbitCamera>();
- NDebug.Assert(this.m_UOCamera != null, "メインカメラにはOrbitCameraが必要です。");
- this.m_gcBloom = base.GetComponent<Bloom>();
- NDebug.Assert(this.m_gcBloom != null, "メインカメラにはBloomが必要です。");
- this.m_gcBlur = base.GetComponent<Blur>();
- NDebug.Assert(this.m_gcBlur != null, "メインカメラにはBlurが必要です。");
- this.m_gcVignett = base.GetComponent<Vignetting>();
- NDebug.Assert(this.m_gcVignett != null, "メインカメラにはVignettが必要です。");
- NDebug.Assert(this.m_FadeTargetCamera != null, "メインカメラにはフェード対象が必要です。");
- this.m_FadeMyCamera = base.GetComponent<ScreenOverlay>();
- NDebug.Assert(this.m_FadeMyCamera != null, "メインカメラ自身にフェード用ScreenOverlayが必要です。");
- this.m_fBloomDefIntensity = this.m_gcBloom.bloomIntensity;
- this.m_fDefaultFieldOfView = this.camera.fieldOfView;
- this.m_fNearClipPlane = this.camera.nearClipPlane;
- this.m_fFarClipPlane = this.camera.farClipPlane;
- }
- public virtual void Start()
- {
- base.StartCoroutine(this.OnCalcMaidDistance());
- }
- protected virtual void OnEnable()
- {
- UICamera.fallThrough = base.gameObject;
- }
- protected virtual void OnDisable()
- {
- UICamera.fallThrough = null;
- }
- protected virtual void OnHover(bool isOver)
- {
- this.m_bFallThrough = isOver;
- }
- public void Blur(bool f_bBlur)
- {
- if (this.m_gcBlur != null)
- {
- this.m_gcBlur.enabled = f_bBlur;
- }
- }
- public void Vignett(bool f_bVignett)
- {
- if (this.m_gcVignett != null)
- {
- this.m_gcVignett.enabled = f_bVignett;
- }
- }
- public virtual void OnLevelWasLoaded(int level)
- {
- RenderSettings.fog = false;
- }
- public void SetChaseCamera(Maid f_maid, string f_strAttachBone, Vector3 f_vWorldOffset, bool f_fOnece, float f_fTime)
- {
- this.RemoveChaseCameraAll();
- if (f_maid.body0 == null)
- {
- Debug.LogError("SetChaseCamera メイドのBodyがまだ読まれていません。");
- return;
- }
- Transform transform = CMT.SearchObjName(f_maid.body0.m_trBones, f_strAttachBone, true);
- if (transform != null)
- {
- CameraChase cameraChase = transform.gameObject.AddComponent<CameraChase>();
- cameraChase.StartChase(f_fOnece, f_fTime, f_vWorldOffset);
- }
- }
- public void RemoveChaseCameraAll()
- {
- GameObject characterAll = GameMain.Instance.CharacterMgr.CharacterAll;
- if (characterAll != null)
- {
- CameraChase[] componentsInChildren = characterAll.GetComponentsInChildren<CameraChase>(true);
- for (int i = 0; i < componentsInChildren.Length; i++)
- {
- UnityEngine.Object.Destroy(componentsInChildren[i]);
- }
- }
- }
- public virtual void SetCameraMask(CameraMain.CameraMask f_eMask, bool f_bVisible)
- {
- if (f_bVisible)
- {
- this.camera.cullingMask |= 1 << (int)f_eMask;
- }
- else
- {
- this.camera.cullingMask &= ~(1 << (int)f_eMask);
- }
- }
- public virtual void CameraMaskReset()
- {
- this.camera.cullingMask = this.m_nBackCullingMask;
- }
- public virtual void SetCameraType(CameraMain.CameraType f_eType)
- {
- this.m_UOCamera.enabled = (f_eType == CameraMain.CameraType.Target);
- this.m_eCamType = f_eType;
- }
- public virtual CameraMain.CameraType GetCameraType()
- {
- return this.m_eCamType;
- }
- public virtual void SetControl(bool f_bEnable)
- {
- this.m_UOCamera.mouseControl = f_bEnable;
- }
- public virtual bool GetControl()
- {
- return this.m_UOCamera.mouseControl;
- }
- public virtual void SetTargetPos(Vector3 f_vecWorldPos, bool f_bSelf = true)
- {
- if (this.m_UOCamera != null)
- {
- if (f_bSelf)
- {
- iTween.StopAndSkipToEnd(base.gameObject);
- }
- this.m_UOCamera.SetTargetPos(f_vecWorldPos);
- }
- }
- public virtual Vector3 GetTargetPos()
- {
- if (this.m_UOCamera.target != null)
- {
- return this.m_UOCamera.target.position;
- }
- return default(Vector3);
- }
- public virtual void SetDistance(float f_fDistance, bool f_bSelf = true)
- {
- if (f_bSelf)
- {
- iTween.StopAndSkipToEnd(base.gameObject);
- }
- this.m_UOCamera.SetDistance(f_fDistance);
- }
- public virtual float GetDistance()
- {
- return this.m_UOCamera.distance;
- }
- public virtual void SetAroundAngle(Vector2 f_vecAngle, bool f_bSelf = true)
- {
- if (f_bSelf)
- {
- iTween.StopAndSkipToEnd(base.gameObject);
- }
- this.m_UOCamera.SetAroundAngle(f_vecAngle);
- }
- public virtual Vector2 GetAroundAngle()
- {
- return this.m_UOCamera.GetAroundAngle();
- }
- public virtual void SetTargetOffset(Vector3 f_vOffs, bool is_animation)
- {
- this.m_UOCamera.SetOffset(f_vOffs, is_animation);
- }
- public virtual void SetPos(Vector3 f_vecWorldPos)
- {
- iTween.StopAndSkipToEnd(base.gameObject);
- base.transform.position = f_vecWorldPos;
- }
- public virtual void SetRotation(Vector3 f_vecWorldRot)
- {
- iTween.StopAndSkipToEnd(base.gameObject);
- base.transform.rotation = Quaternion.Euler(f_vecWorldRot);
- }
- public virtual void SetRealHeadPos(Vector3 f_vecWorldPos, bool f_bYFromFloor = false)
- {
- this.SetPos(f_vecWorldPos);
- }
- public virtual void SetRealHeadRot(Vector3 f_vecWorldRot, bool f_bRotYOnly = true)
- {
- this.SetRotation(f_vecWorldRot);
- }
- protected virtual float GetYfromFloor(Vector3 f_vPos)
- {
- return f_vPos.y + this.GetFloorPos(f_vPos).y;
- }
- public virtual Vector3 GetFloorPos(Vector3 f_vPos)
- {
- this.m_rayVRHitFloor.origin = f_vPos;
- this.m_rayVRHitFloor.direction = Vector3.down;
- if (Physics.Raycast(this.m_rayVRHitFloor, out this.m_hitVRFloor, float.PositiveInfinity, 512))
- {
- return this.m_hitVRFloor.point;
- }
- this.m_rayVRHitFloor.origin = new Vector3(f_vPos.x, 100f, f_vPos.z);
- this.m_rayVRHitFloor.direction = Vector3.down;
- if (Physics.Raycast(this.m_rayVRHitFloor, out this.m_hitVRFloor, float.PositiveInfinity, 512))
- {
- return this.m_hitVRFloor.point;
- }
- f_vPos.y = 0f;
- return f_vPos;
- }
- public virtual Vector3 GetPos()
- {
- return base.transform.position;
- }
- public virtual void SetFootPos(Vector3 f_vecFootPos, CameraMain.STAND_SIT f_eState)
- {
- float y;
- if (f_eState == CameraMain.STAND_SIT.STAND)
- {
- y = GameMain.Instance.CMSystem.VRCameraHeightStandOffs;
- }
- else if (f_eState == CameraMain.STAND_SIT.SIT)
- {
- y = GameMain.Instance.CMSystem.VRCameraHeightSitOffs;
- }
- else
- {
- y = this.GetYfromFloor(this.GetRealHeadTransform().position);
- }
- this.SetPos(f_vecFootPos + new Vector3(0f, y, 0f));
- }
- public virtual Transform GetBaseHeadTransform()
- {
- return base.transform;
- }
- public virtual Transform GetRealHeadTransform()
- {
- return base.transform;
- }
- public virtual float GetHeightStandAndSit(CameraMain.STAND_SIT f_eState)
- {
- if (f_eState == CameraMain.STAND_SIT.STAND)
- {
- return GameMain.Instance.CMSystem.VRCameraHeightStandOffs;
- }
- if (f_eState == CameraMain.STAND_SIT.SIT)
- {
- return GameMain.Instance.CMSystem.VRCameraHeightSitOffs;
- }
- return 0f;
- }
- public virtual void SetFromScriptOnTarget(Vector3 f_vCenter, float f_fRadius, Vector2 f_vRotate)
- {
- NDebug.Assert(this.m_eCamType == CameraMain.CameraType.Target, "カメラモードはターゲットでなくてはいけません。");
- iTween.StopAndSkipToEnd(base.gameObject);
- this.SetTargetPos(f_vCenter, true);
- this.SetDistance(f_fRadius, true);
- this.SetAroundAngle(f_vRotate, true);
- this.m_vCenter = f_vCenter;
- this.m_fRadius = f_fRadius;
- this.m_vRotate = f_vRotate;
- }
- public virtual void StartAnimationTo(bool f_bStart, Vector3 f_vSCenter, float f_fSRadius, Vector2 f_vSRotate, Vector3 f_vCenter, float f_fRadius, Vector2 f_vRotate, float f_fTime, string f_strEaseType, bool f_bSkip, float f_fDelay)
- {
- iTween.StopAndSkipToEnd(base.gameObject);
- iTween.EaseType easeType;
- if (string.IsNullOrEmpty(f_strEaseType))
- {
- easeType = iTween.EaseType.linear;
- }
- else
- {
- easeType = (iTween.EaseType)Enum.Parse(typeof(iTween.EaseType), f_strEaseType);
- }
- Vector3 vector;
- float num;
- Vector2 vector2;
- if (!f_bStart)
- {
- vector = this.GetTargetPos();
- num = this.GetDistance();
- vector2 = this.GetAroundAngle();
- }
- else
- {
- vector = f_vSCenter;
- num = f_fSRadius;
- vector2 = f_vSRotate;
- }
- this.m_bMoveSkip = f_bSkip;
- if (this.m_bMoveSkip && GameMain.Instance.IsForceSkip())
- {
- this.SetTargetPos(f_vCenter, true);
- this.SetDistance(f_fRadius, true);
- this.SetAroundAngle(f_vRotate, true);
- this.m_vCenter = f_vCenter;
- this.m_fRadius = f_fRadius;
- this.m_vRotate = f_vRotate;
- }
- else
- {
- iTween.ValueTo(base.gameObject, iTween.Hash(new object[]
- {
- "easetype",
- easeType,
- "from",
- vector,
- "to",
- f_vCenter,
- "time",
- f_fTime,
- "delay",
- f_fDelay,
- "onUpdate",
- "UpdateCamTgt",
- "onComplete",
- "CompleteCam"
- }));
- iTween.ValueTo(base.gameObject, iTween.Hash(new object[]
- {
- "easetype",
- easeType,
- "from",
- num,
- "to",
- f_fRadius,
- "time",
- f_fTime,
- "delay",
- f_fDelay,
- "onUpdate",
- "UpdateCamDistance",
- "onComplete",
- "CompleteCam"
- }));
- iTween.ValueTo(base.gameObject, iTween.Hash(new object[]
- {
- "easetype",
- easeType,
- "from",
- vector2,
- "to",
- f_vRotate,
- "time",
- f_fTime,
- "delay",
- f_fDelay,
- "onUpdate",
- "UpdateCamAngle",
- "onComplete",
- "CompleteCam"
- }));
- }
- }
- public virtual void UpdateCamTgt(Vector3 f_vValue)
- {
- this.SetTargetPos(f_vValue, false);
- this.m_vCenter = f_vValue;
- }
- public virtual void UpdateCamDistance(float f_vValue)
- {
- this.SetDistance(f_vValue, false);
- this.m_fRadius = f_vValue;
- }
- public virtual void UpdateCamAngle(Vector2 f_vAngle)
- {
- this.SetAroundAngle(f_vAngle, false);
- this.m_vRotate = f_vAngle;
- }
- public virtual void CompleteCam()
- {
- }
- public virtual void ResetFromScriptOnTarget()
- {
- NDebug.Assert(this.m_eCamType == CameraMain.CameraType.Target, "カメラモードはターゲットでなくてはいけません。");
- iTween.StopAndSkipToEnd(base.gameObject);
- this.SetTargetPos(this.m_vCenter, true);
- this.SetDistance(this.m_fRadius, true);
- this.SetAroundAngle(this.m_vRotate, true);
- }
- public virtual void Reset(CameraMain.CameraType f_eType, bool f_bControl)
- {
- iTween.StopAndSkipToEnd(base.gameObject);
- base.transform.parent.transform.position = new Vector3(0f, 1.61f, 0f);
- this.CameraMaskReset();
- this.SetCameraType(f_eType);
- this.SetControl(f_bControl);
- this.SetTargetOffset(Vector3.zero, true);
- this.Blur(false);
- this.Vignett(false);
- this.RemoveChaseCameraAll();
- this.FadeInNoUI(0f, true);
- if (this.camera != null)
- {
- this.camera.fieldOfView = this.m_fDefaultFieldOfView;
- this.camera.nearClipPlane = this.m_fNearClipPlane;
- this.camera.farClipPlane = this.m_fFarClipPlane;
- }
- if (f_eType == CameraMain.CameraType.Target)
- {
- this.SetTargetPos(new Vector3(0f, 1.5f, 0f), true);
- if (this.m_UOCamera != null)
- {
- this.m_UOCamera.SetAroundAngle(new Vector2(180f, 10f));
- this.m_UOCamera.SetDistance(2f);
- }
- }
- else if (f_eType == CameraMain.CameraType.Free)
- {
- this.SetPos(new Vector3(0f, 1.5f, 2f));
- this.SetRotation(new Vector3(10f, -180f, 0f));
- }
- }
- public bool IsFadeProcNoUI()
- {
- return this.m_eMyFadeState != CameraMain.FadeState.Non && this.m_eMyFadeState != CameraMain.FadeState.Out;
- }
- public virtual void FadeOutNoUI(float f_fTime = 0.5f, bool f_bSkipable = true)
- {
- this.m_fMyFadeSkipable = f_bSkipable;
- if (this.m_eMyFadeState == CameraMain.FadeState.Out || this.m_eMyFadeState == CameraMain.FadeState.ProcOut)
- {
- return;
- }
- if (this.m_eMyFadeState == CameraMain.FadeState.ProcIn)
- {
- base.StopCoroutine(this.m_MyFadeRoutineIn);
- }
- this.m_FadeMyCamera.enabled = true;
- this.m_FadeMyCamera.intensity = 1f;
- this.m_fMyFadeTime = f_fTime;
- if (this.m_fMyFadeSkipable)
- {
- this.m_fMyFadeTime *= GameMain.Instance.CMSystem.FadeSpeedRate;
- if (GameMain.Instance.IsForceSkip())
- {
- this.m_fMyFadeTime = 0f;
- }
- }
- if (this.m_fMyFadeTime < 0.001f)
- {
- this.m_eMyFadeState = CameraMain.FadeState.Out;
- this.m_FadeMyCamera.intensity = 0f;
- }
- else
- {
- this.m_eMyFadeState = CameraMain.FadeState.ProcOut;
- base.StartCoroutine(this.m_MyFadeRoutineOut = this.CoMyFadeOut());
- }
- }
- private IEnumerator CoMyFadeOut()
- {
- this.m_fMyFadeNow = 0f;
- yield return null;
- while ((this.m_fMyFadeNow += Time.deltaTime) < this.m_fMyFadeTime)
- {
- this.m_eMyFadeState = CameraMain.FadeState.ProcOut;
- this.m_FadeMyCamera.enabled = true;
- this.m_FadeMyCamera.intensity = 1f - this.m_fMyFadeNow / this.m_fMyFadeTime;
- if (this.m_fMyFadeSkipable && GameMain.Instance.IsForceSkip())
- {
- break;
- }
- yield return null;
- }
- this.m_FadeMyCamera.enabled = true;
- this.m_FadeMyCamera.intensity = 0f;
- this.m_eMyFadeState = CameraMain.FadeState.Out;
- yield break;
- }
- public virtual void FadeInNoUI(float f_fTime = 0.5f, bool f_bSkipable = true)
- {
- this.m_fMyFadeSkipable = f_bSkipable;
- if (this.m_eMyFadeState == CameraMain.FadeState.Non || this.m_eMyFadeState == CameraMain.FadeState.ProcIn)
- {
- return;
- }
- if (this.m_eMyFadeState == CameraMain.FadeState.ProcOut)
- {
- base.StopCoroutine(this.m_MyFadeRoutineOut);
- }
- this.m_FadeMyCamera.enabled = true;
- this.m_FadeMyCamera.intensity = 0f;
- this.m_fMyFadeTime = f_fTime;
- if (this.m_fMyFadeSkipable)
- {
- this.m_fMyFadeTime *= GameMain.Instance.CMSystem.FadeSpeedRate;
- if (GameMain.Instance.IsForceSkip())
- {
- this.m_fMyFadeTime = 0f;
- }
- }
- if (this.m_fMyFadeTime < 0.001f)
- {
- this.m_eMyFadeState = CameraMain.FadeState.Non;
- this.m_FadeMyCamera.enabled = false;
- this.m_FadeMyCamera.intensity = 1f;
- }
- else
- {
- this.m_eMyFadeState = CameraMain.FadeState.ProcIn;
- base.StartCoroutine(this.m_MyFadeRoutineIn = this.CoMyFadeIn());
- }
- }
- private IEnumerator CoMyFadeIn()
- {
- this.m_fMyFadeNow = 0f;
- yield return null;
- while ((this.m_fMyFadeNow += Time.deltaTime) < this.m_fMyFadeTime)
- {
- this.m_eMyFadeState = CameraMain.FadeState.ProcIn;
- this.m_FadeMyCamera.enabled = true;
- this.m_FadeMyCamera.intensity = this.m_fMyFadeNow / this.m_fMyFadeTime;
- if (this.m_fMyFadeSkipable && GameMain.Instance.IsForceSkip())
- {
- break;
- }
- yield return null;
- }
- this.m_FadeMyCamera.enabled = false;
- this.m_FadeMyCamera.intensity = 1f;
- this.m_eMyFadeState = CameraMain.FadeState.Non;
- yield break;
- }
- public bool IsFadeProc()
- {
- return this.m_eFadeState != CameraMain.FadeState.Non && this.m_eFadeState != CameraMain.FadeState.Out;
- }
- public bool IsFadeOut()
- {
- return this.m_eFadeState != CameraMain.FadeState.Non;
- }
- public CameraMain.FadeState GetFadeState()
- {
- return this.m_eFadeState;
- }
- public bool IsFadeStateNon()
- {
- return this.m_eFadeState == CameraMain.FadeState.Non;
- }
- public void FadeOut(float f_fTime = 0.5f, bool f_bUIEnable = false, CameraMain.dgOnCompleteFade f_dg = null, bool f_bSkipable = true, Color f_color = default(Color))
- {
- this.m_fFadeSkipable = f_bSkipable;
- if (this.m_eFadeState == CameraMain.FadeState.Out || this.m_eFadeState == CameraMain.FadeState.ProcOut)
- {
- return;
- }
- this.m_fFadeColor = f_color;
- if (this.m_eFadeState == CameraMain.FadeState.ProcIn)
- {
- base.StopCoroutine(this.m_FadeRoutineIn);
- this.CompleteFadeIn();
- }
- this.OnOverlayState(true);
- this.OnProcessFade(1f);
- this.m_fFadeTime = f_fTime;
- if (this.m_fFadeSkipable)
- {
- this.m_fFadeTime *= GameMain.Instance.CMSystem.FadeSpeedRate;
- if (GameMain.Instance.IsForceSkip())
- {
- this.m_fFadeTime = 0f;
- }
- }
- UICamera.InputEnable = f_bUIEnable;
- if (f_dg != null)
- {
- this.m_dgOnCompleteFadeOut = (CameraMain.dgOnCompleteFade)Delegate.Combine(this.m_dgOnCompleteFadeOut, f_dg);
- }
- if (this.m_fFadeTime <= 0.001f)
- {
- this.CompleteFadeOut();
- }
- else
- {
- this.m_eFadeState = CameraMain.FadeState.ProcOut;
- base.StartCoroutine(this.m_FadeRoutineOut = this.CoFadeOut());
- }
- }
- private IEnumerator CoFadeOut()
- {
- this.m_fFadeNow = 0f;
- yield return null;
- while ((this.m_fFadeNow += Time.deltaTime) < this.m_fFadeTime)
- {
- this.m_eFadeState = CameraMain.FadeState.ProcOut;
- this.OnOverlayState(true);
- this.OnProcessFade(1f - this.m_fFadeNow / this.m_fFadeTime);
- if (this.m_fFadeSkipable && GameMain.Instance.IsForceSkip())
- {
- break;
- }
- yield return null;
- }
- this.CompleteFadeOut();
- yield break;
- }
- private void CompleteFadeOut()
- {
- this.OnOverlayState(true);
- this.OnProcessFade(0f);
- this.m_eFadeState = CameraMain.FadeState.Out;
- if (this.m_dgOnCompleteFadeOut != null && this.m_dgOnCompleteFadeOut.GetInvocationList() != null && this.m_dgOnCompleteFadeOut.GetInvocationList().Length != 0)
- {
- this.m_dgOnCompleteFadeOut();
- this.m_dgOnCompleteFadeOut = new CameraMain.dgOnCompleteFade(this.Dummy);
- }
- }
- public void FadeIn(float f_fTime = 0.5f, bool f_bUIEnable = false, CameraMain.dgOnCompleteFade f_dg = null, bool f_bSkipable = true, bool f_bColorIsSameOut = true, Color f_color = default(Color))
- {
- this.m_fFadeSkipable = f_bSkipable;
- if (this.m_eFadeState == CameraMain.FadeState.Non || this.m_eFadeState == CameraMain.FadeState.ProcIn)
- {
- return;
- }
- if (!f_bColorIsSameOut)
- {
- this.m_fFadeColor = f_color;
- }
- if (this.m_eFadeState == CameraMain.FadeState.ProcOut)
- {
- base.StopCoroutine(this.m_FadeRoutineOut);
- this.CompleteFadeOut();
- }
- this.OnOverlayState(true);
- this.OnProcessFade(0f);
- this.m_fFadeTime = f_fTime;
- if (this.m_fFadeSkipable)
- {
- this.m_fFadeTime *= GameMain.Instance.CMSystem.FadeSpeedRate;
- if (GameMain.Instance.IsForceSkip())
- {
- this.m_fFadeTime = 0f;
- }
- }
- UICamera.InputEnable = f_bUIEnable;
- if (f_dg != null)
- {
- this.m_dgOnCompleteFadeIn = (CameraMain.dgOnCompleteFade)Delegate.Combine(this.m_dgOnCompleteFadeIn, f_dg);
- }
- if (f_fTime <= 0.001f)
- {
- this.CompleteFadeIn();
- }
- else
- {
- this.m_eFadeState = CameraMain.FadeState.ProcIn;
- base.StartCoroutine(this.m_FadeRoutineIn = this.CoFadeIn());
- this.OnStartFadeIn();
- }
- }
- private IEnumerator CoFadeIn()
- {
- this.m_fFadeNow = 0f;
- yield return null;
- while ((this.m_fFadeNow += Time.deltaTime) < this.m_fFadeTime)
- {
- this.m_eFadeState = CameraMain.FadeState.ProcIn;
- this.OnOverlayState(true);
- this.OnProcessFade(this.m_fFadeNow / this.m_fFadeTime);
- if (this.m_fFadeSkipable && GameMain.Instance.IsForceSkip())
- {
- break;
- }
- yield return null;
- }
- this.CompleteFadeIn();
- yield break;
- }
- private void CompleteFadeIn()
- {
- this.OnOverlayState(false);
- this.OnProcessFade(1f);
- this.m_eFadeState = CameraMain.FadeState.Non;
- if (this.m_dgOnCompleteFadeIn != null && this.m_dgOnCompleteFadeIn.GetInvocationList() != null && this.m_dgOnCompleteFadeIn.GetInvocationList().Length != 0)
- {
- this.m_dgOnCompleteFadeIn();
- this.m_dgOnCompleteFadeIn = new CameraMain.dgOnCompleteFade(this.Dummy);
- }
- UICamera.InputEnable = true;
- }
- private void Dummy()
- {
- }
- protected virtual float GetFadeIntensity()
- {
- return this.m_FadeTargetCamera.intensity;
- }
- protected virtual void OnProcessFade(float f_fIntensity)
- {
- this.m_FadeTargetCamera.intensity = f_fIntensity;
- this.m_FadeTargetCamera.color = this.m_fFadeColor;
- }
- protected virtual void OnOverlayState(bool f_bEnable)
- {
- this.m_FadeTargetCamera.enabled = f_bEnable;
- }
- protected virtual void OnStartFadeIn()
- {
- }
- protected virtual IEnumerator OnCalcMaidDistance()
- {
- for (;;)
- {
- if (this.m_bCalcNearClip)
- {
- float fMin = 25f;
- for (int nM = 0; nM < GameMain.Instance.CharacterMgr.GetMaidCount(); nM++)
- {
- Maid maid = GameMain.Instance.CharacterMgr.GetMaid(nM);
- if (maid != null && maid.Visible && maid.body0.isLoadedBody)
- {
- float sqrMagnitude = (maid.body0.Pelvis.position - base.transform.position).sqrMagnitude;
- if (fMin > sqrMagnitude)
- {
- fMin = sqrMagnitude;
- }
- }
- yield return null;
- }
- if (fMin < 9f)
- {
- this.camera.nearClipPlane = 0.01f;
- }
- else
- {
- this.camera.nearClipPlane = 0.1f;
- }
- }
- yield return null;
- }
- yield break;
- }
- protected virtual void Update()
- {
- if (this.m_gcBloom != null)
- {
- bool enabled = this.m_gcBloom.enabled;
- this.m_gcBloom.enabled = GameMain.Instance.CMSystem.Bloom;
- this.m_gcBloom.bloomIntensity = this.m_fBloomDefIntensity * (float)GameMain.Instance.CMSystem.BloomValue * 0.01f;
- if (this.m_gcBloom.bloomIntensity <= 0.01f)
- {
- this.m_gcBloom.enabled = false;
- }
- else
- {
- this.m_gcBloom.enabled = true;
- }
- if (this.m_gcBloom.enabled != enabled)
- {
- GameMain.Instance.BroadcastMessage("OnChangeScreenSizeOrAA", SendMessageOptions.DontRequireReceiver);
- }
- }
- if (!this.changeing_ && (this.back_screen_size_.width != this.CurrentScreenWidth || this.back_screen_size_.height != this.CurrentScreenHeight || this.back_antialias_ != this.CurrentAntialias || this.back_full_screen_ != this.CurrentFullScreen))
- {
- this.back_screen_size_.width = this.CurrentScreenWidth;
- this.back_screen_size_.height = this.CurrentScreenHeight;
- this.back_antialias_ = this.CurrentAntialias;
- this.back_full_screen_ = this.CurrentFullScreen;
- if (!GameMain.Instance.VRMode || GameMain.Instance.VRDummyMode)
- {
- GameMain.Instance.BroadcastMessage("OnChangeScreenSizeOrAA", SendMessageOptions.DontRequireReceiver);
- Screen.SetResolution(Screen.width, Screen.height, Screen.fullScreen);
- base.StartCoroutine(this.ResumeNguiRoot());
- }
- }
- if ((Input.GetKey(KeyCode.LeftShift) || Input.GetKey(KeyCode.RightShift)) && (Input.GetKeyDown(KeyCode.S) || Input.GetKeyDown(KeyCode.SysReq)) && !this.screen_shot_normal_)
- {
- this.screen_shot_normal_ = true;
- base.StartCoroutine(this.SaveScreenShotNormal());
- }
- if ((Input.GetKey(KeyCode.LeftAlt) || Input.GetKey(KeyCode.RightAlt)) && (Input.GetKeyDown(KeyCode.S) || Input.GetKeyDown(KeyCode.SysReq)) && !this.screen_shot_noui_)
- {
- this.screen_shot_noui_ = true;
- base.StartCoroutine(this.SaveScreenShotNoUI());
- }
- if (GameMain.Instance.IsForceSkip() && this.m_bMoveSkip)
- {
- iTween.StopAndSkipToEnd(base.gameObject);
- }
- }
- private IEnumerator ResumeNguiRoot()
- {
- Debug.Log("ResumeNguiRoot Start");
- this.changeing_ = true;
- this.CurrentAntialias = 0;
- yield return null;
- UILabel.OnFontTextureChanged();
- this.CurrentAntialias = this.back_antialias_;
- Debug.Log("ResumeNguiRoot End");
- this.changeing_ = false;
- yield break;
- }
- private void UIHide()
- {
- NDebug.Assert(!this.hide_ui_, "UIを表示した状態から非表示にして下さい。");
- this.ui_cam_hide_list_.Clear();
- UICamera[] array = NGUITools.FindActive<UICamera>();
- foreach (UICamera uicamera in array)
- {
- Camera component = uicamera.GetComponent<Camera>();
- if (component.enabled)
- {
- UIRoot uiroot = NGUITools.FindInParents<UIRoot>(uicamera.gameObject);
- if (!(uiroot == null))
- {
- UIPanel component2 = uiroot.GetComponent<UIPanel>();
- if (!(component2 == null))
- {
- if (0 > component2.name.ToLower().IndexOf("fix") && 0f < component2.alpha)
- {
- component2.alpha = 0f;
- this.ui_cam_hide_list_.Add(uicamera);
- }
- }
- }
- }
- }
- this.ui_hide_object_list_.Clear();
- GameObject gameObject = GameObject.Find("WorldTransformAxisParent");
- if (gameObject != null)
- {
- Transform transform = gameObject.transform;
- for (int j = 0; j < transform.childCount; j++)
- {
- if (transform.gameObject.activeSelf)
- {
- transform.gameObject.SetActive(true);
- this.ui_hide_object_list_.Add(transform.gameObject);
- }
- }
- gameObject.SetActive(false);
- }
- GizmoRender.UIVisible = false;
- this.hide_ui_ = true;
- }
- private void UIResume()
- {
- NDebug.Assert(this.hide_ui_, "UIを非表示にしてから表示して下さい。");
- foreach (UICamera uicamera in this.ui_cam_hide_list_)
- {
- Camera component = uicamera.GetComponent<Camera>();
- UIRoot uiroot = NGUITools.FindInParents<UIRoot>(uicamera.gameObject);
- if (!(uiroot == null))
- {
- UIPanel component2 = uiroot.GetComponent<UIPanel>();
- if (component2 != null)
- {
- component2.alpha = 1f;
- }
- }
- }
- this.ui_cam_hide_list_.Clear();
- for (int i = 0; i < this.ui_hide_object_list_.Count; i++)
- {
- this.ui_hide_object_list_[i].SetActive(true);
- }
- this.ui_hide_object_list_.Clear();
- GizmoRender.UIVisible = true;
- this.hide_ui_ = false;
- }
- public void ScreenShot(bool f_bNoUI)
- {
- this.custom_screenshot_ = false;
- if (f_bNoUI)
- {
- base.StartCoroutine(this.SaveScreenShotNoUI());
- }
- else
- {
- base.StartCoroutine(this.SaveScreenShotNormal());
- }
- }
- public void ScreenShot(string file_path, int super_size, bool no_ui_mode)
- {
- this.custom_screenshot_ = true;
- this.custom_screenshot_save_file_path_ = file_path;
- this.custom_screenshot_super_size_ = super_size;
- if (no_ui_mode)
- {
- base.StartCoroutine(this.SaveScreenShotNoUI());
- }
- else
- {
- base.StartCoroutine(this.SaveScreenShotNormal());
- }
- }
- protected IEnumerator SaveScreenShotNormal()
- {
- yield return new WaitForEndOfFrame();
- int super_size = this.ss_super_size_[(int)GameMain.Instance.CMSystem.ScreenShotSuperSize];
- string file_path = this.GetTimeFileName();
- if (this.custom_screenshot_)
- {
- file_path = this.custom_screenshot_save_file_path_;
- super_size = this.custom_screenshot_super_size_;
- }
- Application.CaptureScreenshot(file_path, super_size);
- yield return new WaitForEndOfFrame();
- this.screen_shot_normal_ = false;
- yield break;
- }
- protected IEnumerator SaveScreenShotNoUI()
- {
- this.UIHide();
- yield return new WaitForEndOfFrame();
- int super_size = this.ss_super_size_[(int)GameMain.Instance.CMSystem.ScreenShotSuperSize];
- string file_path = this.GetTimeFileName();
- if (this.custom_screenshot_)
- {
- file_path = this.custom_screenshot_save_file_path_;
- super_size = this.custom_screenshot_super_size_;
- }
- Application.CaptureScreenshot(file_path, super_size);
- yield return new WaitForEndOfFrame();
- this.UIResume();
- this.screen_shot_noui_ = false;
- yield break;
- }
- private string GetTimeFileName()
- {
- string text = Path.Combine(GameMain.Instance.SerializeStorageManager.StoreDirectoryPath, "ScreenShot");
- if (!Directory.Exists(text))
- {
- Directory.CreateDirectory(text);
- }
- return text + "\\img" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".png";
- }
- public Camera camera
- {
- get
- {
- if (this.camera_ == null)
- {
- this.camera_ = base.GetComponent<Camera>();
- }
- return this.camera_;
- }
- }
- private CameraMain.CameraType m_eCamType;
- protected int m_nBackCullingMask;
- protected UltimateOrbitCamera m_UOCamera;
- public FadeInAndFadeOutOnGUI m_FadeTargetCamera;
- private ScreenOverlay m_FadeMyCamera;
- private Bloom m_gcBloom;
- private Blur m_gcBlur;
- private Vignetting m_gcVignett;
- public bool m_bCalcNearClip = true;
- protected float m_fDefaultFieldOfView;
- protected float m_fNearClipPlane;
- protected float m_fFarClipPlane;
- protected bool m_bMoveSkip;
- protected float m_fBloomDefIntensity = 2.85f;
- protected Ray m_rayVRHitFloor = default(Ray);
- protected RaycastHit m_hitVRFloor = default(RaycastHit);
- protected bool m_bFallThrough;
- protected CameraMain.FadeState m_eMyFadeState;
- private bool m_fMyFadeSkipable;
- private float m_fMyFadeNow;
- private float m_fMyFadeTime;
- private IEnumerator m_MyFadeRoutineOut;
- private IEnumerator m_MyFadeRoutineIn;
- protected CameraMain.FadeState m_eFadeState;
- private bool m_fFadeSkipable;
- protected CameraMain.dgOnCompleteFade m_dgOnCompleteFadeOut;
- protected CameraMain.dgOnCompleteFade m_dgOnCompleteFadeIn;
- private float m_fFadeNow;
- private float m_fFadeTime;
- private IEnumerator m_FadeRoutineOut;
- private IEnumerator m_FadeRoutineIn;
- private Color m_fFadeColor = Color.black;
- private int[] ss_super_size_ = new int[]
- {
- 1,
- 2,
- 4
- };
- private int back_antialias_;
- private bool back_full_screen_;
- private bool changeing_;
- private CameraMain.TexSize back_screen_size_;
- protected bool screen_shot_noui_;
- protected bool screen_shot_normal_;
- private List<UICamera> ui_cam_hide_list_ = new List<UICamera>();
- private List<GameObject> ui_hide_object_list_ = new List<GameObject>();
- private bool hide_ui_;
- private Camera camera_;
- protected Vector3 m_vCenter = new Vector3(0f, 1.5f, 0f);
- protected float m_fRadius = 2f;
- protected Vector2 m_vRotate = new Vector2(180f, 10f);
- private bool custom_screenshot_;
- private string custom_screenshot_save_file_path_;
- private int custom_screenshot_super_size_;
- public enum CameraType
- {
- Target,
- Free
- }
- public enum CameraMask
- {
- Character = 10,
- BG = 20,
- OvrTouchLookObj = 19
- }
- public enum STAND_SIT
- {
- NON,
- STAND,
- SIT
- }
- public enum FadeState
- {
- Non,
- ProcIn,
- ProcOut,
- Out
- }
- public delegate void dgOnCompleteFade();
- private struct TexSize
- {
- public int width;
- public int height;
- }
- }
|