OnaholeBaseNodeMenuManager.cs 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390
  1. using System;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using wf;
  5. public class OnaholeBaseNodeMenuManager : MonoBehaviour
  6. {
  7. public static OnaholeNodeButton CreateBasicNodeButton(GameObject parent, string text, string uniqueName, bool sizeSmall, bool drawNextMark)
  8. {
  9. GameObject gameObject = Utility.CreatePrefab(parent, "SceneYotogi/CBL/BasicNodeMenu", true);
  10. OnaholeNodeButton component = gameObject.GetComponent<OnaholeNodeButton>();
  11. component.selectType = OnaholeNodeButton.SelectType.None;
  12. component.text = text;
  13. component.uniqueName = uniqueName;
  14. component.visibleNextMarker = drawNextMark;
  15. component.sizeModeBig = !sizeSmall;
  16. return component;
  17. }
  18. public static OnaholeNodeSlider CreateNodeSlider(GameObject parent, OnaholeNodeSlider.SliderType type, string uniqueName)
  19. {
  20. GameObject gameObject = Utility.CreatePrefab(parent, "SceneYotogi/CBL/NodeSliderMenu", true);
  21. OnaholeNodeSlider component = gameObject.GetComponent<OnaholeNodeSlider>();
  22. component.selectType = OnaholeNodeButton.SelectType.None;
  23. component.uniqueName = uniqueName;
  24. component.SetSliderType(type);
  25. return component;
  26. }
  27. public OnaholeNodeIconButton CreateNodeIconMenu(GameObject parent, string uniqueName)
  28. {
  29. GameObject gameObject = Utility.CreatePrefab(parent, "SceneYotogi/CBL/NodeIconMenu", true);
  30. OnaholeNodeIconButton component = gameObject.GetComponent<OnaholeNodeIconButton>();
  31. component.selectType = OnaholeNodeButton.SelectType.None;
  32. component.uniqueName = uniqueName;
  33. return component;
  34. }
  35. public bool inputUpKey
  36. {
  37. get
  38. {
  39. return this.isInputEnabled && base.gameObject.activeInHierarchy && YotogiManager.instans.inputCBLUpKey;
  40. }
  41. }
  42. public bool inputDownKey
  43. {
  44. get
  45. {
  46. return this.isInputEnabled && base.gameObject.activeInHierarchy && YotogiManager.instans.inputCBLDownKey;
  47. }
  48. }
  49. public bool inputRightKye
  50. {
  51. get
  52. {
  53. return this.isInputEnabled && base.gameObject.activeInHierarchy && YotogiManager.instans.inputCBLRightKey;
  54. }
  55. }
  56. public bool inputLeftKey
  57. {
  58. get
  59. {
  60. return this.isInputEnabled && base.gameObject.activeInHierarchy && YotogiManager.instans.inputCBLLeftKey;
  61. }
  62. }
  63. public bool inputEnterKey
  64. {
  65. get
  66. {
  67. return this.isInputEnabled && base.gameObject.activeInHierarchy && YotogiManager.instans.inputCBLCancelKey;
  68. }
  69. }
  70. public bool inputCancelKey
  71. {
  72. get
  73. {
  74. return this.isInputEnabled && base.gameObject.activeInHierarchy && YotogiManager.instans.inputCBLEnterKey;
  75. }
  76. }
  77. public NodeButtonData selectedNodeButton
  78. {
  79. get
  80. {
  81. foreach (NodeButtonData nodeButtonData in this.menuButtons)
  82. {
  83. if (nodeButtonData.selectType == OnaholeNodeButton.SelectType.Select || nodeButtonData.selectType == OnaholeNodeButton.SelectType.Focus)
  84. {
  85. return nodeButtonData;
  86. }
  87. }
  88. return null;
  89. }
  90. }
  91. public void NextItem()
  92. {
  93. List<NodeButtonData> list = this.menuButtons;
  94. if (this.operationMap != null && 0 < this.operationMap.Count)
  95. {
  96. foreach (List<NodeButtonData> list2 in this.operationMap)
  97. {
  98. foreach (NodeButtonData nodeButtonData in list2)
  99. {
  100. if (nodeButtonData.selectType == OnaholeNodeButton.SelectType.Select || nodeButtonData.selectType == OnaholeNodeButton.SelectType.Focus)
  101. {
  102. list = list2;
  103. break;
  104. }
  105. }
  106. }
  107. }
  108. NodeButtonData nodeButtonData2 = null;
  109. for (int i = 0; i < list.Count; i++)
  110. {
  111. if (list[i].selectType == OnaholeNodeButton.SelectType.Select || list[i].selectType == OnaholeNodeButton.SelectType.Focus)
  112. {
  113. nodeButtonData2 = list[i];
  114. int num = i;
  115. for (;;)
  116. {
  117. num++;
  118. if (list.Count <= num)
  119. {
  120. num = -1;
  121. }
  122. else if (list[num].selectType != OnaholeNodeButton.SelectType.Disable)
  123. {
  124. break;
  125. }
  126. }
  127. nodeButtonData2 = list[num];
  128. break;
  129. }
  130. }
  131. if (nodeButtonData2 != null)
  132. {
  133. this.SetFocusButton(nodeButtonData2);
  134. GameMain.Instance.SoundMgr.PlaySystem(SoundMgr.SeType.Hover);
  135. }
  136. }
  137. public void PrevItem()
  138. {
  139. List<NodeButtonData> list = this.menuButtons;
  140. if (this.operationMap != null && 0 < this.operationMap.Count)
  141. {
  142. foreach (List<NodeButtonData> list2 in this.operationMap)
  143. {
  144. foreach (NodeButtonData nodeButtonData in list2)
  145. {
  146. if (nodeButtonData.selectType == OnaholeNodeButton.SelectType.Select || nodeButtonData.selectType == OnaholeNodeButton.SelectType.Focus)
  147. {
  148. list = list2;
  149. break;
  150. }
  151. }
  152. }
  153. }
  154. NodeButtonData nodeButtonData2 = null;
  155. for (int i = 0; i < list.Count; i++)
  156. {
  157. if (list[i].selectType == OnaholeNodeButton.SelectType.Select || list[i].selectType == OnaholeNodeButton.SelectType.Focus)
  158. {
  159. nodeButtonData2 = list[i];
  160. int num = i;
  161. for (;;)
  162. {
  163. num--;
  164. if (num < 0)
  165. {
  166. num = list.Count;
  167. }
  168. else if (list[num].selectType != OnaholeNodeButton.SelectType.Disable)
  169. {
  170. break;
  171. }
  172. }
  173. nodeButtonData2 = list[num];
  174. break;
  175. }
  176. }
  177. if (nodeButtonData2 != null)
  178. {
  179. this.SetFocusButton(nodeButtonData2);
  180. GameMain.Instance.SoundMgr.PlaySystem(SoundMgr.SeType.Hover);
  181. }
  182. }
  183. public void RightItem()
  184. {
  185. if (this.operationMap == null || this.operationMap.Count <= 1)
  186. {
  187. return;
  188. }
  189. List<NodeButtonData> list = null;
  190. for (int i = 0; i < this.operationMap.Count; i++)
  191. {
  192. for (int j = 0; j < this.operationMap[i].Count; j++)
  193. {
  194. NodeButtonData nodeButtonData = this.operationMap[i][j];
  195. if (nodeButtonData.selectType == OnaholeNodeButton.SelectType.Select || nodeButtonData.selectType == OnaholeNodeButton.SelectType.Focus)
  196. {
  197. list = new List<NodeButtonData>();
  198. for (int k = 0; k < this.operationMap.Count; k++)
  199. {
  200. list.Add(this.operationMap[k][j]);
  201. }
  202. break;
  203. }
  204. }
  205. if (list != null)
  206. {
  207. break;
  208. }
  209. }
  210. if (list == null)
  211. {
  212. return;
  213. }
  214. NodeButtonData nodeButtonData2 = null;
  215. for (int l = 0; l < list.Count; l++)
  216. {
  217. if (list[l].selectType == OnaholeNodeButton.SelectType.Select || list[l].selectType == OnaholeNodeButton.SelectType.Focus)
  218. {
  219. nodeButtonData2 = list[l];
  220. int num = l;
  221. for (;;)
  222. {
  223. num++;
  224. if (list.Count <= num)
  225. {
  226. num = -1;
  227. }
  228. else if (list[num].selectType != OnaholeNodeButton.SelectType.Disable)
  229. {
  230. break;
  231. }
  232. }
  233. nodeButtonData2 = list[num];
  234. break;
  235. }
  236. }
  237. if (nodeButtonData2 != null)
  238. {
  239. this.SetFocusButton(nodeButtonData2);
  240. GameMain.Instance.SoundMgr.PlaySystem(SoundMgr.SeType.Hover);
  241. }
  242. }
  243. public void LeftItem()
  244. {
  245. if (this.operationMap == null || this.operationMap.Count <= 1)
  246. {
  247. return;
  248. }
  249. List<NodeButtonData> list = null;
  250. for (int i = 0; i < this.operationMap.Count; i++)
  251. {
  252. for (int j = 0; j < this.operationMap[i].Count; j++)
  253. {
  254. NodeButtonData nodeButtonData = this.operationMap[i][j];
  255. if (nodeButtonData.selectType == OnaholeNodeButton.SelectType.Select || nodeButtonData.selectType == OnaholeNodeButton.SelectType.Focus)
  256. {
  257. list = new List<NodeButtonData>();
  258. for (int k = 0; k < this.operationMap.Count; k++)
  259. {
  260. list.Add(this.operationMap[k][j]);
  261. }
  262. break;
  263. }
  264. }
  265. if (list != null)
  266. {
  267. break;
  268. }
  269. }
  270. if (list == null)
  271. {
  272. return;
  273. }
  274. NodeButtonData nodeButtonData2 = null;
  275. for (int l = 0; l < list.Count; l++)
  276. {
  277. if (list[l].selectType == OnaholeNodeButton.SelectType.Select || list[l].selectType == OnaholeNodeButton.SelectType.Focus)
  278. {
  279. nodeButtonData2 = list[l];
  280. int num = l;
  281. for (;;)
  282. {
  283. num--;
  284. if (num < 0)
  285. {
  286. num = list.Count;
  287. }
  288. else if (list[num].selectType != OnaholeNodeButton.SelectType.Disable)
  289. {
  290. break;
  291. }
  292. }
  293. nodeButtonData2 = list[num];
  294. break;
  295. }
  296. }
  297. if (nodeButtonData2 != null)
  298. {
  299. this.SetFocusButton(nodeButtonData2);
  300. GameMain.Instance.SoundMgr.PlaySystem(SoundMgr.SeType.Hover);
  301. }
  302. }
  303. protected virtual void OnEnterMenu()
  304. {
  305. GameMain.Instance.SoundMgr.PlaySystem(SoundMgr.SeType.Click);
  306. }
  307. protected virtual void OnCancelMenu()
  308. {
  309. GameMain.Instance.SoundMgr.PlaySystem(SoundMgr.SeType.Click);
  310. }
  311. protected virtual void Update()
  312. {
  313. if (this.inputDownKey)
  314. {
  315. this.NextItem();
  316. }
  317. else if (this.inputUpKey)
  318. {
  319. this.PrevItem();
  320. }
  321. }
  322. protected NodeButtonData GetNodeButtonData(string uniquName)
  323. {
  324. foreach (NodeButtonData nodeButtonData in this.menuButtons)
  325. {
  326. if (nodeButtonData.button.uniqueName == uniquName)
  327. {
  328. return nodeButtonData;
  329. }
  330. }
  331. return null;
  332. }
  333. protected void SetFocusButton(NodeButtonData buttonData)
  334. {
  335. if (buttonData == null)
  336. {
  337. return;
  338. }
  339. foreach (NodeButtonData nodeButtonData in this.menuButtons)
  340. {
  341. if (nodeButtonData.button.selectType != OnaholeNodeButton.SelectType.Disable)
  342. {
  343. nodeButtonData.button.selectType = ((buttonData.button != nodeButtonData.button) ? OnaholeNodeButton.SelectType.None : OnaholeNodeButton.SelectType.Focus);
  344. }
  345. }
  346. }
  347. protected void SetSelectedButton(NodeButtonData buttonData)
  348. {
  349. if (buttonData == null)
  350. {
  351. return;
  352. }
  353. foreach (NodeButtonData nodeButtonData in this.menuButtons)
  354. {
  355. if (nodeButtonData.button.selectType != OnaholeNodeButton.SelectType.Disable)
  356. {
  357. nodeButtonData.button.selectType = ((buttonData.button != nodeButtonData.button) ? OnaholeNodeButton.SelectType.None : OnaholeNodeButton.SelectType.Select);
  358. }
  359. }
  360. }
  361. [SerializeField]
  362. protected UIGrid menuButtonGrid;
  363. protected List<NodeButtonData> menuButtons = new List<NodeButtonData>();
  364. protected List<List<NodeButtonData>> operationMap = new List<List<NodeButtonData>>();
  365. public bool isInputEnabled;
  366. }