CameraMain.cs 29 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.IO;
  5. using UnityEngine;
  6. public class CameraMain : MonoBehaviour
  7. {
  8. private int CurrentScreenWidth
  9. {
  10. get
  11. {
  12. return (int)((float)Screen.width);
  13. }
  14. }
  15. private int CurrentScreenHeight
  16. {
  17. get
  18. {
  19. return (int)((float)Screen.height);
  20. }
  21. }
  22. private int CurrentAntialias
  23. {
  24. get
  25. {
  26. return QualitySettings.antiAliasing;
  27. }
  28. set
  29. {
  30. QualitySettings.antiAliasing = value;
  31. }
  32. }
  33. private bool CurrentFullScreen
  34. {
  35. get
  36. {
  37. return Screen.fullScreen;
  38. }
  39. }
  40. public virtual bool IsBloomEnabled
  41. {
  42. get
  43. {
  44. return this.m_gcBloom.enabled;
  45. }
  46. }
  47. public virtual bool IsFallThrough
  48. {
  49. get
  50. {
  51. return this.m_bFallThrough;
  52. }
  53. }
  54. protected virtual void Awake()
  55. {
  56. this.m_nBackCullingMask = this.camera.cullingMask;
  57. this.back_screen_size_.width = this.CurrentScreenWidth;
  58. this.back_screen_size_.height = this.CurrentScreenHeight;
  59. this.back_antialias_ = this.CurrentAntialias;
  60. this.back_full_screen_ = this.CurrentFullScreen;
  61. this.m_UOCamera = base.GetComponent<UltimateOrbitCamera>();
  62. NDebug.Assert(this.m_UOCamera != null, "メインカメラにはOrbitCameraが必要です。");
  63. this.m_gcBloom = base.GetComponent<Bloom>();
  64. NDebug.Assert(this.m_gcBloom != null, "メインカメラにはBloomが必要です。");
  65. this.m_gcBlur = base.GetComponent<Blur>();
  66. NDebug.Assert(this.m_gcBlur != null, "メインカメラにはBlurが必要です。");
  67. this.m_gcVignett = base.GetComponent<Vignetting>();
  68. NDebug.Assert(this.m_gcVignett != null, "メインカメラにはVignettが必要です。");
  69. NDebug.Assert(this.m_FadeTargetCamera != null, "メインカメラにはフェード対象が必要です。");
  70. this.m_FadeMyCamera = base.GetComponent<ScreenOverlay>();
  71. NDebug.Assert(this.m_FadeMyCamera != null, "メインカメラ自身にフェード用ScreenOverlayが必要です。");
  72. this.m_fBloomDefIntensity = this.m_gcBloom.bloomIntensity;
  73. this.m_fDefaultFieldOfView = this.camera.fieldOfView;
  74. this.m_fNearClipPlane = this.camera.nearClipPlane;
  75. this.m_fFarClipPlane = this.camera.farClipPlane;
  76. }
  77. public virtual void Start()
  78. {
  79. base.StartCoroutine(this.OnCalcMaidDistance());
  80. }
  81. protected virtual void OnEnable()
  82. {
  83. UICamera.fallThrough = base.gameObject;
  84. }
  85. protected virtual void OnDisable()
  86. {
  87. UICamera.fallThrough = null;
  88. }
  89. protected virtual void OnHover(bool isOver)
  90. {
  91. this.m_bFallThrough = isOver;
  92. }
  93. public void Blur(bool f_bBlur)
  94. {
  95. if (this.m_gcBlur != null)
  96. {
  97. this.m_gcBlur.enabled = f_bBlur;
  98. }
  99. }
  100. public void Vignett(bool f_bVignett)
  101. {
  102. if (this.m_gcVignett != null)
  103. {
  104. this.m_gcVignett.enabled = f_bVignett;
  105. }
  106. }
  107. public virtual void OnLevelWasLoaded(int level)
  108. {
  109. RenderSettings.fog = false;
  110. }
  111. public void SetChaseCamera(Maid f_maid, string f_strAttachBone, Vector3 f_vWorldOffset, bool f_fOnece, float f_fTime)
  112. {
  113. this.RemoveChaseCameraAll();
  114. if (f_maid.body0 == null)
  115. {
  116. Debug.LogError("SetChaseCamera メイドのBodyがまだ読まれていません。");
  117. return;
  118. }
  119. Transform transform = CMT.SearchObjName(f_maid.body0.m_trBones, f_strAttachBone, true);
  120. if (transform != null)
  121. {
  122. CameraChase cameraChase = transform.gameObject.AddComponent<CameraChase>();
  123. cameraChase.StartChase(f_fOnece, f_fTime, f_vWorldOffset);
  124. }
  125. }
  126. public void RemoveChaseCameraAll()
  127. {
  128. GameObject characterAll = GameMain.Instance.CharacterMgr.CharacterAll;
  129. if (characterAll != null)
  130. {
  131. CameraChase[] componentsInChildren = characterAll.GetComponentsInChildren<CameraChase>(true);
  132. for (int i = 0; i < componentsInChildren.Length; i++)
  133. {
  134. UnityEngine.Object.Destroy(componentsInChildren[i]);
  135. }
  136. }
  137. }
  138. public virtual void SetCameraMask(CameraMain.CameraMask f_eMask, bool f_bVisible)
  139. {
  140. if (f_bVisible)
  141. {
  142. this.camera.cullingMask |= 1 << (int)f_eMask;
  143. }
  144. else
  145. {
  146. this.camera.cullingMask &= ~(1 << (int)f_eMask);
  147. }
  148. }
  149. public virtual void CameraMaskReset()
  150. {
  151. this.camera.cullingMask = this.m_nBackCullingMask;
  152. }
  153. public virtual void SetCameraType(CameraMain.CameraType f_eType)
  154. {
  155. this.m_UOCamera.enabled = (f_eType == CameraMain.CameraType.Target);
  156. this.m_eCamType = f_eType;
  157. }
  158. public virtual CameraMain.CameraType GetCameraType()
  159. {
  160. return this.m_eCamType;
  161. }
  162. public virtual void SetControl(bool f_bEnable)
  163. {
  164. this.m_UOCamera.mouseControl = f_bEnable;
  165. }
  166. public virtual bool GetControl()
  167. {
  168. return this.m_UOCamera.mouseControl;
  169. }
  170. public virtual void SetTargetPos(Vector3 f_vecWorldPos, bool f_bSelf = true)
  171. {
  172. if (this.m_UOCamera != null)
  173. {
  174. if (f_bSelf)
  175. {
  176. iTween.StopAndSkipToEnd(base.gameObject);
  177. }
  178. this.m_UOCamera.SetTargetPos(f_vecWorldPos);
  179. }
  180. }
  181. public virtual Vector3 GetTargetPos()
  182. {
  183. if (this.m_UOCamera.target != null)
  184. {
  185. return this.m_UOCamera.target.position;
  186. }
  187. return default(Vector3);
  188. }
  189. public virtual void SetDistance(float f_fDistance, bool f_bSelf = true)
  190. {
  191. if (f_bSelf)
  192. {
  193. iTween.StopAndSkipToEnd(base.gameObject);
  194. }
  195. this.m_UOCamera.SetDistance(f_fDistance);
  196. }
  197. public virtual float GetDistance()
  198. {
  199. return this.m_UOCamera.distance;
  200. }
  201. public virtual void SetAroundAngle(Vector2 f_vecAngle, bool f_bSelf = true)
  202. {
  203. if (f_bSelf)
  204. {
  205. iTween.StopAndSkipToEnd(base.gameObject);
  206. }
  207. this.m_UOCamera.SetAroundAngle(f_vecAngle);
  208. }
  209. public virtual Vector2 GetAroundAngle()
  210. {
  211. return this.m_UOCamera.GetAroundAngle();
  212. }
  213. public virtual void SetTargetOffset(Vector3 f_vOffs, bool is_animation)
  214. {
  215. this.m_UOCamera.SetOffset(f_vOffs, is_animation);
  216. }
  217. public virtual void SetPos(Vector3 f_vecWorldPos)
  218. {
  219. iTween.StopAndSkipToEnd(base.gameObject);
  220. base.transform.position = f_vecWorldPos;
  221. }
  222. public virtual void SetRotation(Vector3 f_vecWorldRot)
  223. {
  224. iTween.StopAndSkipToEnd(base.gameObject);
  225. base.transform.rotation = Quaternion.Euler(f_vecWorldRot);
  226. }
  227. public virtual void SetRealHeadPos(Vector3 f_vecWorldPos, bool f_bYFromFloor = false)
  228. {
  229. this.SetPos(f_vecWorldPos);
  230. }
  231. public virtual void SetRealHeadRot(Vector3 f_vecWorldRot, bool f_bRotYOnly = true)
  232. {
  233. this.SetRotation(f_vecWorldRot);
  234. }
  235. protected virtual float GetYfromFloor(Vector3 f_vPos)
  236. {
  237. return f_vPos.y + this.GetFloorPos(f_vPos).y;
  238. }
  239. public virtual Vector3 GetFloorPos(Vector3 f_vPos)
  240. {
  241. this.m_rayVRHitFloor.origin = f_vPos;
  242. this.m_rayVRHitFloor.direction = Vector3.down;
  243. if (Physics.Raycast(this.m_rayVRHitFloor, out this.m_hitVRFloor, float.PositiveInfinity, 512))
  244. {
  245. return this.m_hitVRFloor.point;
  246. }
  247. this.m_rayVRHitFloor.origin = new Vector3(f_vPos.x, 100f, f_vPos.z);
  248. this.m_rayVRHitFloor.direction = Vector3.down;
  249. if (Physics.Raycast(this.m_rayVRHitFloor, out this.m_hitVRFloor, float.PositiveInfinity, 512))
  250. {
  251. return this.m_hitVRFloor.point;
  252. }
  253. f_vPos.y = 0f;
  254. return f_vPos;
  255. }
  256. public virtual Vector3 GetPos()
  257. {
  258. return base.transform.position;
  259. }
  260. public virtual void SetFootPos(Vector3 f_vecFootPos, CameraMain.STAND_SIT f_eState)
  261. {
  262. float y;
  263. if (f_eState == CameraMain.STAND_SIT.STAND)
  264. {
  265. y = GameMain.Instance.CMSystem.VRCameraHeightStandOffs;
  266. }
  267. else if (f_eState == CameraMain.STAND_SIT.SIT)
  268. {
  269. y = GameMain.Instance.CMSystem.VRCameraHeightSitOffs;
  270. }
  271. else
  272. {
  273. y = this.GetYfromFloor(this.GetRealHeadTransform().position);
  274. }
  275. this.SetPos(f_vecFootPos + new Vector3(0f, y, 0f));
  276. }
  277. public virtual Transform GetBaseHeadTransform()
  278. {
  279. return base.transform;
  280. }
  281. public virtual Transform GetRealHeadTransform()
  282. {
  283. return base.transform;
  284. }
  285. public virtual float GetHeightStandAndSit(CameraMain.STAND_SIT f_eState)
  286. {
  287. if (f_eState == CameraMain.STAND_SIT.STAND)
  288. {
  289. return GameMain.Instance.CMSystem.VRCameraHeightStandOffs;
  290. }
  291. if (f_eState == CameraMain.STAND_SIT.SIT)
  292. {
  293. return GameMain.Instance.CMSystem.VRCameraHeightSitOffs;
  294. }
  295. return 0f;
  296. }
  297. public virtual void SetFromScriptOnTarget(Vector3 f_vCenter, float f_fRadius, Vector2 f_vRotate)
  298. {
  299. NDebug.Assert(this.m_eCamType == CameraMain.CameraType.Target, "カメラモードはターゲットでなくてはいけません。");
  300. iTween.StopAndSkipToEnd(base.gameObject);
  301. this.SetTargetPos(f_vCenter, true);
  302. this.SetDistance(f_fRadius, true);
  303. this.SetAroundAngle(f_vRotate, true);
  304. this.m_vCenter = f_vCenter;
  305. this.m_fRadius = f_fRadius;
  306. this.m_vRotate = f_vRotate;
  307. }
  308. 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)
  309. {
  310. iTween.StopAndSkipToEnd(base.gameObject);
  311. iTween.EaseType easeType;
  312. if (string.IsNullOrEmpty(f_strEaseType))
  313. {
  314. easeType = iTween.EaseType.linear;
  315. }
  316. else
  317. {
  318. easeType = (iTween.EaseType)Enum.Parse(typeof(iTween.EaseType), f_strEaseType);
  319. }
  320. Vector3 vector;
  321. float num;
  322. Vector2 vector2;
  323. if (!f_bStart)
  324. {
  325. vector = this.GetTargetPos();
  326. num = this.GetDistance();
  327. vector2 = this.GetAroundAngle();
  328. }
  329. else
  330. {
  331. vector = f_vSCenter;
  332. num = f_fSRadius;
  333. vector2 = f_vSRotate;
  334. }
  335. this.m_bMoveSkip = f_bSkip;
  336. if (this.m_bMoveSkip && GameMain.Instance.IsForceSkip())
  337. {
  338. this.SetTargetPos(f_vCenter, true);
  339. this.SetDistance(f_fRadius, true);
  340. this.SetAroundAngle(f_vRotate, true);
  341. this.m_vCenter = f_vCenter;
  342. this.m_fRadius = f_fRadius;
  343. this.m_vRotate = f_vRotate;
  344. }
  345. else
  346. {
  347. iTween.ValueTo(base.gameObject, iTween.Hash(new object[]
  348. {
  349. "easetype",
  350. easeType,
  351. "from",
  352. vector,
  353. "to",
  354. f_vCenter,
  355. "time",
  356. f_fTime,
  357. "delay",
  358. f_fDelay,
  359. "onUpdate",
  360. "UpdateCamTgt",
  361. "onComplete",
  362. "CompleteCam"
  363. }));
  364. iTween.ValueTo(base.gameObject, iTween.Hash(new object[]
  365. {
  366. "easetype",
  367. easeType,
  368. "from",
  369. num,
  370. "to",
  371. f_fRadius,
  372. "time",
  373. f_fTime,
  374. "delay",
  375. f_fDelay,
  376. "onUpdate",
  377. "UpdateCamDistance",
  378. "onComplete",
  379. "CompleteCam"
  380. }));
  381. iTween.ValueTo(base.gameObject, iTween.Hash(new object[]
  382. {
  383. "easetype",
  384. easeType,
  385. "from",
  386. vector2,
  387. "to",
  388. f_vRotate,
  389. "time",
  390. f_fTime,
  391. "delay",
  392. f_fDelay,
  393. "onUpdate",
  394. "UpdateCamAngle",
  395. "onComplete",
  396. "CompleteCam"
  397. }));
  398. }
  399. }
  400. public virtual void UpdateCamTgt(Vector3 f_vValue)
  401. {
  402. this.SetTargetPos(f_vValue, false);
  403. this.m_vCenter = f_vValue;
  404. }
  405. public virtual void UpdateCamDistance(float f_vValue)
  406. {
  407. this.SetDistance(f_vValue, false);
  408. this.m_fRadius = f_vValue;
  409. }
  410. public virtual void UpdateCamAngle(Vector2 f_vAngle)
  411. {
  412. this.SetAroundAngle(f_vAngle, false);
  413. this.m_vRotate = f_vAngle;
  414. }
  415. public virtual void CompleteCam()
  416. {
  417. }
  418. public virtual void ResetFromScriptOnTarget()
  419. {
  420. NDebug.Assert(this.m_eCamType == CameraMain.CameraType.Target, "カメラモードはターゲットでなくてはいけません。");
  421. iTween.StopAndSkipToEnd(base.gameObject);
  422. this.SetTargetPos(this.m_vCenter, true);
  423. this.SetDistance(this.m_fRadius, true);
  424. this.SetAroundAngle(this.m_vRotate, true);
  425. }
  426. public virtual void Reset(CameraMain.CameraType f_eType, bool f_bControl)
  427. {
  428. iTween.StopAndSkipToEnd(base.gameObject);
  429. base.transform.parent.transform.position = new Vector3(0f, 1.61f, 0f);
  430. this.CameraMaskReset();
  431. this.SetCameraType(f_eType);
  432. this.SetControl(f_bControl);
  433. this.SetTargetOffset(Vector3.zero, true);
  434. this.Blur(false);
  435. this.Vignett(false);
  436. this.RemoveChaseCameraAll();
  437. this.FadeInNoUI(0f, true);
  438. if (this.camera != null)
  439. {
  440. this.camera.fieldOfView = this.m_fDefaultFieldOfView;
  441. this.camera.nearClipPlane = this.m_fNearClipPlane;
  442. this.camera.farClipPlane = this.m_fFarClipPlane;
  443. }
  444. if (f_eType == CameraMain.CameraType.Target)
  445. {
  446. this.SetTargetPos(new Vector3(0f, 1.5f, 0f), true);
  447. if (this.m_UOCamera != null)
  448. {
  449. this.m_UOCamera.SetAroundAngle(new Vector2(180f, 10f));
  450. this.m_UOCamera.SetDistance(2f);
  451. }
  452. }
  453. else if (f_eType == CameraMain.CameraType.Free)
  454. {
  455. this.SetPos(new Vector3(0f, 1.5f, 2f));
  456. this.SetRotation(new Vector3(10f, -180f, 0f));
  457. }
  458. }
  459. public bool IsFadeProcNoUI()
  460. {
  461. return this.m_eMyFadeState != CameraMain.FadeState.Non && this.m_eMyFadeState != CameraMain.FadeState.Out;
  462. }
  463. public virtual void FadeOutNoUI(float f_fTime = 0.5f, bool f_bSkipable = true)
  464. {
  465. this.m_fMyFadeSkipable = f_bSkipable;
  466. if (this.m_eMyFadeState == CameraMain.FadeState.Out || this.m_eMyFadeState == CameraMain.FadeState.ProcOut)
  467. {
  468. return;
  469. }
  470. if (this.m_eMyFadeState == CameraMain.FadeState.ProcIn)
  471. {
  472. base.StopCoroutine(this.m_MyFadeRoutineIn);
  473. }
  474. this.m_FadeMyCamera.enabled = true;
  475. this.m_FadeMyCamera.intensity = 1f;
  476. this.m_fMyFadeTime = f_fTime;
  477. if (this.m_fMyFadeSkipable)
  478. {
  479. this.m_fMyFadeTime *= GameMain.Instance.CMSystem.FadeSpeedRate;
  480. if (GameMain.Instance.IsForceSkip())
  481. {
  482. this.m_fMyFadeTime = 0f;
  483. }
  484. }
  485. if (this.m_fMyFadeTime < 0.001f)
  486. {
  487. this.m_eMyFadeState = CameraMain.FadeState.Out;
  488. this.m_FadeMyCamera.intensity = 0f;
  489. }
  490. else
  491. {
  492. this.m_eMyFadeState = CameraMain.FadeState.ProcOut;
  493. base.StartCoroutine(this.m_MyFadeRoutineOut = this.CoMyFadeOut());
  494. }
  495. }
  496. private IEnumerator CoMyFadeOut()
  497. {
  498. this.m_fMyFadeNow = 0f;
  499. yield return null;
  500. while ((this.m_fMyFadeNow += Time.deltaTime) < this.m_fMyFadeTime)
  501. {
  502. this.m_eMyFadeState = CameraMain.FadeState.ProcOut;
  503. this.m_FadeMyCamera.enabled = true;
  504. this.m_FadeMyCamera.intensity = 1f - this.m_fMyFadeNow / this.m_fMyFadeTime;
  505. if (this.m_fMyFadeSkipable && GameMain.Instance.IsForceSkip())
  506. {
  507. break;
  508. }
  509. yield return null;
  510. }
  511. this.m_FadeMyCamera.enabled = true;
  512. this.m_FadeMyCamera.intensity = 0f;
  513. this.m_eMyFadeState = CameraMain.FadeState.Out;
  514. yield break;
  515. }
  516. public virtual void FadeInNoUI(float f_fTime = 0.5f, bool f_bSkipable = true)
  517. {
  518. this.m_fMyFadeSkipable = f_bSkipable;
  519. if (this.m_eMyFadeState == CameraMain.FadeState.Non || this.m_eMyFadeState == CameraMain.FadeState.ProcIn)
  520. {
  521. return;
  522. }
  523. if (this.m_eMyFadeState == CameraMain.FadeState.ProcOut)
  524. {
  525. base.StopCoroutine(this.m_MyFadeRoutineOut);
  526. }
  527. this.m_FadeMyCamera.enabled = true;
  528. this.m_FadeMyCamera.intensity = 0f;
  529. this.m_fMyFadeTime = f_fTime;
  530. if (this.m_fMyFadeSkipable)
  531. {
  532. this.m_fMyFadeTime *= GameMain.Instance.CMSystem.FadeSpeedRate;
  533. if (GameMain.Instance.IsForceSkip())
  534. {
  535. this.m_fMyFadeTime = 0f;
  536. }
  537. }
  538. if (this.m_fMyFadeTime < 0.001f)
  539. {
  540. this.m_eMyFadeState = CameraMain.FadeState.Non;
  541. this.m_FadeMyCamera.enabled = false;
  542. this.m_FadeMyCamera.intensity = 1f;
  543. }
  544. else
  545. {
  546. this.m_eMyFadeState = CameraMain.FadeState.ProcIn;
  547. base.StartCoroutine(this.m_MyFadeRoutineIn = this.CoMyFadeIn());
  548. }
  549. }
  550. private IEnumerator CoMyFadeIn()
  551. {
  552. this.m_fMyFadeNow = 0f;
  553. yield return null;
  554. while ((this.m_fMyFadeNow += Time.deltaTime) < this.m_fMyFadeTime)
  555. {
  556. this.m_eMyFadeState = CameraMain.FadeState.ProcIn;
  557. this.m_FadeMyCamera.enabled = true;
  558. this.m_FadeMyCamera.intensity = this.m_fMyFadeNow / this.m_fMyFadeTime;
  559. if (this.m_fMyFadeSkipable && GameMain.Instance.IsForceSkip())
  560. {
  561. break;
  562. }
  563. yield return null;
  564. }
  565. this.m_FadeMyCamera.enabled = false;
  566. this.m_FadeMyCamera.intensity = 1f;
  567. this.m_eMyFadeState = CameraMain.FadeState.Non;
  568. yield break;
  569. }
  570. public bool IsFadeProc()
  571. {
  572. return this.m_eFadeState != CameraMain.FadeState.Non && this.m_eFadeState != CameraMain.FadeState.Out;
  573. }
  574. public bool IsFadeOut()
  575. {
  576. return this.m_eFadeState != CameraMain.FadeState.Non;
  577. }
  578. public CameraMain.FadeState GetFadeState()
  579. {
  580. return this.m_eFadeState;
  581. }
  582. public bool IsFadeStateNon()
  583. {
  584. return this.m_eFadeState == CameraMain.FadeState.Non;
  585. }
  586. 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))
  587. {
  588. this.m_fFadeSkipable = f_bSkipable;
  589. if (this.m_eFadeState == CameraMain.FadeState.Out || this.m_eFadeState == CameraMain.FadeState.ProcOut)
  590. {
  591. return;
  592. }
  593. this.m_fFadeColor = f_color;
  594. if (this.m_eFadeState == CameraMain.FadeState.ProcIn)
  595. {
  596. base.StopCoroutine(this.m_FadeRoutineIn);
  597. this.CompleteFadeIn();
  598. }
  599. this.OnOverlayState(true);
  600. this.OnProcessFade(1f);
  601. this.m_fFadeTime = f_fTime;
  602. if (this.m_fFadeSkipable)
  603. {
  604. this.m_fFadeTime *= GameMain.Instance.CMSystem.FadeSpeedRate;
  605. if (GameMain.Instance.IsForceSkip())
  606. {
  607. this.m_fFadeTime = 0f;
  608. }
  609. }
  610. UICamera.InputEnable = f_bUIEnable;
  611. if (f_dg != null)
  612. {
  613. this.m_dgOnCompleteFadeOut = (CameraMain.dgOnCompleteFade)Delegate.Combine(this.m_dgOnCompleteFadeOut, f_dg);
  614. }
  615. if (this.m_fFadeTime <= 0.001f)
  616. {
  617. this.CompleteFadeOut();
  618. }
  619. else
  620. {
  621. this.m_eFadeState = CameraMain.FadeState.ProcOut;
  622. base.StartCoroutine(this.m_FadeRoutineOut = this.CoFadeOut());
  623. }
  624. }
  625. private IEnumerator CoFadeOut()
  626. {
  627. this.m_fFadeNow = 0f;
  628. yield return null;
  629. while ((this.m_fFadeNow += Time.deltaTime) < this.m_fFadeTime)
  630. {
  631. this.m_eFadeState = CameraMain.FadeState.ProcOut;
  632. this.OnOverlayState(true);
  633. this.OnProcessFade(1f - this.m_fFadeNow / this.m_fFadeTime);
  634. if (this.m_fFadeSkipable && GameMain.Instance.IsForceSkip())
  635. {
  636. break;
  637. }
  638. yield return null;
  639. }
  640. this.CompleteFadeOut();
  641. yield break;
  642. }
  643. private void CompleteFadeOut()
  644. {
  645. this.OnOverlayState(true);
  646. this.OnProcessFade(0f);
  647. this.m_eFadeState = CameraMain.FadeState.Out;
  648. if (this.m_dgOnCompleteFadeOut != null && this.m_dgOnCompleteFadeOut.GetInvocationList() != null && this.m_dgOnCompleteFadeOut.GetInvocationList().Length != 0)
  649. {
  650. this.m_dgOnCompleteFadeOut();
  651. this.m_dgOnCompleteFadeOut = new CameraMain.dgOnCompleteFade(this.Dummy);
  652. }
  653. }
  654. 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))
  655. {
  656. this.m_fFadeSkipable = f_bSkipable;
  657. if (this.m_eFadeState == CameraMain.FadeState.Non || this.m_eFadeState == CameraMain.FadeState.ProcIn)
  658. {
  659. return;
  660. }
  661. if (!f_bColorIsSameOut)
  662. {
  663. this.m_fFadeColor = f_color;
  664. }
  665. if (this.m_eFadeState == CameraMain.FadeState.ProcOut)
  666. {
  667. base.StopCoroutine(this.m_FadeRoutineOut);
  668. this.CompleteFadeOut();
  669. }
  670. this.OnOverlayState(true);
  671. this.OnProcessFade(0f);
  672. this.m_fFadeTime = f_fTime;
  673. if (this.m_fFadeSkipable)
  674. {
  675. this.m_fFadeTime *= GameMain.Instance.CMSystem.FadeSpeedRate;
  676. if (GameMain.Instance.IsForceSkip())
  677. {
  678. this.m_fFadeTime = 0f;
  679. }
  680. }
  681. UICamera.InputEnable = f_bUIEnable;
  682. if (f_dg != null)
  683. {
  684. this.m_dgOnCompleteFadeIn = (CameraMain.dgOnCompleteFade)Delegate.Combine(this.m_dgOnCompleteFadeIn, f_dg);
  685. }
  686. if (f_fTime <= 0.001f)
  687. {
  688. this.CompleteFadeIn();
  689. }
  690. else
  691. {
  692. this.m_eFadeState = CameraMain.FadeState.ProcIn;
  693. base.StartCoroutine(this.m_FadeRoutineIn = this.CoFadeIn());
  694. this.OnStartFadeIn();
  695. }
  696. }
  697. private IEnumerator CoFadeIn()
  698. {
  699. this.m_fFadeNow = 0f;
  700. yield return null;
  701. while ((this.m_fFadeNow += Time.deltaTime) < this.m_fFadeTime)
  702. {
  703. this.m_eFadeState = CameraMain.FadeState.ProcIn;
  704. this.OnOverlayState(true);
  705. this.OnProcessFade(this.m_fFadeNow / this.m_fFadeTime);
  706. if (this.m_fFadeSkipable && GameMain.Instance.IsForceSkip())
  707. {
  708. break;
  709. }
  710. yield return null;
  711. }
  712. this.CompleteFadeIn();
  713. yield break;
  714. }
  715. private void CompleteFadeIn()
  716. {
  717. this.OnOverlayState(false);
  718. this.OnProcessFade(1f);
  719. this.m_eFadeState = CameraMain.FadeState.Non;
  720. if (this.m_dgOnCompleteFadeIn != null && this.m_dgOnCompleteFadeIn.GetInvocationList() != null && this.m_dgOnCompleteFadeIn.GetInvocationList().Length != 0)
  721. {
  722. this.m_dgOnCompleteFadeIn();
  723. this.m_dgOnCompleteFadeIn = new CameraMain.dgOnCompleteFade(this.Dummy);
  724. }
  725. UICamera.InputEnable = true;
  726. }
  727. private void Dummy()
  728. {
  729. }
  730. protected virtual float GetFadeIntensity()
  731. {
  732. return this.m_FadeTargetCamera.intensity;
  733. }
  734. protected virtual void OnProcessFade(float f_fIntensity)
  735. {
  736. this.m_FadeTargetCamera.intensity = f_fIntensity;
  737. this.m_FadeTargetCamera.color = this.m_fFadeColor;
  738. }
  739. protected virtual void OnOverlayState(bool f_bEnable)
  740. {
  741. this.m_FadeTargetCamera.enabled = f_bEnable;
  742. }
  743. protected virtual void OnStartFadeIn()
  744. {
  745. }
  746. protected virtual IEnumerator OnCalcMaidDistance()
  747. {
  748. for (;;)
  749. {
  750. if (this.m_bCalcNearClip)
  751. {
  752. float fMin = 25f;
  753. for (int nM = 0; nM < GameMain.Instance.CharacterMgr.GetMaidCount(); nM++)
  754. {
  755. Maid maid = GameMain.Instance.CharacterMgr.GetMaid(nM);
  756. if (maid != null && maid.Visible && maid.body0.isLoadedBody)
  757. {
  758. float sqrMagnitude = (maid.body0.Pelvis.position - base.transform.position).sqrMagnitude;
  759. if (fMin > sqrMagnitude)
  760. {
  761. fMin = sqrMagnitude;
  762. }
  763. }
  764. yield return null;
  765. }
  766. if (fMin < 9f)
  767. {
  768. this.camera.nearClipPlane = 0.01f;
  769. }
  770. else
  771. {
  772. this.camera.nearClipPlane = 0.1f;
  773. }
  774. }
  775. yield return null;
  776. }
  777. yield break;
  778. }
  779. protected virtual void Update()
  780. {
  781. if (this.m_gcBloom != null)
  782. {
  783. bool enabled = this.m_gcBloom.enabled;
  784. this.m_gcBloom.enabled = GameMain.Instance.CMSystem.Bloom;
  785. this.m_gcBloom.bloomIntensity = this.m_fBloomDefIntensity * (float)GameMain.Instance.CMSystem.BloomValue * 0.01f;
  786. if (this.m_gcBloom.bloomIntensity <= 0.01f)
  787. {
  788. this.m_gcBloom.enabled = false;
  789. }
  790. else
  791. {
  792. this.m_gcBloom.enabled = true;
  793. }
  794. if (this.m_gcBloom.enabled != enabled)
  795. {
  796. GameMain.Instance.BroadcastMessage("OnChangeScreenSizeOrAA", SendMessageOptions.DontRequireReceiver);
  797. }
  798. }
  799. 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))
  800. {
  801. this.back_screen_size_.width = this.CurrentScreenWidth;
  802. this.back_screen_size_.height = this.CurrentScreenHeight;
  803. this.back_antialias_ = this.CurrentAntialias;
  804. this.back_full_screen_ = this.CurrentFullScreen;
  805. if (!GameMain.Instance.VRMode || GameMain.Instance.VRDummyMode)
  806. {
  807. GameMain.Instance.BroadcastMessage("OnChangeScreenSizeOrAA", SendMessageOptions.DontRequireReceiver);
  808. Screen.SetResolution(Screen.width, Screen.height, Screen.fullScreen);
  809. base.StartCoroutine(this.ResumeNguiRoot());
  810. }
  811. }
  812. if ((Input.GetKey(KeyCode.LeftShift) || Input.GetKey(KeyCode.RightShift)) && (Input.GetKeyDown(KeyCode.S) || Input.GetKeyDown(KeyCode.SysReq)) && !this.screen_shot_normal_)
  813. {
  814. this.screen_shot_normal_ = true;
  815. base.StartCoroutine(this.SaveScreenShotNormal());
  816. }
  817. if ((Input.GetKey(KeyCode.LeftAlt) || Input.GetKey(KeyCode.RightAlt)) && (Input.GetKeyDown(KeyCode.S) || Input.GetKeyDown(KeyCode.SysReq)) && !this.screen_shot_noui_)
  818. {
  819. this.screen_shot_noui_ = true;
  820. base.StartCoroutine(this.SaveScreenShotNoUI());
  821. }
  822. if (GameMain.Instance.IsForceSkip() && this.m_bMoveSkip)
  823. {
  824. iTween.StopAndSkipToEnd(base.gameObject);
  825. }
  826. }
  827. private IEnumerator ResumeNguiRoot()
  828. {
  829. Debug.Log("ResumeNguiRoot Start");
  830. this.changeing_ = true;
  831. this.CurrentAntialias = 0;
  832. yield return null;
  833. UILabel.OnFontTextureChanged();
  834. this.CurrentAntialias = this.back_antialias_;
  835. Debug.Log("ResumeNguiRoot End");
  836. this.changeing_ = false;
  837. yield break;
  838. }
  839. private void UIHide()
  840. {
  841. NDebug.Assert(!this.hide_ui_, "UIを表示した状態から非表示にして下さい。");
  842. this.ui_cam_hide_list_.Clear();
  843. UICamera[] array = NGUITools.FindActive<UICamera>();
  844. foreach (UICamera uicamera in array)
  845. {
  846. Camera component = uicamera.GetComponent<Camera>();
  847. if (component.enabled)
  848. {
  849. UIRoot uiroot = NGUITools.FindInParents<UIRoot>(uicamera.gameObject);
  850. if (!(uiroot == null))
  851. {
  852. UIPanel component2 = uiroot.GetComponent<UIPanel>();
  853. if (!(component2 == null))
  854. {
  855. if (0 > component2.name.ToLower().IndexOf("fix") && 0f < component2.alpha)
  856. {
  857. component2.alpha = 0f;
  858. this.ui_cam_hide_list_.Add(uicamera);
  859. }
  860. }
  861. }
  862. }
  863. }
  864. this.ui_hide_object_list_.Clear();
  865. GameObject gameObject = GameObject.Find("WorldTransformAxisParent");
  866. if (gameObject != null)
  867. {
  868. Transform transform = gameObject.transform;
  869. for (int j = 0; j < transform.childCount; j++)
  870. {
  871. if (transform.gameObject.activeSelf)
  872. {
  873. transform.gameObject.SetActive(true);
  874. this.ui_hide_object_list_.Add(transform.gameObject);
  875. }
  876. }
  877. gameObject.SetActive(false);
  878. }
  879. GizmoRender.UIVisible = false;
  880. this.hide_ui_ = true;
  881. }
  882. private void UIResume()
  883. {
  884. NDebug.Assert(this.hide_ui_, "UIを非表示にしてから表示して下さい。");
  885. foreach (UICamera uicamera in this.ui_cam_hide_list_)
  886. {
  887. Camera component = uicamera.GetComponent<Camera>();
  888. UIRoot uiroot = NGUITools.FindInParents<UIRoot>(uicamera.gameObject);
  889. if (!(uiroot == null))
  890. {
  891. UIPanel component2 = uiroot.GetComponent<UIPanel>();
  892. if (component2 != null)
  893. {
  894. component2.alpha = 1f;
  895. }
  896. }
  897. }
  898. this.ui_cam_hide_list_.Clear();
  899. for (int i = 0; i < this.ui_hide_object_list_.Count; i++)
  900. {
  901. this.ui_hide_object_list_[i].SetActive(true);
  902. }
  903. this.ui_hide_object_list_.Clear();
  904. GizmoRender.UIVisible = true;
  905. this.hide_ui_ = false;
  906. }
  907. public void ScreenShot(bool f_bNoUI)
  908. {
  909. this.custom_screenshot_ = false;
  910. if (f_bNoUI)
  911. {
  912. base.StartCoroutine(this.SaveScreenShotNoUI());
  913. }
  914. else
  915. {
  916. base.StartCoroutine(this.SaveScreenShotNormal());
  917. }
  918. }
  919. public void ScreenShot(string file_path, int super_size, bool no_ui_mode)
  920. {
  921. this.custom_screenshot_ = true;
  922. this.custom_screenshot_save_file_path_ = file_path;
  923. this.custom_screenshot_super_size_ = super_size;
  924. if (no_ui_mode)
  925. {
  926. base.StartCoroutine(this.SaveScreenShotNoUI());
  927. }
  928. else
  929. {
  930. base.StartCoroutine(this.SaveScreenShotNormal());
  931. }
  932. }
  933. protected IEnumerator SaveScreenShotNormal()
  934. {
  935. yield return new WaitForEndOfFrame();
  936. int super_size = this.ss_super_size_[(int)GameMain.Instance.CMSystem.ScreenShotSuperSize];
  937. string file_path = this.GetTimeFileName();
  938. if (this.custom_screenshot_)
  939. {
  940. file_path = this.custom_screenshot_save_file_path_;
  941. super_size = this.custom_screenshot_super_size_;
  942. }
  943. Application.CaptureScreenshot(file_path, super_size);
  944. yield return new WaitForEndOfFrame();
  945. this.screen_shot_normal_ = false;
  946. yield break;
  947. }
  948. protected IEnumerator SaveScreenShotNoUI()
  949. {
  950. this.UIHide();
  951. yield return new WaitForEndOfFrame();
  952. int super_size = this.ss_super_size_[(int)GameMain.Instance.CMSystem.ScreenShotSuperSize];
  953. string file_path = this.GetTimeFileName();
  954. if (this.custom_screenshot_)
  955. {
  956. file_path = this.custom_screenshot_save_file_path_;
  957. super_size = this.custom_screenshot_super_size_;
  958. }
  959. Application.CaptureScreenshot(file_path, super_size);
  960. yield return new WaitForEndOfFrame();
  961. this.UIResume();
  962. this.screen_shot_noui_ = false;
  963. yield break;
  964. }
  965. private string GetTimeFileName()
  966. {
  967. string fullPath = Path.GetFullPath(".\\");
  968. string text = fullPath + "ScreenShot";
  969. if (!Directory.Exists(text))
  970. {
  971. Directory.CreateDirectory(text);
  972. }
  973. return text + "\\img" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".png";
  974. }
  975. public Camera camera
  976. {
  977. get
  978. {
  979. if (this.camera_ == null)
  980. {
  981. this.camera_ = base.GetComponent<Camera>();
  982. }
  983. return this.camera_;
  984. }
  985. }
  986. private CameraMain.CameraType m_eCamType;
  987. protected int m_nBackCullingMask;
  988. protected UltimateOrbitCamera m_UOCamera;
  989. public FadeInAndFadeOutOnGUI m_FadeTargetCamera;
  990. private ScreenOverlay m_FadeMyCamera;
  991. private Bloom m_gcBloom;
  992. private Blur m_gcBlur;
  993. private Vignetting m_gcVignett;
  994. public bool m_bCalcNearClip = true;
  995. protected float m_fDefaultFieldOfView;
  996. protected float m_fNearClipPlane;
  997. protected float m_fFarClipPlane;
  998. protected bool m_bMoveSkip;
  999. protected float m_fBloomDefIntensity = 2.85f;
  1000. protected Ray m_rayVRHitFloor = default(Ray);
  1001. protected RaycastHit m_hitVRFloor = default(RaycastHit);
  1002. protected bool m_bFallThrough;
  1003. protected CameraMain.FadeState m_eMyFadeState;
  1004. private bool m_fMyFadeSkipable;
  1005. private float m_fMyFadeNow;
  1006. private float m_fMyFadeTime;
  1007. private IEnumerator m_MyFadeRoutineOut;
  1008. private IEnumerator m_MyFadeRoutineIn;
  1009. protected CameraMain.FadeState m_eFadeState;
  1010. private bool m_fFadeSkipable;
  1011. protected CameraMain.dgOnCompleteFade m_dgOnCompleteFadeOut;
  1012. protected CameraMain.dgOnCompleteFade m_dgOnCompleteFadeIn;
  1013. private float m_fFadeNow;
  1014. private float m_fFadeTime;
  1015. private IEnumerator m_FadeRoutineOut;
  1016. private IEnumerator m_FadeRoutineIn;
  1017. private Color m_fFadeColor = Color.black;
  1018. private int[] ss_super_size_ = new int[]
  1019. {
  1020. 1,
  1021. 2,
  1022. 4
  1023. };
  1024. private int back_antialias_;
  1025. private bool back_full_screen_;
  1026. private bool changeing_;
  1027. private CameraMain.TexSize back_screen_size_;
  1028. protected bool screen_shot_noui_;
  1029. protected bool screen_shot_normal_;
  1030. private List<UICamera> ui_cam_hide_list_ = new List<UICamera>();
  1031. private List<GameObject> ui_hide_object_list_ = new List<GameObject>();
  1032. private bool hide_ui_;
  1033. private Camera camera_;
  1034. protected Vector3 m_vCenter = new Vector3(0f, 1.5f, 0f);
  1035. protected float m_fRadius = 2f;
  1036. protected Vector2 m_vRotate = new Vector2(180f, 10f);
  1037. private bool custom_screenshot_;
  1038. private string custom_screenshot_save_file_path_;
  1039. private int custom_screenshot_super_size_;
  1040. public enum CameraType
  1041. {
  1042. Target,
  1043. Free
  1044. }
  1045. public enum CameraMask
  1046. {
  1047. Character = 10,
  1048. BG = 20,
  1049. OvrTouchLookObj = 19
  1050. }
  1051. public enum STAND_SIT
  1052. {
  1053. NON,
  1054. STAND,
  1055. SIT
  1056. }
  1057. public enum FadeState
  1058. {
  1059. Non,
  1060. ProcIn,
  1061. ProcOut,
  1062. Out
  1063. }
  1064. public delegate void dgOnCompleteFade();
  1065. private struct TexSize
  1066. {
  1067. public int width;
  1068. public int height;
  1069. }
  1070. }