Example #1
0
 public void Abort()
 {
     textQueue.Clear();
     textPlayer.Abort();
     textBox.hide();
     currentText = null;
 }
Example #2
0
    private void advanceText()
    {
        currentDuration = 0;

        if (currentText != null)
        {
            if (currentText.callback != null)
            {
                currentText.callback();
            }
        }

        if (textQueue.Count > 0)
        {
            if (textQueue[0].text.text.Length > 0)
            {
                textBox.show();
            }
            else
            {
                textBox.hide();
            }
            currentText = textQueue[0];
            textQueue.RemoveAt(0);
            textFinishedPlaying = false;
            textPlayer.PlayText(currentText.text, onTextPlayed);
            Sounds.PlayOneShot(Sounds.instance.advanceText, .4f);
        }
        else
        {
            reset();
        }
    }
Example #3
0
    public void Enqueue(List <TextData> text, bool force = false)
    {
        if (text.Count == 0)
        {
            return;
        }

        if (force)
        {
            textQueue.Clear();
            currentText     = null;
            currentDuration = 0;
        }
        text.ForEach((q) => { textQueue.Add(new QueuedText(q, null)); });
    }
        protected override void OnUpdate(ref UpdateParams p)
        {
            base.OnUpdate(ref p);

            // compensate for the level's scaling.
            //Motion.Scale = 1f / Parent.Motion.Scale;

            if (q.Count > 0)
            {
                // clean up q - items that should be removed
                List <QueuedText> toRemove = new List <QueuedText>();
                foreach (QueuedText t in q)
                {
                    if (t.Text.Delete == true)
                    {
                        toRemove.Add(t);
                    }
                }
                foreach (QueuedText t in toRemove)
                {
                    q.Remove(t);
                }

                // check which item should be displayed
                // the highest priority one which is earliest in queue
                int        highestPri = -32000;
                QueuedText winnerItem = null;
                foreach (QueuedText t in q)
                {
                    // by default, text is not active. Only the winning text will be.
                    t.Text.Active = false;
                    if (t.Priority > highestPri && t.Text.StartTime <= SimTime)
                    {
                        highestPri = t.Priority;
                        winnerItem = t;
                    }
                }

                // activate only the winning item
                if (winnerItem != null)
                {
                    currentItem             = winnerItem;
                    currentItem.Text.Active = true;
                }
            }
        }
Example #5
0
        public void OnUpdate(ScriptContext p)
        {
            if (q.Count == 0)
            {
                return;
            }

            // clean up q - items that should be removed
            List <QueuedText> toRemove = new List <QueuedText>();

            foreach (QueuedText t in q)
            {
                if (!t.Text.IsActive)
                {
                    toRemove.Add(t);
                }
            }
            foreach (QueuedText t in toRemove)
            {
                q.Remove(t);
            }

            // check which item should be displayed
            // the highest priority one which is earliest in queue
            int        highestPri = -32000;
            QueuedText winnerItem = null;

            foreach (QueuedText t in q)
            {
                // by default, text is not active. Only the winning text will be.
                t.Text.IsEnabled = false;
                if (t.Priority > highestPri /*&& t.Text.StartTime <= SimTime */)
                {
                    highestPri = t.Priority;
                    winnerItem = t;
                }
            }

            // activate only the winning item
            if (winnerItem != null)
            {
                currentItem = winnerItem;
                currentItem.Text.IsEnabled = true;
            }
        }
        public void OnUpdate(ScriptContext p)
        {
            if (q.Count == 0)
                return;

            // clean up q - items that should be removed
            List<QueuedText> toRemove = new List<QueuedText>();
            foreach (QueuedText t in q)
            {
                if (!t.Text.IsActive)
                    toRemove.Add(t);
            }
            foreach (QueuedText t in toRemove)
            {
                q.Remove(t);
            }

            // check which item should be displayed
            // the highest priority one which is earliest in queue
            int highestPri = -32000;
            QueuedText winnerItem = null;
            foreach (QueuedText t in q)
            {
                // by default, text is not active. Only the winning text will be.
                t.Text.IsEnabled = false;
                if (t.Priority > highestPri /*&& t.Text.StartTime <= SimTime */ )
                {
                    highestPri = t.Priority;
                    winnerItem = t;
                }
            }

            // activate only the winning item
            if (winnerItem != null )
            {
                currentItem = winnerItem;
                currentItem.Text.IsEnabled = true;
            }
        }
Example #7
0
 private void reset()
 {
     currentText     = null;
     currentDuration = 0;
     textBox.hide();
 }