protected void CreateDialogChoices() { if (Conv.Continues) { float offset = 0.0f; float fadeDelay = 0.05f; List <Exchange> RunningOutgoingChoices = Conv.RunningOutgoingChoices; List <GUIConversationBubble> choices = new List <GUIConversationBubble> (); foreach (Exchange outgoingChoice in RunningOutgoingChoices) { GameObject newPlayerDialogChoiceGameObject = NGUITools.AddChild(PlayerDialogChoicesParent, PlayerDialogChoicePrototype); GUIPlayerDialogChoice playerDialogChoice = newPlayerDialogChoiceGameObject.GetComponent <GUIPlayerDialogChoice> (); playerDialogChoice.Choice = outgoingChoice; playerDialogChoice.ChoiceButtonMessage.target = gameObject; playerDialogChoice.ChoiceButtonMessage.functionName = "MakeDialogChoice"; playerDialogChoice.gameObject.name = "Choice_" + outgoingChoice.Name; GUIConversationBubble bubble = playerDialogChoice.GetComponent <GUIConversationBubble> (); bubble.FadedColor = (outgoingChoice.NumTimesChosen > 0); bubble.FadeDelay = fadeDelay; bubble.EnableAutomatically = false; playerDialogChoice.Offset = offset; bubble.SetProps(outgoingChoice.CleanPlayerDialog, Colors.Get.ConversationPlayerBackground, Colors.Get.ConversationPlayerOption); offset -= bubble.Height; fadeDelay += 0.05f; choices.Add(bubble); } PlayerDialogChoicesScrollbar.scrollValue = 0.0f; PlayerDialogChoicesScrollbar.ForceUpdate(); StartCoroutine(WaitForDialogChoicesToBeReady(choices)); } }
public void ClearSpeeches() { //Debug.Log("Clearing speeches"); GUIManager.Get.ReleaseFocus(this); mCurrentSpeech = CharacterSpeech.Empty; mUpdatingSpeeches = false; Get.mSpeechesToDisplay.Clear(); if (CurrentBubble != null) { CurrentBubble.DestroyBubble(); CurrentBubble = null; } }
protected void ClearDialogChoices() { List <Transform> childrenToMove = new List <Transform> (); foreach (Transform child in PlayerDialogChoicesParent.transform) { childrenToMove.Add(child); } foreach (Transform childToMove in childrenToMove) { GUIConversationBubble bubble = childToMove.GetComponent <GUIConversationBubble> (); bubble.DestroyBubble(); childToMove.parent = childToMove.parent.parent; } PlayerDialogChoicesScrollbar.scrollValue = 0f; PlayerDialogChoicesScrollbar.ForceUpdate(); }
protected void CreateNextPageChoice() { GameObject newPlayerDialogChoiceGameObject = NGUITools.AddChild(PlayerDialogChoicesParent, PlayerDialogChoicePrototype); GUIPlayerDialogChoice playerDialogChoice = newPlayerDialogChoiceGameObject.GetComponent <GUIPlayerDialogChoice> (); playerDialogChoice.Choice = null; playerDialogChoice.ChoiceButtonMessage.target = gameObject; playerDialogChoice.ChoiceButtonMessage.functionName = "MakeDialogChoice"; playerDialogChoice.gameObject.name = "Choice_" + (-1).ToString(); playerDialogChoice.transform.localPosition = new Vector3(0f, -250f, 0f); GUIConversationBubble bubble = playerDialogChoice.GetComponent <GUIConversationBubble> (); bubble.EnableAutomatically = true; bubble.FadedColor = false; bubble.FadeDelay = 0.05f; bubble.SetProps("(More)", Colors.Get.ConversationPlayerBackground, Colors.Get.ConversationPlayerOption); playerDialogChoice.Offset = 0.0f; }
protected GUIConversationBubble CreateBubble(bool obex) { if (VRManager.VRMode) { BubbleParent.transform.localPosition = VROffset; } else { BubbleParent.transform.localPosition = DefaultOffset; } //create the new conversation bubble GameObject newBubbleGameObject = NGUITools.AddChild(BubbleParent, obex ? ConversationBubblePrototypeObex : ConversationBubblePrototype); GUIConversationBubble bubble = newBubbleGameObject.GetComponent <GUIConversationBubble> (); //bubble.SetProps (mCurrentSpeech.Speech, mCurrentSpeech.CharacterName, CharacterColor, Colors.Get.MenuButtonTextColorDefault); bubble.FadedColor = false; bubble.FadeDelay = 0.125f; bubble.transform.localPosition = new Vector3(-bubble.Collider.center.x, 0f, -10f); return(bubble); }
protected IEnumerator UpdateSpeeches() { //Debug.Log("Updating speeches now"); if (!HasFocus) { if (!GUIManager.Get.GetFocus(this)) { //Debug.Log("Couldn't get focus, not updating speeches"); ClearSpeeches(); yield break; } } mCurrentSpeech = mSpeechesToDisplay.Dequeue(); if (mCurrentSpeech.IsEmpty) { yield break; } mCurrentSpeech.StartTime = WorldClock.AdjustedRealTime; CharacterColor = Colors.Saturate(Colors.ColorFromString(mCurrentSpeech.CharacterName, 100)); Panel.enabled = true; if (CurrentBubble != null && !CurrentBubble.IsDestroying) { //we may be able to use the same bubble //if the character's name is the same if (mCurrentSpeech.CharacterName != CurrentBubble.CharacterName.text || mCurrentSpeech.ObexFont != mCurrentSpeech.ObexFont) { CurrentBubble.DestroyBubble(); CurrentBubble = CreateBubble(mCurrentSpeech.ObexFont); } } else { CurrentBubble = CreateBubble(mCurrentSpeech.ObexFont); } //set the properties on the speech bubble //it will fade in on its own CurrentBubble.SetProps(mCurrentSpeech.Speech, mCurrentSpeech.CharacterName, CharacterColor, Colors.Get.MenuButtonTextColorDefault); while (CurrentBubble.Alpha < 1f) { //Debug.Log("Waiting for alwpha to hit 1..."); if (!HasFocus || mCurrentSpeech.IsEmpty || GUIManager.Get.HasActivePrimaryInterface || GUIManager.Get.HasActiveSecondaryInterface) { ClearSpeeches(); yield break; } yield return(null); } //now wait for the speech duration to end before making it fade out double waitUntil = mCurrentSpeech.StartTime + (mCurrentSpeech.Duration * Profile.Get.CurrentPreferences.Accessibility.OnScreenTextSpeed); while (WorldClock.AdjustedRealTime < waitUntil) { //Debug.Log("Waiting until finished..."); if (!HasFocus || mCurrentSpeech.IsEmpty || GUIManager.Get.HasActivePrimaryInterface || GUIManager.Get.HasActiveSecondaryInterface) { ClearSpeeches(); yield break; } yield return(null); } if (!HasFocus || mCurrentSpeech.IsEmpty) { ClearSpeeches(); yield break; } //now let it fade out on its own CurrentBubble.SetProps(string.Empty, string.Empty, CharacterColor, Colors.Get.MenuButtonTextColorDefault); while (CurrentBubble.Alpha > 0f) { //Debug.Log("Waiting for alwpha to hit 0..."); if (!HasFocus || mCurrentSpeech.IsEmpty || GUIManager.Get.HasActivePrimaryInterface || GUIManager.Get.HasActiveSecondaryInterface) { ClearSpeeches(); yield break; } yield return(null); } //if we're all done then fade out and close the panel over time if (mSpeechesToDisplay.Count > 0) { //Debug.Log("Getting next speech..."); //whoops, one was added while we were waiting //re-start this coroutine and exit immediately StartCoroutine(UpdateSpeeches()); yield break; } ClearSpeeches(); mUpdatingSpeeches = false; yield break; }