public static int RetriveHabitatTypeIndex(HabitatType type) { switch (type) { case HabitatType.Forest: return(0); case HabitatType.Meadow: return(1); case HabitatType.Scrub: return(2); case HabitatType.Grassland: return(3); case HabitatType.Fell: return(4); case HabitatType.NotSpecified: return(5); } Preconditions.Fail("unsuppoted habitat type: " + type); return(-1); }
public static int CountCagesByTypeAndOccupation(HabitatType cageType, int numberAnimals) { var querySelectedCages = from cage in cagesDB where cage.Type == cageType && cage.AnimalsInCage.Count == numberAnimals select cage; return(querySelectedCages.Count()); }
public Cage(long id, double width, double height, double depth, HabitatType type) { this.CageID = id; this.Width = width; this.Height = height; this.Depth = depth; this.Price = (decimal)(width * depth); this.IsRepaired = true; this.Type = type; this.AnimalsInCage = new List <Animal>(); }
public Animal( long animalID, AnimalSpeciesType type, Gender gender, int age, FoodType foodType, decimal price, long cageID, HabitatType habitat, HealthStatus healthStatus) : this(animalID) { this.Type = type; this.Gender = gender; this.Age = age; this.FoodType = foodType; this.Price = price; this.CageID = cageID; this.Habitat = habitat; this.HealthStatus = healthStatus; }
public Flying(long animalID, AnimalSpeciesType type, Gender gender, int age, FoodType foodType, decimal price, long cageID, HabitatType habitat, HealthStatus healthStatus) : base(animalID, type, gender, age, foodType, price, cageID, habitat, healthStatus) { }
public Penguin(long animalID, Gender gender, int age, decimal price, long cageID, HabitatType habitat, HealthStatus healthStatus) : base(animalID, AnimalSpeciesType.Penguin, gender, age, FoodType.Meat, price, cageID, habitat, healthStatus) { this.fly = isFlyable(); this.bird = isBird(); }
public int Resolve(HabitatType type) { return(_priorityDict[type]); }
public static HabitatMap Create( MyRectangle areaOnMap, Vector2 mapGridSize, List <HabitatField> habitatFields, HabitatType defaultHabitatType, HabitatTypePriorityResolver priorityResolver) { var fullTree = new MyQuadtree <HabitatFieldInTree>(); habitatFields.ForEach(c => fullTree.Add(new HabitatFieldInTree() { Field = c })); int gridXCount = Mathf.CeilToInt(areaOnMap.Width / mapGridSize.x); int gridYCount = Mathf.CeilToInt(areaOnMap.Height / mapGridSize.y); var gridTreeArray = new MyQuadtree <HabitatFieldInTree> [gridXCount, gridYCount]; for (int gridX = 0; gridX < gridXCount; gridX++) { for (int gridY = 0; gridY < gridYCount; gridY++) { var gridArea = new MyRectangle( areaOnMap.X + gridX * mapGridSize.x, areaOnMap.Y + gridY * mapGridSize.y, mapGridSize.x, mapGridSize.y); var geometryEnvelope = MyNetTopologySuiteUtils.ToGeometryEnvelope(gridArea); var fieldsInArea = fullTree.QueryWithIntersection(geometryEnvelope); //Debug.Log("U34: "+fieldsInArea.Count(c => c.Field.Type == HabitatType.Fell)); //if (fieldsInArea.Count(c => c.Field.Type == HabitatType.Fell) > 0 ) //{ // Debug.Log($"J2: {StringUtils.ToString(fieldsInArea.Where(c => c.Field.Type == HabitatType.Fell).Select(c => c.Field.Geometry.AsText()))}"); //} var fieldsInEnvelope = fieldsInArea.Select(c => new HabitatField() { Geometry = MySafeIntersection(c.Field.Geometry, geometryEnvelope), Type = c.Field.Type }).Where(c => c.Geometry != null && !c.Geometry.IsEmpty); // removal of elements one on other var sortedFields = fieldsInEnvelope.OrderByDescending(c => priorityResolver.Resolve(c.Type)) .ToList(); for (int i = 0; i < sortedFields.Count; i++) { var current = sortedFields[i]; for (int j = i + 1; j < sortedFields.Count; j++) { var other = sortedFields[j]; other.Geometry = other.Geometry.Difference(current.Geometry); } } sortedFields = sortedFields.Where(c => !c.Geometry.IsEmpty).ToList(); var notUsedAreaInGrid = geometryEnvelope; foreach (var cutGeometry in sortedFields.Select(c => c.Geometry)) { notUsedAreaInGrid = notUsedAreaInGrid.Difference(cutGeometry); } if (!notUsedAreaInGrid.IsEmpty) { sortedFields.Add( new HabitatField() { Type = defaultHabitatType, Geometry = notUsedAreaInGrid } ); } var singleFieldsInTree = sortedFields.SelectMany(c => MyNetTopologySuiteUtils .ToSinglePolygons(c.Geometry).Select(poly => new HabitatField() { Geometry = poly, Type = c.Type })).Select(c => new HabitatFieldInTree() { Field = c }).ToList(); gridTreeArray[gridX, gridY] = MyQuadtree <HabitatFieldInTree> .CreateWithElements(singleFieldsInTree); } } return(new HabitatMap( new Vector2(areaOnMap.X, areaOnMap.Y), mapGridSize, new IntVector2(gridXCount, gridYCount), gridTreeArray)); }
public Hoodie(long animalID, Gender gender, int age, decimal price, long cageID, HabitatType habitat, HealthStatus healthStatus) : base(animalID, AnimalSpeciesType.Eagle, gender, age, FoodType.Mix, price, cageID, habitat, healthStatus) { }