Add the ability to ask questions ABOUT the guards

This commit is contained in:
WillJeynes
2026-08-25 14:57:05 +01:00
parent 514ba1f26f
commit cf651447d3
18 changed files with 769 additions and 29 deletions
+35 -13
View File
@@ -3,6 +3,7 @@ using System.Collections.Generic;
using DefaultNamespace;
using JetBrains.Annotations;
using Newtonsoft.Json.Linq;
using NUnit.Framework;
using TMPro;
using UnityEngine;
using UnityEngine.Rendering;
@@ -85,16 +86,29 @@ public class DialogManager : Singleton<DialogManager>
//special keywords
if (kvp.Key == "DOORS")
{
for (int i = 0; i < LevelLoader.Instance.Doors.Count; i++)
foreach (var man in LevelLoader.Instance.Doors)
{
PopulateSingleQuestionOption(new KeyValuePair<string, JToken>("door " + (i+1), kvp.Value));
PopulateSingleQuestionOption(new KeyValuePair<string, JToken>(man.GetUnknownDescription(), kvp.Value));
}
}
else if (kvp.Key == "GUARDS")
else if (kvp.Key.StartsWith("GUARDS"))
{
for (int i = 0; i < LevelLoader.Instance.Guards.Count; i++)
foreach (var man in LevelLoader.Instance.Guards)
{
PopulateSingleQuestionOption(new KeyValuePair<string, JToken>("guard " + (i+1), kvp.Value));
string postfix = "";
if (man == currentGuard)
{
if (kvp.Key.EndsWith("YOU"))
{
postfix = " (you)";
}
else
{
//this lowkey breaks most puzzes cause double negative makes all tell truth
continue;
}
}
PopulateSingleQuestionOption(new KeyValuePair<string, JToken>(man.GetUnknownDescription() + postfix, kvp.Value));
}
}
else if (kvp.Key == "QUESTION")
@@ -178,7 +192,7 @@ public class DialogManager : Singleton<DialogManager>
FullQuestion = FullQuestionPrefixes.Pop() + FullQuestion;
}
Debug.LogError(FullQuestion);
Debug.Log(FullQuestion);
string q = "";
string r = "";
@@ -189,22 +203,30 @@ public class DialogManager : Singleton<DialogManager>
q += item;
r = item + " " + r;
if (item.StartsWith("guard "))
int ig = LevelLoader.Instance.Guards.FindIndex(
guard => item.StartsWith(guard.GetUnknownDescription())
);
if (ig >= 0)
{
FullQuestion = FullQuestion.ReplaceLast("GS", "G" + (int.Parse(item[^1].ToString())-1));
FullQuestion = FullQuestion.ReplaceLast("GS", "G" + ig);
}
if (item.StartsWith("door "))
int id = LevelLoader.Instance.Doors.FindIndex(
door => item.StartsWith(door.GetUnknownDescription())
);
if (id >= 0)
{
FullQuestion = FullQuestion.ReplaceLast("DS", "D" + (int.Parse(item[^1].ToString())-1));
FullQuestion = FullQuestion.ReplaceLast("DS", "D" + id);
}
}
Debug.LogError(q);
Debug.LogError(FullQuestion);
Debug.Log(FullQuestion);
//now get a response from the guard being questioned
var response = currentGuard.Answer(FullQuestion);
Debug.Log(response);
r = r.Replace("NOREC_", "");