123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390 |
- using System;
- using System.Collections.Generic;
- using UnityEngine;
- using wf;
- public class OnaholeBaseNodeMenuManager : MonoBehaviour
- {
- public static OnaholeNodeButton CreateBasicNodeButton(GameObject parent, string text, string uniqueName, bool sizeSmall, bool drawNextMark)
- {
- GameObject gameObject = Utility.CreatePrefab(parent, "SceneYotogi/CBL/BasicNodeMenu", true);
- OnaholeNodeButton component = gameObject.GetComponent<OnaholeNodeButton>();
- component.selectType = OnaholeNodeButton.SelectType.None;
- component.text = text;
- component.uniqueName = uniqueName;
- component.visibleNextMarker = drawNextMark;
- component.sizeModeBig = !sizeSmall;
- return component;
- }
- public static OnaholeNodeSlider CreateNodeSlider(GameObject parent, OnaholeNodeSlider.SliderType type, string uniqueName)
- {
- GameObject gameObject = Utility.CreatePrefab(parent, "SceneYotogi/CBL/NodeSliderMenu", true);
- OnaholeNodeSlider component = gameObject.GetComponent<OnaholeNodeSlider>();
- component.selectType = OnaholeNodeButton.SelectType.None;
- component.uniqueName = uniqueName;
- component.SetSliderType(type);
- return component;
- }
- public OnaholeNodeIconButton CreateNodeIconMenu(GameObject parent, string uniqueName)
- {
- GameObject gameObject = Utility.CreatePrefab(parent, "SceneYotogi/CBL/NodeIconMenu", true);
- OnaholeNodeIconButton component = gameObject.GetComponent<OnaholeNodeIconButton>();
- component.selectType = OnaholeNodeButton.SelectType.None;
- component.uniqueName = uniqueName;
- return component;
- }
- public bool inputUpKey
- {
- get
- {
- return this.isInputEnabled && base.gameObject.activeInHierarchy && YotogiManager.instans.inputCBLUpKey;
- }
- }
- public bool inputDownKey
- {
- get
- {
- return this.isInputEnabled && base.gameObject.activeInHierarchy && YotogiManager.instans.inputCBLDownKey;
- }
- }
- public bool inputRightKye
- {
- get
- {
- return this.isInputEnabled && base.gameObject.activeInHierarchy && YotogiManager.instans.inputCBLRightKey;
- }
- }
- public bool inputLeftKey
- {
- get
- {
- return this.isInputEnabled && base.gameObject.activeInHierarchy && YotogiManager.instans.inputCBLLeftKey;
- }
- }
- public bool inputEnterKey
- {
- get
- {
- return this.isInputEnabled && base.gameObject.activeInHierarchy && YotogiManager.instans.inputCBLCancelKey;
- }
- }
- public bool inputCancelKey
- {
- get
- {
- return this.isInputEnabled && base.gameObject.activeInHierarchy && YotogiManager.instans.inputCBLEnterKey;
- }
- }
- public NodeButtonData selectedNodeButton
- {
- get
- {
- foreach (NodeButtonData nodeButtonData in this.menuButtons)
- {
- if (nodeButtonData.selectType == OnaholeNodeButton.SelectType.Select || nodeButtonData.selectType == OnaholeNodeButton.SelectType.Focus)
- {
- return nodeButtonData;
- }
- }
- return null;
- }
- }
- public void NextItem()
- {
- List<NodeButtonData> list = this.menuButtons;
- if (this.operationMap != null && 0 < this.operationMap.Count)
- {
- foreach (List<NodeButtonData> list2 in this.operationMap)
- {
- foreach (NodeButtonData nodeButtonData in list2)
- {
- if (nodeButtonData.selectType == OnaholeNodeButton.SelectType.Select || nodeButtonData.selectType == OnaholeNodeButton.SelectType.Focus)
- {
- list = list2;
- break;
- }
- }
- }
- }
- NodeButtonData nodeButtonData2 = null;
- for (int i = 0; i < list.Count; i++)
- {
- if (list[i].selectType == OnaholeNodeButton.SelectType.Select || list[i].selectType == OnaholeNodeButton.SelectType.Focus)
- {
- nodeButtonData2 = list[i];
- int num = i;
- for (;;)
- {
- num++;
- if (list.Count <= num)
- {
- num = -1;
- }
- else if (list[num].selectType != OnaholeNodeButton.SelectType.Disable)
- {
- break;
- }
- }
- nodeButtonData2 = list[num];
- break;
- }
- }
- if (nodeButtonData2 != null)
- {
- this.SetFocusButton(nodeButtonData2);
- GameMain.Instance.SoundMgr.PlaySystem(SoundMgr.SeType.Hover);
- }
- }
- public void PrevItem()
- {
- List<NodeButtonData> list = this.menuButtons;
- if (this.operationMap != null && 0 < this.operationMap.Count)
- {
- foreach (List<NodeButtonData> list2 in this.operationMap)
- {
- foreach (NodeButtonData nodeButtonData in list2)
- {
- if (nodeButtonData.selectType == OnaholeNodeButton.SelectType.Select || nodeButtonData.selectType == OnaholeNodeButton.SelectType.Focus)
- {
- list = list2;
- break;
- }
- }
- }
- }
- NodeButtonData nodeButtonData2 = null;
- for (int i = 0; i < list.Count; i++)
- {
- if (list[i].selectType == OnaholeNodeButton.SelectType.Select || list[i].selectType == OnaholeNodeButton.SelectType.Focus)
- {
- nodeButtonData2 = list[i];
- int num = i;
- for (;;)
- {
- num--;
- if (num < 0)
- {
- num = list.Count;
- }
- else if (list[num].selectType != OnaholeNodeButton.SelectType.Disable)
- {
- break;
- }
- }
- nodeButtonData2 = list[num];
- break;
- }
- }
- if (nodeButtonData2 != null)
- {
- this.SetFocusButton(nodeButtonData2);
- GameMain.Instance.SoundMgr.PlaySystem(SoundMgr.SeType.Hover);
- }
- }
- public void RightItem()
- {
- if (this.operationMap == null || this.operationMap.Count <= 1)
- {
- return;
- }
- List<NodeButtonData> list = null;
- for (int i = 0; i < this.operationMap.Count; i++)
- {
- for (int j = 0; j < this.operationMap[i].Count; j++)
- {
- NodeButtonData nodeButtonData = this.operationMap[i][j];
- if (nodeButtonData.selectType == OnaholeNodeButton.SelectType.Select || nodeButtonData.selectType == OnaholeNodeButton.SelectType.Focus)
- {
- list = new List<NodeButtonData>();
- for (int k = 0; k < this.operationMap.Count; k++)
- {
- list.Add(this.operationMap[k][j]);
- }
- break;
- }
- }
- if (list != null)
- {
- break;
- }
- }
- if (list == null)
- {
- return;
- }
- NodeButtonData nodeButtonData2 = null;
- for (int l = 0; l < list.Count; l++)
- {
- if (list[l].selectType == OnaholeNodeButton.SelectType.Select || list[l].selectType == OnaholeNodeButton.SelectType.Focus)
- {
- nodeButtonData2 = list[l];
- int num = l;
- for (;;)
- {
- num++;
- if (list.Count <= num)
- {
- num = -1;
- }
- else if (list[num].selectType != OnaholeNodeButton.SelectType.Disable)
- {
- break;
- }
- }
- nodeButtonData2 = list[num];
- break;
- }
- }
- if (nodeButtonData2 != null)
- {
- this.SetFocusButton(nodeButtonData2);
- GameMain.Instance.SoundMgr.PlaySystem(SoundMgr.SeType.Hover);
- }
- }
- public void LeftItem()
- {
- if (this.operationMap == null || this.operationMap.Count <= 1)
- {
- return;
- }
- List<NodeButtonData> list = null;
- for (int i = 0; i < this.operationMap.Count; i++)
- {
- for (int j = 0; j < this.operationMap[i].Count; j++)
- {
- NodeButtonData nodeButtonData = this.operationMap[i][j];
- if (nodeButtonData.selectType == OnaholeNodeButton.SelectType.Select || nodeButtonData.selectType == OnaholeNodeButton.SelectType.Focus)
- {
- list = new List<NodeButtonData>();
- for (int k = 0; k < this.operationMap.Count; k++)
- {
- list.Add(this.operationMap[k][j]);
- }
- break;
- }
- }
- if (list != null)
- {
- break;
- }
- }
- if (list == null)
- {
- return;
- }
- NodeButtonData nodeButtonData2 = null;
- for (int l = 0; l < list.Count; l++)
- {
- if (list[l].selectType == OnaholeNodeButton.SelectType.Select || list[l].selectType == OnaholeNodeButton.SelectType.Focus)
- {
- nodeButtonData2 = list[l];
- int num = l;
- for (;;)
- {
- num--;
- if (num < 0)
- {
- num = list.Count;
- }
- else if (list[num].selectType != OnaholeNodeButton.SelectType.Disable)
- {
- break;
- }
- }
- nodeButtonData2 = list[num];
- break;
- }
- }
- if (nodeButtonData2 != null)
- {
- this.SetFocusButton(nodeButtonData2);
- GameMain.Instance.SoundMgr.PlaySystem(SoundMgr.SeType.Hover);
- }
- }
- protected virtual void OnEnterMenu()
- {
- GameMain.Instance.SoundMgr.PlaySystem(SoundMgr.SeType.Click);
- }
- protected virtual void OnCancelMenu()
- {
- GameMain.Instance.SoundMgr.PlaySystem(SoundMgr.SeType.Click);
- }
- protected virtual void Update()
- {
- if (this.inputDownKey)
- {
- this.NextItem();
- }
- else if (this.inputUpKey)
- {
- this.PrevItem();
- }
- }
- protected NodeButtonData GetNodeButtonData(string uniquName)
- {
- foreach (NodeButtonData nodeButtonData in this.menuButtons)
- {
- if (nodeButtonData.button.uniqueName == uniquName)
- {
- return nodeButtonData;
- }
- }
- return null;
- }
- protected void SetFocusButton(NodeButtonData buttonData)
- {
- if (buttonData == null)
- {
- return;
- }
- foreach (NodeButtonData nodeButtonData in this.menuButtons)
- {
- if (nodeButtonData.button.selectType != OnaholeNodeButton.SelectType.Disable)
- {
- nodeButtonData.button.selectType = ((buttonData.button != nodeButtonData.button) ? OnaholeNodeButton.SelectType.None : OnaholeNodeButton.SelectType.Focus);
- }
- }
- }
- protected void SetSelectedButton(NodeButtonData buttonData)
- {
- if (buttonData == null)
- {
- return;
- }
- foreach (NodeButtonData nodeButtonData in this.menuButtons)
- {
- if (nodeButtonData.button.selectType != OnaholeNodeButton.SelectType.Disable)
- {
- nodeButtonData.button.selectType = ((buttonData.button != nodeButtonData.button) ? OnaholeNodeButton.SelectType.None : OnaholeNodeButton.SelectType.Select);
- }
- }
- }
- [SerializeField]
- protected UIGrid menuButtonGrid;
- protected List<NodeButtonData> menuButtons = new List<NodeButtonData>();
- protected List<List<NodeButtonData>> operationMap = new List<List<NodeButtonData>>();
- public bool isInputEnabled;
- }
|