using UnityEngine; using System; using System.Collections; using System.Collections.Generic; using System.Text.RegularExpressions; namespace Fungus { /** * A rectangular screen area for rendering story text. * Rooms may contain any number of Pages. * If a Page is a child of a View, then transitioning to that View will automatically activate the Page. */ [ExecuteInEditMode] public class Page : 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 }; [HideInInspector] 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