Beispiel #1
0
        public DialogEntry(PersonState spkr, Sprite[] sprs, string msg, bool isInfo, bool isInfoRequest, AudioClipIndex audioClip, bool isCustom = false, UISentenceCallback callback = null, List <string> subjects = null, List <string> objects = null)
        {
            speaker               = spkr;
            sprites               = sprs;
            message               = msg;
            isInfoExchange        = isInfo;
            isInfoExchangeRequest = isInfoRequest;

            this.audio = audioClip;

            isCustomSentence       = isCustom;
            customSentenceCallback = callback;
            subjectOverrides       = subjects;
            objectOverrides        = objects;
        }
Beispiel #2
0
 public void QueueCustomSentence(PersonState speaker, Sprite[] sprites, string[] optionsA, string[] optionsB, UISentenceCallback callback)
 {
     mDialogEntries.Add(new DialogEntry(speaker, sprites, "", false, false, AudioClipIndex.NONE, true, callback, new List <string>(optionsA), new List <string>(optionsB)));
 }
Beispiel #3
0
 // Displays the sentence-construction UI.
 public void AskForSentence(Sprite[] images, UISentenceCallback sentenceCallback, List <string> subjectOverrides = null, List <string> objectOverrides = null)
 {
     ShowUISentence(images, sentenceCallback, subjectOverrides, objectOverrides);
 }
Beispiel #4
0
    private void ShowUISentence(Sprite[] sprites, UISentenceCallback callback, List <string> subjectOverrides = null, List <string> objectOverrides = null)
    {
        // Show the Journal, so that the player can give a good clue
        ShowJournal();

        // Make the UI visible
        transform.Find("dialogView").gameObject.SetActive(true);
        transform.Find("dialogView/V overlay/dialog").gameObject.SetActive(false);
        transform.Find("dialogView/V overlay/H buttons").gameObject.SetActive(false);
        transform.Find("dialogView/V overlay/H sentenceBuilder").gameObject.SetActive(true);

        // Display sprites
        // Hide extra sprites and create new sprites as needed
        Transform spriteContainer = transform.Find("dialogView/H images");

        for (int i = 0; i < Mathf.Max(sprites.Length, spriteContainer.childCount); i++)
        {
            Image image;
            if (i < spriteContainer.childCount)
            {
                image = spriteContainer.GetChild(i).GetComponent <Image>();
            }
            else
            {
                image = Instantiate(spriteContainer.GetChild(0), spriteContainer).GetComponent <Image>();
            }
            image.gameObject.SetActive(i < sprites.Length);
            if (i < sprites.Length)
            {
                // A null sprite can take up space
                image.color = sprites[i] == null ? new Color(0, 0, 0, 0) : Color.white;
                // Update a visible sprite
                image.sprite = null; // clear sprite to reset size information
                image.sprite = sprites[i];
            }
        }

        // Set the list of options to the list of discovered words.
        // Default to having discovered the hair colors of people other than yourself.
        List <Noun> knownWords = GameState.Get().Player.knowledge.KnownWords.ToList();

        knownWords.Sort();
        List <string> knownWordStrings = knownWords.ConvertAll <string>(noun => noun.ToString());

        Transform sentenceBuilder = transform.Find("dialogView/V overlay/H sentenceBuilder");
        Dropdown  subjectDropdown = sentenceBuilder.Find("Subject").GetComponent <Dropdown>();

        subjectDropdown.ClearOptions();
        if (subjectOverrides != null)
        {
            subjectDropdown.AddOptions(subjectOverrides);
        }
        else
        {
            subjectDropdown.AddOptions(knownWordStrings);
        }
        subjectDropdown.RefreshShownValue();

        Dropdown objectDropdown = sentenceBuilder.Find("DirectObject").GetComponent <Dropdown>();

        objectDropdown.ClearOptions();
        if (objectOverrides != null)
        {
            objectDropdown.AddOptions(objectOverrides);
        }
        else
        {
            List <string> tmp = new List <string>();
            tmp.Add(UNSELECTED_DROPDOWN_VALUE);
            objectDropdown.AddOptions(tmp);
            objectDropdown.AddOptions(knownWordStrings);
        }
        objectDropdown.RefreshShownValue();

        mSentenceCallback = callback;
        EventSystem.current.GetComponent <EventSystem>().SetSelectedGameObject(subjectDropdown.gameObject);
    }