Beispiel #1
0
                public void Setting_Existing_Timer_To_Negative_Time_Sets_Time_To_0(float time)
                {
                    DownTimer timer = A.DownTimer();

                    timer.SetNewDefaultTime(time);

                    Assert.AreEqual(0, timer.Time);
                }
Beispiel #2
0
                public void Setting_Existing_Timer_To_0_Sets_Time_To_0()
                {
                    DownTimer timer = A.DownTimer();

                    timer.SetNewDefaultTime(0);

                    Assert.AreEqual(0, timer.Time);
                }
Beispiel #3
0
                public void Setting_Existing_Timer_With_Positive_Time_Sets_Time_To_Correct_Value(float time)
                {
                    DownTimer timer = A.DownTimer();

                    timer.SetNewDefaultTime(time);

                    Assert.AreEqual(time, timer.Time);
                }
        private void InitAutoHealTimer()
        {
            healTimer = new DownTimer(1f / vigorStat.ActualValue);

            healTimer.OnTimerEnd += () => healthSysBehav.Heal(resolveStat.ActualValue, this);
            healTimer.OnTimerEnd += () => healTimer.SetNewDefaultTime(1f / vigorStat.ActualValue);
            healTimer.OnTimerEnd += () => healTimer.Reset();

            healthSysBehav.StatsBasedHealthContainer.onHealthChange += (cur, max) =>
            {
                var wasDamaged = cur < prevHealth;
                if (wasDamaged)
                {
                    healTimer.Reset();
                }

                prevHealth = cur;
            };
        }