diff --git a/Assets/LevelData/h_puzzle.json b/Assets/LevelData/h_puzzle.json index aa36565..3d5dc54 100644 --- a/Assets/LevelData/h_puzzle.json +++ b/Assets/LevelData/h_puzzle.json @@ -2,15 +2,15 @@ "doors": [ { "type": "DEFAULT", - "action": "LIFE" + "action": "PUZZLE" }, { "type": "DEFAULT", - "action": "LIFE" + "action": "PUZZLE" }, { "type": "DEFAULT", - "action": "LIFE" + "action": "PUZZLE" } ], "guards": [ @@ -28,14 +28,14 @@ } ], "doorsmods": [ - "BLUE", - "WHITE", - "BLACK" + "#BLUE", + "#WHITE", + "#BLACK" ], "introdialog": "These guards are fans of riddles", "dialog": { "what": { - "is your riddle": "RIDDLE" + "is your statement": "RIDDLE" } } } \ No newline at end of file diff --git a/Assets/LevelData/i_cup.json b/Assets/LevelData/i_cup.json new file mode 100644 index 0000000..86d483a --- /dev/null +++ b/Assets/LevelData/i_cup.json @@ -0,0 +1,56 @@ +{ + "doors": [ + { + "type": "DEFAULT", + "action": "DEATH" + }, + { + "type": "DEFAULT", + "action": "DEATH" + }, + { + "type": "DEFAULT", + "action": "LIFE" + } + ], + "guards": [ + { + "type": "BASE", + "action": "LIAR" + }, + { + "type": "BASE", + "action": "TRUTHER" + } + ], + "guardsmods": [ + "HAT", + "SHORT" + ], + "doorsmods": [ + "#LEFT", + "#CENTER", + "#RIGHT" + ], + "globalmod": "CUP", + "introdialog": "These doors get restless after every question asked", + "dialog": { + "is": { + "DOORS": { + "safe": "DS#safe", + "unsafe": "DS#safe!" + }, + "GUARDS_YOU": { + "short": "GS#short", + "wearing a hat": "GS#hat" + } + }, + "NOREC_what would": { + "GUARDS": { + "answer to:": { + "QUESTION": "GS%" + } + } + } + } +} \ No newline at end of file diff --git a/Assets/LevelData/i_cup.json.meta b/Assets/LevelData/i_cup.json.meta new file mode 100644 index 0000000..d9e7bde --- /dev/null +++ b/Assets/LevelData/i_cup.json.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 3f7768c50f1e44d6b0965af3ba420fde +timeCreated: 1787829244 \ No newline at end of file diff --git a/Assets/LevelData/supporting/parlor.json b/Assets/LevelData/supporting/parlor.json index 2b1c2bc..c26e41c 100644 --- a/Assets/LevelData/supporting/parlor.json +++ b/Assets/LevelData/supporting/parlor.json @@ -1,300 +1,300 @@ { "boxes": [ { + "color": "Black", "statements": [ - "A box with a false statement contains the gems", - "The statement on the blue box is true", - "The blue box contains the gems" - ], - "color": "Black" + "A door with a false statement leads to safety", + "What the guard at the blue door says is true", + "The blue door leads to safety" + ] }, { + "color": "White", "statements": [ "All three statements are false", "Two statements are false", - "The gems are in a box with a false statement" - ], - "color": "White" + "Safety lies behind a door with a false statement" + ] }, { + "color": "White", "statements": [ - "Every box is black", - "Every box contains gems", - "The statement on one of the other two boxes would be true if you replaced the word 'every' with the word 'this'" - ], - "color": "White" + "Every door is black", + "Every door leads to safety", + "What the guard at one of the other two doors says would be true if you replaced the word 'every' with the word 'this'" + ] }, { + "color": "Black", "statements": [ - "Gems are in both the black box and the white box", - "Gems are in both the blue box and the black box", - "Gems are not in the white box or the blue box" - ], - "color": "Black" + "Safety lies behind both the black door and the white door", + "Safety lies behind both the blue door and the black door", + "Safety does not lie behind the white door or the blue door" + ] }, { + "color": "White", "statements": [ - "One of the other boxes is false", - "You will open this box and find it empty", - "The blue box is true" - ], - "color": "White" + "One of the other guards is lying", + "You will open this door and find death waiting", + "The guard at the blue door is telling the truth" + ] }, { + "color": "White", "statements": [ - "One of the other two boxes is false", - "You will open this box and find it empty", - "The blue box is true" - ], - "color": "White" + "One of the other two guards is lying", + "You will open this door and find death waiting", + "The guard at the blue door is telling the truth" + ] }, { + "color": "White", "statements": [ - "Only one box is true", - "Only one box contains the gems", - "The gems are in the white box" - ], - "color": "White" + "Only one guard is telling the truth", + "Only one door leads to safety", + "Safety lies behind the white door" + ] }, { + "color": "White", "statements": [ - "Only one box is true", - "The black box contains the gems", - "The blue box contains the gems" - ], - "color": "White" + "Only one guard is telling the truth", + "The black door leads to safety", + "The blue door leads to safety" + ] }, { + "color": "White", "statements": [ "Only one statement is false", "Only one statement is true", - "The gems are in a box with a false statement" - ], - "color": "White" + "Safety lies behind a door with a false statement" + ] }, { + "color": "Black", "statements": [ - "The black box contains gems", - "This box and the blue box are empty", - "All three boxes are empty" - ], - "color": "Black" + "The black door leads to safety", + "This door and the blue door lead to death", + "All three doors lead to death" + ] }, { + "color": "Black", "statements": [ - "The black box contains the gems", - "This box and the blue box are empty", - "All three boxes are empty" - ], - "color": "Black" + "The black door leads to safety", + "This door and the blue door lead to death", + "All three doors lead to death" + ] }, { + "color": "Black", "statements": [ - "The black box is black", - "The black box is true.", - "The black box is empty" - ], - "color": "Black" + "The black door is black", + "The guard at the black door is telling the truth.", + "The black door leads to death" + ] }, { + "color": "Blue", "statements": [ - "The black box is false", - "The black box is true", - "A false box contains the gems" - ], - "color": "Blue" + "The guard at the black door is lying", + "The guard at the black door is telling the truth", + "A false door leads to safety" + ] }, { + "color": "Blue", "statements": [ - "The black box is not empty", - "The statement on the black box is true", - "A box with a false statement contains the gems" - ], - "color": "Blue" + "The black door does not lead to death", + "What the guard at the black door says is true", + "A door with a false statement leads to safety" + ] }, { + "color": "White", "statements": [ - "The black box is true", - "The gems are in the true box", - "The blue box is true" - ], - "color": "White" + "The guard at the black door is telling the truth", + "Safety lies behind the true door", + "The guard at the blue door is telling the truth" + ] }, { + "color": "Black", "statements": [ - "The empty boxes are both true", - "The gems are in the black box", - "This is not an empty box" - ], - "color": "Black" + "The guards at the deadly doors are both telling the truth", + "Safety lies behind the black door", + "This is not a deadly door" + ] }, { + "color": "Black", "statements": [ - "The empty boxes both have true statements", - "The blue box has a true statement", - "This box contains the gems" - ], - "color": "Black" + "The guards at the deadly doors are both telling the truth", + "The guard at the blue door is telling the truth", + "This door leads to safety" + ] }, { + "color": "White", "statements": [ - "The gems are in a box with a false statement", - "The blue box is false", - "The white box is false" - ], - "color": "White" + "Safety lies behind a door with a false statement", + "The guard at the blue door is lying", + "The guard at the white door is lying" + ] }, { + "color": "Blue", "statements": [ - "The gems are in another box", - "The truth is on another box", - "The words \"another box\" are on another box" - ], - "color": "Blue" + "Safety lies behind another door", + "The truth is spoken by another door", + "The words \"another door\" are spoken by another door" + ] }, { + "color": "Black", "statements": [ - "The gems are in the black box", + "Safety lies behind the black door", "This statement is of no help at all", - "This box and the blue box are both false" - ], - "color": "Black" + "This guard and the guard at the blue door are both lying" + ] }, { + "color": "Blue", "statements": [ - "The gems are in the black box", - "The gems are in the white box", - "Only one box displays a true statement" - ], - "color": "Blue" + "Safety lies behind the black door", + "Safety lies behind the white door", + "Only one guard is telling the truth" + ] }, { + "color": "Black", "statements": [ - "The gems are in the box with the word \"blue\" on it", + "Safety lies behind the door with the word \"blue\" on it", "", - "The gems are in a box that is actually blue" - ], - "color": "Black" + "Safety lies behind a door that is actually blue" + ] }, { + "color": "Black", "statements": [ - "The gems are in the false box", - "The gems are in the false box", - "Only one of the other boxes is false" - ], - "color": "Black" + "Safety lies behind the false door", + "Safety lies behind the false door", + "Only one of the other guards is lying" + ] }, { + "color": "Blue", "statements": [ - "The gems are in the only box with a true statement", - "One of the other boxes is true", - "The gems are in the only box with a false statement" - ], - "color": "Blue" + "Safety lies behind the only door with a true statement", + "One of the other guards is telling the truth", + "Safety lies behind the only door with a false statement" + ] }, { + "color": "Blue", "statements": [ - "The gems are in the only true box", + "Safety lies behind the only true door", "Only one statement is true", - "The blue box contains the gems" - ], - "color": "Blue" + "The blue door leads to safety" + ] }, { + "color": "Blue", "statements": [ - "The gems are in the white box", - "A box with a false statement contains the gems", - "The statement on the white box is true" - ], - "color": "Blue" + "Safety lies behind the white door", + "A door with a false statement leads to safety", + "What the guard at the white door says is true" + ] }, { + "color": "White", "statements": [ - "The gems are in the white box", + "Safety lies behind the white door", "Statements with the word \"white\" are always true", - "The statement on the white box is true" - ], - "color": "White" + "What the guard at the white door says is true" + ] }, { + "color": "Black", "statements": [ - "The gems are in the white box", + "Safety lies behind the white door", "The other two statements are both true", - "The gems are not in the blue box" - ], - "color": "Black" + "Safety does not lie behind the blue door" + ] }, { + "color": "Blue", "statements": [ - "The gems are in this box", + "Safety lies behind this door", "This statement is of no help of all", - "The gems are in the blue box" - ], - "color": "Blue" + "Safety lies behind the blue door" + ] }, { + "color": "White", "statements": [ - "The gems are not in a box with a true statement", - "The statement on the blue box is true as is this statement", - "The gems are not in a box with a true statement" - ], - "color": "White" + "Safety does not lie behind a door with a true statement", + "What the guard at the blue door says is true as is this statement", + "Safety does not lie behind a door with a true statement" + ] }, { + "color": "White", "statements": [ - "The gems are not in the box with a unique statement", + "Safety does not lie behind the door with a unique statement", "This statement is unique", - "The gems are not in the box with a unique statement" - ], - "color": "White" + "Safety does not lie behind the door with a unique statement" + ] }, { + "color": "Blue", "statements": [ - "The gems are not in the white box", - "The gems are not in this box", - "The gems are in this box" - ], - "color": "Blue" + "Safety does not lie behind the white door", + "Safety does not lie behind this door", + "Safety lies behind this door" + ] }, { + "color": "White", "statements": [ - "The gems are not in this box", - "The blue box is true", - "The gems are in this box" - ], - "color": "White" + "Safety does not lie behind this door", + "The guard at the blue door is telling the truth", + "Safety lies behind this door" + ] }, { + "color": "Black", "statements": [ - "The other two boxes are true", - "The other two boxes are blue", - "The other two boxes are empty" - ], - "color": "Black" + "The other two guards are telling the truth", + "The other two doors are blue", + "The other two doors lead to death" + ] }, { + "color": "White", "statements": [ "There are two false statements", "This is the only true statement", - "The white box is empty" - ], - "color": "White" + "The white door leads to death" + ] }, { + "color": "Black", "statements": [ - "There are two true boxes", - "There are two empty boxes", - "This box is empty" - ], - "color": "Black" + "There are two truthful guards", + "There are two deadly doors", + "This door leads to death" + ] }, { + "color": "Blue", "statements": [ "There is only one true statement", - "A gems are in a box with a false statement", + "Safety lies behind a door with a false statement", "There are two true statements" - ], - "color": "Blue" + ] } ] } \ No newline at end of file diff --git a/Assets/Scenes/MainMenu.unity b/Assets/Scenes/MainMenu.unity index 3200324..3515abc 100644 --- a/Assets/Scenes/MainMenu.unity +++ b/Assets/Scenes/MainMenu.unity @@ -666,6 +666,9 @@ MonoBehaviour: - {fileID: 4900000, guid: f8aa8b1537c54d6a91f84f42c5242517, type: 3} - {fileID: 4900000, guid: 74689c3b2e3e4aa2b95c0cc2d4d0609a, type: 3} - {fileID: 4900000, guid: 952c1e81a6ca4c5ca91390ad12e714ab, type: 3} + - {fileID: 4900000, guid: dc3e4e9757d445debb596fe2f5fad7a4, type: 3} + - {fileID: 4900000, guid: 3f7768c50f1e44d6b0965af3ba420fde, type: 3} + parlorPuzzles: {fileID: 4900000, guid: 665a3d6096294d17ab0ea2e2db862bbb, type: 3} --- !u!4 &516359711 Transform: m_ObjectHideFlags: 0 diff --git a/Assets/Scenes/Scene_Loadtest.unity b/Assets/Scenes/Scene_Loadtest.unity index 26e9dd5..ce6f0e2 100644 --- a/Assets/Scenes/Scene_Loadtest.unity +++ b/Assets/Scenes/Scene_Loadtest.unity @@ -368,6 +368,58 @@ CanvasRenderer: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 28945337} m_CullTransparentMesh: 1 +--- !u!1 &111963511 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 111963513} + - component: {fileID: 111963512} + m_Layer: 0 + m_Name: CupShuffle + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!114 &111963512 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 111963511} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: aac4d07d6a79b7b379cd8e5dd08ad7ec, type: 3} + m_Name: + m_EditorClassIdentifier: '::' + cups: + - {fileID: 0} + - {fileID: 0} + - {fileID: 0} + numberOfSwaps: 6 + swapDuration: 0.5 + arcHeight: 1 + delayBetweenSwaps: 0.1 +--- !u!4 &111963513 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 111963511} + serializedVersion: 2 + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 20.10972, y: -1.9, z: 4.50587} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 0} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!1 &141379855 GameObject: m_ObjectHideFlags: 0 @@ -7172,3 +7224,4 @@ SceneRoots: - {fileID: 1008838629} - {fileID: 537607019} - {fileID: 604863488} + - {fileID: 111963513} diff --git a/Assets/Scripts/CupShuffle.cs b/Assets/Scripts/CupShuffle.cs new file mode 100644 index 0000000..971e1a1 --- /dev/null +++ b/Assets/Scripts/CupShuffle.cs @@ -0,0 +1,87 @@ +using System; +using System.Collections; +using System.Linq; +using UnityEngine; +using Utils; +using Random = UnityEngine.Random; + +public class CupShuffle : Singleton +{ + public GameObject[] cups = new GameObject[3]; // assign 3 GameObjects in Inspector + public int numberOfSwaps = 6; // how many swaps in the shuffle + public float swapDuration = 0.5f; // time per swap + public float arcHeight = 1.0f; // how high objects hop during swap + public float delayBetweenSwaps = 0.1f; + + private Vector3[] positions = new Vector3[3]; // the 3 fixed slot positions + private int[] slotOccupant = new int[3]; // which cup index currently sits in slot i + + public void StartShuffle() + { + cups = LevelLoader.Instance.Doors.ConvertAll((item) => item.gameObject).ToArray(); + // Record starting positions as the 3 fixed slots + for (int i = 0; i < 3; i++) + { + positions[i] = cups[i].transform.position; + slotOccupant[i] = i; // cup i starts in slot i + } + + StartCoroutine(ShuffleRoutine()); + } + + IEnumerator ShuffleRoutine() + { + for (int s = 0; s < numberOfSwaps; s++) + { + // Pick two different slots to swap + int slotA = Random.Range(0, 3); + int slotB; + do { slotB = Random.Range(0, 3); } while (slotB == slotA); + + yield return StartCoroutine(SwapSlots(slotA, slotB)); + yield return new WaitForSeconds(delayBetweenSwaps); + } + + var sorted = cups.ToList(); + sorted.Sort((a,b) => Mathf.RoundToInt(a.transform.position.x - b.transform.position.x)); + sorted[0].GetComponent().mod = "#LEFT"; + sorted[1].GetComponent().mod = "#CENTER"; + sorted[2].GetComponent().mod = "#RIGHT"; + } + + IEnumerator SwapSlots(int slotA, int slotB) + { + GameObject objA = cups[slotOccupant[slotA]]; + GameObject objB = cups[slotOccupant[slotB]]; + + Vector3 startA = positions[slotA]; + Vector3 startB = positions[slotB]; + Vector3 endA = positions[slotB]; + Vector3 endB = positions[slotA]; + + float t = 0f; + while (t < swapDuration) + { + t += Time.deltaTime; + float normalized = Mathf.Clamp01(t / swapDuration); + float ease = Mathf.SmoothStep(0f, 1f, normalized); + + // Arc offset (sine curve peaks at the midpoint of the move) + float arc = Mathf.Sin(ease * Mathf.PI) * arcHeight; + + objA.transform.position = Vector3.Lerp(startA, endA, ease) + Vector3.up * arc; + objB.transform.position = Vector3.Lerp(startB, endB, ease) + Vector3.up * arc; + + yield return null; + } + + // Snap to exact final positions + objA.transform.position = endA; + objB.transform.position = endB; + + // Update which cup occupies which slot + int temp = slotOccupant[slotA]; + slotOccupant[slotA] = slotOccupant[slotB]; + slotOccupant[slotB] = temp; + } +} diff --git a/Assets/Scripts/CupShuffle.cs.meta b/Assets/Scripts/CupShuffle.cs.meta new file mode 100644 index 0000000..6500a79 --- /dev/null +++ b/Assets/Scripts/CupShuffle.cs.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: aac4d07d6a79b7b379cd8e5dd08ad7ec \ No newline at end of file diff --git a/Assets/Scripts/DialogManager.cs b/Assets/Scripts/DialogManager.cs index 6823f5f..5367e80 100644 --- a/Assets/Scripts/DialogManager.cs +++ b/Assets/Scripts/DialogManager.cs @@ -248,13 +248,17 @@ public class DialogManager : Singleton var response = FullQuestionCopt; - if (!FullQuestion.Contains("$")) + if (FullQuestion == "RIDDLE") + { + response = currentGuard.puzzle; + } + else if (!FullQuestion.Contains("$")) { //now get a response from the guard being questioned response = currentGuard.Answer(FullQuestion).ToRandomString(); - } - + + response = response.Replace("$", ""); string responsePrefix = ""; diff --git a/Assets/Scripts/DoorManager.cs b/Assets/Scripts/DoorManager.cs index 2c84c88..f259582 100644 --- a/Assets/Scripts/DoorManager.cs +++ b/Assets/Scripts/DoorManager.cs @@ -83,7 +83,13 @@ public class DoorManager : MonoBehaviour, IDescribable if (mod == "RED" || mod == "BLUE" || mod == "PLAIN") { return $"the {mod} door"; - } // add more modification here + } + + if (mod == "#LEFT" || mod == "#CENTER" || mod == "#RIGHT") + { + return $"the {mod.Replace("#","")} door"; + } + // add more modification here return "the door"; } diff --git a/Assets/Scripts/LevelLoader.cs b/Assets/Scripts/LevelLoader.cs index c322748..173a983 100644 --- a/Assets/Scripts/LevelLoader.cs +++ b/Assets/Scripts/LevelLoader.cs @@ -92,7 +92,7 @@ public class LevelLoader : Singleton var manager = guardinstance.GetComponent(); manager.type = data.guards[i].action; - manager.puzzle = parlorData.boxes[puzzleId].puzzles[i]; + manager.puzzle = parlorData.boxes[puzzleId].statements[i]; if (data.guardsmods == null || data.guardsmods.Count == 0) { diff --git a/Assets/Scripts/SpeechManager.cs b/Assets/Scripts/SpeechManager.cs index 966bd90..cdad929 100644 --- a/Assets/Scripts/SpeechManager.cs +++ b/Assets/Scripts/SpeechManager.cs @@ -25,6 +25,8 @@ public class SpeechManager : Singleton public string Status = "TALKING"; + private int counter = 0; + void Start() { playerPanel = transform.FindChildRecursive("PLAYERPANEL").gameObject; @@ -53,6 +55,10 @@ public class SpeechManager : Singleton { AudioManager.Instance.PlaySound("Select"); gameObject.SetActive(false); + if (counter++ > 0 && LevelLoader.Instance.GlobalModifier == "CUP") + { + CupShuffle.Instance.StartShuffle(); + } } } diff --git a/Assets/Scripts/Utils/LevelData.cs b/Assets/Scripts/Utils/LevelData.cs index a0d84f6..8b659ae 100644 --- a/Assets/Scripts/Utils/LevelData.cs +++ b/Assets/Scripts/Utils/LevelData.cs @@ -37,7 +37,7 @@ namespace Utils [System.Serializable] public class Puzzle { - public string[] puzzles; + public string[] statements; public string color; } } \ No newline at end of file