using System;
using System.Collections.Generic;
using System.Linq;
namespace DunGen.Graph
{
///
/// A line segment on the dungeon flow graph, representing a series of tiles forming a path through the dungeon
///
[Serializable]
public class GraphLine
{
public DungeonFlow Graph;
///
/// A collection of dungeon archetypes, of which one will be chosen to populate this segment of the dungeon
///
public List DungeonArchetypes = new List();
///
/// This segment's normalized position on the graph (0-1)
///
public float Position;
///
/// This segment's normalized length (0-1)
///
public float Length;
///
/// A list of possible keys to be placed in this area
///
public List Keys = new List();
///
/// A list of possible locked doors to be placed in this area
///
public List Locks = new List();
public GraphLine(DungeonFlow graph)
{
Graph = graph;
}
public DungeonArchetype GetRandomArchetype(RandomStream randomStream, IEnumerable usedArchetypes)
{
var validArchetypes = DungeonArchetypes.Where(a => !a.Unique || !usedArchetypes.Contains(a));
if (!validArchetypes.Any())
validArchetypes = DungeonArchetypes;
int index = randomStream.Next(0, validArchetypes.Count());
return validArchetypes.ElementAt(index);
}
}
}