protected SpawnDict(SpawnDict <TK, TV> other) { this.spawns = new Dictionary <TK, SpawnRate>(); foreach (TK key in other.spawns.Keys) { this.spawns.Add(key, new SpawnRate(other.spawns[key].Spawn, other.spawns[key].Rate)); } }
public CategorySpawnChooser(CategorySpawnChooser <T> other) { Spawns = new SpawnDict <string, SpawnList <T> >(); foreach (string key in other.Spawns.GetKeys()) { SpawnList <T> list = new SpawnList <T>(); SpawnList <T> otherList = other.Spawns.GetSpawn(key); for (int ii = 0; ii < otherList.Count; ii++) { list.Add(otherList.GetSpawn(ii), otherList.GetSpawnRate(ii)); } Spawns.Add(key, list, other.Spawns.GetSpawnRate(key)); } }
public SpawnDict <TK, TV> GetSpawnList(int level) { SpawnDict <TK, TV> newList = new SpawnDict <TK, TV>(); foreach (TK key in this.spawns.Keys) { SpawnRange spawn = this.spawns[key]; if (spawn.Range.Min <= level && level < spawn.Range.Max) { newList.Add(key, spawn.Spawn, spawn.Rate); } } return(newList); }
public T Pick(IRandom rand) { SpawnDict <string, SpawnList <T> > tempSpawn = new SpawnDict <string, SpawnList <T> >(); foreach (string key in Spawns.GetKeys()) { SpawnList <T> otherList = Spawns.GetSpawn(key); if (!otherList.CanPick) { continue; } tempSpawn.Add(key, otherList, Spawns.GetSpawnRate(key)); } SpawnList <T> choice = tempSpawn.Pick(rand); return(choice.Pick(rand)); }
public CategorySpawnChooser(SpawnDict <string, SpawnList <T> > spawns) { Spawns = spawns; }
public CategorySpawnChooser() { Spawns = new SpawnDict <string, SpawnList <T> >(); }