void SpawnFishies() { var mommyFish = new Fish(true, new Point(-100, (Screen.PrimaryScreen.Bounds.Height / 2) - 50), 0.5, Fish.FishGender.Female); var daddyFish = new Fish(false, new Point(Screen.AllScreens.Sum(x => x.Bounds.Width) + 100, (Screen.PrimaryScreen.Bounds.Height / 2) - 50), 0.5, Fish.FishGender.Male); var random = new Random(); mommyFish.BirthDate = DateTime.Now.AddMinutes(-1 * random.Next(2, 12)); daddyFish.BirthDate = DateTime.Now.AddMinutes(-1 * new Random(random.Next()).Next(2, 12)); mommyFish.LocationChanged += Fishie_Moved; mommyFish.FishEvent += Fishie_Event; daddyFish.LocationChanged += Fishie_Moved; daddyFish.FishEvent += Fishie_Event; Fishies.Add(mommyFish); Fishies.Add(daddyFish); mommyFish.Show(); daddyFish.Show(); }
public Fish[] CreateBaby(Fish daddy) { var babies = new List<Fish>(); if (new Random().NextDouble() > 0.8) { this.LastBred = DateTime.Now; daddy.LastBred = DateTime.Now; var location = new Point(this.Location.X - this.Width, this.Location.Y); var babyFish = new Fish(this.toRight, location, 0.4); babyFish.Show(); babies.Add(babyFish); var seed = new Random().NextDouble(); if (seed < 0.2) { // Twins babyFish = new Fish(this.toRight, location, 0.4); babyFish.Show(); babies.Add(babyFish); } if (seed < 0.05) { // Triplets babyFish = new Fish(this.toRight, location, 0.4); babyFish.Show(); babies.Add(babyFish); } if ((Math.Round(new Random((int)(seed * 10)).NextDouble(), 2) < 0.1)) { Kill("died in child birth."); } } return babies.ToArray(); }