public void ShowSelectionPanel(UISelectionPanelType type) { HideUIPanel(); switch (type) { case UISelectionPanelType.Character: var temp = Instantiate(_selectionPanel); temp.transform.SetParent(_canvas.transform, false); SelectionPanel newPanel = temp.GetComponent <SelectionPanel>(); newPanel.InitPanel(type); UpdateCurrentPanel(newPanel.gameObject); break; } }
public void InitPanel(UISelectionPanelType type) { _button1.gameObject.SetActive(false); _button2.gameObject.SetActive(false); _button3.gameObject.SetActive(false); _button4.gameObject.SetActive(false); _button5.gameObject.SetActive(false); _button6.gameObject.SetActive(false); switch (type) { case UISelectionPanelType.Generic: _button3.gameObject.SetActive(true); _button4.gameObject.SetActive(true); break; case UISelectionPanelType.Character: _button3.gameObject.SetActive(true); _button4.gameObject.SetActive(true); _button5.gameObject.SetActive(true); _button6.gameObject.SetActive(true); _button3.GetComponentInChildren <Text>().text = "Fight"; _button4.GetComponentInChildren <Text>().text = "Talk"; _button5.GetComponentInChildren <Text>().text = "Skill"; _button6.GetComponentInChildren <Text>().text = "Flee"; _button3.onClick.AddListener(() => Root.GetComponentFromRoot <EncounterHandler>().StartCombatEncounter((BaseEnemy)Root.GetComponentFromRoot <UIHandler>().CurrentTargetThing)); _button4.onClick.AddListener(() => Root.GetComponentFromRoot <UIHandler>().BuildDialoguePanel(Root.GetComponentFromRoot <UIHandler>().CurrentTargetThing)); _button5.onClick.AddListener(() => Root.GetComponentFromRoot <UIHandler>().ShowSelectionPanel(UISelectionPanelType.Generic)); //_button6.onClick.AddListener(_onButtonClickAction); break; case UISelectionPanelType.Item: _button3.gameObject.SetActive(true); _button4.gameObject.SetActive(true); _button3.GetComponentInChildren <Text>().text = "Take"; _button4.GetComponentInChildren <Text>().text = "Leave"; break; } }