using UnityEngine; using System; using System.Collections; using System.Collections.Generic; using System.Text.RegularExpressions; namespace Fungus { /** * Manages and draws a text box for rendering story text and multiple choice menus. */ [ExecuteInEditMode] public class PageController : MonoBehaviour { /// Options for default Page position on screen public enum PagePosition { /// Page appears full-size and horizontally centered at top of screen. Top, /// Page appears centered in middle of screen, with height fitted to content. Middle, /// Page appears full-size and horizontally centered at bottom of screen. Bottom } /** * Defines a rect in normalized screen space coordinates. * e.g. x1 = 0 means left of screen, x2 = 1 means right of screen. */ public class ScreenRect { public float x1; public float y1; public float x2; public float y2; } /// Options for controlling page layout public enum Layout { /// Use the full rect to display the page. FullSize, /// Resize to fit displayed text and snap to top of rect. FitToTop, /// Resize to fit displayed text and snap to middle of rect. FitToMiddle, /// Resize to fit displayed text and snap to bottom of rect. FitToBottom } /// Controls layout of content within Page rect. public Layout layout = Layout.FullSize; /// Supported states for Page public enum Mode { /// No content to be displayed. Idle, /// Show a single line of text and wait for player input. Say, /// Show a multiple choice menu and wait for player to select an option. Choose }; /// Current Page story telling state public Mode mode = Mode.Idle; /// Screen space rect for Page in pixels. public Rect pageRect; string headerText = ""; string footerText = ""; string displayedStoryText = ""; string originalStoryText = ""; Action deferredAction; Action continueAction; class Option { public string optionText; public Action optionAction; public Option(string _optionText, Action _optionAction) { optionText = _optionText; optionAction = _optionAction; } } List