Ejemplo n.º 1
0
        private void button1_Click(object sender, EventArgs e)
        {
            AquariumObject ToInsert;

            switch (comboBox1.SelectedItem.ToString())
            {
            case "Rock":
                ToInsert = new Rock(HereWeGo, selectedX, selectedY);
                break;

            case "Seaweed":
                ToInsert = new Seaweed(HereWeGo, selectedX, selectedY, (int)FoodField.Value);
                break;

            case "Herbivore":
                ToInsert = new HerbivoreFish(HereWeGo, selectedX, selectedY, GenderField.SelectedItem.ToString() == "Male" ? true : false, (int)AgeField.Value, (int)SatietyField.Value, (int)FoodField.Value, (int)PregnancyField.Value);
                break;

            case "Predator":
                ToInsert = new PredatorFish(HereWeGo, selectedX, selectedY, GenderField.SelectedItem.ToString() == "Male" ? true : false, (int)AgeField.Value, (int)SatietyField.Value, (int)PregnancyField.Value);
                break;

            default:
                ToInsert = null;
                break;
            }
            HereWeGo.Territory[selectedX, selectedY] = ToInsert;
            DrawAquarium(HereWeGo, tableLayoutPanel1);
        }
Ejemplo n.º 2
0
        protected void AvoidHunters()
        {
            PredatorFish ClosestHunter = GetClosestSuitableObject(obj => obj is PredatorFish) as PredatorFish;

            if (ClosestHunter == null || Math.Sqrt(Math.Pow(this.X - ClosestHunter.X, 2) + Math.Pow(this.X - ClosestHunter.X, 2)) > 10)
            {
                throw new Exception("No close hunters");
            }
            else
            {
                Escape(ClosestHunter);
            }
        }
Ejemplo n.º 3
0
 public void BeingHuntedBy(PredatorFish hunter)
 {
     Hunter = hunter;
 }