public override BlockReturn Run(BlockReturn param)
        {
            var msg = new InventoryNoticeMessage(title.value, message.value, duration, color);
            msg.Show();

            return BlockReturn.OK;
        }
Exemplo n.º 2
0
        public virtual void Repaint(InventoryNoticeMessage message)
        {
            this.showTime = (int)message.duration;
            this.dateTime = message.time;

            if (string.IsNullOrEmpty(message.title) == false)
            {
                if (this.title != null)
                {
                    this.title.text = string.Format(message.title, message.parameters);
                    this.title.color = message.color;
                }
            }
            else
                title.gameObject.SetActive(false);


            this.message.text = string.Format(message.message, message.parameters);
            this.message.color = message.color;

            if (this.time != null)
            {
                this.time.text = dateTime.ToShortTimeString();
                this.time.color = message.color;
            }
        }
        public override void OnEnter()
        {
            var m = new InventoryNoticeMessage(title.Value, message.Value, duration, color.Value);

            if (item != null)
                m.Show(item.name, item.description);
            else
                m.Show();
        }
        public override TaskStatus OnUpdate()
        {
            var m = new InventoryNoticeMessage(title.Value, message.Value, duration, color.Value);

            if (item != null)
                m.Show(item.name, item.description);
            else
                m.Show();

            return TaskStatus.Success;
        }
        public virtual void AddMessage(InventoryNoticeMessage message)
        {
            // Fire even if we do the nullcheck, just incase other people want to use their own implementation.
            if (OnNewMessage != null)
                OnNewMessage(message, message.parameters);

            if (string.IsNullOrEmpty(message.message))
                return;

            bool scrollbarAtBottom = false;
            if (scrollRect != null && scrollRect.verticalScrollbar != null && scrollRect.verticalScrollbar.value < 0.05f)
                scrollbarAtBottom = true;

            // Incase we don't actually want to display anything and just port the data to some other class through events.
            if (noticeRowPrefab != null)
            {
                var item = pool.Get();
                //var item = GameObject.Instantiate<NoticeMessageUI>(noticeRowPrefab);
                item.transform.SetParent(container);
                item.transform.SetSiblingIndex(0); // Move to the top of the list
                item.SetMessage(message);

                if (onNewMessageAudioClip != null)
                    InventoryUIUtility.AudioPlayOneShot(onNewMessageAudioClip);

                messages.Add(item);
            }

            if (messages.Count > maxMessages)
            {
                StartCoroutine(DestroyAfter(messages[0], messages[0].hideAnimation.length));
                messages[0].Hide();
                messages.RemoveAt(0);
            }

            if (scrollbarAtBottom)
                scrollRect.verticalNormalizedPosition = 0.0f;
        }