Implement final scene

This commit is contained in:
WillJeynes
2026-08-29 20:44:27 +01:00
parent fec7b392b5
commit 0c897631bc
18 changed files with 6049 additions and 4748 deletions
+24 -7
View File
@@ -16,7 +16,7 @@ public class DialogManager : Singleton<DialogManager>
{
private GuardManager currentGuard;
private JObject dialogTree;
public JObject dialogTree;
[CanBeNull] private JObject currentItem;
@@ -25,8 +25,8 @@ public class DialogManager : Singleton<DialogManager>
public GameObject AskButton;
private Transform QuestionOptionArea;
private Transform QuestionInfillArea;
public Transform QuestionOptionArea;
public Transform QuestionInfillArea;
private Stack<string> FullQuestionPrefixes = new Stack<string>();
private string FullQuestion;
@@ -62,7 +62,13 @@ public class DialogManager : Singleton<DialogManager>
public void StartDialog(GuardManager guardId)
{
gameObject.SetActive(true);
dialogTree = LevelLoader.Instance.SpeechTree;
AskButton.SetActive(false);
QuestionOptionArea = transform.FindChildRecursive("ADDQOPTIONSHERE");
if (!GlobalStateManager.Instance.finalScene)
{
dialogTree = LevelLoader.Instance.SpeechTree;
}
currentGuard = guardId;
currentItem = dialogTree;
@@ -85,6 +91,7 @@ public class DialogManager : Singleton<DialogManager>
foreach (var kvp in currentItem)
{
Debug.Log(kvp.ToString());
//special keywords
if (kvp.Key == "DOORS")
{
@@ -137,7 +144,13 @@ public class DialogManager : Singleton<DialogManager>
AudioManager.Instance.PlaySound("WordAdd");
if (kvp.Value is JValue)
{
AddQuestionInfill(currentItem, kvp.Key + "?");
string addition = "?";
if (GlobalStateManager.Instance.finalScene)
{
addition = ".";
}
AddQuestionInfill(currentItem, kvp.Key + addition);
currentItem = null;
AskButton.SetActive(true);
@@ -259,8 +272,12 @@ public class DialogManager : Singleton<DialogManager>
}
var cdoor = LevelLoader.Instance.Doors.First((d) => d.type == "LIFE");
response = response.Replace("CDOOR", cdoor.mod.Replace("#",""));
var cdoor = LevelLoader.Instance.Doors.FirstOrDefault((d) => d.type == "LIFE");
if (cdoor != null)
{
response = response.Replace("CDOOR", cdoor.mod.Replace("#",""));
}
response = response.Replace("$", "");
+38
View File
@@ -0,0 +1,38 @@
using System.Collections;
using System.Collections.Generic;
using Newtonsoft.Json.Linq;
using UnityEngine;
public class EndSceneManager : MonoBehaviour
{
public TextAsset data;
// Start is called once before the first execution of Update after the MonoBehaviour is created
void Start()
{
LevelLoader.Instance.Guards = new List<GuardManager>();
LevelLoader.Instance.Doors = new List<DoorManager>();
var text = data.ToString();
DialogManager.Instance.dialogTree = JObject.Parse(text)["dialog"] as JObject;
DialogManager.Instance.StartDialog(GetComponent<GuardManager>());
StartCoroutine(DoSomethingAfterOneSecond());
}
IEnumerator DoSomethingAfterOneSecond()
{
yield return new WaitForSeconds(1f);
// Code to run after 1 second
DialogManager.Instance.gameObject.SetActive(true);
}
// Update is called once per frame
void Update()
{
}
}
+2
View File
@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 4bcd7646b8692c0c9b30c14a38141b66
+16 -3
View File
@@ -15,6 +15,8 @@ public class GlobalStateManager : Singleton<GlobalStateManager>
public TextAsset parlorPuzzles;
public bool finalScene = false;
//aaaaa theres nicer syntax for this i think
protected override bool dontDestroyOnLoad()
{
@@ -47,10 +49,12 @@ public class GlobalStateManager : Singleton<GlobalStateManager>
if (LevelIntended == levels.Count)
{
//win scene!!!
finalScene = true;
SceneManager.LoadScene(2);
}
else
{
finalScene = false;
//Reload game scene to start next level??
SceneManager.LoadScene(1);
}
@@ -73,8 +77,17 @@ public class GlobalStateManager : Singleton<GlobalStateManager>
public void LoadSpecificLevel(int level)
{
LevelIntended = level;
//load game scene
SceneManager.LoadScene(1);
if (level == levels.Count)
{
finalScene = true;
SceneManager.LoadScene(2);
}
else
{
finalScene = false;
LevelIntended = level;
//load game scene
SceneManager.LoadScene(1);
}
}
}
+13 -10
View File
@@ -46,17 +46,20 @@ public class GuardManager : MonoBehaviour, IDescribable
// Update is called once per frame
void Update()
{
if (isfocussed == 2 && focusLight.intensity < 250)
if (focusLight != null)
{
focusLight.intensity += Time.deltaTime * 100;
}
else if (isfocussed == 1 && focusLight.intensity < 150)
{
focusLight.intensity += Time.deltaTime * 100;
}
else if (isfocussed == 0 && focusLight.intensity > 100)
{
focusLight.intensity -= Time.deltaTime * 100;
if (isfocussed == 2 && focusLight.intensity < 250)
{
focusLight.intensity += Time.deltaTime * 100;
}
else if (isfocussed == 1 && focusLight.intensity < 150)
{
focusLight.intensity += Time.deltaTime * 100;
}
else if (isfocussed == 0 && focusLight.intensity > 100)
{
focusLight.intensity -= Time.deltaTime * 100;
}
}
}
+20 -1
View File
@@ -1,5 +1,6 @@
using TMPro;
using UnityEngine;
using UnityEngine.SceneManagement;
using UnityEngine.UI;
using Utils;
@@ -72,16 +73,19 @@ public class MainMenuController : MonoBehaviour
Destroy(child.gameObject);
}
GameObject levelButton;
for (int i = 0; i < GlobalStateManager.Instance.levels.Count; i++)
{
int levelIndex = i;
GameObject levelButton = Instantiate(LevelItemPrefab, parent);
levelButton = Instantiate(LevelItemPrefab, parent);
if (i <= GlobalStateManager.Instance.HighestLevel)
{
levelButton.GetComponentInChildren<Button>().onClick.AddListener(() => {
AudioManager.Instance.PlaySound("Select");
GlobalStateManager.Instance.finalScene = false;
GlobalStateManager.Instance.LoadSpecificLevel(levelIndex);
});
}
@@ -91,5 +95,20 @@ public class MainMenuController : MonoBehaviour
}
levelButton.GetComponentInChildren<TextMeshProUGUI>().text = (i + 1).ToString();
}
levelButton = Instantiate(LevelItemPrefab, parent);
if (GlobalStateManager.Instance.HighestLevel == GlobalStateManager.Instance.levels.Count)
{
levelButton.GetComponentInChildren<Button>().onClick.AddListener(() => {
AudioManager.Instance.PlaySound("Select");
GlobalStateManager.Instance.LoadSpecificLevel(GlobalStateManager.Instance.levels.Count);
});
}
else
{
levelButton.GetComponent<Image>().color = Color.red;
}
levelButton.GetComponentInChildren<TextMeshProUGUI>().text = "FIN";
levelButton.GetComponentInChildren<TextMeshProUGUI>().fontSize/=2;
}
}
+9
View File
@@ -4,6 +4,7 @@ using System.Collections.Generic;
using JetBrains.Annotations;
using TMPro;
using UnityEngine;
using UnityEngine.SceneManagement;
using UnityEngine.UI;
using Utils;
@@ -56,10 +57,18 @@ public class SpeechManager : Singleton<SpeechManager>
{
AudioManager.Instance.PlaySound("Select");
gameObject.SetActive(false);
//BORKBORKBORK
if (counter++ > 0 && LevelLoader.Instance.GlobalModifier == "CUP")
{
CupShuffle.Instance.StartShuffle();
}
//BORKBORKBORKBORK
if (GlobalStateManager.Instance.finalScene)
{
SceneManager.LoadScene(0);
}
}
}