OnaholeNodeTouchMenuManager.cs 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202
  1. using System;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. public class OnaholeNodeTouchMenuManager : OnaholeBaseNodeMenuManager
  5. {
  6. public bool isOpen
  7. {
  8. get
  9. {
  10. return base.gameObject.activeSelf;
  11. }
  12. }
  13. private OnaholeNodeTouchMenuManager.UIMode uiMode
  14. {
  15. get
  16. {
  17. return (!this.menuButtonGrid.gameObject.activeSelf) ? OnaholeNodeTouchMenuManager.UIMode.Play : OnaholeNodeTouchMenuManager.UIMode.Menu;
  18. }
  19. set
  20. {
  21. if (value == OnaholeNodeTouchMenuManager.UIMode.Menu)
  22. {
  23. this.menuButtonGrid.gameObject.SetActive(true);
  24. this.playImageWidget.gameObject.SetActive(false);
  25. this.playImageWidget.alpha = 1f;
  26. }
  27. else
  28. {
  29. this.menuButtonGrid.gameObject.SetActive(false);
  30. this.playImageWidget.gameObject.SetActive(true);
  31. this.playImageWidget.alpha = 1f;
  32. }
  33. }
  34. }
  35. public void AddMenu(string menuText, Action<OnaholeNodeTouchMenuManager> onClickEvent)
  36. {
  37. GameObject gameObject = this.menuButtonGrid.gameObject;
  38. if (!this.onClickEventDic.ContainsKey(menuText))
  39. {
  40. this.menuButtons.Add(new NodeButtonData(OnaholeBaseNodeMenuManager.CreateBasicNodeButton(gameObject, menuText, menuText, true, false), new Action(this.OnClickStartToucMode)));
  41. this.onClickEventDic.Add(menuText, onClickEvent);
  42. }
  43. }
  44. public void ClearMenu()
  45. {
  46. foreach (NodeButtonData nodeButtonData in this.menuButtons)
  47. {
  48. UnityEngine.Object.DestroyImmediate(nodeButtonData.button.gameObject);
  49. }
  50. this.menuButtons.Clear();
  51. this.menuButtonGrid.Reposition();
  52. this.onClickEventDic.Clear();
  53. this.Close();
  54. }
  55. public void Open()
  56. {
  57. this.Close();
  58. if (this.menuButtons.Count == 0 || this.menuButtons[this.menuButtons.Count - 1].button.uniqueName != "close")
  59. {
  60. this.menuButtons.Add(new NodeButtonData(OnaholeBaseNodeMenuManager.CreateBasicNodeButton(this.menuButtonGrid.gameObject, "弄りモードを終了", "close", true, false), new Action(this.OnCancelMenu)));
  61. }
  62. this.changeInput = 1;
  63. base.SetFocusButton(this.menuButtons[0]);
  64. base.gameObject.SetActive(true);
  65. this.menuButtonGrid.Reposition();
  66. this.uiMode = OnaholeNodeTouchMenuManager.UIMode.Menu;
  67. GameMain.Instance.SoundMgr.PlaySystem(SoundMgr.SeType.Click);
  68. }
  69. public void Close()
  70. {
  71. this.reservCallMenu = false;
  72. this.isInputEnabled = false;
  73. this.changeInput = -1;
  74. base.gameObject.SetActive(false);
  75. }
  76. public void SelectMenu(string menuText)
  77. {
  78. this.Close();
  79. if (this.menuButtons.Count == 0)
  80. {
  81. return;
  82. }
  83. foreach (NodeButtonData nodeButtonData in this.menuButtons)
  84. {
  85. if (menuText == nodeButtonData.button.uniqueName)
  86. {
  87. this.changeInput = 1;
  88. base.gameObject.SetActive(true);
  89. base.SetFocusButton(nodeButtonData);
  90. this.OnClickStartToucMode();
  91. break;
  92. }
  93. }
  94. }
  95. public void ChangeMenuMode()
  96. {
  97. this.reservCallMenu = true;
  98. }
  99. private void OnClickStartToucMode()
  100. {
  101. if (base.selectedNodeButton == null)
  102. {
  103. return;
  104. }
  105. string uniqueName = base.selectedNodeButton.button.uniqueName;
  106. if (this.onClickEventDic.ContainsKey(uniqueName) && this.onClickEventDic[uniqueName] != null)
  107. {
  108. this.onClickEventDic[uniqueName](this);
  109. }
  110. this.uiMode = OnaholeNodeTouchMenuManager.UIMode.Play;
  111. }
  112. protected override void OnEnterMenu()
  113. {
  114. if (base.selectedNodeButton != null)
  115. {
  116. if (base.selectedNodeButton.button.uniqueName != "close")
  117. {
  118. base.OnEnterMenu();
  119. }
  120. base.selectedNodeButton.enterEvent();
  121. }
  122. }
  123. protected override void OnCancelMenu()
  124. {
  125. }
  126. protected override void Update()
  127. {
  128. if (this.uiMode == OnaholeNodeTouchMenuManager.UIMode.Menu)
  129. {
  130. if (base.inputDownKey)
  131. {
  132. base.NextItem();
  133. }
  134. else if (base.inputUpKey)
  135. {
  136. base.PrevItem();
  137. }
  138. else if (base.inputEnterKey || base.inputRightKye)
  139. {
  140. this.OnEnterMenu();
  141. }
  142. else if (base.inputCancelKey || base.inputLeftKey)
  143. {
  144. this.OnCancelMenu();
  145. }
  146. }
  147. else if (base.inputEnterKey)
  148. {
  149. GameMain.Instance.SoundMgr.PlaySystem(SoundMgr.SeType.Click);
  150. this.uiMode = OnaholeNodeTouchMenuManager.UIMode.Menu;
  151. }
  152. else if (base.inputCancelKey)
  153. {
  154. GameMain.Instance.SoundMgr.PlaySystem(SoundMgr.SeType.Click);
  155. this.playImageWidget.alpha = (float)((!Mathf.Approximately(1f, this.playImageWidget.alpha)) ? 1 : 0);
  156. }
  157. if (this.changeInput != -1)
  158. {
  159. this.isInputEnabled = (this.changeInput == 1);
  160. }
  161. this.changeInput = -1;
  162. if (this.reservCallMenu)
  163. {
  164. this.uiMode = OnaholeNodeTouchMenuManager.UIMode.Menu;
  165. GameMain.Instance.SoundMgr.PlaySystem(SoundMgr.SeType.Click);
  166. }
  167. this.reservCallMenu = false;
  168. }
  169. [SerializeField]
  170. private UIWidget playImageWidget;
  171. [SerializeField]
  172. [Header("夜伽から貰ってくるコンポーネント群")]
  173. private YotogiPlayManagerWithChubLip playManager;
  174. public Action onCallModeEnd;
  175. private int changeInput;
  176. private Dictionary<string, Action<OnaholeNodeTouchMenuManager>> onClickEventDic = new Dictionary<string, Action<OnaholeNodeTouchMenuManager>>();
  177. private bool reservCallMenu;
  178. public enum UIMode
  179. {
  180. Menu,
  181. Play
  182. }
  183. }