/// <summary> /// Triggers stat mutation and chance to mutate into new plant /// </summary> /// <param name="modification"></param> public void NaturalMutation(PlantTrayModification modification) { //Chance to actually mutate //if (random.Next(1, 2) != 1) return; //Stat mutations WeedResistance = StatMutation(WeedResistance, 100); WeedGrowthRate = BadStatMutation(WeedGrowthRate, 100); GrowthSpeed = StatMutation(GrowthSpeed, 100); Potency = StatMutation(Potency, 100); Endurance = StatMutation(Endurance, 100); Yield = StatMutation(Yield, 100); Lifespan = StatMutation(Lifespan, 100); switch (modification) { case PlantTrayModification.None: break; case PlantTrayModification.WeedResistance: WeedResistance = SpecialStatMutation(WeedResistance, 100); break; case PlantTrayModification.WeedGrowthRate: WeedGrowthRate = SpecialStatMutation(WeedGrowthRate, 100); break; case PlantTrayModification.GrowthSpeed: GrowthSpeed = SpecialStatMutation(GrowthSpeed, 100); break; case PlantTrayModification.Potency: Potency = SpecialStatMutation(Potency, 100); break; case PlantTrayModification.Endurance: Endurance = SpecialStatMutation(Endurance, 100); break; case PlantTrayModification.Yield: Yield = SpecialStatMutation(Yield, 100); break; case PlantTrayModification.Lifespan: Lifespan = SpecialStatMutation(Lifespan, 100); break; } CheckMutation(WeedResistance, 0, 100); CheckMutation(WeedGrowthRate, 0, 100); CheckMutation(GrowthSpeed, 0, 100); CheckMutation(Potency, 0, 100); CheckMutation(Endurance, 0, 100); CheckMutation(Yield, 0, 100); CheckMutation(Lifespan, 0, 100); if (random.Next(100) > 95) { Mutation(); } }
public static PlantData MutateNewPlant(PlantData plantData, PlantTrayModification modification) { PlantData newPlant = new PlantData(); newPlant.SetValues(plantData); newPlant.Health = 100; newPlant.Age = 0; newPlant.NaturalMutation(modification); return(newPlant); }
/// <summary> /// Called when plant creates food /// </summary> public void SetUpFood(PlantData newPlantData, PlantTrayModification modification) { plantData = PlantData.MutateNewPlant(newPlantData, modification); SyncSize(SizeScale, 0.5f + (newPlantData.Potency / 200f)); SetupChemicalContents(); if (edible != null) { SetupEdible(); } }
/// <summary> /// Triggers stat mutation and chance to mutate into new plant /// </summary> /// <param name="modification"></param> public void NaturalMutation(PlantTrayModification modification) { //Stat mutations WeedResistance = StatMutation(WeedResistance, StatMutationType.Normal); WeedGrowthRate = StatMutation(WeedGrowthRate, StatMutationType.Bad); GrowthSpeed = StatMutation(GrowthSpeed, StatMutationType.Normal); Potency = StatMutation(Potency, StatMutationType.Normal); Endurance = StatMutation(Endurance, StatMutationType.Normal); Yield = StatMutation(Yield, StatMutationType.Normal); Lifespan = StatMutation(Lifespan, StatMutationType.Normal); switch (modification) { case PlantTrayModification.None: break; case PlantTrayModification.WeedResistance: WeedResistance = StatMutation(WeedResistance, StatMutationType.Special); break; case PlantTrayModification.WeedGrowthRate: WeedGrowthRate = StatMutation(WeedGrowthRate, StatMutationType.Special); break; case PlantTrayModification.GrowthSpeed: GrowthSpeed = StatMutation(GrowthSpeed, StatMutationType.Special); break; case PlantTrayModification.Potency: Potency = StatMutation(Potency, StatMutationType.Special); break; case PlantTrayModification.Endurance: Endurance = StatMutation(Endurance, StatMutationType.Special); break; case PlantTrayModification.Yield: Yield = StatMutation(Yield, StatMutationType.Special); break; case PlantTrayModification.Lifespan: Lifespan = StatMutation(Lifespan, StatMutationType.Special); break; } if (random.Next(100) > 95) { Mutation(); } }