using System; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; public class FacilityPowerUpManager : MonoBehaviour { public Facility selectingFacility { get { return this.m_SelectingFacility; } set { this.m_SelectingFacility = value; } } private void Start() { this.SetUpBackGroundAndCamera(); this.GetTagBackup(); this.OpenFacilityUIList(); this.SetOKButtonEnable(this.IsOKButtonEnable()); CharacterMgr characterMgr = GameMain.Instance.CharacterMgr; Maid maid = null; if (characterMgr.GetMaidCount() > 0 && characterMgr.GetMaid(0)) { maid = characterMgr.GetMaid(0); } else { Debug.LogWarning("メイド0番の取得に失敗しました。"); } this.m_Maid = maid; for (int i = 0; i < characterMgr.GetMaidCount(); i++) { if (characterMgr.GetMaid(i) != null) { characterMgr.GetMaid(i).Visible = false; } } if (!uGUITutorialPanel.IsOpened()) { uGUITutorialPanel.OpenTutorial("SceneFacilityPowerUp", null, false); } } private void SetUpBackGroundAndCamera() { GameMain.Instance.BgMgr.ChangeBg("EmpireClub_Entrance"); GameMain.Instance.MainCamera.FadeIn(0.5f, false, null, true, true, default(Color)); CameraMain mainCamera = GameMain.Instance.MainCamera; GameMain.Instance.MainLight.Reset(); mainCamera.Reset(CameraMain.CameraType.Target, true); this.m_CachedMainCameraControlEnabled = mainCamera.GetControl(); mainCamera.SetControl(false); } public void OpenFacilityUIList() { this.m_FacilityUIList.Show(); this.SetOKButtonEnable(this.IsOKButtonEnable()); this.m_FacilityUIInfo.gameObject.SetActive(false); } public void OpenFacilityUIPowerUpList(Facility facility) { this.selectingFacility = facility; this.m_FacilityUIPowerUpList.Show(facility, delegate(Facility.PowerUpRecipe powerUpRecipe) { this.OpenFacilityUIMaterialList(powerUpRecipe.id); this.OpenFacilityUIPreviousDefaultParams(powerUpRecipe.id); this.OpenFacilityUINextDefaultParams(powerUpRecipe.id); this.OpenFacilityUIPreviousAdditionalParams(powerUpRecipe.id); }); this.m_NowRecipeData = null; this.m_FacilityUIPowerUpMaterialList.DeleteDropdown(); this.m_FacilityUIPreviousParams.ResetDefaultParam(); this.m_FacilityUIPreviousParams.ResetAdditionalParam(); this.m_FacilityUINextParams.ResetDefaultParam(); this.m_FacilityUINextParams.ResetAdditionalParam(); this.SetOKButtonEnable(this.IsOKButtonEnable()); } public void OpenFacilityUIMaterialList(int recipeID) { this.m_NowRecipeData = new Facility.RecipeData(recipeID); this.m_FacilityUIPowerUpMaterialList.Show(recipeID, this.selectingFacility, delegate(int[] materialIDArray) { this.OpenFacilityUINextAdditionalParams(materialIDArray); }); this.SetOKButtonEnable(this.IsOKButtonEnable()); } public void OpenFacilityUIPreviousDefaultParams(int recipeID) { this.m_FacilityUIPreviousParams.Show(recipeID); this.SetOKButtonEnable(this.IsOKButtonEnable()); } public void OpenFacilityUIPreviousAdditionalParams(int recipeID) { Facility selectingFacility = this.m_SelectingFacility; Facility.RecipeData recipeData = selectingFacility.GetRecipeData(recipeID); Facility.FacilityParameter parameter = Facility.RecipeData.CalcFacilityParameter(recipeData); this.m_FacilityUIPreviousParams.UpdateAdditionalParams(parameter); this.SetOKButtonEnable(this.IsOKButtonEnable()); } public void OpenFacilityUINextDefaultParams(int recipeID) { this.m_FacilityUINextParams.Show(recipeID); this.SetOKButtonEnable(this.IsOKButtonEnable()); } public void OpenFacilityUINextAdditionalParams(params int[] materialID) { Facility.FacilityParameter previous = new Facility.FacilityParameter(); Facility.FacilityParameter next = new Facility.FacilityParameter(); Facility.RecipeData recipeData = this.m_SelectingFacility.GetRecipeData(this.m_NowRecipeData.id); if (recipeData != null) { previous = Facility.RecipeData.CalcFacilityParameter(recipeData); } next = Facility.RecipeData.CalcFacilityParameter(materialID); this.m_FacilityUINextParams.UpdateAdditionalParamsComparison(previous, next); if (materialID != null && this.m_NowRecipeData != null) { this.m_NowRecipeData.materialIDArray = materialID; } this.SetOKButtonEnable(this.IsOKButtonEnable()); } public void RefreshAllFacilityUI() { this.m_SelectingFacility = null; this.m_NowRecipeData = null; this.m_FacilityUIList.Show(); this.m_FacilityUIPowerUpList.Hide(); this.m_FacilityUIPowerUpMaterialList.DeleteDropdown(); this.m_FacilityUIPreviousParams.ResetDefaultParam(); this.m_FacilityUIPreviousParams.ResetAdditionalParam(); this.m_FacilityUINextParams.ResetDefaultParam(); this.m_FacilityUINextParams.ResetAdditionalParam(); this.SetOKButtonEnable(this.IsOKButtonEnable()); } public void ButtonEventOK() { if (!GameMain.Instance.SysDlg.IsDecided) { return; } uGUIUtility.SetActiveEventSystem(false); GameMain.Instance.SysDlg.Show("施設の強化を実行しますか?", SystemDialog.TYPE.YES_NO, delegate { GameMain.Instance.SysDlg.Close(); this.m_SelectingFacility.SetRecipeData(this.m_NowRecipeData); if (this.m_Maid != null && this.m_SelectingFacility != null && this.m_NowRecipeData != null) { GameMain.Instance.FacilityMgr.AddCacheFacilityPowewrUpResult(this.m_Maid, this.m_SelectingFacility, this.m_NowRecipeData); } int facilityAchievement = GameMain.Instance.FacilityMgr.GetFacilityAchievement("施設強化回数"); GameMain.Instance.FacilityMgr.SetFacilityAchievement("施設強化回数", (facilityAchievement + 1).ToString()); uGUIUtility.SetActiveEventSystem(true); this.SceneClose(delegate { this.JumpLabel(this.m_strScriptLabelPowerUp); }); }, delegate { GameMain.Instance.SysDlg.Close(); uGUIUtility.SetActiveEventSystem(true); }); } public void ButtonEventEXIT() { if (!GameMain.Instance.SysDlg.IsDecided) { return; } uGUIUtility.SetActiveEventSystem(false); GameMain.Instance.SysDlg.Show("施設の強化をせずに終了します。\nよろしいですか?", SystemDialog.TYPE.YES_NO, delegate { GameMain.Instance.SysDlg.Close(); uGUIUtility.SetActiveEventSystem(true); this.SceneClose(delegate { this.JumpLabel(this.m_strScriptLabelReturn); }); }, delegate { GameMain.Instance.SysDlg.Close(); uGUIUtility.SetActiveEventSystem(true); }); } public void UpdateFacilityInfo(Facility facility) { if (!this.m_FacilityUIInfo.gameObject.activeSelf) { this.m_FacilityUIInfo.gameObject.SetActive(true); } this.m_FacilityUIInfo.SetFacilityInfo(facility, true); } private bool IsOKButtonEnable() { if (!this.m_SelectingFacility) { return false; } if (this.m_NowRecipeData == null) { return false; } FacilityDataTable.FacilityRecipeData facilityRecipeData = FacilityDataTable.GetFacilityRecipeData(this.m_NowRecipeData.id); if (!facilityRecipeData.IsSatisfyTheConditions()) { return false; } foreach (int materialID in this.m_NowRecipeData.materialIDArray) { if (!GameMain.Instance.FacilityMgr.GetFacilityPowerUpItemEnable(materialID)) { return false; } } return true; } private void SetOKButtonEnable(bool b) { this.m_ButtonOK.interactable = b; } private void GetTagBackup() { Dictionary tag_backup = GameMain.Instance.ScriptMgr.adv_kag.tag_backup; string a; if (tag_backup != null && tag_backup.TryGetValue("name", out a) && a == "SceneFacilityPowerUp") { if (!tag_backup.TryGetValue("label", out this.m_strScriptLabelReturn)) { Debug.LogWarning("[SceneFacilityPowerUp]戻り先ラベル「label」がありません"); } if (!tag_backup.TryGetValue("label_power_up", out this.m_strScriptLabelPowerUp)) { Debug.LogWarning("[SceneFacilityPowerUp]戻り先ラベル「label_power_up」が無い"); } } } private void JumpLabel(string strLabel) { if (string.IsNullOrEmpty(strLabel)) { Debug.LogWarning("[SceneFacilityPowerUp]スクリプトのジャンプ先ラベルが空でした"); return; } ScriptManager scriptMgr = GameMain.Instance.ScriptMgr; scriptMgr.adv_kag.JumpLabel(strLabel); scriptMgr.adv_kag.Exec(); } private void SceneClose(Action callback) { GameMain.Instance.MainCamera.FadeOut(0.5f, false, delegate { if (callback != null) { callback(); } }, true, default(Color)); } private void OnDestroy() { if (GameMain.Instance != null) { CameraMain mainCamera = GameMain.Instance.MainCamera; if (mainCamera != null) { mainCamera.SetControl(this.m_CachedMainCameraControlEnabled); } } } [SerializeField] private FacilityUIList m_FacilityUIList; [SerializeField] private FacilityUIPowerUpList m_FacilityUIPowerUpList; [SerializeField] private FacilityUIPowerUpMaterialList m_FacilityUIPowerUpMaterialList; [SerializeField] private FacilityUIPreviewParams m_FacilityUIPreviousParams; [SerializeField] private FacilityUIPreviewParams m_FacilityUINextParams; [SerializeField] private FacilityInfoUI m_FacilityUIInfo; [SerializeField] private Button m_ButtonOK; private Facility m_SelectingFacility; private Facility.RecipeData m_NowRecipeData; private Maid m_Maid; private bool m_CachedMainCameraControlEnabled = true; private string m_strScriptLabelReturn = string.Empty; private string m_strScriptLabelPowerUp = string.Empty; }