Example #1
0
        private static void ApplyAttributes(Cell cell, Tile[,] template)
        {
            int w = template.GetLength(0), h = template.GetLength(1);
            var attr = cell.Attributes;

            if ((attr & AttributeType.Exit) == AttributeType.Exit)
                template[w/2, h/2].Attributes = AttributeType.Exit;
            else if ((attr & AttributeType.Entry) == AttributeType.Entry)
                template[w/2, h/2].Attributes = AttributeType.Entry;

            // apply monster spawns in center
            if ((attr & AttributeType.MobSpawn) == AttributeType.MobSpawn)
            {
                Iterate(template, (point, tile) =>
                {
                   if (tile.MaterialType == MaterialType.Floor && (point.X > w/2.0f && point.Y < h/2.0f))
                   {
                        template[point.X, point.Y].Attributes |= AttributeType.MobSpawn;
                       return false;
                   }
                    return true;
                });
            }

            // apply loot chests in corners of rooms
            if ((attr & AttributeType.Loot) == AttributeType.Loot )
            {
                if (cell.Type == CellType.Room)
                {
                    template[1, 1].Attributes |= AttributeType.Loot;
                    template[w - 2, h - 2].Attributes |= AttributeType.Loot;
                }
                else if (cell.Type == CellType.Corridor)
                {
                    template[w/2, h/2].Attributes |= AttributeType.Loot;
                }
            }
        }
 private Cell ApplyAttributes(Cell newCell)
 {
     if (_random.Chance(_params.MobSpawns) && (!_params.MobsInRoomsOnly || newCell.Type == CellType.Room))
     {
         newCell.Attributes |= AttributeType.MobSpawn;
     }
     if (_random.Chance(_params.Loot) && newCell.Type == CellType.Room)
     {
         newCell.Attributes |= AttributeType.Loot;
     }
     if (_random.Chance(_params.Doors))
     {
         newCell.Attributes |= AttributeType.Doors;
     }
     return newCell;
 }