FacilityPowerUpManager.cs 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324
  1. using System;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEngine.UI;
  5. public class FacilityPowerUpManager : MonoBehaviour
  6. {
  7. public Facility selectingFacility
  8. {
  9. get
  10. {
  11. return this.m_SelectingFacility;
  12. }
  13. set
  14. {
  15. this.m_SelectingFacility = value;
  16. }
  17. }
  18. private void Start()
  19. {
  20. this.SetUpBackGroundAndCamera();
  21. this.GetTagBackup();
  22. this.OpenFacilityUIList();
  23. this.SetOKButtonEnable(this.IsOKButtonEnable());
  24. CharacterMgr characterMgr = GameMain.Instance.CharacterMgr;
  25. Maid maid = null;
  26. if (characterMgr.GetMaidCount() > 0 && characterMgr.GetMaid(0))
  27. {
  28. maid = characterMgr.GetMaid(0);
  29. }
  30. else
  31. {
  32. Debug.LogWarning("メイド0番の取得に失敗しました。");
  33. }
  34. this.m_Maid = maid;
  35. for (int i = 0; i < characterMgr.GetMaidCount(); i++)
  36. {
  37. if (characterMgr.GetMaid(i) != null)
  38. {
  39. characterMgr.GetMaid(i).Visible = false;
  40. }
  41. }
  42. if (!uGUITutorialPanel.IsOpened())
  43. {
  44. uGUITutorialPanel.OpenTutorial("SceneFacilityPowerUp", null, false);
  45. }
  46. }
  47. private void SetUpBackGroundAndCamera()
  48. {
  49. GameMain.Instance.BgMgr.ChangeBg("EmpireClub_Entrance");
  50. GameMain.Instance.MainCamera.FadeIn(0.5f, false, null, true, true, default(Color));
  51. CameraMain mainCamera = GameMain.Instance.MainCamera;
  52. GameMain.Instance.MainLight.Reset();
  53. mainCamera.Reset(CameraMain.CameraType.Target, true);
  54. this.m_CachedMainCameraControlEnabled = mainCamera.GetControl();
  55. mainCamera.SetControl(false);
  56. }
  57. public void OpenFacilityUIList()
  58. {
  59. this.m_FacilityUIList.Show();
  60. this.SetOKButtonEnable(this.IsOKButtonEnable());
  61. this.m_FacilityUIInfo.gameObject.SetActive(false);
  62. }
  63. public void OpenFacilityUIPowerUpList(Facility facility)
  64. {
  65. this.selectingFacility = facility;
  66. this.m_FacilityUIPowerUpList.Show(facility, delegate(Facility.PowerUpRecipe powerUpRecipe)
  67. {
  68. this.OpenFacilityUIMaterialList(powerUpRecipe.id);
  69. this.OpenFacilityUIPreviousDefaultParams(powerUpRecipe.id);
  70. this.OpenFacilityUINextDefaultParams(powerUpRecipe.id);
  71. this.OpenFacilityUIPreviousAdditionalParams(powerUpRecipe.id);
  72. });
  73. this.m_NowRecipeData = null;
  74. this.m_FacilityUIPowerUpMaterialList.DeleteDropdown();
  75. this.m_FacilityUIPreviousParams.ResetDefaultParam();
  76. this.m_FacilityUIPreviousParams.ResetAdditionalParam();
  77. this.m_FacilityUINextParams.ResetDefaultParam();
  78. this.m_FacilityUINextParams.ResetAdditionalParam();
  79. this.SetOKButtonEnable(this.IsOKButtonEnable());
  80. }
  81. public void OpenFacilityUIMaterialList(int recipeID)
  82. {
  83. this.m_NowRecipeData = new Facility.RecipeData(recipeID);
  84. this.m_FacilityUIPowerUpMaterialList.Show(recipeID, this.selectingFacility, delegate(int[] materialIDArray)
  85. {
  86. this.OpenFacilityUINextAdditionalParams(materialIDArray);
  87. });
  88. this.SetOKButtonEnable(this.IsOKButtonEnable());
  89. }
  90. public void OpenFacilityUIPreviousDefaultParams(int recipeID)
  91. {
  92. this.m_FacilityUIPreviousParams.Show(recipeID);
  93. this.SetOKButtonEnable(this.IsOKButtonEnable());
  94. }
  95. public void OpenFacilityUIPreviousAdditionalParams(int recipeID)
  96. {
  97. Facility selectingFacility = this.m_SelectingFacility;
  98. Facility.RecipeData recipeData = selectingFacility.GetRecipeData(recipeID);
  99. Facility.FacilityParameter parameter = Facility.RecipeData.CalcFacilityParameter(recipeData);
  100. this.m_FacilityUIPreviousParams.UpdateAdditionalParams(parameter);
  101. this.SetOKButtonEnable(this.IsOKButtonEnable());
  102. }
  103. public void OpenFacilityUINextDefaultParams(int recipeID)
  104. {
  105. this.m_FacilityUINextParams.Show(recipeID);
  106. this.SetOKButtonEnable(this.IsOKButtonEnable());
  107. }
  108. public void OpenFacilityUINextAdditionalParams(params int[] materialID)
  109. {
  110. Facility.FacilityParameter previous = new Facility.FacilityParameter();
  111. Facility.FacilityParameter next = new Facility.FacilityParameter();
  112. Facility.RecipeData recipeData = this.m_SelectingFacility.GetRecipeData(this.m_NowRecipeData.id);
  113. if (recipeData != null)
  114. {
  115. previous = Facility.RecipeData.CalcFacilityParameter(recipeData);
  116. }
  117. next = Facility.RecipeData.CalcFacilityParameter(materialID);
  118. this.m_FacilityUINextParams.UpdateAdditionalParamsComparison(previous, next);
  119. if (materialID != null && this.m_NowRecipeData != null)
  120. {
  121. this.m_NowRecipeData.materialIDArray = materialID;
  122. }
  123. this.SetOKButtonEnable(this.IsOKButtonEnable());
  124. }
  125. public void RefreshAllFacilityUI()
  126. {
  127. this.m_SelectingFacility = null;
  128. this.m_NowRecipeData = null;
  129. this.m_FacilityUIList.Show();
  130. this.m_FacilityUIPowerUpList.Hide();
  131. this.m_FacilityUIPowerUpMaterialList.DeleteDropdown();
  132. this.m_FacilityUIPreviousParams.ResetDefaultParam();
  133. this.m_FacilityUIPreviousParams.ResetAdditionalParam();
  134. this.m_FacilityUINextParams.ResetDefaultParam();
  135. this.m_FacilityUINextParams.ResetAdditionalParam();
  136. this.SetOKButtonEnable(this.IsOKButtonEnable());
  137. }
  138. public void ButtonEventOK()
  139. {
  140. if (!GameMain.Instance.SysDlg.IsDecided)
  141. {
  142. return;
  143. }
  144. uGUIUtility.SetActiveEventSystem(false);
  145. GameMain.Instance.SysDlg.Show(SceneFacilityManagement.GetDialogText("施設の強化を実行しますか?"), SystemDialog.TYPE.YES_NO, delegate
  146. {
  147. GameMain.Instance.SysDlg.Close();
  148. this.m_SelectingFacility.SetRecipeData(this.m_NowRecipeData);
  149. if (this.m_Maid != null && this.m_SelectingFacility != null && this.m_NowRecipeData != null)
  150. {
  151. GameMain.Instance.FacilityMgr.AddCacheFacilityPowewrUpResult(this.m_Maid, this.m_SelectingFacility, this.m_NowRecipeData);
  152. }
  153. int facilityAchievement = GameMain.Instance.FacilityMgr.GetFacilityAchievement<int>("施設強化回数");
  154. GameMain.Instance.FacilityMgr.SetFacilityAchievement("施設強化回数", (facilityAchievement + 1).ToString());
  155. uGUIUtility.SetActiveEventSystem(true);
  156. this.SceneClose(delegate
  157. {
  158. this.JumpLabel(this.m_strScriptLabelPowerUp);
  159. });
  160. }, delegate
  161. {
  162. GameMain.Instance.SysDlg.Close();
  163. uGUIUtility.SetActiveEventSystem(true);
  164. });
  165. }
  166. public void ButtonEventEXIT()
  167. {
  168. if (!GameMain.Instance.SysDlg.IsDecided)
  169. {
  170. return;
  171. }
  172. uGUIUtility.SetActiveEventSystem(false);
  173. GameMain.Instance.SysDlg.Show(SceneFacilityManagement.GetDialogText("施設の強化をせずに終了します。よろしいですか?"), SystemDialog.TYPE.YES_NO, delegate
  174. {
  175. GameMain.Instance.SysDlg.Close();
  176. uGUIUtility.SetActiveEventSystem(true);
  177. this.SceneClose(delegate
  178. {
  179. this.JumpLabel(this.m_strScriptLabelReturn);
  180. });
  181. }, delegate
  182. {
  183. GameMain.Instance.SysDlg.Close();
  184. uGUIUtility.SetActiveEventSystem(true);
  185. });
  186. }
  187. public void UpdateFacilityInfo(Facility facility)
  188. {
  189. if (!this.m_FacilityUIInfo.gameObject.activeSelf)
  190. {
  191. this.m_FacilityUIInfo.gameObject.SetActive(true);
  192. }
  193. this.m_FacilityUIInfo.SetFacilityInfo(facility, true);
  194. }
  195. private bool IsOKButtonEnable()
  196. {
  197. if (!this.m_SelectingFacility)
  198. {
  199. return false;
  200. }
  201. if (this.m_NowRecipeData == null)
  202. {
  203. return false;
  204. }
  205. FacilityDataTable.FacilityRecipeData facilityRecipeData = FacilityDataTable.GetFacilityRecipeData(this.m_NowRecipeData.id);
  206. if (!facilityRecipeData.IsSatisfyTheConditions())
  207. {
  208. return false;
  209. }
  210. foreach (int materialID in this.m_NowRecipeData.materialIDArray)
  211. {
  212. if (!GameMain.Instance.FacilityMgr.GetFacilityPowerUpItemEnable(materialID))
  213. {
  214. return false;
  215. }
  216. }
  217. return true;
  218. }
  219. private void SetOKButtonEnable(bool b)
  220. {
  221. this.m_ButtonOK.interactable = b;
  222. }
  223. private void GetTagBackup()
  224. {
  225. Dictionary<string, string> tag_backup = GameMain.Instance.ScriptMgr.adv_kag.tag_backup;
  226. string a;
  227. if (tag_backup != null && tag_backup.TryGetValue("name", out a) && a == "SceneFacilityPowerUp")
  228. {
  229. if (!tag_backup.TryGetValue("label", out this.m_strScriptLabelReturn))
  230. {
  231. Debug.LogWarning("[SceneFacilityPowerUp]戻り先ラベル「label」がありません");
  232. }
  233. if (!tag_backup.TryGetValue("label_power_up", out this.m_strScriptLabelPowerUp))
  234. {
  235. Debug.LogWarning("[SceneFacilityPowerUp]戻り先ラベル「label_power_up」が無い");
  236. }
  237. }
  238. }
  239. private void JumpLabel(string strLabel)
  240. {
  241. if (string.IsNullOrEmpty(strLabel))
  242. {
  243. Debug.LogWarning("[SceneFacilityPowerUp]スクリプトのジャンプ先ラベルが空でした");
  244. return;
  245. }
  246. ScriptManager scriptMgr = GameMain.Instance.ScriptMgr;
  247. scriptMgr.adv_kag.JumpLabel(strLabel);
  248. scriptMgr.adv_kag.Exec();
  249. }
  250. private void SceneClose(Action callback)
  251. {
  252. GameMain.Instance.MainCamera.FadeOut(0.5f, false, delegate
  253. {
  254. if (callback != null)
  255. {
  256. callback();
  257. }
  258. }, true, default(Color));
  259. }
  260. private void OnDestroy()
  261. {
  262. if (GameMain.Instance != null)
  263. {
  264. CameraMain mainCamera = GameMain.Instance.MainCamera;
  265. if (mainCamera != null)
  266. {
  267. mainCamera.SetControl(this.m_CachedMainCameraControlEnabled);
  268. }
  269. }
  270. }
  271. [SerializeField]
  272. private FacilityUIList m_FacilityUIList;
  273. [SerializeField]
  274. private FacilityUIPowerUpList m_FacilityUIPowerUpList;
  275. [SerializeField]
  276. private FacilityUIPowerUpMaterialList m_FacilityUIPowerUpMaterialList;
  277. [SerializeField]
  278. private FacilityUIPreviewParams m_FacilityUIPreviousParams;
  279. [SerializeField]
  280. private FacilityUIPreviewParams m_FacilityUINextParams;
  281. [SerializeField]
  282. private FacilityInfoUI m_FacilityUIInfo;
  283. [SerializeField]
  284. private Button m_ButtonOK;
  285. private Facility m_SelectingFacility;
  286. private Facility.RecipeData m_NowRecipeData;
  287. private Maid m_Maid;
  288. private bool m_CachedMainCameraControlEnabled = true;
  289. private string m_strScriptLabelReturn = string.Empty;
  290. private string m_strScriptLabelPowerUp = string.Empty;
  291. }