Inheritance: MonoBehaviour
Ejemplo n.º 1
0
    IEnumerator fakeFeed()
    {
        chatterOpen = true;
        GameObject player = GameObject.FindGameObjectWithTag("Player");

        transform.position = player.transform.position;
        transform.rotation = player.transform.rotation;

        for (int i = 0; i < 15; i++)
        {
            int   panelNum = i / 3;
            int   itemNum  = i % 3;
            float offset   = Random.Range(-0.03f, 0.03f);

            yield return(new WaitForSeconds(chatterWaitTime));

            GameObject obj = (GameObject)Instantiate(Resources.Load("Chatter Item"));
            obj.transform.SetParent(panels[panelNum].transform);
            ChatterItem newItem = obj.GetComponent <ChatterItem>();
            newItem.init(i);

            obj.transform.localPosition = new Vector3(offset, 0.35f - (itemNum * 0.29f) + (offset / 10f), offset);
            obj.transform.localScale    = new Vector3(0.07f, 0.07f, 0.07f);
            obj.transform.localRotation = Quaternion.identity;

            newItem.GetComponent <Animator>().Play("Chatter Item Open");
            newItem.GetComponent <AudioSource>().Play();
        }
    }
Ejemplo n.º 2
0
        public void SendMessage(string Text, Player Speaker = null, bool Host = false)
        {
            if (CurrentRoom.IsHost(App.CurrentUser))
            {
                foreach (var Client in App.Server)
                {
                    Client.SendAsync(Encoding.UTF8.GetBytes("ChatMessage|*|" +
                                                            (Speaker?.Id.ToString() ?? "System") + "|*|" + Text));
                }
            }
            else
            {
                App.Client.SendAsync(Encoding.UTF8.GetBytes("ChatMessage|*|" +
                                                            (Speaker?.Id.ToString() ?? "System") + "|*|" + Text));
            }

            bool        ScrollToBottom = ChatScrollViewer.HorizontalOffset >= ChatStack.ActualHeight - ChatScrollViewer.ActualHeight;
            ChatterItem Item           = new ChatterItem();

            Item.Init(Text, Speaker, Host);

            Item.Opacity = 0;
            ChatStack.Children.Add(Item);
            var HeightAnimation = new DoubleAnimation()
            {
                From           = ChatStack.ActualHeight,
                To             = ChatStack.Children.OfType <FrameworkElement>().Sum(O => O.Height),
                Duration       = TimeSpan.FromSeconds(0.3),
                EasingFunction = new ExponentialEase()
                {
                    EasingMode = EasingMode.EaseInOut
                }
            };

            HeightAnimation.Completed += delegate
            {
                Item.BeginAnimation(OpacityProperty, new DoubleAnimation()
                {
                    From           = 0,
                    To             = 1,
                    Duration       = TimeSpan.FromSeconds(0.2),
                    EasingFunction = new ExponentialEase()
                    {
                        EasingMode = EasingMode.EaseInOut
                    }
                });
                if (ScrollToBottom)
                {
                    ChatScrollViewer.ScrollToBottom();
                }
            };
            ChatStack.BeginAnimation(HeightProperty, HeightAnimation);
        }
Ejemplo n.º 3
0
    IEnumerator getPhoto(string url, ChatterItem item)
    {
        sf.getChatterPhoto(url);

        // wait for query results
        while (sf.response == null)
        {
            yield return(new WaitForSeconds(0.1f));
        }

        item.photoImage.enabled = true;
        item.photoImage.texture = sf.sfTexture;
        item.photoRetrieved     = true;
    }
Ejemplo n.º 4
0
    IEnumerator popinFeed()
    {
        yield return(new WaitForSeconds(0.5f));

        int num = 0;

        chatterOpen           = true;
        raycaster.chatterOpen = true;
        GameObject player = GameObject.FindGameObjectWithTag("Player");

        transform.position = player.transform.position;
        transform.rotation = player.transform.rotation;

        foreach (JSONValue row in chatterArray)
        {
            int   panelNum = num / 3;
            int   itemNum  = num % 3;
            float offset   = Random.Range(-0.03f, 0.03f);

            yield return(new WaitForSeconds(chatterWaitTime));

            JSONObject rec = JSONObject.Parse(row.ToString());
            GameObject obj = (GameObject)Instantiate(Resources.Load("Chatter Item"));
            obj.transform.SetParent(panels[panelNum].transform);
            ChatterItem newItem = obj.GetComponent <ChatterItem>();
            newItem.initMain(rec, this);

            obj.transform.localPosition = new Vector3(offset, 0.35f - (itemNum * 0.29f) + (offset / 10f), offset);
            obj.transform.localScale    = new Vector3(0.07f, 0.07f, 0.07f);
            obj.transform.localRotation = Quaternion.identity;

            newItem.GetComponent <Animator>().Play("Chatter Item Open");
            newItem.GetComponent <AudioSource>().Play();

            num++;
        }

        GameObject[] items = GameObject.FindGameObjectsWithTag("Chatter Item");
        foreach (GameObject item in items)
        {
            ChatterItem chatterItem = item.GetComponent <ChatterItem>();
            chatterItem.getPhoto();

            while (!chatterItem.photoRetrieved)
            {
                yield return(new WaitForSeconds(0.1f));
            }
        }
    }
Ejemplo n.º 5
0
        public ProgressItem BeginProgress(string Description, double Length)
        {
            bool        ScrollToBottom = ChatScrollViewer.HorizontalOffset >= ChatStack.ActualHeight - ChatScrollViewer.ActualHeight;
            ChatterItem Item           = new ChatterItem();
            var         ProgressItem   = Item.SystemProgressInit(Description, Length);

            Item.Opacity = 0;
            ChatStack.Children.Add(Item);
            var HeightAnimation = new DoubleAnimation()
            {
                From           = ChatStack.ActualHeight,
                To             = ChatStack.Children.OfType <FrameworkElement>().Sum(O => O.Height),
                Duration       = TimeSpan.FromSeconds(0.3),
                EasingFunction = new ExponentialEase()
                {
                    EasingMode = EasingMode.EaseInOut
                }
            };

            HeightAnimation.Completed += delegate
            {
                Item.BeginAnimation(OpacityProperty, new DoubleAnimation()
                {
                    From           = 0,
                    To             = 1,
                    Duration       = TimeSpan.FromSeconds(0.2),
                    EasingFunction = new ExponentialEase()
                    {
                        EasingMode = EasingMode.EaseInOut
                    }
                });
                if (ScrollToBottom)
                {
                    ChatScrollViewer.ScrollToBottom();
                }
            };
            ChatStack.BeginAnimation(HeightProperty, HeightAnimation);

            return(ProgressItem);
        }
Ejemplo n.º 6
0
        public void SendMessageAlone(string Text, Player Speaker = null, bool Host = false)
        {
            bool        ScrollToBottom = ChatScrollViewer.HorizontalOffset >= ChatStack.ActualHeight - ChatScrollViewer.ActualHeight;
            ChatterItem Item           = new ChatterItem();

            Item.Init(Text, Speaker, Host);

            Item.Opacity = 0;
            ChatStack.Children.Add(Item);
            var HeightAnimation = new DoubleAnimation()
            {
                From           = ChatStack.ActualHeight,
                To             = ChatStack.Children.OfType <FrameworkElement>().Sum(O => O.Height),
                Duration       = TimeSpan.FromSeconds(0.3),
                EasingFunction = new ExponentialEase()
                {
                    EasingMode = EasingMode.EaseInOut
                }
            };

            HeightAnimation.Completed += delegate
            {
                Item.BeginAnimation(OpacityProperty, new DoubleAnimation()
                {
                    From           = 0,
                    To             = 1,
                    Duration       = TimeSpan.FromSeconds(0.2),
                    EasingFunction = new ExponentialEase()
                    {
                        EasingMode = EasingMode.EaseInOut
                    }
                });
                if (ScrollToBottom)
                {
                    ChatScrollViewer.ScrollToBottom();
                }
            };
            ChatStack.BeginAnimation(HeightProperty, HeightAnimation);
        }
Ejemplo n.º 7
0
 public void getChatterPhoto(string url, ChatterItem item)
 {
     StartCoroutine(getPhoto(url, item));
 }
Ejemplo n.º 8
0
    IEnumerator getPhoto(string url, ChatterItem item)
    {
        sf.getChatterPhoto (url);

        // wait for query results
        while(sf.response == null){
            yield return new WaitForSeconds(0.1f);
        }

        item.photoImage.enabled = true;
        item.photoImage.texture = sf.sfTexture;
        item.photoRetrieved = true;
    }
Ejemplo n.º 9
0
 public void getChatterPhoto(string url, ChatterItem item)
 {
     StartCoroutine(getPhoto(url, item));
 }