using System; using UnityEngine; namespace scoutmode { public class ScoutMainScreenManager : WfScreenChildren { public new SceneScoutScreenManager parent_mgr { get { return base.parent_mgr as SceneScoutScreenManager; } } public ScoutMaidData scoutingMaidData { get; private set; } public ScoutMaidData selectedScoutMaid { get; private set; } public string SelectedStageName { get { return this.progressInformation.SelectStage.ToString(); } } private ScoutManager Manager { get { return ScoutManager.Instance; } } public override void Awake() { base.Awake(); if (this.menus != null) { ScoutMainScreenManager.MenuButton[] array = this.menus; for (int i = 0; i < array.Length; i++) { ScoutMainScreenManager.MenuButton menu = array[i]; ScoutMainScreenManager $this = this; if (menu.button != null) { EventDelegate.Add(menu.button.onClick, delegate() { $this.OnClickMenuButton(menu.type); }); } } } } protected override void OnCall() { GameMain.Instance.MainLight.Reset(); GameMain.Instance.CharacterMgr.ResetCharaPosAll(); GameMain.Instance.MainCamera.Reset(CameraMain.CameraType.Target, true); GameMain.Instance.CharacterMgr.DeactivateCharaAll(); GameMain.Instance.CharacterMgr.Deactivate(0, false); GameMain.Instance.SoundMgr.PlayBGM("BGM015.ogg", 1f, true); GameMain.Instance.BgMgr.ChangeBg((!GameMain.Instance.CharacterMgr.status.isDaytime) ? "ShinShitsumu_ChairRot_Night" : "ShinShitsumu_ChairRot"); this.showStatusPanel = false; this.OnSelectedScoutMaid(null); this.scoutCharaSelect.callbackGetScoutMaidList = (() => this.Manager.scoutMaidList); this.scoutCharaSelect.callbackSelectItem = new Action(this.OnSelectedScoutMaid); this.scoutCharaSelect.SetData(); this.progressInformation.SetStage((!GameMain.Instance.CharacterMgr.status.isDaytime) ? ScoutProgressInformation.Stage.Club : ScoutProgressInformation.Stage.ShoppingMall); foreach (ScoutMaidData scoutMaidData in this.Manager.scoutMaidList) { if (scoutMaidData.instanceData.enabled && scoutMaidData.instanceData.stageName == this.SelectedStageName) { this.scoutingMaidData = scoutMaidData; break; } } this.UpdateProgressInfoCharacter(); ScoutOption scoutOption = this.scoutOption; scoutOption.onChangeValue = (Action)Delegate.Combine(scoutOption.onChangeValue, new Action(delegate(ScoutOption.SettingType type, string value) { if (type == ScoutOption.SettingType.BaseChara) { this.UpdateProgressInfoCharacter(); } })); foreach (ScoutMainScreenManager.MenuButton menuButton in this.menus) { if (menuButton.type == ScoutMainScreenManager.ButtonType.Cancel) { menuButton.button.transform.parent.gameObject.SetActive(false); break; } } uGUITutorialPanel.OpenTutorial("SceneScout", null, false); GameMain.Instance.SysShortcut.strSceneHelpName = "SceneScout"; } public void OnClickMenuButton(ScoutMainScreenManager.ButtonType type) { Debug.Log(type.ToString()); if (type == ScoutMainScreenManager.ButtonType.AddScoutMaid) { this.AddScoutMaid(); } else if (type == ScoutMainScreenManager.ButtonType.DeleteScoutMaid) { this.DeleteScoutMaid(this.scoutCharaSelect.selectedMaidData); } else if (type == ScoutMainScreenManager.ButtonType.Start) { this.StartScout(); } else if (type == ScoutMainScreenManager.ButtonType.ShowStatus) { this.showStatusPanel = !this.showStatusPanel; this.UpdateShowPanels(); } else if (type == ScoutMainScreenManager.ButtonType.Exist) { this.parent_mgr.CallExist(this); } else if (type == ScoutMainScreenManager.ButtonType.Cancel) { this.Manager.CancelScout(this.scoutingMaidData); this.scoutingMaidData = null; this.UpdateProgressInfoCharacter(); this.UpdateShowPanels(); } } private bool StartScout() { ScoutMaidData callScoutMaid = null; if (this.scoutingMaidData == null) { callScoutMaid = this.selectedScoutMaid; if (!ScoutManager.Instance.options.baseCharaSelect) { callScoutMaid = this.Manager.GetRandomWaitingScoutmaid(); } else if (callScoutMaid != null && callScoutMaid.instanceData.enabled) { GameMain.Instance.SysDlg.Show("指定キャラクターは既にスカウト中のため開始できません", SystemDialog.TYPE.OK, null, null); return false; } if (callScoutMaid == null) { GameMain.Instance.SysDlg.Show("新たにスカウトを開始するメイドが存在しません", SystemDialog.TYPE.OK, null, null); return false; } this.Manager.CreateRandomScoutMaidData(callScoutMaid, ScoutManager.Instance.options); } else { foreach (ScoutMaidData scoutMaidData in this.Manager.scoutMaidList) { if (scoutMaidData.instanceData.enabled && scoutMaidData.instanceData.stageName == this.SelectedStageName) { callScoutMaid = scoutMaidData; break; } } } if (callScoutMaid == null) { return false; } this.onFinishEvent = delegate() { this.Manager.StartScout(this.Manager.ActiveScoutMaid(callScoutMaid, 0), this.SelectedStageName, ScoutManager.Instance.options); this.progressInformation.ChangeBg(this.progressInformation.SelectStage); }; this.parent_mgr.CallStart(this); return true; } private void AddScoutMaid() { this.onFinishEvent = delegate() { Maid maid = GameMain.Instance.CharacterMgr.AddStockMaid(); maid.Visible = true; GameMain.Instance.CharacterMgr.SetActiveMaid(maid, 0); }; this.parent_mgr.CallAddScoutCharacter(this); } private void DeleteScoutMaid(ScoutMaidData scoutMaid) { if (scoutMaid == null) { return; } if (scoutMaid.instanceData.enabled) { GameMain.Instance.SysDlg.Show("スカウト中のため削除できません", SystemDialog.TYPE.OK, null, null); return; } this.Manager.RemoveScoutMaid(scoutMaid); this.scoutCharaSelect.DeleteItem(scoutMaid); if (this.scoutCharaSelect.selectedMaidData == null) { this.OnSelectedScoutMaid(null); } } public void OnSelectedScoutMaid(ScoutMaidData scoutMaid) { foreach (ScoutMainScreenManager.MenuButton menuButton in this.menus) { if (!(menuButton.button == null) && ScoutMainScreenManager.ButtonType.Start > menuButton.type) { if (menuButton.type == ScoutMainScreenManager.ButtonType.DeleteScoutMaid || menuButton.type == ScoutMainScreenManager.ButtonType.ShowStatus) { menuButton.button.isEnabled = (scoutMaid != null); } } } if (scoutMaid != null) { this.scoutCharaSelect.bigThumbnail.SetFile(new string[] { ScoutMaidData.GetThumbnailFilePath(scoutMaid.status.guid, true), ScoutMaidData.GetThumbnailFilePath(scoutMaid.status.guid, false) }); } else { this.scoutCharaSelect.bigThumbnail.SetFile(null); } this.selectedScoutMaid = scoutMaid; this.UpdateProgressInfoCharacter(); this.UpdateShowPanels(); } public void OnAddedScoutMaidReturned() { Maid maid = GameMain.Instance.CharacterMgr.GetMaid(0); this.Manager.AddScoutMaid(maid); GameMain.Instance.CharacterMgr.BanishmentMaid(maid); } private void UpdateShowPanels() { this.scoutCharaSelect.bigThumbnail.Visible = (!this.showStatusPanel && this.selectedScoutMaid != null); this.statusPanel.visible = (this.showStatusPanel && this.selectedScoutMaid != null); if (this.statusPanel.visible) { this.statusPanel.SetDrawStatus(this.selectedScoutMaid); } } private void UpdateProgressInfoCharacter() { bool isEnabled = false; if (this.scoutingMaidData != null) { this.progressInformation.SetCharacter(this.scoutingMaidData, true); isEnabled = true; } else if (this.Manager.options.baseCharaSelect) { this.progressInformation.SetCharacter(this.selectedScoutMaid, false); isEnabled = (this.selectedScoutMaid != null); } else if (this.Manager.GetRandomWaitingScoutmaid() != null) { this.progressInformation.SetCharacterRandom(); isEnabled = true; } else { this.progressInformation.SetCharacter(null, false); } foreach (ScoutMainScreenManager.MenuButton menuButton in this.menus) { if (menuButton.type == ScoutMainScreenManager.ButtonType.Start) { menuButton.button.isEnabled = isEnabled; break; } } } protected override void OnFinish() { if (this.onFinishEvent != null) { this.onFinishEvent(); } this.parent_mgr.CallScreen("Move"); } [SerializeField] private ScoutMainScreenManager.MenuButton[] menus; [SerializeField] private ScoutCharacterSelectCtrl scoutCharaSelect; [SerializeField] private ScoutOption scoutOption; [SerializeField] private ScoutProgressInformation progressInformation; [SerializeField] private ScoutStatusPanel statusPanel; private Action onFinishEvent; private bool showStatusPanel; public enum ButtonType { AddScoutMaid = 10, DeleteScoutMaid = 20, ShowStatus = 30, Start = 100, Exist = 110, Cancel = 120 } [Serializable] private struct MenuButton { public ScoutMainScreenManager.ButtonType type; public UIButton button; } } }