public void DoTransition(QuestPath questPath) { //if ((accessible_pathes_count <= 0) && (voidpathindex <= 0)) then return //Выполнение перехода, если выбран переход var pathindex = questPath.PathIndx; // if (voidpathindex > 0) // { // pathindex = voidpathindex; // } // else // { // if (CheckedAnswer > 0) then // pathindex = accessible_pathes[CheckedAnswer]; // } if (questPath.PathNumber == 0) { //ShowMessage('Ошибка перехода'); return; } var CurrPathX = currentLocationIndx; var CurrPathY = pathindex; PathesWeCanGo[CurrPathX, CurrPathY]--; daysPassed += quest.Paths[pathindex].dayscost; //makedo; for (var i = 0; i < Quest.maxparameters; ++i) { UndoPar[i] = Pars[i]; } currentLocationIndx = quest.Paths[pathindex].ToLocation; QuestParameterDelta[] delta = new QuestParameterDelta[Quest.maxparameters]; for (var i = 0; i < Quest.maxparameters; ++i) { delta[i] = quest.Paths[pathindex].DPars[i]; } ProcessParametersWithDelta(delta); ProcessParVisualOpions(delta); lastpathindex = pathindex; // if (quest.Paths[pathindex].EndPathMessage.Trim() != "") // { // Console.WriteLine(quest.Paths[pathindex].EndPathMessage.Trim()); // } WeAreInTheLocation(); }
private void CreateFinalAnswer(string text) { LastPossibleTransitions.Clear(); var tmp = new QuestPath(); tmp.Clear(); tmp.PathNumber = 0; tmp.PathIndx = -1; tmp.StartPathMessage = text; LastPossibleTransitions.Add(tmp); }
private bool PathIsVoid(QuestPath mixedAnswer) { return(string.IsNullOrEmpty(mixedAnswer.StartPathMessage.Trim())); }
List <QuestPath> PossibleTransitionsInner() { var result = new List <QuestPath>(); var SameTextPathes = new List <QuestPath>(); var mixed_answers = new List <QuestPath>(); var found_answers = new List <QuestPath>(); foreach (var t in CurrentLocation().transitions) { var canGo = PathesWeCanGo[currentLocationIndx, t.PathIndx] >= 1 && ArePathesStillFromHere(t.ToLocation); if (canGo) { t.gatesOk = IsParametersGatesOk(Pars, t.PathIndx); if (t.gatesOk || t.AlwaysShowWhenPlaying) { found_answers.Add(t); } } } var mixed_answers_flags = new bool[found_answers.Count]; for (int i = 0; i < found_answers.Count; ++i) { mixed_answers_flags[i] = true; } for (int i = 0; i < found_answers.Count; ++i) { SameTextPathes.Clear(); var maxprobfix_answers = new List <QuestPath>(); var found = -1; var maxprob = 0.0; if (mixed_answers_flags[i]) { found = i; for (int c = 0; c < mixed_answers_flags.Length; ++c) { if (quest.CompareQuestStrings(found_answers[i].StartPathMessage, found_answers[c].StartPathMessage)) //if (found_answers[i].StartPathMessage.Trim() == found_answers[c].StartPathMessage.Trim()) { mixed_answers_flags[c] = false; maxprobfix_answers.Add(found_answers[c]); if (maxprob < found_answers[c].Probability) { maxprob = found_answers[c].Probability; } } } for (int c = 0; c < maxprobfix_answers.Count; ++c) { if (maxprob <= 100 * maxprobfix_answers[c].Probability) { SameTextPathes.Add(maxprobfix_answers[c]); } } } var PAnswer = GetPathByProbability(SameTextPathes); if (PAnswer != null) { mixed_answers.Add(PAnswer); } } mixed_answers.Sort((p1, p2) => { var order = p1.ShowOrder.CompareTo(p2.ShowOrder); if (order == 0) { order = 1; } return(order); }); if (mixed_answers.Count == 1 && PathIsVoid(mixed_answers[0])) { return(mixed_answers); } else { for (var i = 0; i < mixed_answers.Count; ++i) { if (mixed_answers[i].StartPathMessage.Trim() != "") { QuestPath tmp = mixed_answers[i]; //tmp.StartPathMessage = quest.ProcessString(tmp.StartPathMessage, Pars); //tmp.EndPathMessage = quest.ProcessString(tmp.EndPathMessage, Pars); result.Add(tmp); //AddAnswer(mixed_answers[i].i, mixed_answers[i].text, mixed_answers[i].GatesOk); } } } // foreach (var t in CurrentLocation().transitions) // { // var canGo = PathesWeCanGo[currentLocationIndx, t.PathIndx]; // if (canGo <= 0) continue; // if (ArePathesStillFromHere(currentLocationIndx) == false) continue; // // bool gatesOk = IsParametersGatesOk(Pars, t.PathIndx); // // bool found = false; // foreach (var r in result) // { // if (t.StartPathMessage.Trim() == r.StartPathMessage.Trim()) // found = true; // } // // if (found) // continue; // // // if (gatesOk) // result.Add(t); // else if (t.AlwaysShowWhenPlaying) // result.Add(t); //TODO: if gatesOk == false then it's disabled // } return(result); }