public void RaisePeril(PerilData.PerilType type) { List <string> list = new List <string>(); foreach (KeyValuePair <string, PerilData> kv in game.cd.perils) { if (kv.Value.pType == type) { Peril p = new Peril(kv.Key); if (!p.Disabled()) { list.Add(kv.Key); } } } QueueEvent(list[Random.Range(0, list.Count)]); }
// Queue a peril event of a type public void RaisePeril(PerilData.PerilType type) { List <string> list = new List <string>(); // Find all matching perils foreach (KeyValuePair <string, PerilData> kv in game.cd.perils) { if (kv.Value.pType == type) { Peril p = new Peril(kv.Key); // If peril is valid add to list if (!p.Disabled()) { list.Add(kv.Key); } } } // Queue a random valid peril QueueEvent(list[Random.Range(0, list.Count)]); }