コード例 #1
0
ファイル: ForumApp.cs プロジェクト: sogoodgames/peach
    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); }
                    );
            }
        }
    }
コード例 #2
0
ファイル: ChatApp.cs プロジェクト: sogoodgames/peach
    // ------------------------------------------------------------------------
    // 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();
        }
    }
コード例 #3
0
ファイル: ChatApp.cs プロジェクト: sogoodgames/peach
    // ------------------------------------------------------------------------
    // 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;
    }