예제 #1
0
    // For singular cards
    public void SetDialogQueue(DialogCard card)
    {
        // Refactor later for better performance?
        if (queue == null) Debug.LogError("Why is this null?");

        queue.LoadQueue(SplitCard(card));
        currentCard = queue.Next();
    }
예제 #2
0
 public void SetDialogQueue(DialogCard[] cards)
 {
     // Refactor later for better performance?
     if (queue == null) Debug.LogError("Why is this null?");
     // Time for terrible hacky code.
     // For each card, we divide the card at its return characters, and add a list of all these expanded cards to the queue
     List<DialogCard> expandedCards = new List<DialogCard>();
     foreach (DialogCard card in cards)
     {
         expandedCards.AddRange(SplitCard(card));
     }
     queue.LoadQueue(expandedCards.ToArray());
     currentCard = queue.Next();
 }
예제 #3
0
 public void DisplayNextCard()
 {
     if (backgroundImage.enabled == false)
     {
         backgroundImage.enabled = true;
         dialogText.enabled = true;
     }
     if (currentCard != null)
     {
         StartCoroutine("TranscribeDialog", currentCard);
         if (queue.HasNext())
         {
             currentCard = queue.Next();
         }
         else
             currentCard = null;
     }
     else
     {
         CleanDialogGUI();
     }
 }
예제 #4
0
    IEnumerator TranscribeDialog(DialogCard card)
    {
        dialogText.color = card.textColor;
        audio.Play();

        while (charactersShowing <= card.dialog.Length - 1)
        {
            float speedMultiplier = 1f;
            int charactersInLastFrame = Mathf.FloorToInt(charactersShowing);
            string textToDisplay = "";

            charactersShowing += Time.deltaTime * card.textSpeed * speedMultiplier / 60f;

            int locationOfColorSymbol = card.dialog.Substring(charactersInLastFrame,
                Mathf.FloorToInt(charactersShowing) - charactersInLastFrame).IndexOf("*");

            // WARNING - could break if the machine somehow gets past both *s in one update
            // Also if keyword is last character
            if (locationOfColorSymbol != -1)
            {
                if (!colorTagOpen)
                {
                    // Tag length minus one for the * we are deleting
                    charactersShowing += 16f;
                    // Replace original card text with a rich-text coded string
                    card.dialog = card.dialog.Substring(0, charactersInLastFrame + locationOfColorSymbol) + "<color=#"
                        + ColorToHex(itemTextColor) + ">" + card.dialog.Substring(charactersInLastFrame
                            + locationOfColorSymbol + 1);
                    colorTagOpen = true;
                }
                else
                {
                    charactersShowing += 7f;
                    // Replace original card text with a rich-text coded string
                    card.dialog = card.dialog.Substring(0, charactersInLastFrame + locationOfColorSymbol) + "</color>"
                        + card.dialog.Substring(charactersInLastFrame + locationOfColorSymbol + 1);
                    colorTagOpen = false;
                }
            }
            if (colorTagOpen)
            {
                textToDisplay = card.dialog.Substring(0, Mathf.FloorToInt(charactersShowing)) + "</color>";
            }
            else
            {
                textToDisplay = dialogText.text = card.dialog.Substring(0, Mathf.FloorToInt(charactersShowing));
            }
            dialogText.text = textToDisplay;

            yield return null;
        }

        dialogText.text = card.dialog;
        allTextDisplayed = true;
        charactersShowing = 0;
        audio.Stop();
    }
예제 #5
0
    private DialogCard[] SplitCard(DialogCard card)
    {
        string[] parts = card.dialog.Split('\n');
        DialogCard[] cards = new DialogCard[parts.Length];

        for (int i = 0; i < parts.Length; i++)
        {
            cards[i] = new DialogCard(card.textSpeed, parts[i]);
            cards[i].textColor = card.textColor;
            cards[i].backgroundColor = card.backgroundColor;
        }
        return cards;
    }
예제 #6
0
 public void CleanDialogGUI()
 {
     audio.Stop();
     allTextDisplayed = false;
     colorTagOpen = false;
     backgroundImage.enabled = false;
     dialogText.text = "";
     dialogText.enabled = true;
     currentCard = null;
 }
예제 #7
0
	public void LoadQueue(DialogCard[] cards) {
		queue = cards;
		dialogPointer = 0;
	}