using System; using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.Events; using UnityEngine.UI; public class OverworldUIManager : UIManager { //info display private GameMaster gm; private SettingsManager sm; private int i = 0; private GoodGuy currentSource, currentTarget; private Action currentAction; public int currentPanel = 0; //inventory info [Header("Set panels here")] [SerializeField] private GameObject partyObject = null; [SerializeField] private List party; [SerializeField] private GameObject pause_panel = null; [SerializeField] private GameObject[] panel = null; public Text desc_text = null; public enum Panel { Main = 0, Inventory = 1, Abilities = 2, Status = 3, Save = 4, Load = 5, Settings = 6, Quit = 7, Description = 8 } public void showPause(bool onOff) { hideAllPanels(); if (onOff) { pause_panel.SetActive(true); } else { currentPanel = 0; pause_panel.SetActive(false); } } void Start() { gm = GameMaster.Instance; sm = panel[(int)Panel.Settings].GetComponent(); desc_text = panel[(int)Panel.Description].GetComponentInChildren(); //set party int i = 0; GoodGuy g; party = new List(); foreach(Stats s in gm.Party) { g = AbilityDB.GetGoodGuy(partyObject, s); g.inBattle = false; g.stats = gm.Party[i]; party.Add(g); i++; } showPause(false); } public void hideAllPanels() { for(i = 1; i < panel.Length; i++) { panel[i].SetActive(false); } desc_text.text = ""; } public void ShowPanel(int p) //shows and updates panels { if (p < 0 || p > 7) return; if (p == currentPanel) { //if equal, disable it panel[p].SetActive(false); panel[(int)Panel.Description].SetActive(false); currentPanel = 0; return; } if(currentPanel != 0) { //disable other panel, except main panel[currentPanel].SetActive(false); panel[(int)Panel.Description].SetActive(false); } //enable new panel panel[p].SetActive(true); panel[(int)Panel.Description].SetActive(true); currentPanel = p; //Handle Panel switch ((Panel)p) { case Panel.Inventory: handleInventory(); break; case Panel.Abilities: handleAbilities(); break; case Panel.Status: handleStatus(); break; case Panel.Save: handleSave(); break; case Panel.Load: handleLoad(); break; case Panel.Settings: handleSettings(); break; case Panel.Quit: handleQuit(); break; default: break; } } private void handleInventory() { //get inventory buttons object Transform tmp = panel[(int)Panel.Inventory].transform.GetChild(1); Button[] item_buttons = new Button[tmp.childCount]; for(int i = 0; i < tmp.childCount; i++) { item_buttons[i] = tmp.GetChild(i).GetComponent