using System.Collections; using System.Collections.Generic; using Febucci.UI; using TMPro; using UnityEngine; public class UIPanelController : MonoBehaviour { [SerializeField] GameObject inventoryPanel; [SerializeField] GameObject equipPanel; [SerializeField] GameObject statsPanel; [SerializeField] DialoguePanelController dialoguePanel; [SerializeField] public TextMeshProUGUI dialogueText; [SerializeField] public TextMeshProUGUI dialogueNameLeft; [SerializeField] public TextMeshProUGUI dialogueNameRight; [SerializeField] public TextAnimatorPlayer dialogueTextPlayer; private GameAudioController gameAudioController; // Start is called before the first frame update void Start() { inventoryPanel.SetActive(false); equipPanel.SetActive(false); dialoguePanel.gameObject.SetActive(false); statsPanel.SetActive(false); gameAudioController = GameObject.FindGameObjectWithTag("GameAudio") .GetComponent(); } // Update is called once per frame void Update() { if (Input.GetButtonDown("Inventory")) { inventoryPanel.SetActive(!inventoryPanel.activeInHierarchy); if (inventoryPanel.activeInHierarchy) { gameAudioController.audioSource.PlayOneShot( gameAudioController.UI_Inv_WindowOpen); inventoryPanel.GetComponent().RefreshAll(); } else { gameAudioController.audioSource.PlayOneShot( gameAudioController.UI_Inv_WindowClose); } } if (Input.GetButtonDown("Equip")) { equipPanel.SetActive(!equipPanel.activeInHierarchy); if (equipPanel.activeInHierarchy) { gameAudioController.audioSource.PlayOneShot( gameAudioController.UI_Inv_WindowOpen); equipPanel.GetComponent().RefreshAll(); } else { gameAudioController.audioSource.PlayOneShot( gameAudioController.UI_Inv_WindowClose); } } if (Input.GetButtonDown("Stats")) { statsPanel.SetActive(!statsPanel.activeInHierarchy); if (statsPanel.activeInHierarchy) { gameAudioController.audioSource.PlayOneShot( gameAudioController.UI_Inv_WindowOpen); statsPanel.GetComponent().Refresh(); } else { gameAudioController.audioSource.PlayOneShot( gameAudioController.UI_Stat_Close); } } } public bool SkipDialogueTypewriter() { if (!dialoguePanel.gameObject.activeInHierarchy) { return false; } bool skippedSomething = !dialogueTextPlayer.textAnimator.allLettersShown; dialogueTextPlayer.SkipTypewriter(); if (skippedSomething) { gameAudioController.audioSource.PlayOneShot( gameAudioController.UI_Dialogue_Skip); } return skippedSomething; } public void ActivateDialoguePanel() { dialoguePanel.gameObject.SetActive(true); } public void DeactivateDialoguePanel() { dialoguePanel.Reset(); dialoguePanel.gameObject.SetActive(false); } public void IterateCutscene(DialogueStatement statement) { ActivateDialoguePanel(); dialogueTextPlayer.ShowText(statement.statement); if (statement.placements != null) { foreach (DialogueCGPlacement placement in statement.placements) { dialoguePanel.ShowCG(placement.location, placement.cg, placement.expressionIndex); } } dialoguePanel.SetTalkingPosition(statement.talkingSpot); if (statement.talkingSpot < 2) { // TODO: Disable right spot, enable left } else { // TODO: Disable left spot, enable right } if (statement.blockOutName) { if (statement.talkingSpot < 2) { dialogueNameLeft.text = "???"; dialogueNameRight.text = ""; } else { dialogueNameRight.text = "???"; dialogueNameLeft.text = ""; } } else if (statement.npcID == NpcID.NONE) { dialogueNameLeft.text = ""; dialogueNameRight.text = ""; } else { string npcName = ((Npc)NpcInfo.npcs[statement.npcID]).name; if (statement.talkingSpot < 2) { dialogueNameLeft.text = npcName; dialogueNameRight.text = ""; } else { dialogueNameRight.text = npcName; dialogueNameLeft.text = ""; } } } }