SceneEmpireLifeMode.cs 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Text;
  4. using UnityEngine;
  5. using UnityEngine.Events;
  6. using UnityEngine.UI;
  7. public class SceneEmpireLifeMode : MonoBehaviour
  8. {
  9. private EmpireLifeModeManager lifeModeMgr
  10. {
  11. get
  12. {
  13. EmpireLifeModeManager result;
  14. if ((result = this.m_LifeModeMgr) == null)
  15. {
  16. result = (this.m_LifeModeMgr = GameMain.Instance.LifeModeMgr);
  17. }
  18. return result;
  19. }
  20. }
  21. private string strNextJumpLabel { get; set; }
  22. private void Start()
  23. {
  24. if (EmpireLifeModeData.GetAllDatas(true).Count <= 0)
  25. {
  26. NDebug.Assert("不正な処理が実行されました。", false);
  27. return;
  28. }
  29. GameMain.Instance.MainLight.Reset();
  30. GameMain.Instance.CharacterMgr.DeactivateCharaAll();
  31. GameMain.Instance.MainCamera.Reset(CameraMain.CameraType.Target, true);
  32. GameMain.Instance.SoundMgr.VoiceStopAll();
  33. GameMain.Instance.SoundMgr.StopSe();
  34. GameMain.Instance.MainCamera.FadeOut(0f, false, null, true, default(Color));
  35. ADVKagManager adv_kag = GameMain.Instance.ScriptMgr.adv_kag;
  36. if (!adv_kag.tag_backup.TryGetValue("label_start", out this.m_StrScenarioStartLabel))
  37. {
  38. Debug.LogFormat("イベント開始時のラベルが未指定です\nラベル名 : {0}", new object[]
  39. {
  40. "label_start"
  41. });
  42. }
  43. if (!adv_kag.tag_backup.TryGetValue("label_end", out this.m_StrOKLabel))
  44. {
  45. Debug.LogFormat("終了時のラベルが未指定です\nラベル名 : {0}", new object[]
  46. {
  47. "label_end"
  48. });
  49. }
  50. this.m_ButtonOK.onClick.AddListener(new UnityAction(this.OnClickOK));
  51. this.m_ButtonShuffle.onClick.AddListener(delegate()
  52. {
  53. this.MaidRandomAllocate();
  54. this.ShowMaidIconsOfEventData();
  55. });
  56. if (SceneEmpireLifeMode.m_SelectedEventObject != null)
  57. {
  58. }
  59. if (this.lifeModeMgr.executedEventList.Count <= 0)
  60. {
  61. this.lifeModeMgr.CreateStoryEvent();
  62. int num = (10 > this.lifeModeMgr.lifeModeAllMaidList.Count) ? 1 : 2;
  63. for (int i = 0; i < num; i++)
  64. {
  65. if (UnityEngine.Random.Range(0, 100) > 80)
  66. {
  67. this.lifeModeMgr.CreateRandomEventOfNowState();
  68. }
  69. }
  70. this.lifeModeMgr.AllMaidRandomAllocate();
  71. this.lifeModeMgr.CreateEventListOfMaidAllocateData();
  72. Debug.Log("イベントを作成しました。");
  73. }
  74. this.m_FacilityListUI.ShowFacilityList();
  75. this.ShowMaidIconsOfEventData();
  76. GameMain.Instance.MainCamera.FadeIn(0.5f, false, new CameraMain.dgOnCompleteFade(this.OnCompleteFadeIn), true, true, default(Color));
  77. }
  78. private void OnCompleteFadeIn()
  79. {
  80. }
  81. private void OnCompleteFadeOut()
  82. {
  83. if (SceneEmpireLifeMode.m_SelectedEventObject != null)
  84. {
  85. this.lifeModeMgr.SetupScenarioEvent(SceneEmpireLifeMode.m_SelectedEventObject, delegate
  86. {
  87. ADVKagManager adv_kag2 = GameMain.Instance.ScriptMgr.adv_kag;
  88. NDebug.Assert(!string.IsNullOrEmpty(this.strNextJumpLabel), "SceneEmpireLifeMode.cs\n飛び先ラベルが空でした");
  89. adv_kag2.JumpLabel(this.strNextJumpLabel);
  90. adv_kag2.Exec();
  91. });
  92. return;
  93. }
  94. Debug.Log("エンパイアライフモードのループを終了。");
  95. ADVKagManager adv_kag = GameMain.Instance.ScriptMgr.adv_kag;
  96. NDebug.Assert(!string.IsNullOrEmpty(this.strNextJumpLabel), "SceneEmpireLifeMode.cs\n飛び先ラベルが空でした");
  97. adv_kag.JumpLabel(this.strNextJumpLabel);
  98. adv_kag.Exec();
  99. }
  100. private void OnClickOK()
  101. {
  102. SceneEmpireLifeMode.m_SelectedEventObject = null;
  103. this.strNextJumpLabel = this.m_StrOKLabel;
  104. GameMain.Instance.MainCamera.FadeOut(0.5f, false, new CameraMain.dgOnCompleteFade(this.OnCompleteFadeOut), true, default(Color));
  105. }
  106. private void OnClickEventFrame(EmpireLifeModeManager.EventDataObject eventObj)
  107. {
  108. StringBuilder stringBuilder = new StringBuilder();
  109. stringBuilder.AppendLine(string.Format("[{0}] {1} 種類:{2}[{3}]", new object[]
  110. {
  111. eventObj.targetEvent.ID,
  112. eventObj.targetEvent.strUniqueName,
  113. eventObj.targetEvent.dataScenarioType,
  114. eventObj.targetEvent.GetPriorityScenarioType()
  115. }));
  116. stringBuilder.AppendLine(string.Format("実行する施設 : {0} ({1})", eventObj.targetFacility.facilityName, eventObj.targetFacility.defaultName));
  117. foreach (Maid maid in eventObj.targetMaidList)
  118. {
  119. stringBuilder.AppendLine(string.Format("{0} ({1})", maid.status.fullNameJpStyle, maid.status.personal.drawName));
  120. }
  121. Debug.Log(stringBuilder.ToString());
  122. SceneEmpireLifeMode.m_SelectedEventObject = eventObj;
  123. this.strNextJumpLabel = this.m_StrScenarioStartLabel;
  124. GameMain.Instance.MainCamera.FadeOut(0.5f, false, new CameraMain.dgOnCompleteFade(this.OnCompleteFadeOut), true, default(Color));
  125. }
  126. public void MaidRandomAllocate()
  127. {
  128. this.lifeModeMgr.DeleteNowEventList();
  129. this.lifeModeMgr.CreateStoryEvent();
  130. int num = (10 > this.lifeModeMgr.lifeModeAllMaidList.Count) ? 1 : 2;
  131. for (int i = 0; i < num; i++)
  132. {
  133. if (UnityEngine.Random.Range(0, 100) > 80)
  134. {
  135. this.lifeModeMgr.CreateRandomEventOfNowState();
  136. }
  137. }
  138. this.lifeModeMgr.AllMaidRandomAllocate();
  139. this.lifeModeMgr.CreateEventListOfMaidAllocateData();
  140. }
  141. public void ShowMaidIconsOfNowAllocateState()
  142. {
  143. Debug.LogWarning("ShowMaidIconsOfNowAllocateState()\nこの関数は使わなくなる?");
  144. foreach (EmpireLifeModeFacilityUI.FacilityLifeModeViewer facilityLifeModeViewer in this.m_FacilityListUI.GetAllItem())
  145. {
  146. Facility nowShowingFacility = facilityLifeModeViewer.GetNowShowingFacility();
  147. List<Maid> maidList;
  148. if (!(nowShowingFacility == null) && this.lifeModeMgr.nowMaidAllocationDic.TryGetValue(nowShowingFacility, out maidList))
  149. {
  150. facilityLifeModeViewer.listViewerParentMaidIcon.Show<uGUIListViewer>(maidList.Count, delegate(int index, uGUIListViewer viewer)
  151. {
  152. viewer.Show<Transform>(1, delegate(int notUseIndex, Transform trans)
  153. {
  154. RawImage componentInChildren = trans.GetComponentInChildren<RawImage>();
  155. Maid maid = maidList[index];
  156. componentInChildren.texture = maid.GetThumIcon();
  157. Text componentInChildren2 = componentInChildren.GetComponentInChildren<Text>();
  158. if (componentInChildren2 != null)
  159. {
  160. if (componentInChildren.texture == null)
  161. {
  162. componentInChildren2.text = string.Format("{0}\n({1})", maid.status.charaName.GetFullName(" "), maid.status.personal.drawName);
  163. }
  164. else
  165. {
  166. componentInChildren2.text = string.Empty;
  167. }
  168. }
  169. });
  170. });
  171. }
  172. }
  173. }
  174. public void ShowMaidIconsOfEventData()
  175. {
  176. List<EmpireLifeModeManager.EventDataObject> nowEventList = this.lifeModeMgr.nowEventList;
  177. foreach (EmpireLifeModeFacilityUI.FacilityLifeModeViewer facilityLifeModeViewer in this.m_FacilityListUI.GetAllItem())
  178. {
  179. SceneEmpireLifeMode.<ShowMaidIconsOfEventData>c__AnonStorey2 <ShowMaidIconsOfEventData>c__AnonStorey = new SceneEmpireLifeMode.<ShowMaidIconsOfEventData>c__AnonStorey2();
  180. <ShowMaidIconsOfEventData>c__AnonStorey.$this = this;
  181. Facility nowShowingFacility = facilityLifeModeViewer.GetNowShowingFacility();
  182. if (!(nowShowingFacility == null))
  183. {
  184. <ShowMaidIconsOfEventData>c__AnonStorey.eventList = new List<EmpireLifeModeManager.EventDataObject>();
  185. foreach (EmpireLifeModeManager.EventDataObject eventDataObject in nowEventList)
  186. {
  187. if (eventDataObject.targetFacility == nowShowingFacility)
  188. {
  189. <ShowMaidIconsOfEventData>c__AnonStorey.eventList.Add(eventDataObject);
  190. }
  191. }
  192. facilityLifeModeViewer.listViewerParentMaidIcon.Show<uGUIListViewer>(<ShowMaidIconsOfEventData>c__AnonStorey.eventList.Count, delegate(int eventIndex, uGUIListViewer viewer)
  193. {
  194. RawImage component = viewer.transform.Find("event type icon").GetComponent<RawImage>();
  195. component.texture = EmpireLifeModeAPI.GetIconScenarioType(<ShowMaidIconsOfEventData>c__AnonStorey.eventList[eventIndex].targetEvent.dataScenarioType);
  196. component.gameObject.SetActive(component.texture != null);
  197. viewer.Show<Transform>(<ShowMaidIconsOfEventData>c__AnonStorey.eventList[eventIndex].targetMaidList.Count, delegate(int maidIndex, Transform trans)
  198. {
  199. RawImage componentInChildren = trans.GetComponentInChildren<RawImage>();
  200. Maid maid = <ShowMaidIconsOfEventData>c__AnonStorey.eventList[eventIndex].targetMaidList[maidIndex];
  201. componentInChildren.texture = maid.GetThumIcon();
  202. Text componentInChildren2 = componentInChildren.GetComponentInChildren<Text>();
  203. if (componentInChildren2 != null)
  204. {
  205. if (componentInChildren.texture == null)
  206. {
  207. componentInChildren2.text = string.Format("{0}\n({1})", maid.status.charaName.GetFullName(" "), maid.status.personal.drawName);
  208. }
  209. else
  210. {
  211. componentInChildren2.text = string.Empty;
  212. }
  213. }
  214. trans.SetAsFirstSibling();
  215. });
  216. Button component2 = viewer.GetComponent<Button>();
  217. component2.onClick.AddListener(delegate()
  218. {
  219. <ShowMaidIconsOfEventData>c__AnonStorey.OnClickEventFrame(<ShowMaidIconsOfEventData>c__AnonStorey.eventList[eventIndex]);
  220. });
  221. });
  222. }
  223. }
  224. }
  225. [SerializeField]
  226. private EmpireLifeModeFacilityUI m_FacilityListUI;
  227. [SerializeField]
  228. private Button m_ButtonOK;
  229. [SerializeField]
  230. private Button m_ButtonShuffle;
  231. private string m_StrScenarioStartLabel;
  232. private string m_StrOKLabel;
  233. private static EmpireLifeModeManager.EventDataObject m_SelectedEventObject;
  234. private EmpireLifeModeManager m_LifeModeMgr;
  235. }