using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.EventSystems; using Michsky.MUIP; using TMPro; using Febucci.UI; public class DialogueController : MonoBehaviour, IPointerClickHandler { [SerializeField] TextMeshProUGUI textTMPro; [SerializeField] TextMeshProUGUI nameTMPro; [SerializeField] TextAnimatorPlayer typer; [SerializeField] ButtonManager button; [SerializeField] RectTransform optionMenu; [SerializeField] bool clickAnywhere = false; [SerializeField] VNController vn = null; [HideInInspector] List interactions; [HideInInspector] public int dialogueIndex = 0; // Whether to use VNData.NextScene or to pick a random Manager scene // for the given SidePiece. [SerializeField] bool chooseManagerScene = false; private void Interact() { if (dialogueIndex >= interactions.Count && optionMenu != null) { optionMenu.gameObject.SetActive(true); return; } if (dialogueIndex >= interactions.Count) { vn.Done(); return; } DialogueInteraction d = interactions[dialogueIndex]; if (vn != null) { vn.Interact(d); } nameTMPro.SetText(d.name); textTMPro.SetText(d.text); if (d.unlock != Unlockable.None) { GameData.Unlock(d.unlock); } dialogueIndex += 1; } public void NextButtonPressed() { if (typer.textAnimator.allLettersShown) { if (button.enabled) { button.enabled = false; } Interact(); } else { typer.SkipTypewriter(); } } public void OnPointerClick(PointerEventData eventData) { if (clickAnywhere) { NextButtonPressed(); } } // Start is called before the first frame update void Start() { if (clickAnywhere) { button.gameObject.SetActive(false); } else { button.enabled = false; } if (optionMenu != null) { optionMenu.gameObject.SetActive(false); } if (chooseManagerScene) { VNData.NextScene = VNData.GetRandomManagerScene(GameData.GLOBAL.sidePiece); } // The scene to play is pre-loaded here. interactions = VNData.DIALOGUE[VNData.NextScene]; GameData.GLOBAL.viewedScenes.Add(VNData.NextScene); vn.SetUp(VNData.NextScene); Interact(); } // Update is called once per frame void Update() { } }