//private bool hasGameFinished = false; //private bool gameWon = false; //private bool gameLost = false; // Use this for initialization void Start() { sD = GetComponent <StoryDisplay>(); //Disable button on startup MasterUI.anchorMax = new Vector2(1, 2); MasterUI.anchorMin = new Vector2(0, 2); MasterUI.sizeDelta = new Vector2(500, 500); }
/** * Draws the numbered option to the screen. */ protected abstract void DisplayOption(int optionNumber, int totalOptions, string text, Canvas canvas, StoryDisplay parser);
/** * Draws to the GUI based on the text in the story.. */ protected abstract void DisplayMoment(string text, Canvas canvas, StoryDisplay parser);
protected override void DisplayOption(int optionNumber, int totalOptions, string text, Canvas canvas, StoryDisplay parser) { //Create the new button from the prefab and configure position in regards to parent (button origin). Button newButton = UnityEngine.Object.Instantiate(buttonBase, Vector3.zero, Quaternion.identity, optionsOrigin); newButton.transform.localPosition = new Vector3( optionNumber * buttonRelativeDifferences.x - buttonRelativeDifferences.x * totalOptions / 2, optionNumber * buttonRelativeDifferences.y - buttonRelativeDifferences.y * totalOptions / 2, newButton.transform.localPosition.z //Don't change z. ); //Configure button as an option button. newButton.GetComponentInChildren <Text>().text = text; newButton.onClick.AddListener(delegate() { Debug.Log("Selecting Option " + optionNumber); OnSelectOption(optionNumber); }); newButton.name = text; optionButtons.Add(newButton); }
protected override void DisplayMoment(string text, Canvas canvas, StoryDisplay parser) { //Add the new text to the text on screen. textBeingDisplayed = textBeingDisplayed.Insert(textBeingDisplayed.Length, text); displayText.text = textBeingDisplayed; }