public static List<IPlant> load_plants(Ground parent,kindstatus status) { DPLANT dna = new DPLANT(); List<IPlant> List = new List<IPlant>(); List<DPLANT> query; if(status == kindstatus.Growup || status ==kindstatus.Reproduction){ query = Context.DPLANT.Where(S => S.PARENT_ID == parent.GroundID && !S.STATUS.Contains( kindstatus.Seed.ToString()) ).ToList(); } else{ query = Context.DPLANT.Where(S => S.PARENT_ID == parent.GroundID && S.STATUS.Contains( kindstatus.Seed.ToString()) ).ToList(); } foreach (DPLANT item in query) { Plant newplant = new Plant(parent, item.aliveID); newplant.CurrentLifeCycle = (int)item.CURRENTLIFECYCLE; newplant.Generation = (int)item.GENERATION; newplant.NextReproductionCycle = (int)item.NEXTREPRODUCTIONCYCLE; newplant.Size = (int)item.SIZE; newplant.Waterdeposit = (int)item.WATERDEPOSIT; switch (item.STATUS) { case "Seed": newplant.Status = kindstatus.Seed; break; case "Growup": newplant.Status = kindstatus.Growup; break; case "Reproduction": newplant.Status = kindstatus.Reproduction; break; } List.Add(newplant); } return List; }
protected virtual void reproduccion() { if (_currentLifeCycle >= 25 + nextReproductionCycle) { _status = kindstatus.Reproduction; nextReproductionCycle += 10; } }
/// <summary> /// Change the status of the plant to Died if any of the condition to die are met /// </summary> protected virtual void Died() { if (_currentLifeCycle == _dna.dnachain.Single(s => s.name == "lifeciclelimit").valor) { _status = kindstatus.Dead; } if (life<= 0) { _status = kindstatus.Dead; } }