Esempio n. 1
0
        public void TestFlashTimer()
        {
            var flashTimer = new FlashTimer(2, 1.0f);

            Assert.AreEqual(true, flashTimer.IsFlashOn);

            flashTimer.OnUpdate(new TimeSlice(0.5f));
            Assert.AreEqual(true, flashTimer.IsFlashOn);

            flashTimer.OnUpdate(new TimeSlice(0.5f));
            Assert.AreEqual(false, flashTimer.IsFlashOn);

            flashTimer.OnUpdate(new TimeSlice(0.5f));
            Assert.AreEqual(false, flashTimer.IsFlashOn);

            flashTimer.OnUpdate(new TimeSlice(0.5f));
            Assert.AreEqual(true, flashTimer.IsFlashOn);

            Assert.AreEqual(false, flashTimer.IsFinished);
            flashTimer.OnUpdate(new TimeSlice(2.0f));
            Assert.AreEqual(false, flashTimer.IsFlashOn);
            Assert.AreEqual(true, flashTimer.IsFinished);
        }
Esempio n. 2
0
        protected override void Update()
        {
            base.Update();

            if (null != flashTimer)
            {
                flashTimer.OnUpdate(new TimeSlice(Time.deltaTime));

                if (flashTimer.IsFinished)
                {
                    flashTimer          = null;
                    multiRenderer.Color = defaultColor;
                }
                else
                {
                    multiRenderer.Color = flashTimer.IsFlashOn ? flashColor : defaultColor;
                }
            }
        }