private void DrawFish(Dweller fish) { if (fish.turn) { if (fish.Satiety != 0) { g.DrawImage(rightfish, fish.X, fish.Y, fish.Width, fish.Height); fish.turn = false; } /* else * { * g.DrawImage(rightdie, fish.X, fish.Y, fish.Width, fish.Height); * }*/ } else { if (fish.Satiety != 0) { g.DrawImage(leftfish, fish.X, fish.Y, 150, 95); } /* else * { * g.DrawImage(leftdie, fish.X, fish.Y, fish.Width, fish.Height); * }*/ } }
public bool IsDeath(Dweller f) { if (f.Satiety == 0) { return(true); } return(false); }
public bool IsHungry(Dweller f) { if (f.Satiety < 30) { return(true); } return(false); }
private void Startwork_Click(object sender, EventArgs e) { bmp = new Bitmap(Width, Height); g = Graphics.FromImage(bmp); g.DrawImage(Image.FromFile("background.png"), 0, 0); BackgroundImage = bmp; h2o = new Aquarium(); timer1.Enabled = true; draw = new Draw(); int t = temperature.Value; CreatorDweller creator; creator = new CreatorFish(); IStrategy fs = new FishStrategy(); Dweller f = creator.Create(rnd, fs); h2o.AllFish.Add(f); }
public void Move(Dweller f, List <Eat> food) { if (IsHungry(f)) { Eating(f, food); } int dx = f.X - f.TX; int dy = f.Y - f.TY; if (dx < 0) { f.X += dx / 10; f.turn = true; } else if (dx == 0) { f.X += 0; } else { f.X -= dx / 10; } if (dy < 0) { f.Y += dy / 10; } else if (dy == 0) { f.Y += 0; } else { f.Y -= dy / 10; } f.Pictureliife.X = f.X; f.Pictureliife.Y = f.Y; }
public void Move(Dweller f, List <Eat> plant) { if (IsHungry(f)) { Eating(f, plant); } int dx = f.TX - f.X; int stepX = 1; if (Math.Abs(dx) > 2) { if (dx < 0) { f.X -= stepX; } else { f.X += stepX; f.turn = true; } } f.Pictureliife.X = f.X; }
public void Eating(Dweller f, List <Eat> Feed) { double min = 5000; int indexI = -1; int indj = -1; double distance; foreach (Eat ea in Feed) { for (int j = 0; j < Feed.Count; j++) { for (int k = 0; k < ea.Korm.Count; k++) { distance = Math.Sqrt((f.X - ea.Korm.ElementAt(k).x) * (f.X - ea.Korm.ElementAt(k).x) + (f.Y - ea.Korm.ElementAt(k).y) * (f.Y - ea.Korm.ElementAt(k).y)); if (distance < min) { min = distance; indexI = k; indj = j; } } } } if (min <= 20) { Feed[indj].Korm.RemoveAt(indexI); f.Satiety += 15; return; } int dx = f.X - Feed[indj].Korm[indexI].x; int dy = f.Y - Feed[indj].Korm[indexI].y; int stepX = 10; int stepY = 5; if (dx < 0) { f.X += stepX; } else if (dx == 0) { f.X += 0; } else { f.X -= stepX; } if (dy < 0) { f.Y += stepY; } else if (dy == 0) { f.Y += 0; } else { f.Y -= stepY; } f.Pictureliife.X = f.X; f.Pictureliife.Y = f.Y; }
//private int light; //private Fish[] fish; //private Fry[] fry; //private Snail[] snail; public void AddFish(Dweller fish) { AllFish.Add(fish); }
public void Death(Dweller f) { if (IsDeath(f)) { } }