private void SwitchState(UI_State state) { if (_uiState == state) { return; } _uiState = state; switch (_uiState) { case UI_State.SHOW_BTN_IN_MM: InitShowBtnInMM(); break; case UI_State.HIDE_BTN_IN_MM: InitHideBtnInMM(); break; case UI_State.SHOW_BTN_IN_RM: InitShowBtnInRM(); break; case UI_State.HIDE_BTN_IN_RM: InitHideBtnInRM(); break; } }
void Update() { UseAxisEsc(); UseAxisAction(); //Debug currentUiInGameMenu = uiInGameMenu; currentUiState = uiState; }
public void SetActive(UI_State state) { //Debug.Log(" fail"); switch (state) { case UI_State.E_SUCCESS_COMPLETED://选宝箱完成列表 pnlSuccess.gameObject.SetActive(true); pnlSelectBox.gameObject.SetActive(false); break; case UI_State.E_SUCCESS://成功选宝箱列表 pnlSuccess.gameObject.SetActive(false); pnlSelectBox.gameObject.SetActive(true); break; case UI_State.E_FAILED://失败列表 pnlFail.gameObject.SetActive(true); pnlFail.ShowEffect(); //Debug.Log("to fail"); break; case UI_State.E_CENSUS://战斗统计列表 pnlStatistics.gameObject.SetActive(true); break; } }
public void ChangeState(int nextState) { uiState = (UI_State)nextState; for (int i = 0; i < uiMenuTransform.Length; i++) { if (uiMenuTransform[i].name == uiState.ToString()) { currentMenuTransform = uiMenuTransform[i]; currentMenuTransform.gameObject.SetActive(true); } else { uiMenuTransform[i].gameObject.SetActive(false); } } if (UI_Controller.uiState == UI_State.Quit) { QuitApplication(); } currentMenu = currentMenuTransform; }
void Update() { if (Input.GetKeyDown(KeyCode.Tab) && cooldown == 0) { menuActive = !menuActive; if (menuActive) { //HUD UI_HUD.i.GetComponent <CanvasGroup>().alpha = 0; //Update Elements MenuRequestAbilitiesInfo(); playerCore.GetComponent <PlayerInventory>().CmdFindItemsInProximity(); MenuInventoryRequest(); //Root StartCoroutine(Fade(1)); root.blocksRaycasts = true; root.interactable = true; //UI UI_State.ChangeState(true); } else { //HUD UI_HUD.i.GetComponent <CanvasGroup>().alpha = 1; //Root root.alpha = 0; root.blocksRaycasts = false; root.interactable = false; //Character characterMenu.alpha = 0; characterMenu.blocksRaycasts = false; characterMenu.interactable = false; //Ability abilityMenu.alpha = 0; abilityMenu.blocksRaycasts = false; abilityMenu.interactable = false; //UI UI_State.ChangeState(false); } //Apply cooldown cooldown = 0.35f; } if (menuActive) { //Proximity Update Collider[] proximityItems = Physics.OverlapSphere(playerCore.transform.position, 1.5f, itemLayerMask); if (savedProximity.Length != proximityItems.Length) { playerCore.GetComponent <PlayerInventory>().CmdFindItemsInProximity(); } } cooldown = Mathf.Clamp(cooldown - Time.deltaTime, 0, 0.6f); }
public void ChangeActiveUI(string stateName) { List <GameObject> ui_all = new List <GameObject>(); ui_all.Add(menuMain); ui_all.Add(menuSettings); ui_all.Add(menuGameOver); ui_all.Add(menuAbout); List <GameObject> ui_active = new List <GameObject>(); // choose active ui elements switch (stateName) { case "MenuMain": currentState = UI_State.MenuMain; ui_active.Add(menuMain); TurnUIOnOff(ui_all, ui_active); GameManager.Instance.ChangeState(GameState.MENU); break; case "MenuSettings": currentState = UI_State.MenuSettings; ui_active.Add(menuSettings); TurnUIOnOff(ui_all, ui_active); GameManager.Instance.ChangeState(GameState.MENU); break; case "MenuGameOver": currentState = UI_State.MenuGameOver; ui_active.Add(menuGameOver); TurnUIOnOff(ui_all, ui_active); GameManager.Instance.ChangeState(GameState.MENU); break; case "MenuAbout": currentState = UI_State.MenuAbout; ui_active.Add(menuAbout); TurnUIOnOff(ui_all, ui_active); GameManager.Instance.ChangeState(GameState.MENU); break; case "GameplayMain": currentState = UI_State.GameplayMain; TurnUIOnOff(ui_all, ui_active); GameManager.Instance.StartANewGame(); break; default: break; } ButtonToggleAudio[] buttonsAudio = FindObjectsOfType <ButtonToggleAudio>(); foreach (ButtonToggleAudio bttn in buttonsAudio) { if (bttn.gameObject.activeInHierarchy) { bttn.Refresh(); } } }
IEnumerator ExcuteTask() { if (commonds_queue.Count == 0) { yield break; } while (commonds_queue.Count > 0) { UI_Commond commond = commonds_queue.Dequeue(); if (commond.operation_type == UI_Commond_Type.Show) { if (commond.operation_id != -1) { Debug.LogError("不能根据id显示界面!"); } int panelType = commond.operation_panelType; bool hasShow = false; List <UI_PanelBase> loaded = null; if (UI_Type_Loaded_Dic.ContainsKey(panelType)) { loaded = UI_Type_Loaded_Dic[panelType]; if (loaded != null && loaded.Count > 0) { int loadedCount = loaded.Count; for (int i = 0; i < loadedCount; i++) { if (loaded[i].State == UI_State.Close) { loaded[i].transform.SetAsLastSibling(); yield return(loaded[i].ShowThisPanel()); hasShow = true; while (UI_PopPanel_Stack.Count > 0) { UI_PanelBase top = UI_PopPanel_Stack.Peek(); switch (top.State) { case UI_State.Show: top.PauseThisPanel(); break; case UI_State.Pause: Debug.LogError("未知暂停状态的面板!"); break; case UI_State.Close: UI_PopPanel_Stack.Pop(); continue; case UI_State.Unknow: break; } break; } UI_PopPanel_Stack.Push(loaded[i]); break; } } } else { UI_Type_Loaded_Dic.Remove(panelType); loaded = new List <UI_PanelBase>(); UI_Type_Loaded_Dic.Add(panelType, loaded); } } else { loaded = new List <UI_PanelBase>(); UI_Type_Loaded_Dic.Add(panelType, loaded); } if (!hasShow) { if (UI_Type_Prefab_Dic.ContainsKey(panelType)) { if (UI_Type_Prefab_Dic[panelType] is null) { Debug.LogError("加载的预制体为空!"); continue; } UI_PanelBase panel = Instantiate(UI_Type_Prefab_Dic[panelType], popRoot).GetComponent <UI_PanelBase>(); panel.transform.SetAsLastSibling(); yield return(panel.ShowThisPanel()); UI_Type_Loaded_Dic[panelType].Add(panel); UI_ID_Loaded_Dic.Add(panel.UI_ID, panel); hasShow = true; while (UI_PopPanel_Stack.Count > 0) { UI_PanelBase top = UI_PopPanel_Stack.Peek(); switch (top.State) { case UI_State.Show: top.PauseThisPanel(); break; case UI_State.Pause: Debug.LogError("未知暂停状态的面板!"); break; case UI_State.Close: UI_PopPanel_Stack.Pop(); continue; case UI_State.Unknow: break; } break; } UI_PopPanel_Stack.Push(panel); } else { if (UI_Type_Path_Dic.ContainsKey(panelType)) { GameObject prefab = Resources.Load <GameObject>(UI_Prefab_Path_Pre + UI_Type_Path_Dic[panelType]); if (prefab is null) { Debug.LogError("预制体路径错误!"); continue; } else { UI_Type_Prefab_Dic.Add(panelType, prefab); UI_PanelBase panel = Instantiate(UI_Type_Prefab_Dic[panelType], popRoot).GetComponent <UI_PanelBase>(); if (panel is UI_PopPanelBase) { } else { panel.transform.SetParent(menuRoot); } panel.transform.SetAsLastSibling(); yield return(panel.ShowThisPanel()); UI_Type_Loaded_Dic[panelType].Add(panel); UI_ID_Loaded_Dic.Add(panel.UI_ID, panel); hasShow = true; while (UI_PopPanel_Stack.Count > 0) { UI_PanelBase top = UI_PopPanel_Stack.Peek(); switch (top.State) { case UI_State.Show: top.PauseThisPanel(); break; case UI_State.Pause: Debug.LogError("未知暂停状态的面板!"); break; case UI_State.Close: UI_PopPanel_Stack.Pop(); continue; case UI_State.Unknow: break; } break; } UI_PopPanel_Stack.Push(panel); } } else { Debug.LogError("没有配置预制体路径!"); continue; } } } } else { if (UI_ID_Loaded_Dic.ContainsKey(commond.operation_id)) { UI_State oldState = UI_ID_Loaded_Dic[commond.operation_id].State; if (oldState != UI_State.Close) { yield return(UI_ID_Loaded_Dic[commond.operation_id].CloseThisPanel()); if (oldState == UI_State.Show) { while (UI_PopPanel_Stack.Count > 0 && UI_PopPanel_Stack.Peek().State == UI_State.Close) { UI_PopPanel_Stack.Pop(); } if (UI_PopPanel_Stack.Count > 0 && UI_PopPanel_Stack.Peek().State == UI_State.Pause) { UI_PopPanel_Stack.Peek().ResumeThisPanel(); } } } } else { Debug.LogError("不存在该id的面板!"); } } } taskCoroutine = null; }