string GetSwitchValue(TaskSwitch sw, Dictionary <string, object> localVariables, TaskRandom random) { string val = TranslateStringValue(sw.Value, localVariables); var cases = TranslateStringValues(sw.Cases, localVariables); int index = cases.ToList().IndexOf(val); string result; if (sw.IsTexts) { if (index >= 0 && index < sw.ValuesTexts.Length) { result = RenderText(sw.ValuesTexts[index], random.GetSubRandom(), Setting.Level); } else { result = RenderText(sw.DefaultText, random.GetSubRandom(), Setting.Level); } } else if (index >= 0 && index < sw.Values.Length) { result = TranslateStringValue(sw.Values[index], localVariables); } else { result = TranslateStringValue(sw.Default, localVariables); } // Save local variable if (sw.IsLocalVariableSource) { localVariables[sw.Id] = result; } // Save global variable if (sw.IsGlobal) { globalVariables[sw.Id] = result; } return(result); }
public override string GetValue(TaskRandom rnd) => Render.RenderText(Texts[rnd.NextInt(Texts.Length)], rnd.GetSubRandom(), Render.Setting.Level);
private void RenderText(TaskText text) { output.AppendLine(RenderText(text, random.GetSubRandom(), Setting.Level)); }