using UnityEngine; using UnityEngine.UI; using UnityEngine.Events; using System; using System.Collections; using System.Collections.Generic; namespace Fungus.Script { public class Dialog : MonoBehaviour { public enum DialogSide { Left, Right }; public class Option { public string text; public Action onSelect; } public Canvas dialogCanvas; public List optionButtons = new List(); public Text nameText; public Text storyText; public Image continueImage; public Image leftImage; public Image rightImage; List optionActions = new List(); public void ShowDialog(bool visible) { if (dialogCanvas != null) { dialogCanvas.gameObject.SetActive(visible); } } public void SetCharacter(Character character) { if (character == null) { if (leftImage != null) leftImage.enabled = false; if (rightImage != null) rightImage.enabled = false; if (nameText != null) nameText.text = ""; } else { SetCharacterImage(character.characterImage, character.dialogSide); SetCharacterName(character.name, character.characterColor); } } public void SetCharacterImage(Sprite image, DialogSide side) { if (leftImage != null) { if (image != null && side == DialogSide.Left) { leftImage.sprite = image; leftImage.enabled = true; } else { leftImage.enabled = false; } } if (rightImage != null) { if (image != null && side == DialogSide.Right) { rightImage.sprite = image; rightImage.enabled = true; } else { rightImage.enabled = false; } } } public void SetCharacterName(string name, Color color) { if (nameText != null) { nameText.text = name; nameText.color = color; } } public void Say(string text, Action onComplete) { Clear(); if (storyText != null) { storyText.text = text; } StartCoroutine(WriteText(text, delegate { ShowContinueIcon(true); StartCoroutine(WaitForInput(onComplete)); })); } public void Say(string text, List