Beispiel #1
0
    // ------------------------------------------------------------------------
    private void DrawChatOptions(Message message)
    {
        if (message == null)
        {
            Debug.LogError("Message null.");
            return;
        }
        if (!message.Player)
        {
            Debug.LogError("Hecked up script config. NPC has chat options.");
            return;
        }
        if (!message.HasOptions())
        {
            Debug.LogError("Attempting to draw options for message with no options.");
            return;
        }

        // if we've answered this question multiple times, mark this convo done
        if (m_activeChat.VisitedMessages.FindAll(m => m.Node == message.Node).Count > 1)
        {
            FinishConvo();
            return;
        }

        for (int i = 0; i < message.Options.Length; i++)
        {
            // if we've already been to this conversation option,
            // skip drawing whatever option we selected last time
            if (message.MadeSelection() && i == message.OptionSelection)
            {
                continue;
            }

            // draw bubble
            GameObject option = Instantiate(
                MessageOptionPrefab,
                ChatOptionsParent
                ) as GameObject;

            // setup bubble
            MessageButton messageButton = option.GetComponent <MessageButton>();

            // check if clue needs met
            if (PhoneOS.ClueRequirementMet(message.ClueNeeded[i]))
            {
                // set button text & hook up option function
                messageButton.Text.text = message.Options[i];
                SetButtonListener(messageButton.Button, message, i);
                //Debug.Log("created option [" + message.options[i] + "] with index " + i + " for message " + message.node);
            }
            else
            {
                // mark it as unavilable
                messageButton.Text.text = "[clue needed]";
            }
        }
    }
Beispiel #2
0
    public override void Open()
    {
        base.Open();

        int i = 1;

        foreach (ForumPostData post in PhoneOS.ActiveForumPosts)
        {
            GameObject postObj = Instantiate(
                ForumPostPrefab,
                ForumPostParent)
                                 as GameObject;

            ForumPostUI postUI = postObj.GetComponent <ForumPostUI>();
            if (postUI)
            {
                // set all basic info
                postUI.TitleText.text    = post.Title;
                postUI.UsernameText.text = "u/" + post.Username;
                postUI.MetaInfoText.text = post.NumComments
                                           + " comments / posted "
                                           + post.Time
                                           + " hours ago";
                postUI.BodyText.text = post.Body;

                // tint every other image
                if (i % 2 == 0)
                {
                    postUI.BackgroundImg1.color *= 1.2f;
                    postUI.BackgroundImg2.color *= 1.2f;
                }
                i++;

                // load profile icon
                Sprite icon = PhoneOS.UserIconAssets[post.Icon];
                if (icon)
                {
                    postUI.ProfileImage.sprite = icon;
                }

                // load post image
                postUI.SetPhotoContent(post, PhoneOS);

                // let phone OS know when we encounter this post
                postUI.OpenPostButton.onClick.AddListener(
                    delegate { PhoneOS.FoundClue(post.ClueGiven); }
                    );
            }
        }
    }
Beispiel #3
0
 private void PopulateNotes()
 {
     foreach (ClueID clue in clueNotes.Keys)
     {
         if (PhoneOS.ClueRequirementMet(clue))
         {
             GameObject noteObj = Instantiate(NotePrefab, NotesParent);
             NoteUI     noteUI  = noteObj.GetComponent <NoteUI>();
             if (noteUI)
             {
                 noteUI.Text.text = clueNotes[clue];
             }
         }
     }
 }
Beispiel #4
0
    // ------------------------------------------------------------------------
    // Methods : Conversation coroutines
    // ------------------------------------------------------------------------
    private IEnumerator RunMessage(Message message)
    {
        if (message == null)
        {
            Debug.LogError("Message null.");
            yield break;
        }

        // record that we visited this message (don't force)
        m_activeChat.VisitMessage(message, false);

        // draw either player or friend messages
        if (message.Player)
        {
            // if this has options, draw them; otherwise, draw messages
            if (message.HasOptions())
            {
                DrawChatOptions(message);
            }
            else
            {
                m_drawBubblesCoroutine = RunChatBubbles(message, PlayerChatBubblePrefab);
                yield return(StartCoroutine(m_drawBubblesCoroutine));
            }
        }
        else
        {
            m_drawBubblesCoroutine = RunChatBubbles(message, FriendChatBubblePrefab);
            yield return(StartCoroutine(m_drawBubblesCoroutine));
        }

        // record any clues found
        if (message.ClueGiven != ClueID.NoClue)
        {
            PhoneOS.FoundClue(message.ClueGiven);
        }

        // if we're not waiting on an option selection, draw the next message
        if (!message.HasOptions())
        {
            MoveConversation();
        }
    }
Beispiel #5
0
    // ------------------------------------------------------------------------
    // Methods : Conversation running
    // ------------------------------------------------------------------------
    // i know this creates some duplicated code,
    // but avoiding the coroutines is a lot more convienent
    // for just wanting to draw all of the read messages with no delay
    private void FillChatWithVisitedMessages()
    {
        foreach (Message message in m_activeChat.VisitedMessages)
        {
            // record any clues found
            // in case the player missed them last time
            if (message.ClueGiven != ClueID.NoClue)
            {
                PhoneOS.FoundClue(message.ClueGiven);
            }

            // draw the message
            if (message.Player)
            {
                if (message.HasOptions())
                {
                    if (message.MadeSelection())
                    {
                        DrawChatBubble(message, 0, PlayerChatBubblePrefab);
                    }
                    else
                    {
                        DrawChatOptions(message);
                    }
                }
                else
                {
                    for (int i = 0; i < message.Messages.Length; i++)
                    {
                        DrawChatBubble(message, i, PlayerChatBubblePrefab);
                    }
                }
            }
            else
            {
                for (int i = 0; i < message.Messages.Length; i++)
                {
                    DrawChatBubble(message, i, FriendChatBubblePrefab);
                }
            }
        }
        m_needsScroll = true;
    }