private void DeployBubble(DialogueBubble speechBubble, Vector3 speakerPosition)
    {
        Vector2 speakerScreenPosition = dialogueCamera.WorldToScreenPoint(speakerPosition);

        float   relativeXdisplacment = (Camera.main.pixelWidth / 2.0f - speakerScreenPosition.x) / Camera.main.pixelWidth;
        float   relativeYdisplacment = (Camera.main.pixelHeight / 2.0f - speakerScreenPosition.y) / Camera.main.pixelHeight + 0.1f; // The dialogue should always be in the upper portion of the screen
        Vector2 displacementVector   = new Vector2(relativeXdisplacment, relativeYdisplacment);

        // The speech bubble needs to face in the same direction as the camera,
        // in order for the opaque side to show
        Vector3 awayFromCamera = Camera.main.transform.forward;
        //awayFromCamera.y = 0;
        Quaternion faceCameraRotation = Quaternion.LookRotation(awayFromCamera, Vector3.up);

        DialogueUIController.DeployDialogueBubbleAt(speechBubble, speakerPosition, displacementVector, faceCameraRotation);
    }
    //This hacky implementation is kind of bad but I really don't want to mess with making the animator do this
    public void init(Dialogue dialogue)
    {
        currentLineNumber = dialogue.currentPosition;
        activeDialogue    = dialogue;
        int speakingLineCount = activeDialogue.speakingLineCount;

        speechBubbles = new List <DialogueBubble>(speakingLineCount);
        randomSeedsX  = new List <float>(speakingLineCount);
        randomSeedsY  = new List <float>(speakingLineCount);

        for (int i = 0; i < speakingLineCount; i++)
        {
            DialogueBubble speechBubble = DialogueUIController.GenerateSpeechBubblePrefab();
            speechBubbles.Add(speechBubble);
            randomSeedsX.Add(Random.Range(-1.0f, 1.0f));
            randomSeedsY.Add(Random.Range(0f, 1.0f));
        }
    }
示例#3
0
    public override void Initial()
    {
        ScreenRatio  = Screen.height / Screen.width;
        _nextStepBtn = transform.GetComponent <Button>();
        _nextStepBtn.onClick.RemoveAllListeners();
        _nextStepBtn.onClick.AddListener(ClickBtn);

        _oneScene = transform.Find("One") as RectTransform;

        #region data
        graduation_image = _oneScene.Find("graduation_image").GetComponent <Image>();
        platform_image   = _oneScene.Find("platform_image").GetComponent <Image>();
        dialogueBox      = transform.Find("DialogueBox_Tetragonum").GetComponent <DialogueBoxTetragonumComponent>();
        papapa_image     = _oneScene.Find("papapa_image").GetComponent <Image>();
        papapa_text1     = papapa_image.transform.Find("Text1").GetComponent <Text>();
        papapa_text2     = papapa_image.transform.Find("Text2").GetComponent <Text>();

        compere_image           = _oneScene.Find("compere_image").GetComponent <Image>();
        compereHand_image       = compere_image.transform.Find("compereHand_image").GetComponent <Image>();
        compereHand2_image      = compere_image.transform.Find("compereHand2_image").GetComponent <Image>();
        appearOnTheStage0_image = transform.Find("appearOnTheStage0_image").GetComponent <Image>();
        appearOnTheStage1_image = appearOnTheStage0_image.transform.Find("appearOnTheStage1_image").GetComponent <Image>();
        appearOnTheStage2_image = appearOnTheStage0_image.transform.Find("appearOnTheStage2_image").GetComponent <Image>();
        appearOnTheStage3_image = appearOnTheStage0_image.transform.Find("appearOnTheStage3_image").GetComponent <Image>();
        appearOnTheStage4_image = appearOnTheStage0_image.transform.Find("appearOnTheStage4_image").GetComponent <Image>();
        lecture_image           = _oneScene.Find("lecture_image").GetComponent <Image>();
        passerby_image          = _oneScene.Find("passerby_image").GetComponent <Image>();
        passerbyDialgoue        = passerby_image.transform.Find("passerbyDialgoue").GetComponent <DialogueBubble>();
        groupPhoto_image        = _oneScene.Find("groupPhoto_image").GetComponent <Image>();
        white = groupPhoto_image.transform.Find("white").GetComponent <Image>();

        PhotoMaskTop    = transform.Find("PhotoMaskTop") as RectTransform;
        PhotoMaskBottom = transform.Find("PhotoMaskBottom") as RectTransform;
        photo_btn       = PhotoMaskBottom.Find("photo_btn").GetComponent <Button>();

        //下一步按钮
        save_btn     = _oneScene.Find("NextBtnGroup/SaveButton").GetComponent <Button>();
        savebtn_text = save_btn.transform.Find("Text").GetComponent <Text>();
        next_btn     = _oneScene.Find("NextBtnGroup/NextButton").GetComponent <Button>();
        nextbtn_text = next_btn.transform.Find("Text").GetComponent <Text>();
        #endregion
        base.Initial();
    }
    //Displays the a speech bubble according to its text and position in the overall dialogue
    public void DisplaySpeechBubble(SpeakingLineContent speakingLineContent, Vector3 speakerPosition)
    {
        int lineNumber = speakingLineContent.lineNumber;

        ready = false;
        Vector2 speakerScreenPosition = dialogueCamera.WorldToScreenPoint(speakerPosition);

        float relativeXdisplacment = (Camera.main.pixelWidth / 2.0f - speakerScreenPosition.x) / Camera.main.pixelWidth;
        float relativeYdisplacment = (Camera.main.pixelHeight / 2.0f - speakerScreenPosition.y) / Camera.main.pixelHeight + 0.1f; // The dialogue should always be in the upper portion of the screen

        Vector2 displacementVector = new Vector2(relativeXdisplacment, relativeYdisplacment);

        // *(offscreen dialogue we will need to handle seperately)
        DialogueBubble speechBubble = speechBubbles[lineNumber];

        speechBubble.SetDialogueBubbleContent(speakingLineContent);
        DialogueUIController.DeploySpeechBubbleAt(speechBubble, speakerPosition, displacementVector);

        StartCoroutine(animateLogs(lineNumber));
    }
    //Automatically animates the logs to the current state of the underlying dialogue data structure
    public IEnumerator animateLogs(int targetLineNumber)
    {
        // a bunch of the log advance/roll backwards stuff just isn't going to work with the current branching choice system
        // hacking it out so we always are looking at the latest dialogue
        currentLineNumber = dialogueBubbles.Count - 2;
        targetLineNumber  = dialogueBubbles.Count - 1;

        if (currentLineNumber != targetLineNumber)
        {
            int offset = targetLineNumber - currentLineNumber;

            //crappy concurrency lol
            float logTweenTime = 0.2f;
            float delta        = z_offset / logTweenTime * Time.deltaTime;

            while (logTweenTime > 0)
            {
                logTweenTime -= Time.deltaTime;
                for (int i = 0; i < dialogueBubbles.Count; i++)
                {
                    DialogueBubble animatedSpeechBubble = dialogueBubbles[i];
                    if (offset > 0)
                    {
                        if (targetLineNumber - offset <= i && i < targetLineNumber)
                        {
                            animatedSpeechBubble.transform.position += (Vector3.right * randomSeedsX[i] + Vector3.up * randomSeedsY[i]) * delta;
                        }
                    }
                    else
                    {
                        if (targetLineNumber <= i && i < targetLineNumber - offset)
                        {
                            animatedSpeechBubble.transform.position -= (Vector3.right * randomSeedsX[i] + Vector3.up * randomSeedsY[i]) * delta;
                        }
                    }
                    if (targetLineNumber - onScreenSpeechBubbleLimit < i && i <= targetLineNumber)
                    {
                        DialogueUIController.DeployDialogueBubble(animatedSpeechBubble);
                    }
                    // a bunch of the log advance/roll backwards stuff just isn't going to work with the current branching choice system, commenting out for now
                    if (i <= targetLineNumber - onScreenSpeechBubbleLimit)
                    {
                        DialogueUIController.HideDialogueBubble(animatedSpeechBubble);
                    }
                    if (i > targetLineNumber)
                    {
                        DialogueUIController.HideDialogueBubble(animatedSpeechBubble);
                    }
                    if (i == targetLineNumber)
                    {
                        animatedSpeechBubble.Focus();
                    }
                    int currentPosition = Mathf.Clamp(currentLineNumber - i, 0, onScreenSpeechBubbleLimit);
                    int targetPosition  = Mathf.Clamp(targetLineNumber - i, 0, onScreenSpeechBubbleLimit);
                    animatedSpeechBubble.transform.position += (targetPosition - currentPosition) * Vector3.forward * delta;
                }
                yield return(null);
            }
            for (int i = 0; i < dialogueBubbles.Count; i++)
            {
                if (i != targetLineNumber)
                {
                    dialogueBubbles[i].Blur();
                }
            }
            currentLineNumber = targetLineNumber;
        }

        // Audioooo
        AudioMaster.instance.PlayDialogueAdvanceSfx();

        yield return(new WaitForSeconds(0.2f));

        while (!Controls.confirmInputDown())
        {
            yield return(null);
        }

        ready = true;
    }
示例#6
0
 public static void DeployDialogueBubbleAt(DialogueBubble dialogueBubble, Vector3 speakerPosition, Vector2 displacementVector, Quaternion rotation)
 {
     dialogueBubble.gameObject.SetActive(true);
     dialogueBubble.DeployAt(speakerPosition, displacementVector, rotation);
 }
示例#7
0
 public static void DeploySpeechBubbleAt(DialogueBubble speechBubble, Vector3 speakerPosition, Vector2 displacementVector)
 {
     speechBubble.gameObject.SetActive(true);
     speechBubble.DeployAt(speakerPosition, displacementVector);
 }
 // Quick and fast way for other scripts to yell at the player?
 public void SummonDialogueBubble(string bubbleText, string title = "")
 {
     DialogueBubble.SummonDialogueBubble(bubbleText, title, DialogueBubblePrefab, DialogueBubbleCanvas.transform);
 }
    //Automatically animates the logs to the current state of the underlying dialogue data structure
    public IEnumerator animateLogs(int targetLineNumber)
    {
        Debug.Log(targetLineNumber);
        Debug.Log(currentLineNumber);
        if (currentLineNumber != targetLineNumber)
        {
            int offset = targetLineNumber - currentLineNumber;

            //crappy concurrency lol
            float logTweenTime = 0.2f;
            float delta        = z_offset / logTweenTime * Time.deltaTime;

            while (logTweenTime > 0)
            {
                logTweenTime -= Time.deltaTime;
                for (int i = 0; i < speechBubbles.Count; i++)
                {
                    DialogueBubble animatedSpeechBubble = speechBubbles[i];
                    if (offset > 0)
                    {
                        if (targetLineNumber - offset <= i && i < targetLineNumber)
                        {
                            animatedSpeechBubble.transform.position += (Vector3.right * randomSeedsX[i] + Vector3.up * randomSeedsY[i]) * delta;
                        }
                    }
                    else
                    {
                        if (targetLineNumber <= i && i < targetLineNumber - offset)
                        {
                            animatedSpeechBubble.transform.position -= (Vector3.right * randomSeedsX[i] + Vector3.up * randomSeedsY[i]) * delta;
                        }
                    }
                    if (targetLineNumber - onScreenSpeechBubbleLimit < i && i <= targetLineNumber)
                    {
                        DialogueUIController.DeploySpeechBubble(animatedSpeechBubble);
                    }
                    if (i <= targetLineNumber - onScreenSpeechBubbleLimit)
                    {
                        DialogueUIController.HideSpeechBubble(animatedSpeechBubble);
                    }
                    if (i > targetLineNumber)
                    {
                        DialogueUIController.HideSpeechBubble(animatedSpeechBubble);
                    }
                    if (i == targetLineNumber)
                    {
                        animatedSpeechBubble.Focus();
                    }
                    int currentPosition = Mathf.Clamp(currentLineNumber - i, 0, onScreenSpeechBubbleLimit);
                    int targetPosition  = Mathf.Clamp(targetLineNumber - i, 0, onScreenSpeechBubbleLimit);
                    animatedSpeechBubble.transform.position += (targetPosition - currentPosition) * Vector3.forward * delta;
                }
                yield return(null);
            }
            for (int i = 0; i < speechBubbles.Count; i++)
            {
                if (i != targetLineNumber)
                {
                    speechBubbles[i].Blur();
                }
            }
            currentLineNumber = targetLineNumber;
        }
        yield return(new WaitForSeconds(0.2f));

        while (!Controls.confirmInputDown())
        {
            yield return(null);
        }
        ready = true;
    }