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
+59 -3
View File
@@ -7,10 +7,21 @@ using Utils;
public class GuardManager : MonoBehaviour, IDescribable
{
public string type;
public string mod;
public GameObject hat;
// Start is called once before the first execution of Update after the MonoBehaviour is created
void Start()
{
if (mod == "SHORT")
{
transform.localScale = new Vector3(1f, 0.1f, 1f);
}
else if (mod == "HAT")
{
Instantiate(hat, transform);
}
}
// Update is called once per frame
@@ -64,8 +75,6 @@ public class GuardManager : MonoBehaviour, IDescribable
{
if (question[0] == 'G')
{
Debug.Log(question);
Debug.Log(question.Substring(1,1));
int index = int.Parse(question.Substring(1,1));
var guard = LevelLoader.Instance.Guards[index];
return guard.Answer(question.Substring(3));
@@ -84,6 +93,12 @@ public class GuardManager : MonoBehaviour, IDescribable
var door = LevelLoader.Instance.Doors[index];
return door.GetProperty(question.Substring(3));
}
else if (question[0] == 'G')
{
int index = int.Parse(question.Substring(1,1));
var guard = LevelLoader.Instance.Guards[index];
return guard.GetProperty(question.Substring(3));
}
else
{
throw new NotImplementedException();
@@ -104,4 +119,45 @@ public class GuardManager : MonoBehaviour, IDescribable
{
return "Describe " + type;
}
public string GetUnknownDescription()
{
if (mod == "SHORT")
{
return "the short guard";
}
else if (mod == "HAT")
{
return "the guard with the hat";
}// add more modification here
throw new NotImplementedException();
}
public QuestionAnswer GetProperty(string property)
{
var answer = QuestionAnswer.NO_YES;
if (property.StartsWith("hat"))
{
answer = mod == "HAT" ? QuestionAnswer.YES : QuestionAnswer.NO;
}
if (property.StartsWith("short"))
{
answer = mod == "SHORT" ? QuestionAnswer.YES : QuestionAnswer.NO;
}
if (property.EndsWith("!"))
{
//we want opposite, so switch
return answer switch
{
QuestionAnswer.YES => QuestionAnswer.NO,
QuestionAnswer.NO => QuestionAnswer.YES,
QuestionAnswer.NO_YES => QuestionAnswer.NO_YES // i think? since we cannot confidently lie?
};
}
//else return base
return answer;
}
}