private EnemyVO[] PopulateEnemies(MapVO map, List <EnemyVO> enemies) { // TODO: Isolate enemies appropriate to the current party List <EnemyVO> result = new List <EnemyVO>(); if (result == null) { return new EnemyVO[] {} } ; // No Enemies int numRooms = map.Rooms.Length - 1; RoomVO room; int i; foreach (EnemyVO enemy in enemies) { i = Util.RNG.Generate(1, numRooms); room = map.Rooms[i]; if (!room.HostHere && Util.RNG.Generate(0, 100) < ENEMY_CHANCE) { if (room.Enemies == null) { room.Enemies = new List <EnemyVO>(); } room.Enemies.Add(enemy); } } return(result.ToArray()); } }
private void HandleMap(MapVO map) { if (map != null) { DrawMap(_model.Map); AmbitionApp.Unsubscribe <MapVO>(HandleMap); } }
private void DrawMap(MapVO map) { List <UIVertex[]> quads = new List <UIVertex[]>(); foreach (RoomVO room in map.Rooms) { if (room != null && room.Vertices != null) { int len = room.Vertices.Length; for (int i = 0; i < len; i += 2) { DrawLine(room.Vertices[i], room.Vertices[i + 1], room.Vertices[(i + 2) % len], room.Vertices[(i + 3) % len], quads); } } } _walls = quads.ToArray(); }
private MapVO BuildRandomMap(PartyVO party) { MapVO map = new MapVO(); FactionVO faction = AmbitionApp.GetModel <FactionModel>().Factions[party.Faction]; // Room size is proportional to how "baroque" the structure is. // Curvilinear features are a function of "modernness," which will be determined by the host. // Overall size of the house will be proportional to the "Importance" of the party. int hyphen = (int)party.Importance + Util.RNG.Generate(3); // the width of the hyphen in rooms int pavilion = (int)party.Importance + Util.RNG.Generate(3); // length of the pavilion in rooms int jut = Util.RNG.Generate(0, 2); int spacing = (int)(Util.RNG.Generate(faction.Baroque[0], faction.Baroque[1]) * .01f * MAX_ROOM_WIDTH); // Median room spacing float curve1 = .1f * Util.RNG.Generate(6, 11); float delta; RoomVO room; if (spacing < MIN_ROOM_WIDTH) { spacing = MIN_ROOM_WIDTH; } int salonX = Util.RNG.Generate(spacing, spacing + spacing); int salonY = Util.RNG.Generate(spacing, (int)(spacing * PHI)); int salonH = Util.RNG.Generate(salonY, spacing + spacing); delta = 0f; //(float)((salonX - Util.RNG.Generate(spacing, salonX)>>1)); // Make the vestibule room = MakeRectRoom((int)(delta), 0, salonX - (int)(delta + delta), salonY); room.Cleared = true; room.Features = new string[0]; room.Difficulty = 0; room.Name = "Vestibule"; // Make the Salon room = MakeRectRoom(0, salonY, salonX, salonH); room.Name = "Salon"; MakeRectRoom(salonX, salonY, spacing, salonH); MakeRectRoom(-spacing, salonY, spacing, salonH); MakeRectRoom(salonX - (int)(delta), 0, spacing + (int)(delta), salonY); MakeRectRoom(-spacing, 0, spacing + (int)(delta), salonY); for (int column = 0; column <= hyphen; column++) { delta = column == hyphen ? 1 : (float)(hyphen - column); for (int numrooms = (int)Math.Ceiling(pavilion * curve1 / delta) - 1; numrooms >= 0; numrooms--) { MakeRectRoom(salonX + spacing + column * spacing, -numrooms * spacing, spacing, numrooms > 0 ? spacing : salonY); MakeRectRoom(-(column + 2) * spacing, -numrooms * spacing, spacing, numrooms > 0 ? spacing : salonY); } for (int numrooms = 1 + (int)Math.Floor((float)(jut) / delta); numrooms > 0; numrooms--) { MakeRectRoom( salonX + spacing + column * spacing, salonY + (numrooms - 1) * salonH, spacing, numrooms > 1 ? spacing : salonH); MakeRectRoom( -(column + 2) * spacing, salonY + (numrooms - 1) * salonH, spacing, numrooms > 1 ? spacing : salonH); } } foreach (KeyValuePair <RoomVO, List <RoomVO> > kvp in _rooms) { kvp.Key.Doors = kvp.Value.Where(r => r != kvp.Key).ToArray(); } map.Rooms = _rooms.Keys.ToArray(); return(map); }