public void SetDriver(ZooAdapter zoo) { double supBoundaryX = -1; double infBoundaryX = -1; double supBoundaryY = 1; double infBoundaryY = 1; decimal interval = 2m / (decimal)_map.BoxCount; for (int i = 0; i < _map.BoxCount; i++) { infBoundaryY -= (double)interval; for (int y = 0; y < _map.BoxCount; y++) { supBoundaryX += (double)interval; Driver driver = new Driver(); driver.InferiorBoundaryX = infBoundaryX; driver.SuperiorBoundaryY = supBoundaryY; driver.Interval = (double)interval; driver.Zoo = zoo; _map[i, y].Driver = driver; infBoundaryX += (double)interval; } supBoundaryY -= (double)interval; infBoundaryX = -1; supBoundaryX = -1; } }
public void SetZoo(ZooAdapter zoo) { if (_zoo == zoo) { return; } if (zoo != null) { if (_zooWatch.IsRunning) { _zooWatch.Reset(); } if (_drawWatch.IsRunning) { _drawWatch.Reset(); } _zooWatch.Start(); _drawWatch.Reset(); _zoo = zoo; InitializeMap(); } else { _viewPort.AreaChanged -= _viewPort_AreaChanged; _viewPort = null; _map = null; _zoo = null; Invalidate(); } }
public void DriversAssignment(ZooAdapter zoo, List <AnimalAdapter> animals, AnimalsRedering animalsShapes) { UnsetDriversAnimals(); for (int n = 0; n < animals.Count; n++) { bool shortCut = false; double supBoundaryX = -1; double infBoundaryX = -1; double supBoundaryY = 1; double infBoundaryY = 1; decimal interval = 2m / (decimal)_map.BoxCount; for (int i = 0; i < _map.BoxCount; i++) { if (i == _map.BoxCount - 1) { infBoundaryY = -1; } else { infBoundaryY -= (double)interval; } for (int y = 0; y < _map.BoxCount; y++) { if (y == _map.BoxCount - 1) { supBoundaryX = 1; } else { supBoundaryX += (double)interval; } if (animals[n].X >= infBoundaryX && animals[n].X <= supBoundaryX && animals[n].Y <= supBoundaryY && animals[n].Y >= infBoundaryY) { _map[i, y].Driver.AddAnimal(animals[n]); _map[i, y].Driver.CastAnimalsRedering = animalsShapes; shortCut = true; break; } infBoundaryX += (double)interval; } if (shortCut == true) { break; } supBoundaryY -= (double)interval; infBoundaryX = -1; supBoundaryX = -1; } } }