SceneMgr.cs 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. using System;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. namespace com.workman.cm3d2.scene.dailyEtc
  5. {
  6. public class SceneMgr : MonoBehaviour
  7. {
  8. private void Start()
  9. {
  10. this.m_tagBackup = null;
  11. this.advKag = GameMain.Instance.ScriptMgr.adv_kag;
  12. if (this.advKag.tag_backup != null && 0 < this.advKag.tag_backup.Count)
  13. {
  14. NDebug.Assert(this.advKag.tag_backup.ContainsKey("label"), "SceneCallにlabelの設定がされていませんでした");
  15. this.m_tagBackup = this.advKag.tag_backup;
  16. this.m_sceneName = this.advKag.tag_backup["name"];
  17. this.m_mgr = base.GetComponent<SceneMgr>();
  18. if (this.m_sceneName == "SceneDaily")
  19. {
  20. NDebug.Assert(this.advKag.tag_backup.ContainsKey("type"), "SceneCallにtypeの設定がされていませんでした");
  21. this.m_openType = this.advKag.tag_backup["type"];
  22. this.DispatcherSceneDaily(this.m_openType);
  23. }
  24. else if (this.m_sceneName == "SceneUserEdit")
  25. {
  26. this.m_mgr.GetManager<UserEditMgr>();
  27. }
  28. else if (this.m_sceneName == "SceneStartDaily")
  29. {
  30. this.m_mgr.GetManager<StartDailyMgr>().OpenStartDailyPanel();
  31. }
  32. else if (this.m_sceneName == "SceneTitle")
  33. {
  34. BaseMgr<TitleMgr>.Instance.OpenTitlePanel();
  35. }
  36. else if (!(this.m_sceneName == "SceneCompetitiveShow"))
  37. {
  38. if (this.m_sceneName == "SceneStaffRoll")
  39. {
  40. this.m_mgr.GetManager<StaffRollMgr>().OpenStaffRollPanel();
  41. }
  42. }
  43. }
  44. }
  45. private void DispatcherSceneDaily(string openType)
  46. {
  47. if (openType == "Daytime")
  48. {
  49. this.m_mgr.GetManager<DailyMgr>().OpenDaytimePanel();
  50. }
  51. else if (openType == "Night")
  52. {
  53. this.m_mgr.GetManager<DailyMgr>().OpenNightPanel();
  54. }
  55. else if (openType == "ResultIncome")
  56. {
  57. this.m_mgr.GetManager<ResultIncomeMgr>().OpenResultIncomePanel();
  58. }
  59. else if (openType == "ResultWorkDaytime")
  60. {
  61. this.m_mgr.GetManager<ResultWorkMgr>().OpenResultDaytimePanel();
  62. }
  63. else if (openType == "ResultWorkNight")
  64. {
  65. this.m_mgr.GetManager<ResultWorkMgr>().OpenResultNightPanel();
  66. }
  67. else if (openType == "Status")
  68. {
  69. }
  70. }
  71. public void OpenMaidExaminationPanel()
  72. {
  73. this.m_mgr.GetManager<MaidExaminationMgr>().OpenMaidExaminationPanel(null, null, null);
  74. }
  75. public void CloseScene()
  76. {
  77. this.GoToLabel("label");
  78. }
  79. public void GoToLabel(string labelName)
  80. {
  81. if (this.advKag != null && this.m_tagBackup != null)
  82. {
  83. if (this.m_tagBackup.ContainsKey(labelName))
  84. {
  85. string text = this.m_tagBackup[labelName];
  86. if (text != null)
  87. {
  88. Debug.Log(string.Format("Call 名前={0}, タイプ={1}, ラベル={2}", this.m_sceneName, this.m_openType, labelName));
  89. this.advKag.JumpLabel(text);
  90. this.advKag.Exec();
  91. }
  92. else
  93. {
  94. Debug.LogError(string.Format("指定したラベルが取得できません。名前={0}, タイプ={1}, ラベル={2}", this.m_sceneName, this.m_openType, labelName));
  95. }
  96. }
  97. else
  98. {
  99. Debug.LogError(string.Format("指定したラベルが取得できません。名前={0}, タイプ={1}, ラベル={2}", this.m_sceneName, this.m_openType, labelName));
  100. }
  101. }
  102. }
  103. public T GetManager<T>() where T : BasePanelMgr
  104. {
  105. if (this.m_poolMgr == null)
  106. {
  107. this.m_poolMgr = new Dictionary<Type, BasePanelMgr>();
  108. }
  109. if (this.m_poolMgr.ContainsKey(typeof(T)))
  110. {
  111. return (T)((object)this.m_poolMgr[typeof(T)]);
  112. }
  113. T componentInManager = this.GetComponentInManager<T>();
  114. componentInManager.BaseInit();
  115. this.m_poolMgr.Add(typeof(T), componentInManager);
  116. return componentInManager;
  117. }
  118. private T GetComponentInManager<T>() where T : BasePanelMgr
  119. {
  120. this.m_goUIRoot = this.GetUIRoot(this.uiRootPath);
  121. GameObject childObject = UTY.GetChildObject(this.m_goUIRoot, "Manager", false);
  122. string arg = this.uiRootPath + "/Manager";
  123. NDebug.Assert(childObject != null, string.Format("{0}が見つかりませんでした", arg));
  124. T componentInChildren = childObject.GetComponentInChildren<T>();
  125. NDebug.Assert(childObject != null, string.Format("{0}の子供に指定されたコンポーネント({1})が存在しません。", arg, typeof(T)));
  126. return componentInChildren;
  127. }
  128. private GameObject GetUIRoot(string uiRootPath)
  129. {
  130. if (this.m_goUIRoot == null)
  131. {
  132. return GameObject.Find(uiRootPath);
  133. }
  134. return this.m_goUIRoot;
  135. }
  136. private ADVKagManager advKag;
  137. private SceneMgr m_mgr;
  138. private GameObject m_goUIRoot;
  139. private Dictionary<Type, BasePanelMgr> m_poolMgr;
  140. private Dictionary<string, string> m_tagBackup;
  141. private string m_sceneName;
  142. private string m_openType;
  143. private string uiRootPath = "/UI Root";
  144. }
  145. }