private void initEntities() { List<Entity> entities = new List<Entity>(); Random r = new Random(); Entity current = null; Boolean allowed = false; int entityType; int x, y; for (int i = 0; i < NUMBER_OF_ENTITY_SPAWNS; i++) { // random entity type //entityType = r.Next(6) + 1; // random entity location Vector2 location = new Vector2(); do { entityType = r.Next(5); x = r.Next(20); y = r.Next(15); location.X = x * 32; location.Y = y * 32; // Hard code for cabinets if (isEntityAllowed(entityType, x, y)) { allowed = true; } else { allowed = false; } } while (!allowed || roomEntitiesLocationIsUsed(x, y, roomSpawns, 2)); /* This location now has a special random object in there. Do not spawn * other objects such as other hiding spots or items. */ roomSpawns.Add(new Vector2(x, y)); if (entityType != Entity.ITEM_SPAWNER && entityType != Entity.GENERIC) { roomSpawns.Add(new Vector2(x + 1, y)); roomSpawns.Add(new Vector2(x, y + 1)); roomSpawns.Add(new Vector2(x + 1, y + 1)); } // instantiate switch (entityType) { case Entity.CABINET: current = new Cabinet("Cabinet", location); break; case Entity.BED: current = new Bed("Bed", location); break; case Entity.ITEM_SPAWNER: current = new ItemSpawnEntity("Chest", location); break; case Entity.CURTAIN: current = new Curtain("Curtain", location); break; case Entity.GENERIC: current = new Entity("Generic", location, Entity.SMALL); break; } // add to list listOfEntities.Add(current); // reset allowed = false; x = y = 0; } }