public static EventData.Outcome chooseOutcome(EventData.Choice c, EventContext ctx) { double sum = 0; foreach (var o in c.outcomes) { sum += o.weight; } double rand = Eleven.random.NextDouble() * sum; foreach (var o in c.outcomes) { rand -= o.weight; if (rand <= 0) { ctx.updateEnvironment(o.environment); foreach (var e in o.effects) { EventRuntime.evaluate(e, ctx); } return(o); } } throw new Exception("unable to choose event outcome. "); }
public void dismiss(EventData.Choice c, EventContext ctx) { var o = EventManager.chooseOutcome(c, ctx); ui.world.audioStore.playClickSelect(); ui.removeBlocker(this.gameObject); if (o.description != null && o.description.Length > 0) { ui.world.prefabStore.popMsg(bindReferences(o.description, ctx, ui.world.map), true); } }