private Line prepareLine()
    {
        Line line = _currentDialogue.Lines[_dialogueProgress];

        for (int i = 0; i < _characterImages.Length; i++)
        {
            //Disable any extra images
            if (i >= line.LineCharacters.Length)
            {
                _characterImages[i].gameObject.SetActive(false); continue;
            }

            LineCharacter lineCharacter = line.LineCharacters[i];

            if (!lineCharacter.HasCharacter)
            {
                Debug.LogWarning("LineCharacter of index " + i + " in the dialogue " + _currentDialogue.name + " is not assigned.");
                _characterImages[i].gameObject.SetActive(false);
                continue;
            }

            Sprite characterExpression = line.GetCharacterExpression(lineCharacter);
            if (lineCharacter.HideCharacterImage || characterExpression == null)
            {
                _characterImages[i].gameObject.SetActive(false);
                continue;
            }
            _characterImages[i].gameObject.SetActive(true);
            _characterImages[i].sprite = characterExpression;
        }

        //Handle normal and localized names
        LineCharacter speaker = line.GetSpeaker();

        if (speaker.CharacterNameIsLocalized)
        {
            _speechNameLocalizedStingEvent.StringReference = speaker.GetLocalizedName();
            _speechNameLocalizedStingEvent.enabled         = true;
        }
        else
        {
            _speechNameLocalizedStingEvent.GetComponent <TextMeshProUGUI>().text = speaker.GetName();
            _speechNameLocalizedStingEvent.enabled = false;
        }
        _clickToContinue.SetActive(false);

        //Force update the canvas, so that the speaker name box is the correct size
        Canvas.ForceUpdateCanvases();
        _speechNameLocalizedStingEvent.gameObject.SetActive(false);
        _speechNameLocalizedStingEvent.gameObject.SetActive(true);

        //Disregard fuctions if they are not set
        if (line.BackgroundSprite != null)
        {
            _backgroundImage.sprite = line.BackgroundSprite;
        }
        if (line.AmbientSoundToStartPlaying != null)
        {
            SoundManager.Instance.PlayNewAmbientClip(line.AmbientSoundToStartPlaying);
        }

        return(line);
    }
Ejemplo n.º 2
0
 public Sprite GetCharacterExpression(LineCharacter pLineCharacter)
 {
     return(pLineCharacter.GetExpression());
 }