private void numericUpDownCurrentTorpor_ValueChanged(object sender, EventArgs e) { var duration = new TimeSpan(0, 0, Taming.SecondsUntilWakingUp(selectedSpecies, (int)nudLevel.Value, (double)numericUpDownCurrentTorpor.Value)); lbTimeUntilWakingUp.Text = string.Format(Loc.S("lbTimeUntilWakingUp"), Utils.Duration(duration)); if (duration.TotalSeconds < 30) { lbTimeUntilWakingUp.ForeColor = Color.DarkRed; } else if (duration.TotalSeconds < 120) { lbTimeUntilWakingUp.ForeColor = Color.DarkGoldenrod; } else { lbTimeUntilWakingUp.ForeColor = Color.Black; } wakeUpTime = DateTime.Now.Add(duration); }
/// <summary> /// Update the info when all food can be fed at once. /// </summary> private void UpdateTimeToFeedAll(bool enoughFood = true) { double hunger = (double)(nudTotalFood.Value - nudCurrentFood.Value); if (hunger < 0) { hunger = 0; } if (hunger > neededHunger) { hunger = neededHunger; } var durationStarving = new TimeSpan(0, 0, (int)((neededHunger - hunger) / foodDepletion)); lbTimeUntilStarving.Text = (enoughFood ? $"{Loc.S("TimeUntilFeedingAllFood")}: {Utils.Duration(durationStarving)}" : ""); if ((double)nudTotalFood.Value < neededHunger) { lbTimeUntilStarving.Text += (lbTimeUntilStarving.Text.Length > 0 ? "\n" : "") + $"{Loc.S("WarningMoreStarvingThanFood")}"; lbTimeUntilStarving.ForeColor = Color.DarkRed; } else { lbTimeUntilStarving.ForeColor = SystemColors.ControlText; } starvingTime = DateTime.Now.Add(durationStarving); }