123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202 |
- 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<OnaholeNodeTouchMenuManager> 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<string, Action<OnaholeNodeTouchMenuManager>> onClickEventDic = new Dictionary<string, Action<OnaholeNodeTouchMenuManager>>();
- private bool reservCallMenu;
- public enum UIMode
- {
- Menu,
- Play
- }
- }
|