public void Tick() { DateTime now = DateTime.Now; DateTime alertTime = now.AddMinutes(1); if (updateListView) { listViewBabies.BeginUpdate(); foreach (ListViewItem lvi in listViewBabies.Items) { if ((lvi.Tag.GetType() == typeof(IncubationTimerEntry))) { var t = (IncubationTimerEntry)lvi.Tag; int i = Values.V.speciesNames.IndexOf(t.mother.species); if (i >= 0) { lvi.SubItems[2].Text = Utils.timeLeft(t.incubationEnd); lvi.SubItems[3].Text = Utils.duration((int)(Values.V.species[i].breeding.maturationTimeAdjusted / 10)); lvi.SubItems[4].Text = Utils.duration((int)Values.V.species[i].breeding.maturationTimeAdjusted); double diff = t.incubationEnd.Subtract(alertTime).TotalSeconds; if (diff >= 0 && diff < 1) { timerControl.playSound("Birth", 1); } } } else if ((lvi.Tag.GetType() == typeof(Creature))) { var c = (Creature)lvi.Tag; int i = Values.V.speciesNames.IndexOf(c.species); if (i >= 0 && Values.V.species[i].breeding != null) { DateTime babyUntil = c.growingUntil.AddSeconds(-0.9 * Values.V.species[i].breeding.maturationTimeAdjusted); lvi.SubItems[3].Text = Utils.timeLeft(babyUntil); lvi.SubItems[4].Text = Utils.timeLeft(c.growingUntil); } } } listViewBabies.EndUpdate(); } else { foreach (ListViewItem lvi in listViewBabies.Items) { if ((lvi.Tag.GetType() == typeof(IncubationTimerEntry))) { var t = (IncubationTimerEntry)lvi.Tag; int i = Values.V.speciesNames.IndexOf(t.mother.species); double diff = t.incubationEnd.Subtract(alertTime).TotalSeconds; if (diff >= 0 && diff < 1) { timerControl.playSound("Birth", 1); } } } } }
private void updateFirstFeedingWaiting() { int s = Taming.durationAfterFirstFeeding(speciesIndex, (int)nudLevel.Value, foodDepletion); if (s > 0) { firstFeedingWaiting = "\n\nWaiting time after first feeding: ~" + Utils.duration(s); } else { firstFeedingWaiting = ""; } }
private void numericUpDownCurrentTorpor_ValueChanged(object sender, EventArgs e) { var duration = new TimeSpan(0, 0, Taming.secondsUntilWakingUp(speciesIndex, (int)nudLevel.Value, (double)numericUpDownCurrentTorpor.Value)); labelTimeUntilWakingUp.Text = "Time until wake-up: " + Utils.duration(duration); if (duration.TotalSeconds < 30) { labelTimeUntilWakingUp.ForeColor = Color.DarkRed; } else if (duration.TotalSeconds < 120) { labelTimeUntilWakingUp.ForeColor = Color.DarkGoldenrod; } else { labelTimeUntilWakingUp.ForeColor = Color.Black; } wakeUpTime = DateTime.Now.Add(duration); }
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); }
private void nudCurrentFood_ValueChanged(object sender, EventArgs e) { var duration = new TimeSpan(0, 0, (int)((double)nudCurrentFood.Value / foodDepletion)); lblTimeUntilStarving.Text = "Time until starving: " + Utils.duration(duration); if (duration.TotalSeconds < 30) { lblTimeUntilStarving.ForeColor = Color.DarkRed; } else if (duration.TotalSeconds < 120) { lblTimeUntilStarving.ForeColor = Color.DarkGoldenrod; } else { lblTimeUntilStarving.ForeColor = Color.Black; } starvingTime = DateTime.Now.Add(duration); }
public void updateTamingData() { if (updateCalculation && speciesIndex >= 0) { updateKOCounting(); TimeSpan duration = new TimeSpan(); int narcoBerries = 0, narcotics = 0, bioToxines = 0, bonusLevel = 0; double te = 0, hunger = 0; bool enoughFood = false; var usedFood = new List <string>(); var foodAmount = new List <int>(); var foodAmountUsed = new List <int>(); quickTamingInfos = "n/a"; int level = (int)nudLevel.Value; if (Values.V.species[speciesIndex].taming.eats != null) { int foodCounter = Values.V.species[speciesIndex].taming.eats.Count; foreach (TamingFoodControl tfc in foodControls) { if (foodCounter == 0) { break; } foodCounter--; usedFood.Add(tfc.FoodName); foodAmount.Add(tfc.amount); tfc.maxFood = Taming.foodAmountNeeded(speciesIndex, level, tamingSpeedMultiplier, tfc.FoodName, Values.V.species[speciesIndex].taming.nonViolent); tfc.tamingDuration = Taming.tamingDuration(speciesIndex, tfc.maxFood, tfc.FoodName, tamingFoodRateMultiplier, Values.V.species[speciesIndex].taming.nonViolent); } Taming.tamingTimes(speciesIndex, level, tamingSpeedMultiplier, tamingFoodRateMultiplier, usedFood, foodAmount, out foodAmountUsed, out duration, out narcoBerries, out narcotics, out bioToxines, out te, out hunger, out bonusLevel, out enoughFood); for (int f = 0; f < foodAmountUsed.Count; f++) { foodControls[f].foodUsed = foodAmountUsed[f]; } } if (enoughFood) { labelResult.Text = "It takes " + Utils.durationUntil(duration) + " to tame the " + Values.V.speciesNames[speciesIndex] + "." + "\n\n" + "Taming Effectiveness: " + Math.Round(100 * te, 1) + " %" + "\nBonus-Level: +" + bonusLevel + " (total level after Taming: " + (nudLevel.Value + bonusLevel) + ")" + "\n\n" + $"Food has to drop by {hunger:F1} units." + "\n\n" + $"{narcoBerries} Narcoberries or\n" + $"{narcotics} Narcotics or\n" + $"{bioToxines} Bio Toxines are needed" + firstFeedingWaiting; if (foodAmountUsed.Count > 0) { quickTamingInfos = Taming.quickInfoOneFood(speciesIndex, level, tamingSpeedMultiplier, tamingFoodRateMultiplier, foodControls[0].FoodName, foodControls[0].maxFood, foodControls[0].foodNameDisplay); // show raw meat or mejoberries as alternative (often used) for (int i = 1; i < usedFood.Count; i++) { if (usedFood[i] == "Raw Meat" || usedFood[i] == "Mejoberry") { quickTamingInfos += "\n\n" + Taming.quickInfoOneFood(speciesIndex, level, tamingSpeedMultiplier, tamingFoodRateMultiplier, foodControls[i].FoodName, foodControls[i].maxFood, foodControls[i].foodNameDisplay); break; } } quickTamingInfos += "\n\n" + koNumbers + "\n\n" + boneDamageAdjustersImmobilization + firstFeedingWaiting; } if (favoriteKibble != null) { if (Kibbles.K.kibble.ContainsKey(favoriteKibble)) { labelResult.Text += "\n\nKibble:" + Kibbles.K.kibble[favoriteKibble].RecipeAsText(); } } } else if (foodAmountUsed.Count == 0) { labelResult.Text = "no taming-data available"; } else { labelResult.Text = "Not enough food to tame the creature!"; } numericUpDownCurrentTorpor.Value = (decimal)(Values.V.species[speciesIndex].stats[7].BaseValue * (1 + Values.V.species[speciesIndex].stats[7].IncPerWildLevel * (level - 1))); // displays the time until the food has decreased enough to tame the creature in one go. var durationStarving = new TimeSpan(0, 0, (int)(hunger / foodDepletion)); lblTimeUntilStarving.Text = "Time until you can feed all needed food in one go: " + Utils.duration(durationStarving); if (Values.V.species[speciesIndex].stats[3].BaseValue * (1 + Values.V.species[speciesIndex].stats[3].IncPerWildLevel * (level / 7)) < hunger) { lblTimeUntilStarving.Text += "\nCareful: this creature could have not enough food, so you might have to feed it before this time to prevent it from starving (check its inventory)!"; lblTimeUntilStarving.ForeColor = Color.DarkRed; } else { lblTimeUntilStarving.ForeColor = SystemColors.ControlText; } starvingTime = DateTime.Now.Add(durationStarving); } }
private void UpdateTamingData() { if (!updateCalculation || selectedSpecies == null) { return; } if (selectedSpecies.taming == null) { NoTamingData(); return; } this.Enabled = true; UpdateKOCounting(); TimeSpan duration = new TimeSpan(); int narcoBerries = 0, narcotics = 0, bioToxines = 0, bonusLevel = 0; double te = 0, hunger = 0; bool enoughFood = false; var usedFood = new List <string>(); var foodAmount = new List <int>(); var foodAmountUsed = new List <int>(); quickTamingInfos = "n/a"; int level = (int)nudLevel.Value; if (selectedSpecies.taming.eats != null) { int foodCounter = selectedSpecies.taming.eats.Count; foreach (TamingFoodControl tfc in foodControls) { if (foodCounter == 0) { break; } foodCounter--; usedFood.Add(tfc.FoodName); foodAmount.Add(tfc.amount); tfc.maxFood = Taming.foodAmountNeeded(selectedSpecies, level, tamingSpeedMultiplier, tfc.FoodName, selectedSpecies.taming.nonViolent); tfc.tamingDuration = Taming.tamingDuration(selectedSpecies, tfc.maxFood, tfc.FoodName, tamingFoodRateMultiplier, selectedSpecies.taming.nonViolent); } Taming.tamingTimes(selectedSpecies, level, tamingSpeedMultiplier, tamingFoodRateMultiplier, usedFood, foodAmount, out foodAmountUsed, out duration, out narcoBerries, out narcotics, out bioToxines, out te, out hunger, out bonusLevel, out enoughFood); for (int f = 0; f < foodAmountUsed.Count; f++) { foodControls[f].foodUsed = foodAmountUsed[f]; } } if (enoughFood) { labelResult.Text = $"It takes {Utils.durationUntil(duration)} to tame the {selectedSpecies.name}.\n\n" + $"Taming Effectiveness: {Math.Round(100 * te, 1)} %\n" + $"Bonus-Level: +{bonusLevel} (total level after Taming: {(nudLevel.Value + bonusLevel)})\n\n" + $"Food has to drop by {hunger:F1} units.\n\n" + $"{narcoBerries} Narcoberries or\n" + $"{narcotics} Narcotics or\n" + $"{bioToxines} Bio Toxines are needed{firstFeedingWaiting}"; labelResult.Text += kibbleRecipe; } else if (foodAmountUsed.Count == 0) { labelResult.Text = Loc.s("noTamingData"); } else { labelResult.Text = Loc.s("notEnoughFoodToTame"); } numericUpDownCurrentTorpor.ValueSave = (decimal)(selectedSpecies.stats[(int)StatNames.Torpidity].BaseValue * (1 + selectedSpecies.stats[(int)StatNames.Torpidity].IncPerWildLevel * (level - 1))); // displays the time until the food has decreased enough to tame the creature in one go. var durationStarving = new TimeSpan(0, 0, (int)(hunger / foodDepletion)); lbTimeUntilStarving.Text = (enoughFood ? $"{Loc.s("TimeUntilFeedingAllFood")}: {Utils.duration(durationStarving)}" : ""); nudCurrentFood.Value = (decimal)(selectedSpecies.stats[(int)StatNames.Food].BaseValue * (1 + selectedSpecies.stats[(int)StatNames.Food].IncPerWildLevel * (level / 7))); // approximating the food level if ((double)nudCurrentFood.Value < hunger) { lbTimeUntilStarving.Text += (lbTimeUntilStarving.Text.Length > 0 ? "\n" : "") + $"{Loc.s("WarningMoreStarvingThanFood")}"; lbTimeUntilStarving.ForeColor = Color.DarkRed; } else { lbTimeUntilStarving.ForeColor = SystemColors.ControlText; } starvingTime = DateTime.Now.Add(durationStarving); //// quicktame infos if (foodAmountUsed.Count > 0) { quickTamingInfos = Taming.quickInfoOneFood(selectedSpecies, level, tamingSpeedMultiplier, tamingFoodRateMultiplier, foodControls[0].FoodName, foodControls[0].maxFood, foodControls[0].foodNameDisplay); // show raw meat or mejoberries as alternative (often used) for (int i = 1; i < usedFood.Count; i++) { if (usedFood[i] == "Raw Meat" || usedFood[i] == "Mejoberry") { quickTamingInfos += "\n\n" + Taming.quickInfoOneFood(selectedSpecies, level, tamingSpeedMultiplier, tamingFoodRateMultiplier, foodControls[i].FoodName, foodControls[i].maxFood, foodControls[i].foodNameDisplay); break; } } quickTamingInfos += "\n\n" + koNumbers + "\n\n" + boneDamageAdjustersImmobilization + firstFeedingWaiting + kibbleRecipe; } }
public void recreateList() { if (cc != null) { updateListView = false; listViewBabies.BeginUpdate(); listViewBabies.Items.Clear(); ListViewGroup g = listViewBabies.Groups[0]; // add eggs / pregnancies foreach (IncubationTimerEntry t in cc.incubationListEntries) { int i = Values.V.speciesNames.IndexOf(t.mother.species); if (i >= 0 && Values.V.species[i].breeding != null) { string kind; if (Values.V.species[i].breeding.gestationTimeAdjusted > 0) { kind = "Gestation"; } else { kind = "Egg"; } string[] cols = new string[] { kind, t.mother.species, Utils.timeLeft(t.incubationEnd), Utils.duration((int)(Values.V.species[i].breeding.maturationTimeAdjusted / 10)), Utils.duration((int)Values.V.species[i].breeding.maturationTimeAdjusted) }; ListViewItem lvi = new ListViewItem(cols, g); lvi.Tag = t; listViewBabies.Items.Add(lvi); } } // add babies / growing DateTime now = DateTime.Now; foreach (Creature c in cc.creatures) { if (c.growingUntil > now) { int i = Values.V.speciesNames.IndexOf(c.species); if (i >= 0 && Values.V.species[i].breeding != null) { DateTime babyUntil = c.growingUntil.AddSeconds(-0.9 * Values.V.species[i].breeding.maturationTimeAdjusted); string[] cols; if (babyUntil > now) { g = listViewBabies.Groups[1]; cols = new string[] { c.name, c.species, "-", Utils.timeLeft(babyUntil), Utils.timeLeft(c.growingUntil) }; } else { g = listViewBabies.Groups[2]; cols = new string[] { c.name, c.species, "-", "-", Utils.timeLeft(c.growingUntil) }; } ListViewItem lvi = new ListViewItem(cols, g); lvi.Tag = c; listViewBabies.Items.Add(lvi); } } } listViewBabies.EndUpdate(); updateListView = true; } }
/// <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); }
private void updateFirstFeedingWaiting() { int s = Taming.durationAfterFirstFeeding(speciesIndex, (int)nudLevel.Value, foodDepletion); if (s > 0) { firstFeedingWaiting = "\n\n" + String.Format(Loc.s("waitingAfterFirstFeeding"), Utils.duration(s)); } else { firstFeedingWaiting = ""; } }