Esempio n. 1
0
        private static int CalculateDistance(ReindeerStats stats, int elapsedSeconds)
        {
            var fullCycleDuration = stats.MoveTime + stats.RestTime;
            var fullCyclesCount   = elapsedSeconds / fullCycleDuration;

            var fullCyclesDuration = fullCycleDuration * fullCyclesCount;
            var fullCyclesDistance = fullCyclesCount * stats.Speed * stats.MoveTime;

            var remainingTime       = elapsedSeconds - fullCyclesDuration;
            var remainingTimeMoving = Math.Min(stats.MoveTime, remainingTime);
            var remainingDistance   = stats.Speed * remainingTimeMoving;

            return(fullCyclesDistance + remainingDistance);
        }
Esempio n. 2
0
        public ReindeerState(ReindeerStats stats)
        {
            Stats = stats;

            _currentActionTimeLeft = Stats.MoveTime;
        }