using System; using System.Collections.Generic; using UnityEngine; public class OnaholeNodeTouchMenuManager : OnaholeBaseNodeMenuManager { public bool isOpen { get { return base.gameObject.activeSelf; } } private OnaholeNodeTouchMenuManager.UIMode uiMode { get { return (!this.menuButtonGrid.gameObject.activeSelf) ? OnaholeNodeTouchMenuManager.UIMode.Play : OnaholeNodeTouchMenuManager.UIMode.Menu; } set { if (value == OnaholeNodeTouchMenuManager.UIMode.Menu) { this.menuButtonGrid.gameObject.SetActive(true); this.playImageWidget.gameObject.SetActive(false); this.playImageWidget.alpha = 1f; } else { this.menuButtonGrid.gameObject.SetActive(false); this.playImageWidget.gameObject.SetActive(true); this.playImageWidget.alpha = 1f; } } } public void AddMenu(string menuText, Action onClickEvent) { GameObject gameObject = this.menuButtonGrid.gameObject; if (!this.onClickEventDic.ContainsKey(menuText)) { this.menuButtons.Add(new NodeButtonData(OnaholeBaseNodeMenuManager.CreateBasicNodeButton(gameObject, menuText, menuText, true, false), new Action(this.OnClickStartToucMode))); this.onClickEventDic.Add(menuText, onClickEvent); } } public void ClearMenu() { foreach (NodeButtonData nodeButtonData in this.menuButtons) { UnityEngine.Object.DestroyImmediate(nodeButtonData.button.gameObject); } this.menuButtons.Clear(); this.menuButtonGrid.Reposition(); this.onClickEventDic.Clear(); this.Close(); } public void Open() { this.Close(); if (this.menuButtons.Count == 0 || this.menuButtons[this.menuButtons.Count - 1].button.uniqueName != "close") { this.menuButtons.Add(new NodeButtonData(OnaholeBaseNodeMenuManager.CreateBasicNodeButton(this.menuButtonGrid.gameObject, "弄りモードを終了", "close", true, false), new Action(this.OnCancelMenu))); } this.changeInput = 1; base.SetFocusButton(this.menuButtons[0]); base.gameObject.SetActive(true); this.menuButtonGrid.Reposition(); this.uiMode = OnaholeNodeTouchMenuManager.UIMode.Menu; GameMain.Instance.SoundMgr.PlaySystem(SoundMgr.SeType.Click); } public void Close() { this.reservCallMenu = false; this.isInputEnabled = false; this.changeInput = -1; base.gameObject.SetActive(false); } public void SelectMenu(string menuText) { this.Close(); if (this.menuButtons.Count == 0) { return; } foreach (NodeButtonData nodeButtonData in this.menuButtons) { if (menuText == nodeButtonData.button.uniqueName) { this.changeInput = 1; base.gameObject.SetActive(true); base.SetFocusButton(nodeButtonData); this.OnClickStartToucMode(); break; } } } public void ChangeMenuMode() { this.reservCallMenu = true; } private void OnClickStartToucMode() { if (base.selectedNodeButton == null) { return; } string uniqueName = base.selectedNodeButton.button.uniqueName; if (this.onClickEventDic.ContainsKey(uniqueName) && this.onClickEventDic[uniqueName] != null) { this.onClickEventDic[uniqueName](this); } this.uiMode = OnaholeNodeTouchMenuManager.UIMode.Play; } protected override void OnEnterMenu() { if (base.selectedNodeButton != null) { if (base.selectedNodeButton.button.uniqueName != "close") { base.OnEnterMenu(); } base.selectedNodeButton.enterEvent(); } } protected override void OnCancelMenu() { } protected override void Update() { if (this.uiMode == OnaholeNodeTouchMenuManager.UIMode.Menu) { if (base.inputDownKey) { base.NextItem(); } else if (base.inputUpKey) { base.PrevItem(); } else if (base.inputEnterKey || base.inputRightKye) { this.OnEnterMenu(); } else if (base.inputCancelKey || base.inputLeftKey) { this.OnCancelMenu(); } } else if (base.inputEnterKey) { GameMain.Instance.SoundMgr.PlaySystem(SoundMgr.SeType.Click); this.uiMode = OnaholeNodeTouchMenuManager.UIMode.Menu; } else if (base.inputCancelKey) { GameMain.Instance.SoundMgr.PlaySystem(SoundMgr.SeType.Click); this.playImageWidget.alpha = (float)((!Mathf.Approximately(1f, this.playImageWidget.alpha)) ? 1 : 0); } if (this.changeInput != -1) { this.isInputEnabled = (this.changeInput == 1); } this.changeInput = -1; if (this.reservCallMenu) { this.uiMode = OnaholeNodeTouchMenuManager.UIMode.Menu; GameMain.Instance.SoundMgr.PlaySystem(SoundMgr.SeType.Click); } this.reservCallMenu = false; } [SerializeField] private UIWidget playImageWidget; [SerializeField] [Header("夜伽から貰ってくるコンポーネント群")] private YotogiPlayManagerWithChubLip playManager; public Action onCallModeEnd; private int changeInput; private Dictionary> onClickEventDic = new Dictionary>(); private bool reservCallMenu; public enum UIMode { Menu, Play } }