Пример #1
0
        // Use this for initialization
        private void Start()
        {
            m_Text = GetComponent <Text>();
            string text = m_Text.text;

            m_Text.text = "";

            // If you don't want the text to fade right away, skip this line.
            Delay.For(0.2f, this).Then(() => FadeTo(text));
        }
Пример #2
0
        public static async void DelayDoesDelay()
        {
            const int timingFudge = 10; // Task.Delay sometimes returns a milli too soon...
            var       delayTime   = TimeSpan.FromSeconds(2);
            var       delay       = new Delay();
            var       stopwatch   = new Stopwatch();

            stopwatch.Start();
            await delay.For((int)delayTime.TotalMilliseconds, CancellationToken.None);

            stopwatch.Stop();

            Assert.True(stopwatch.ElapsedMilliseconds + timingFudge >= delayTime.TotalMilliseconds, String.Format("Requested {0}ms delay but only took {1}ms", delayTime.TotalMilliseconds, stopwatch.ElapsedMilliseconds));
        }
Пример #3
0
 public void PlayDamageTaken()
 {
     SpriteRenderer.material.color = DamageTakenColor;
     Delay.For(0.1f, andThen: () => SpriteRenderer.material.color = Color.white);
 }
Пример #4
0
        public void OnDied(GameEntity entity)
        {
            Animator.PlayDied();

            Delay.For(4f, () => entity.isDestructed = true);
        }