/// <summary> /// Clears the player's saved progress, and presents them with a notification telling them their progress has been cleared. /// </summary> public void ClearPlayerData() { PlayerPrefs.DeleteAll(); this.GetComponent <InkTextDisplay>().EraseUI(); //Tells InkTextDisplay.cs to clear all the onscreen text/buttons. this.GetComponent <InkTextDisplay>().startKnot = null; //Clears the "start knot" field, so that the game doesn't start anywhere that isn't the very beginning. //Creates text informing the player that their saved data has been erased. Text progressHasBeenClearedTextGameObject = Instantiate(textPrefab) as Text; progressHasBeenClearedTextGameObject.text = progressHasBeenClearedText; AccessibleLabel label = progressHasBeenClearedTextGameObject.gameObject.AddComponent(typeof(AccessibleLabel)) as AccessibleLabel; //Adds an accessible label to the text. progressHasBeenClearedTextGameObject.transform.SetParent(this.transform, false); UAP_AccessibilityManager.SelectElement(progressHasBeenClearedTextGameObject.gameObject); //Directs focus to the notification text, so that it starts being read automatically. //Creates a "return to menu" button. Text returnToMenuPressableGameObject = Instantiate(selectableTextPrefab) as Text; //Instantiates a "pressable text gameObject." (Our substitute for a button) returnToMenuPressableGameObject.gameObject.tag = "Return to menu button"; returnToMenuPressableGameObject.text = returnToMenuButtonText; returnToMenuPressableGameObject.transform.SetParent(this.transform, false); //Parents the pressable gameObject to the canvas (this gameObject).he canvas (this gameObject). setToPause = false; //Resets the game's pause status. this.GetComponent <PauseManager>().enabled = false; //Ensures the player can't pause/unpause before starting a new gameplay session. }
/// <summary> /// Asks the player if they're sure they'd like to clear their progress, and gives them the option of doing so. /// </summary> public void OpenAreYouSureScreen() { this.GetComponent <InkTextDisplay>().EraseUI(); //Tells InkTextDisplay.cs to clear all the onscreen text/buttons. //Creates text asking the player if they really want to clear their progress or not. Text areYouSureTextGameObject = Instantiate(textPrefab) as Text; areYouSureTextGameObject.text = areYouSureText; AccessibleLabel label = areYouSureTextGameObject.gameObject.AddComponent(typeof(AccessibleLabel)) as AccessibleLabel; //Adds an accessible label to the text. areYouSureTextGameObject.transform.SetParent(this.transform, false); UAP_AccessibilityManager.SelectElement(areYouSureTextGameObject.gameObject); //Directs focus to the notification text, so that it starts being read automatically. //Creates a "yes" button Text confirmClearDataPressableGameObject = Instantiate(selectableTextPrefab) as Text; //Instantiates a "pressable text gameObject." (Our substitute for a button) confirmClearDataPressableGameObject.gameObject.tag = "Confirm clear progress button"; confirmClearDataPressableGameObject.text = confirmClearDataButtonText; confirmClearDataPressableGameObject.transform.SetParent(this.transform, false); //Parents the pressable gameObject to the canvas (this gameObject). //Creates an "I change my mind" button. Text cancelClearDataPressableGameObject = Instantiate(selectableTextPrefab) as Text; //Instantiates a "pressable text gameObject." (Our substitute for a button) cancelClearDataPressableGameObject.gameObject.tag = "Cancel clear progress button"; cancelClearDataPressableGameObject.text = cancelClearDataButtonText; cancelClearDataPressableGameObject.transform.SetParent(this.transform, false); //Parents the pressable gameObject to the canvas (this gameObject). }
/// <summary> /// Opens the first screen the player sees after they pause. /// </summary> public void OpenMainPauseScreen() { this.GetComponent <InkTextDisplay>().EraseUI(); //Tells InkTextDisplay.cs to clear all the onscreen text/buttons. //Creates text explaining that the game is paused. Text pauseScreenTextGameObject = Instantiate(textPrefab) as Text; pauseScreenTextGameObject.text = pauseScreenText; AccessibleLabel label = pauseScreenTextGameObject.gameObject.AddComponent(typeof(AccessibleLabel)) as AccessibleLabel; //Adds an accessible label to the text. pauseScreenTextGameObject.transform.SetParent(this.transform, false); UAP_AccessibilityManager.SelectElement(pauseScreenTextGameObject.gameObject); //Directs focus to the pause notification text, so that it starts being read automatically. //Creates an "unpause button," as an alternative to swiping up with three fingers again. (Both work for unpausing the game) Text resumePressableGameObject = Instantiate(selectableTextPrefab) as Text; //Instantiates a "pressable text gameObject." (Our substitute for a button) resumePressableGameObject.gameObject.tag = "Resume button"; resumePressableGameObject.text = resumeButtonText; resumePressableGameObject.transform.SetParent(this.transform, false); //Parents the pressable gameObject to the canvas (this gameObject). //Creates a "clear progress" button Text clearProgressPressableGameObject = Instantiate(selectableTextPrefab) as Text; //Instantiates a "pressable text gameObject." (Our substitute for a button) clearProgressPressableGameObject.gameObject.tag = "Are you sure you want to clear progress button"; clearProgressPressableGameObject.text = clearProgressButtonText; clearProgressPressableGameObject.transform.SetParent(this.transform, false); //Parents the pressable gameObject to the canvas (this gameObject). //Creates a "return to menu" button. Text returnToMenuPressableGameObject = Instantiate(selectableTextPrefab) as Text; //Instantiates a "pressable text gameObject." (Our substitute for a button) returnToMenuPressableGameObject.gameObject.tag = "Return to menu button"; returnToMenuPressableGameObject.text = returnToMenuButtonText; returnToMenuPressableGameObject.transform.SetParent(this.transform, false); //Parents the pressable gameObject to the canvas (this gameObject).he canvas (this gameObject). }
/// <summary> /// Opens the "chapter complete screen," which congratulates the player for completing a chapter and provides them with new options. /// </summary> void OpenChapterCompleteScreen() { SaveProgress(); //Ends all sounds. ambiance.Stop(); soundEffects.Stop(); //"Empties out" the AudioSources, to prevent issues with InkTextDisplay.cs' audio code. ambiance.clip = null; soundEffects.clip = null; EraseUI(); //Clears all the onscreen text/buttons. //Informs the player that they've completed a chapter. Text chapterCompleteTextGameObject = Instantiate(textPrefab) as Text; chapterCompleteTextGameObject.text = "<i>Congratulations, you completed Chapter " + chapterNumber + "!</i> " + chapterEndScreenToolTipText; AccessibleLabel label = chapterCompleteTextGameObject.gameObject.AddComponent(typeof(AccessibleLabel)) as AccessibleLabel; //Adds an accessible label to the text. chapterCompleteTextGameObject.transform.SetParent(this.transform, false); UAP_AccessibilityManager.SelectElement(chapterCompleteTextGameObject.gameObject); //Directs focus to the chapter complete notification text, so that it starts being read automatically. //Creates a "return to menu" button. Text returnToMenuPressableGameObject = Instantiate(selectableTextPrefab) as Text; //Instantiates a "pressable text gameObject." (Our substitute for a button) returnToMenuPressableGameObject.gameObject.tag = "Return to menu button"; returnToMenuPressableGameObject.text = returnToMenuButtonText; returnToMenuPressableGameObject.transform.SetParent(this.transform, false); //Parents the pressable gameObject to the canvas (this gameObject). chapterNumber++; //This is now the number of the next chapter. startKnot = "Chapter_" + chapterNumber.ToString() + "_Start"; //Sets the knot at the beginning of the next chapter as the start knot. if (chapterNumber <= totalChaptersImplemented) //Checks to see if the next chapter has been implemented yet. If so, creates a button to take the player to the next chapter. { //Creates a "continue to next chapter" button. Text continueToNextChapterPressableGameObject = Instantiate(selectableTextPrefab) as Text; //Instantiates a "pressable text gameObject." (Our substitute for a button) continueToNextChapterPressableGameObject.gameObject.tag = "Continue to next chapter button"; continueToNextChapterPressableGameObject.text = continueToNextChapterButtonText; continueToNextChapterPressableGameObject.transform.SetParent(this.transform, false); //Parents the pressable gameObject to the canvas (this gameObject). } }
/// <summary> /// Opens the welcome/tutorial text that appears at the start of the game, as well as after the player completes a chapter. /// </summary> public void OpenVoiceOverNotificationText() { this.GetComponent <PauseManager>().enabled = false; //Ensures the player can't pause when they're in the start screen. this.GetComponent <InkTextDisplay>().EraseUI(); //Tells the InkTextDisplay script (also attached to the Canvas) to clear any onscreen elements. Text notificationText = Instantiate(textPrefab) as Text; AccessibleLabel label = notificationText.gameObject.AddComponent(typeof(AccessibleLabel)) as AccessibleLabel; //Adds an accessible label to the text. notificationText.transform.SetParent(this.transform, false); //Prints each of the different tooltip strings one after the other, with spaces between them. notificationText.text = "<i>" + welcomeText + "\n\n" + turnOnVoiceOverText + "\n\n" + feelButtonsBelowText + "\n\n" + pauseTooltipText + "\n\n" + pleaseBeginText + "</i>"; UAP_AccessibilityManager.SelectElement(notificationText.gameObject); //Directs focus to the notification text, so that it starts being read automatically. //Creates a "start game" button Text startGamePressableGameObject = Instantiate(selectableTextPrefab) as Text; //Instantiates a "pressable text gameObject." (Our substitute for a button) startGamePressableGameObject.gameObject.tag = "Start game button"; startGamePressableGameObject.text = startGameButtonText; startGamePressableGameObject.transform.SetParent(this.transform, false); //Parents the pressable gameObject to the canvas (this gameObject). }
/// <summary> /// Resets the text/buttons every time the player makes a dialogue choice. /// </summary> public void RefreshUI(bool loadingSavedData) { bool textInputFieldOpen = false; //Used to determine if an input field should be placed onscreen. EraseUI(); Text storyText = Instantiate(textPrefab) as Text; //Instantiates a text gameObject. //Determines what to load for the next set of story text. if (loadingSavedData == true) { Debug.Log("Loading saved data."); story.state.LoadJson(PlayerPrefs.GetString("storyState")); //Loads the player's saved data. storyText.text = PlayerPrefs.GetString("storyText"); //Loads in the last text the player saw before saving. } else { storyText.text = LoadStoryChunk(); //Otherwise, Loads the next chunk of story content into the text gameObject. } Debug.Log("Number of Detected Tags: " + story.currentTags.Count); //Checks all the Ink tags present in the current chunk of story text, and determines if any of them should trigger any functions. foreach (string tag in story.currentTags) { Debug.Log("Tag: " + tag); if (tag.Contains("Ambiance")) //Checks for any tags related to background ambiance. { PlayNewAmbiance(tag); } else if (tag.Contains("SFX")) //Checks for any tags related to momentary sound effects. { PlayNewSoundEffect(tag); } else if (tag.Contains("Analytics")) //Checks for any tags related to analytics. { TriggerAnalytics(tag); } else if (tag.Contains("Create Custom Name Input Field")) //Checks to see if there should be a text input field onscreen. { //Informs the player that a text field is onscreen. Text enterNameTooltipTextGameObject = Instantiate(textPrefab) as Text; enterNameTooltipTextGameObject.text = enterNameTooltipText; AccessibleLabel label = enterNameTooltipTextGameObject.gameObject.AddComponent(typeof(AccessibleLabel)) as AccessibleLabel; //Adds an accessible label to the text. enterNameTooltipTextGameObject.transform.SetParent(this.transform, false); UAP_AccessibilityManager.SelectElement(enterNameTooltipTextGameObject.gameObject); //Directs focus to the notification text, so that it starts being read automatically. //Creates the text field itself. InputField textInputField = Instantiate(textInputFieldPrefab) as InputField; textInputField.transform.SetParent(this.transform, false); textInputFieldOpen = true; } else if (tag.Contains("CHAPTER COMPLETE: ")) //Checks to see if the player has reached the end of a chapter. { //Identifies which chapter they've just completed, based on the name of the tag string[] stringTagArray = tag.Split(' '); chapterNumber = Int32.Parse(stringTagArray[2]); Debug.Log("Number of finished chapter: " + chapterNumber); OpenChapterCompleteScreen(); //Opens the "chapter complete" screen } } //Presents the next batch of story text to the player (unless there is a text input field onscreen instead) if (textInputFieldOpen == false) { mostRecentStoryText = storyText.text; //Hangs onto the current story text in case the player saves the game and we need to reload at this point. AccessibleLabel label = storyText.gameObject.AddComponent(typeof(AccessibleLabel)) as AccessibleLabel; storyText.transform.SetParent(this.transform, false); //Parents the text gameObject to the canvas (this gameObject). UAP_AccessibilityManager.SelectElement(storyText.gameObject); } //Presents the next batch of dialogue choices to the player foreach (Choice choice in story.currentChoices) { Text choiceText = Instantiate(selectableTextPrefab) as Text; //Instantiates a selectable text gameObject. (Our substitute for a button) choiceText.gameObject.tag = "Dialogue choice"; choiceText.text = choice.text; choiceText.gameObject.name = choice.index.ToString(); //Names the text gameObject after the choice index it represents. choiceText.transform.SetParent(this.transform, false); //Parents the button gameObject to the canvas (this gameObject). } }
public LabelAccessibleObject(AccessibleLabel owner) : base(owner) { this.myowner = owner; }