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); }
public ReindeerState(ReindeerStats stats) { Stats = stats; _currentActionTimeLeft = Stats.MoveTime; }