private void comboBoxSpecies_SelectedIndexChanged(object sender, EventArgs e) { int sI = comboBoxSpecies.SelectedIndex; if (sI >= 0 && Values.V.species[sI].taming != null) { TamingData td = Values.V.species[sI].taming; this.SuspendLayout(); foreach (TamingFoodControl f in foodControls) { Controls.Remove(f); } foodControls.Clear(); TamingFoodControl tf; int i = 0; foreach (string f in td.eats) { tf = new TamingFoodControl(f); if (f == "Kibble") { tf.foodNameDisplay = "Kibble (" + td.favoriteKibble + " Egg)"; } if (td.specialFoodValues != null && td.specialFoodValues.ContainsKey(f) && td.specialFoodValues[f].quantity > 1) { tf.foodNameDisplay = td.specialFoodValues[f].quantity.ToString() + "× " + tf.foodNameDisplay; } tf.Location = new Point(20, 80 + 45 * i); tf.valueChanged += new TamingFoodControl.ValueChangedEventHandler(updateTamingData); tf.Clicked += new TamingFoodControl.ClickedEventHandler(onlyOneFood); foodControls.Add(tf); Controls.Add(tf); i++; } this.ResumeLayout(); if (foodControls.Count > 0) { foodControls[0].amount = Taming.foodAmountNeeded(sI, (int)nudLevel.Value, foodControls[0].foodName, td.nonViolent); } } }
public void setSpeciesIndex(int speciesIndex) { if (speciesIndex >= 0 && Values.V.species[speciesIndex].taming != null && this.speciesIndex != speciesIndex) { this.SuspendLayout(); this.speciesIndex = speciesIndex; // bone damage adjusters Dictionary <double, string> boneDamageAdjusters = new Dictionary <double, string>(); boneDamageAdjustersImmobilization = Taming.boneDamageAdjustersImmobilization(speciesIndex, out boneDamageAdjusters); int ib = 0; foreach (KeyValuePair <double, string> bd in boneDamageAdjusters) { ib++; if (ib >= rbBoneDamageAdjusters.Count) { RadioButton rbBD = new RadioButton(); gbWeaponDamage.Controls.Add(rbBD); rbBD.Location = new Point(6, 173 + 19 * ib); rbBD.AutoSize = false; rbBD.Size = new Size(194, 17); rbBoneDamageAdjusters.Add(rbBD); rbBoneDamageAdjusterValues.Add(1); rbBD.CheckedChanged += new System.EventHandler(this.rbBoneDamage_CheckedChanged); } rbBoneDamageAdjusterValues[ib] = bd.Key; rbBoneDamageAdjusters[ib].Text = bd.Value + " (" + bd.Key.ToString() + "×)"; rbBoneDamageAdjusters[ib].Visible = true; } for (int j = ib + 1; j < rbBoneDamageAdjusters.Count; j++) { rbBoneDamageAdjusters[j].Visible = false; } rbBoneDamageAdjusters[0].Checked = true; // bone damage adjusters adjusted updateCalculation = false; TamingData td = Values.V.species[speciesIndex].taming; favoriteKibble = td.favoriteKibble; foodDepletion = td.foodConsumptionBase * td.foodConsumptionMult * tamingFoodRateMultiplier; TamingFoodControl tf; int i = 0; if (td.eats != null) { for (i = 0; i < td.eats.Count; i++) { string f = td.eats[i]; if (i >= foodControls.Count) { tf = new TamingFoodControl(f); tf.Location = new Point(20, 80 + 45 * i); tf.valueChanged += new TamingFoodControl.ValueChangedEventHandler(updateTamingData); tf.Clicked += new TamingFoodControl.ClickedEventHandler(onlyOneFood); foodControls.Add(tf); Controls.Add(tf); } else { tf = foodControls[i]; tf.FoodName = f; tf.Show(); } if (f == "Kibble") { tf.foodNameDisplay = "Kibble (" + td.favoriteKibble + " Egg)"; } if (td.specialFoodValues != null && td.specialFoodValues.ContainsKey(f) && td.specialFoodValues[f].quantity > 1) { tf.foodNameDisplay = td.specialFoodValues[f].quantity.ToString() + "× " + tf.foodNameDisplay; } } } for (int fci = foodControls.Count - 1; fci >= i; fci--) { foodControls[fci].Hide(); } if (i > 0) { foodControls[0].amount = Taming.foodAmountNeeded(speciesIndex, (int)nudLevel.Value, tamingSpeedMultiplier, foodControls[0].FoodName, td.nonViolent); } updateCalculation = true; updateFirstFeedingWaiting(); updateTamingData(); ResumeLayout(); } }
public void SetSpecies(Species species, bool forceRefresh = false) { if (species == null || (selectedSpecies == species && !forceRefresh)) { return; } selectedSpecies = species; if (species.taming == null) { NoTamingData(); return; } SuspendLayout(); string speciesName = species.name; linkLabelWikiPage.Text = "Wiki: " + speciesName; linkLabelWikiPage.Tag = speciesName; // bone damage adjusters boneDamageAdjustersImmobilization = Taming.BoneDamageAdjustersImmobilization(selectedSpecies, out Dictionary <string, double> boneDamageAdjusters); int ib = 0; foreach (KeyValuePair <string, double> bd in boneDamageAdjusters) { ib++; if (ib >= rbBoneDamageAdjusters.Count) { RadioButton rbBD = new RadioButton(); flcBodyDamageMultipliers.Controls.Add(rbBD); flcBodyDamageMultipliers.SetFlowBreak(rbBD, true); rbBD.AutoSize = true; rbBoneDamageAdjusters.Add(rbBD); rbBoneDamageAdjusterValues.Add(1); rbBD.CheckedChanged += rbBoneDamage_CheckedChanged; } rbBoneDamageAdjusterValues[ib] = bd.Value; rbBoneDamageAdjusters[ib].Text = $"{Loc.S(bd.Key)} (× {bd.Value})"; rbBoneDamageAdjusters[ib].Visible = true; } for (int j = ib + 1; j < rbBoneDamageAdjusters.Count; j++) { rbBoneDamageAdjusters[j].Visible = false; } rbBoneDamageAdjusters[0].Checked = true; // bone damage adjusters adjusted updateCalculation = false; TamingData td = species.taming; kibbleRecipe = string.Empty; // list all recipes of kibbles that give a reasonable affinity (assuming that is larger or equal than 100) foreach (var k in Kibbles.K.kibble) { var kibbleName = $"{k.Key} Kibble"; if (((td.specialFoodValues != null && td.specialFoodValues.TryGetValue(kibbleName, out var kFood)) || Values.V.defaultFoodData.TryGetValue(kibbleName, out kFood)) && kFood.affinity >= 100) { kibbleRecipe += $"\n\n{k.Key} Kibble:{k.Value.RecipeAsText()}"; } } foodDepletion = td.foodConsumptionBase * td.foodConsumptionMult * tamingFoodRateMultiplier; int i = 0; if (td.eats != null) { for (i = 0; i < td.eats.Length; i++) { string f = td.eats[i]; TamingFoodControl tf; // if Augmented are not wanted, and food control already exist, update it and hide it. if (!checkBoxAugmented.Checked && f.Contains("Augmented")) { if (i < foodControls.Count) { tf = foodControls[i]; tf.FoodName = f; tf.Hide(); } continue; } if (i >= foodControls.Count) { tf = new TamingFoodControl(f); tf.valueChanged += UpdateTamingData; tf.Clicked += OnlyOneFood; foodControls.Add(tf); flpTamingFood.Controls.Add(tf); } else { tf = foodControls[i]; tf.FoodName = f; tf.Show(); } // special cases where a creature eats multiple food items of one kind at once if (td.specialFoodValues != null && td.specialFoodValues.ContainsKey(f) && td.specialFoodValues[f].quantity > 1) { tf.foodNameDisplay = td.specialFoodValues[f].quantity + "× " + tf.foodNameDisplay; } } } for (int fci = foodControls.Count - 1; fci >= i; fci--) { foodControls[fci].Hide(); } if (i > 0) { foodControls[0].amount = Taming.FoodAmountNeeded(species, (int)nudLevel.Value, tamingSpeedMultiplier, foodControls[0].FoodName, td.nonViolent); } updateCalculation = true; UpdateFirstFeedingWaiting(); UpdateTamingData(); ResumeLayout(); }
public void SetSpecies(Species species) { if (species == null || selectedSpecies == species) { return; } selectedSpecies = species; if (species.taming == null) { NoTamingData(); return; } SuspendLayout(); string speciesName = species.name; linkLabelWikiPage.Text = "Wiki: " + speciesName; linkLabelWikiPage.Tag = speciesName; // bone damage adjusters boneDamageAdjustersImmobilization = Taming.boneDamageAdjustersImmobilization(selectedSpecies, out Dictionary <string, double> boneDamageAdjusters); int ib = 0; foreach (KeyValuePair <string, double> bd in boneDamageAdjusters) { ib++; if (ib >= rbBoneDamageAdjusters.Count) { RadioButton rbBD = new RadioButton(); gbWeaponDamage.Controls.Add(rbBD); rbBD.Location = new Point(6, 199 + 19 * ib); rbBD.AutoSize = false; rbBD.Size = new Size(194, 17); rbBoneDamageAdjusters.Add(rbBD); rbBoneDamageAdjusterValues.Add(1); rbBD.CheckedChanged += rbBoneDamage_CheckedChanged; } rbBoneDamageAdjusterValues[ib] = bd.Value; rbBoneDamageAdjusters[ib].Text = $"{Loc.s(bd.Key)} (× {bd.Value})"; rbBoneDamageAdjusters[ib].Visible = true; } for (int j = ib + 1; j < rbBoneDamageAdjusters.Count; j++) { rbBoneDamageAdjusters[j].Visible = false; } rbBoneDamageAdjusters[0].Checked = true; // bone damage adjusters adjusted updateCalculation = false; TamingData td = species.taming; kibbleRecipe = ""; // TODO replace with new kibble recipes //if (td.favoriteKibble != null && Kibbles.K.kibble.ContainsKey(td.favoriteKibble)) //{ // kibbleRecipe = "\n\nKibble:" + Kibbles.K.kibble[td.favoriteKibble].RecipeAsText(); //} foodDepletion = td.foodConsumptionBase * td.foodConsumptionMult * tamingFoodRateMultiplier; int i = 0; if (td.eats != null) { for (i = 0; i < td.eats.Count; i++) { string f = td.eats[i]; TamingFoodControl tf; if (i >= foodControls.Count) { tf = new TamingFoodControl(f); tf.valueChanged += UpdateTamingData; tf.Clicked += OnlyOneFood; foodControls.Add(tf); flpTamingFood.Controls.Add(tf); } else { tf = foodControls[i]; tf.FoodName = f; tf.Show(); } if (f == "Kibble") { tf.foodNameDisplay = $"Kibble ({td.favoriteKibble} {Loc.s("Egg")})"; } if (td.specialFoodValues != null && td.specialFoodValues.ContainsKey(f) && td.specialFoodValues[f].quantity > 1) { tf.foodNameDisplay = td.specialFoodValues[f].quantity + "× " + tf.foodNameDisplay; } } } for (int fci = foodControls.Count - 1; fci >= i; fci--) { foodControls[fci].Hide(); } if (i > 0) { foodControls[0].amount = Taming.foodAmountNeeded(species, (int)nudLevel.Value, tamingSpeedMultiplier, foodControls[0].FoodName, td.nonViolent); } updateCalculation = true; UpdateFirstFeedingWaiting(); UpdateTamingData(); ResumeLayout(); }
public void setSpeciesIndex(int speciesIndex) { if (speciesIndex >= 0 && Values.V.species[speciesIndex].taming != null) { this.speciesIndex = speciesIndex; boneDamageAdjusters = Taming.boneDamageAdjustersImmobilisation(speciesIndex); updateCalculation = false; this.SuspendLayout(); TamingData td = Values.V.species[speciesIndex].taming; foodDepletion = td.foodConsumptionBase * td.foodConsumptionMult * Values.V.tamingFoodRateMultiplier; TamingFoodControl tf; int i = 0; if (td.eats != null) { for (i = 0; i < td.eats.Count; i++) { string f = td.eats[i]; if (i >= foodControls.Count) { tf = new TamingFoodControl(f); tf.Location = new Point(20, 80 + 45 * i); tf.valueChanged += new TamingFoodControl.ValueChangedEventHandler(updateTamingData); tf.Clicked += new TamingFoodControl.ClickedEventHandler(onlyOneFood); foodControls.Add(tf); Controls.Add(tf); } else { tf = foodControls[i]; tf.FoodName = f; tf.Show(); } if (f == "Kibble") { tf.foodNameDisplay = "Kibble (" + td.favoriteKibble + " Egg)"; } if (td.specialFoodValues != null && td.specialFoodValues.ContainsKey(f) && td.specialFoodValues[f].quantity > 1) { tf.foodNameDisplay = td.specialFoodValues[f].quantity.ToString() + "× " + tf.foodNameDisplay; } } } for (int fci = foodControls.Count - 1; fci >= i; fci--) { foodControls[fci].Hide(); } if (i > 0) { foodControls[0].amount = Taming.foodAmountNeeded(speciesIndex, (int)nudLevel.Value, evolutionEvent, foodControls[0].FoodName, td.nonViolent); } updateCalculation = true; updateFirstFeedingWaiting(); updateTamingData(); ResumeLayout(); } }
public void setSpeciesIndex(int speciesIndex) { if (speciesIndex >= 0 && Values.V.species[speciesIndex].taming != null && this.speciesIndex != speciesIndex) { SuspendLayout(); this.speciesIndex = speciesIndex; // bone damage adjusters boneDamageAdjustersImmobilization = Taming.boneDamageAdjustersImmobilization(speciesIndex, out Dictionary <double, string> boneDamageAdjusters); int ib = 0; foreach (KeyValuePair <double, string> bd in boneDamageAdjusters) { ib++; if (ib >= rbBoneDamageAdjusters.Count) { RadioButton rbBD = new RadioButton(); gbWeaponDamage.Controls.Add(rbBD); rbBD.Location = new Point(6, 199 + 19 * ib); rbBD.AutoSize = false; rbBD.Size = new Size(194, 17); rbBoneDamageAdjusters.Add(rbBD); rbBoneDamageAdjusterValues.Add(1); rbBD.CheckedChanged += rbBoneDamage_CheckedChanged; } rbBoneDamageAdjusterValues[ib] = bd.Key; rbBoneDamageAdjusters[ib].Text = $"{Loc.s(bd.Value)} ({bd.Key}×)"; rbBoneDamageAdjusters[ib].Visible = true; } for (int j = ib + 1; j < rbBoneDamageAdjusters.Count; j++) { rbBoneDamageAdjusters[j].Visible = false; } rbBoneDamageAdjusters[0].Checked = true; // bone damage adjusters adjusted updateCalculation = false; TamingData td = Values.V.species[speciesIndex].taming; kibbleRecipe = ""; if (td.favoriteKibble != null && Kibbles.K.kibble.ContainsKey(td.favoriteKibble)) { kibbleRecipe = "\n\nKibble:" + Kibbles.K.kibble[td.favoriteKibble].RecipeAsText(); } foodDepletion = td.foodConsumptionBase * td.foodConsumptionMult * tamingFoodRateMultiplier; int i = 0; if (td.eats != null) { for (i = 0; i < td.eats.Count; i++) { string f = td.eats[i]; TamingFoodControl tf; if (i >= foodControls.Count) { tf = new TamingFoodControl(f); tf.valueChanged += updateTamingData; tf.Clicked += onlyOneFood; foodControls.Add(tf); flpTamingFood.Controls.Add(tf); } else { tf = foodControls[i]; tf.FoodName = f; tf.Show(); } if (f == "Kibble") { tf.foodNameDisplay = $"Kibble ({td.favoriteKibble} {Loc.s("Egg")})"; } if (td.specialFoodValues != null && td.specialFoodValues.ContainsKey(f) && td.specialFoodValues[f].quantity > 1) { tf.foodNameDisplay = td.specialFoodValues[f].quantity + "× " + tf.foodNameDisplay; } } } for (int fci = foodControls.Count - 1; fci >= i; fci--) { foodControls[fci].Hide(); } if (i > 0) { foodControls[0].amount = Taming.foodAmountNeeded(speciesIndex, (int)nudLevel.Value, tamingSpeedMultiplier, foodControls[0].FoodName, td.nonViolent); } updateCalculation = true; updateFirstFeedingWaiting(); updateTamingData(); ResumeLayout(); } }
private void comboBoxSpecies_SelectedIndexChanged(object sender, EventArgs e) { int sI = comboBoxSpecies.SelectedIndex; if (sI >= 0 && Values.V.species[sI].taming != null) { this.SuspendLayout(); foreach (TamingFoodControl f in foodControls) Controls.Remove(f); foodControls.Clear(); TamingFoodControl tf; int i = 0; foreach (string f in Values.V.species[sI].taming.eats) { tf = new TamingFoodControl(f); if (f == "Kibble") tf.foodNameDisplay = "Kibble (" + Values.V.species[sI].taming.favoriteKibble + " Egg)"; tf.Location = new Point(20, 80 + 45 * i); tf.valueChanged += new TamingFoodControl.ValueChangedEventHandler(updateTamingData); tf.Clicked += new TamingFoodControl.ClickedEventHandler(onlyOneFood); foodControls.Add(tf); Controls.Add(tf); i++; } this.ResumeLayout(); if (foodControls.Count > 0) { foodControls[0].amount = Taming.foodAmountNeeded(sI, (int)nudLevel.Value, foodControls[0].foodName, Values.V.species[sI].taming.nonViolent); } } }
/// <summary> /// Sets the taming food controls. /// </summary> private void SetTamingFoodControls(Species species) { var td = species.taming; int i = 0; if (td.eats != null) { var length = td.eats.Length; for (; i < length; i++) { string f = td.eats[i]; TamingFoodControl tf; // if Augmented are not wanted, and food control already exist, update it and hide it. if (!checkBoxAugmented.Checked && f.Contains("Augmented")) { if (i < _foodControls.Count) { tf = _foodControls[i]; tf.FoodName = f; tf.Hide(); } continue; } if (i >= _foodControls.Count) { tf = new TamingFoodControl(f); tf.valueChanged += UpdateTamingData; tf.Clicked += OnlyOneFood; _foodControls.Add(tf); flpTamingFood.Controls.Add(tf); } else { tf = _foodControls[i]; tf.FoodName = f; flpTamingFood.Controls.SetChildIndex(tf, i); tf.Show(); } // special cases where a creature eats multiple food items of one kind at once var food = Values.V.GetTamingFood(species, f); if (food != null && food.quantity > 1) { tf.foodNameDisplay = food.quantity + "× " + tf.foodNameDisplay; } } } for (int fci = _foodControls.Count - 1; fci >= i; fci--) { _foodControls[fci].FoodName = null; _foodControls[fci].Hide(); } if (i > 0) { _foodControls[0].amount = Taming.FoodAmountNeeded(species, (int)nudLevel.Value, _tamingSpeedMultiplier, _foodControls[0].FoodName, td.nonViolent); } }