PrivateEventManager.cs 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  1. using System;
  2. using System.Collections;
  3. using PrivateMaidMode;
  4. using UnityEngine;
  5. public class PrivateEventManager : WfScreenChildren
  6. {
  7. protected bool isNoon
  8. {
  9. get
  10. {
  11. return GameMain.Instance.CharacterMgr.status.isDaytime;
  12. }
  13. }
  14. public override void Awake()
  15. {
  16. base.Awake();
  17. this.eventIconVisibleCheckBox.onClick.Add(delegate(WFCheckBox checkBox)
  18. {
  19. this.SetEventListVisible(!checkBox.check);
  20. });
  21. this.eventHelpObject.SetActive(false);
  22. }
  23. protected override void OnCall()
  24. {
  25. this.okButton.gameObject.SetActive(false);
  26. if (ScenePrivateEventModeAwake.callEventId == -1)
  27. {
  28. this.eventHelpObject.SetActive(true);
  29. base.StartCoroutine(this.SetupPrivateMode());
  30. }
  31. else
  32. {
  33. this.eventIconVisibleCheckBox.gameObject.SetActive(false);
  34. this.eventSelectPanel.gameObject.SetActive(false);
  35. }
  36. }
  37. protected IEnumerator SetupPrivateMode()
  38. {
  39. this.setupCompleted = false;
  40. PrivateModeMgr privateModeData = PrivateModeMgr.Instance;
  41. this.maid = privateModeData.PrivateMaid;
  42. if (privateModeData.SelectBG == null)
  43. {
  44. NDebug.Assert("プライベートモードの設定が未設定で始まりました", false);
  45. privateModeData.SetPrivateBG(DataBase.GetData(10).bgData);
  46. }
  47. if (this.maid == null)
  48. {
  49. this.maid = GameMain.Instance.CharacterMgr.GetMaid(0);
  50. }
  51. else
  52. {
  53. GameMain.Instance.CharacterMgr.SetActiveMaid(this.maid, 0);
  54. }
  55. this.maid.AllProcPropSeqStart();
  56. this.maid.Visible = true;
  57. while (this.maid.IsBusy)
  58. {
  59. yield return null;
  60. }
  61. MaidColliderCollect.SuspendColliderAll(this.maid, false);
  62. privateModeData.SelectBG.Apply(this.isNoon);
  63. this.bgEvent = privateModeData.SelectBG.GetEvent(this.isNoon);
  64. if (this.bgEvent != null)
  65. {
  66. UnityEngine.Object.DestroyImmediate(this.eventHitObject);
  67. this.eventHitObject = this.bgEvent.InstantiateHitPrefab(this.bgHitPrefabParent.gameObject);
  68. this.eventHitObject.SetActive(true);
  69. bool flag = false;
  70. foreach (PrivateModeEventObject privateModeEventObject in this.eventHitObject.GetComponentsInChildren<PrivateModeEventObject>())
  71. {
  72. DataBase.BG.Event.PointData eventData = this.bgEvent.GetEventData(privateModeEventObject.GetEventNo());
  73. bool flag2 = this.bgEvent.IsExec(this.maid, privateModeEventObject.GetEventNo());
  74. if (flag2 && !this.bgEvent.IsFinishedReadingFile(this.maid, eventData, this.bgEvent.GetNextScenarioIndex(this.maid, eventData)))
  75. {
  76. privateModeEventObject.CreateNewStar();
  77. }
  78. privateModeEventObject.gameObject.SetActive(flag2);
  79. flag = (flag || flag2);
  80. }
  81. if (this.eventHelpObject != null && (this.bgEvent.eventPointList.Length <= 0 || !flag))
  82. {
  83. UILabel component = UTY.GetChildObject(this.eventHelpObject, "Text/Text", false).GetComponent<UILabel>();
  84. if (component != null)
  85. {
  86. component.text = "イベントはありません";
  87. }
  88. }
  89. }
  90. PrivateModeEventObject.onClickObject = new Action<int>(this.OnClickEventObject);
  91. privateModeData.LoadLocation();
  92. yield return null;
  93. this.eventSelectPanel.Setup(null, null);
  94. this.SetEventListVisible(GameMain.Instance.CMSystem.SConfig.PrivateModeEventListVisible);
  95. this.okButton.gameObject.SetActive(true);
  96. this.setupCompleted = true;
  97. uGUITutorialPanel.OpenTutorial("ScenePrivateEventMode", null, false);
  98. yield break;
  99. }
  100. private void SetEventListVisible(bool visible)
  101. {
  102. this.eventIconVisibleCheckBox.check = !visible;
  103. this.eventSelectPanel.gameObject.SetActive(visible);
  104. UTY.GetChildObject(this.eventHelpObject, "Text", false).SetActive(!visible);
  105. if (this.eventHitObject != null)
  106. {
  107. this.eventHitObject.SetActive(!visible);
  108. }
  109. GameMain.Instance.CMSystem.SConfig.PrivateModeEventListVisible = visible;
  110. }
  111. protected override bool IsCallFadeIn()
  112. {
  113. return this.setupCompleted;
  114. }
  115. public void OnClickOK()
  116. {
  117. if (!this.setupCompleted)
  118. {
  119. return;
  120. }
  121. this.Finish();
  122. }
  123. protected override void OnFinish()
  124. {
  125. if (this.loadScriptAction != null)
  126. {
  127. this.loadScriptAction();
  128. this.loadScriptAction = null;
  129. return;
  130. }
  131. if (this.eventHitObject != null)
  132. {
  133. this.eventHitObject.SetActive(false);
  134. }
  135. PartColliderData.SetDefaultCursor();
  136. string returnFile = ScenePrivateEventModeAwake.returnFile;
  137. if (!string.IsNullOrEmpty(returnFile))
  138. {
  139. GameMain.Instance.ScriptMgr.adv_kag.LoadScriptFile(returnFile, string.Empty);
  140. }
  141. base.parent_mgr.CallScreen("Move");
  142. }
  143. protected void OnClickEventObject(int eventNo)
  144. {
  145. if (this.bgEvent == null || this.maid == null || GameMain.Instance.MainCamera.IsFadeProc())
  146. {
  147. return;
  148. }
  149. this.loadScriptAction = delegate()
  150. {
  151. bool flag = this.bgEvent.LoadScript(this.maid, eventNo);
  152. if (!flag)
  153. {
  154. Debug.LogError("イベントNo" + eventNo + "のイベントは設定されていません");
  155. }
  156. return flag;
  157. };
  158. GameMain.Instance.SoundMgr.PlaySystem(SoundMgr.SeType.Click);
  159. this.Finish();
  160. }
  161. [SerializeField]
  162. private Transform bgHitPrefabParent;
  163. [SerializeField]
  164. private UIButton okButton;
  165. [SerializeField]
  166. private GameObject eventHelpObject;
  167. [SerializeField]
  168. private PrivateEventSelectPanel eventSelectPanel;
  169. [SerializeField]
  170. private WFCheckBox eventIconVisibleCheckBox;
  171. protected bool setupCompleted;
  172. protected Maid maid;
  173. protected DataBase.BG.Event bgEvent;
  174. protected GameObject eventHitObject;
  175. protected Func<bool> loadScriptAction;
  176. }