Beispiel #1
0
 public Animal(Logger log, string name, double size,
               double maxSize, PointF coords, int hunger,
               int thirst, int libido, int drowsiness,
               double hungerInc, double thirstInc, double libidoInc,
               int walkingSpeed, int runningSpeed, char sex,
               EarthField earthField, string mindType) : base(log, name, size, coords)
 {
     this.maxSize      = maxSize;
     this.hunger       = hunger;
     this.thirst       = thirst;
     this.libido       = libido;
     this.drowsiness   = drowsiness;
     this.hungerInc    = hungerInc;
     this.thirstInc    = thirstInc;
     this.libidoInc    = libidoInc;
     this.walkingSpeed = walkingSpeed;
     this.runningSpeed = runningSpeed;
     this.sex          = sex;
     this.earthField   = earthField;
     if (mindType == "carnivore")
     {
         mind = new CarnivoreMind(this);
     }
     else
     {
         mind = new HerbivorousMind(this);
     }
 }
 private void Form1_Load(object sender, EventArgs e)
 {
     DoubleBuffered = true;
     Canvas.Top     = 0;
     Canvas.Left    = 0;
     Canvas.Width   = Width - 16;
     Canvas.Height  = Height - 38;
     EF             = new EarthField(Logger.getNewLogger("test.txt"), "Main field", new Point[] { new Point(0, 0), new Point(Canvas.Width, 0), new Point(Canvas.Width, Canvas.Height), new Point(0, Canvas.Height) });
     Canvas.Image   = new Bitmap(Canvas.Width, Canvas.Height);
     Canvas.Image   = EF.paint(Canvas);
 }
 public WaterField(Logger log, string name, Point[] points, EarthField earthField) : base(log, name, points)
 {
     try {
         if ((border[0].X == 0 && border[1].Y == 0) || (border[1].X == 0 && border[0].Y == 0))
         {
             border = new Point[] { border[0], border[1], new Point(0, 0) }
         }
         ;
         if ((border[0].X == 0 && border[1].Y == earthField.height) || (border[1].X == 0 && border[0].Y == earthField.height))
         {
             border = new Point[] { border[0], border[1], new Point(0, earthField.height) }
         }
         ;
         if ((border[0].X == earthField.width && border[1].Y == 0) || (border[1].X == earthField.width && border[0].Y == 0))
         {
             border = new Point[] { border[0], border[1], new Point(earthField.width, 0) }
         }
         ;
         if ((border[0].X == earthField.width && border[1].Y == earthField.height) || (border[1].X == earthField.width && border[0].Y == earthField.height))
         {
             border = new Point[] { border[0], border[1], new Point(earthField.width, earthField.height) }
         }
         ;
         if (border.Length == 2)
         {
             throw new Exception();
         }
         A  = border[1].Y - border[0].Y;
         B  = border[0].X - border[1].X;
         An = border[1].X - border[0].X;
         Bn = border[1].Y - border[0].Y;
     }
     catch (Exception)
     {
         MessageBox.Show("Wrong coords!");
     }
 }