Resolve WES-76 "87 themeselection"

This commit is contained in:
Lukas Van Rossem
2023-03-13 21:49:40 +00:00
parent 94ec7e0359
commit a267301ab6
23 changed files with 141 additions and 893 deletions

View File

@@ -91,8 +91,12 @@ public class InfoMinigame : MonoBehaviour
gameImage.sprite = minigame.thumbnail;
controls.text = minigame.controls;
// Add click functionality
button.onClick.AddListener(() => SceneManager.LoadScene(minigame.minigameEntryPoint));
// Add click
if (minigame.needsTheme) {
button.onClick.AddListener(() => SceneManager.LoadScene("Common/Scenes/ThemeSelection"));
} else {
button.onClick.AddListener(() => SceneManager.LoadScene(minigame.minigameEntryPoint));
}
}
/// <summary>

View File

@@ -21,6 +21,11 @@ public class Minigame : ScriptableObject
/// </summary>
public string description;
/// <summary>
/// Whether or not the game needs a theme to be selected
/// </summary>
public bool needsTheme;
/// <summary>
/// Reference to the minigame thumbnail
/// </summary>

View File

@@ -2,12 +2,13 @@ using TMPro;
using UnityEngine;
using UnityEngine.SceneManagement;
using UnityEngine.UI;
using System.Collections.Generic;
/// <summary>
/// Handles the display of minigames in the ListMinigameScreen scene
/// </summary>
public class MinigameItem : MonoBehaviour
{
{
/// <summary>
/// Reference to the minigame object
/// </summary>
@@ -45,8 +46,11 @@ public class MinigameItem : MonoBehaviour
// Set appearance
thumbnail.sprite = minigame.thumbnail;
title.text = minigame.title;
// Add click functionality
button.onClick.AddListener(() => SceneManager.LoadScene("Common/Scenes/InfoMinigame"));
button.onClick.AddListener(() => {
PlayerPrefs.SetString("gamePath", minigame.minigameEntryPoint);
SceneManager.LoadScene("Common/Scenes/InfoMinigame");
});
}
}

View File

@@ -0,0 +1,36 @@
using UnityEngine;
/// <summary>
/// JSON structure containing all themes/words
/// </summary>
[System.Serializable]
public class ThemeList
{
public Theme[] themes;
}
/// <summary>
/// Object representing part of the JSON containing word data
/// </summary>
[System.Serializable]
public class Theme
{
public string name;
public string description;
public string[] words;
}
/// <summary>
/// Loader of the themes-JSON
/// </summary>
public class ThemeLoader : MonoBehaviour
{
/// <summary>
/// Loads the JSON file containing all of the themes
/// </summary>
public static ThemeList LoadJson()
{
TextAsset themeJson = Resources.Load<TextAsset>("Common/words");
return JsonUtility.FromJson<ThemeList>(themeJson.text);
}
}

View File

@@ -1,15 +1,25 @@
using UnityEngine;
using UnityEngine.SceneManagement;
/// <summary>
/// Controller for the theme selection screen
/// </summary>
public class ThemeSelectionController : MonoBehaviour
{
[Header("Theme Selection")]
// Theme prefab
/// <summary>
/// Theme prefab
/// </summary>
public GameObject themePrefab;
// Reference to container holding all theme-buttons
/// <summary>
/// Reference to container holding all theme-buttons
/// </summary>
public Transform themesContainer;
/// <summary>
/// Function that is called upon loading the scene
/// </summary>
public void Start()
{
// TODO: change to ScriptableObject
@@ -30,9 +40,12 @@ public class ThemeSelectionController : MonoBehaviour
}
}
/// <summary>
/// Function that is called upon a button click
/// </summary>
public void OnButtonClick(string clickedTheme)
{
PlayerPrefs.SetString("themeName", clickedTheme);
SceneManager.LoadScene("Game");
SceneManager.LoadScene(PlayerPrefs.GetString("gamePath"));
}
}

View File

@@ -0,0 +1,21 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: d7809d135a59849458ccb29ffad535c5, type: 3}
m_Name: JustSign
m_EditorClassIdentifier:
index: 2
title: Just Sign
description: A rhythm game
needsTheme: 1
thumbnail: {fileID: 0}
minigameEntryPoint: JustSign/Scenes/Game
controls: test

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: e726e0b93ea88465db7ee27605deb83f
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 11400000
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1127,7 +1127,7 @@ PrefabInstance:
objectReference: {fileID: 0}
- target: {fileID: 8299246693487308512, guid: 3bccdf365a4fbea4d8fa1aa461d3dc5c, type: 3}
propertyPath: m_OnClick.m_PersistentCalls.m_Calls.Array.data[0].m_Arguments.m_StringArgument
value: SpellingBee/Scenes/ThemeSelection
value: Common/Scenes/ThemeSelection
objectReference: {fileID: 0}
- target: {fileID: 8299246693487308514, guid: 3bccdf365a4fbea4d8fa1aa461d3dc5c, type: 3}
propertyPath: m_Name
@@ -1143,7 +1143,7 @@ PrefabInstance:
objectReference: {fileID: 0}
- target: {fileID: 8299246693487308515, guid: 3bccdf365a4fbea4d8fa1aa461d3dc5c, type: 3}
propertyPath: m_RootOrder
value: 6
value: 5
objectReference: {fileID: 0}
- target: {fileID: 8299246693487308515, guid: 3bccdf365a4fbea4d8fa1aa461d3dc5c, type: 3}
propertyPath: m_AnchorMax.x
@@ -4472,7 +4472,6 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 44fbed5ae228de39b9f727def7578d06, type: 3}
m_Name:
m_EditorClassIdentifier:
input: {fileID: 0}
endText: {fileID: 1502459770}
lpmText: {fileID: 1172084829}
lettersRightText: {fileID: 994850063}

View File

@@ -16,8 +16,9 @@ MonoBehaviour:
title: Spelling Bee
description: In deze minigame krijg je verschillende woorden voorgeschoteld die
je zo snel mogelijk moet spellen met behulp van het vingeralfabet
needsTheme: 1
thumbnail: {fileID: 21300000, guid: d99bb2dc44e35344fa358208a01c06c4, type: 3}
minigameEntryPoint: SpellingBee/Scenes/ThemeSelection
minigameEntryPoint: SpellingBee/Scenes/Game
controls: Je begint dit spel met 5 seconden tijd, voor elk juist antwoord krijg
je extra tijd. Hoe sneller je het spel uitspeelt, hoe meer punten je scoort.
Verloopt de timer, dan heb je het spelletje verloren

View File

@@ -125,7 +125,6 @@ public class GameController : MonoBehaviour
/// </summary>
private DateTime startTime;
/// <summary>
/// Reference to the user list to access the current user
/// </summary>

View File

@@ -4,17 +4,32 @@ using UnityEngine.SceneManagement;
using UnityEngine.UI;
public class SpellingBeeWebcam : MonoBehaviour
{
{
/// <summary>
/// Index of the current camera
/// </summary>
int camdex = 0;
/// <summary>
/// Texture to paste on the display
/// </summary>
WebCamTexture tex;
/// <summary>
/// Display for the video feed
/// </summary>
public RawImage display;
/// <summary>
/// For later use
/// </summary>
public TextMeshProUGUI dynamic;
/// <summary>
/// Initialize the camera view
/// </summary>
void Awake()
{
//popup.SetActive(false);
WebCamDevice device = WebCamTexture.devices[camdex];
tex = new WebCamTexture(device.name);
display.texture = tex;
@@ -22,6 +37,9 @@ public class SpellingBeeWebcam : MonoBehaviour
tex.Play();
}
/// <summary>
/// Switch to a different webcam
/// </summary>
public void SwapCam()
{
if (WebCamTexture.devices.Length > 0)
@@ -44,7 +62,9 @@ public class SpellingBeeWebcam : MonoBehaviour
}
}
// Scene changing is implemented here to avoid problems with webcam
/// <summary>
/// Scene changing is implemented here to avoid problems with webcam
/// </summary>
public void LoadScene(string sceneName)
{
display.texture = null;
@@ -53,24 +73,4 @@ public class SpellingBeeWebcam : MonoBehaviour
SceneManager.LoadScene(sceneName);
}
/*
public void Show_feedback(){
if(popup.activeSelf){
dynamic.text = "";
popup.SetActive(false);
return;
}
double index = UnityEngine.Random.value;
if(index < 0.5){
dynamic.text = "Poor";
}
else if(index > 0.8){
dynamic.text = "Excellent";
}
else{
dynamic.text = "Good";
}
popup.SetActive(true);
}
*/
}

View File

@@ -1,27 +0,0 @@
using UnityEngine;
// JSON structure containing all themes/words
[System.Serializable]
public class ThemeList
{
public Theme[] themes;
}
// Object representing part of the JSON containing word data
[System.Serializable]
public class Theme
{
public string name;
public string description;
public string[] words;
}
public class ThemeLoader : MonoBehaviour
{
// Loads the JSON file containing all of the themes
public static ThemeList LoadJson()
{
TextAsset themeJson = Resources.Load<TextAsset>("SpellingBee/words");
return JsonUtility.FromJson<ThemeList>(themeJson.text);
}
}

File diff suppressed because one or more lines are too long

View File

@@ -1 +1 @@
{"currentUserIndex":0,"storedUsers":[{"username":"testkonijn","avatar":{"instanceID":0},"playtime":0.0,"courses":[{"entries":[{"key":"courseIndex","bytes":[0,1,0,0,0,255,255,255,255,1,0,0,0,0,0,0,0,12,2,0,0,0,70,65,115,115,101,109,98,108,121,45,67,83,104,97,114,112,44,32,86,101,114,115,105,111,110,61,48,46,48,46,48,46,48,44,32,67,117,108,116,117,114,101,61,110,101,117,116,114,97,108,44,32,80,117,98,108,105,99,75,101,121,84,111,107,101,110,61,110,117,108,108,5,1,0,0,0,11,67,111,117,114,115,101,73,110,100,101,120,1,0,0,0,7,118,97,108,117,101,95,95,0,8,2,0,0,0,0,0,0,0,11]},{"key":"courseProgress","bytes":[0,1,0,0,0,255,255,255,255,1,0,0,0,0,0,0,0,4,1,0,0,0,13,83,121,115,116,101,109,46,83,105,110,103,108,101,1,0,0,0,7,109,95,118,97,108,117,101,0,11,205,204,76,62,11]}]}],"minigames":[{"entries":[{"key":"minigameIndex","bytes":[0,1,0,0,0,255,255,255,255,1,0,0,0,0,0,0,0,12,2,0,0,0,70,65,115,115,101,109,98,108,121,45,67,83,104,97,114,112,44,32,86,101,114,115,105,111,110,61,48,46,48,46,48,46,48,44,32,67,117,108,116,117,114,101,61,110,101,117,116,114,97,108,44,32,80,117,98,108,105,99,75,101,121,84,111,107,101,110,61,110,117,108,108,5,1,0,0,0,13,77,105,110,105,103,97,109,101,73,110,100,101,120,1,0,0,0,7,118,97,108,117,101,95,95,0,8,2,0,0,0,0,0,0,0,11]},{"key":"highscore","bytes":[0,1,0,0,0,255,255,255,255,1,0,0,0,0,0,0,0,4,1,0,0,0,12,83,121,115,116,101,109,46,73,110,116,51,50,1,0,0,0,7,109,95,118,97,108,117,101,0,8,0,0,0,0,11]},{"key":"scores","bytes":[0,1,0,0,0,255,255,255,255,1,0,0,0,0,0,0,0,12,2,0,0,0,70,65,115,115,101,109,98,108,121,45,67,83,104,97,114,112,44,32,86,101,114,115,105,111,110,61,48,46,48,46,48,46,48,44,32,67,117,108,116,117,114,101,61,110,101,117,116,114,97,108,44,32,80,117,98,108,105,99,75,101,121,84,111,107,101,110,61,110,117,108,108,4,1,0,0,0,129,1,83,121,115,116,101,109,46,67,111,108,108,101,99,116,105,111,110,115,46,71,101,110,101,114,105,99,46,76,105,115,116,96,49,91,91,71,97,109,101,67,111,110,116,114,111,108,108,101,114,43,83,99,111,114,101,44,32,65,115,115,101,109,98,108,121,45,67,83,104,97,114,112,44,32,86,101,114,115,105,111,110,61,48,46,48,46,48,46,48,44,32,67,117,108,116,117,114,101,61,110,101,117,116,114,97,108,44,32,80,117,98,108,105,99,75,101,121,84,111,107,101,110,61,110,117,108,108,93,93,3,0,0,0,6,95,105,116,101,109,115,5,95,115,105,122,101,8,95,118,101,114,115,105,111,110,4,0,0,22,71,97,109,101,67,111,110,116,114,111,108,108,101,114,43,83,99,111,114,101,91,93,2,0,0,0,8,8,9,3,0,0,0,10,0,0,0,10,0,0,0,7,3,0,0,0,0,1,0,0,0,10,0,0,0,4,20,71,97,109,101,67,111,110,116,114,111,108,108,101,114,43,83,99,111,114,101,2,0,0,0,9,4,0,0,0,9,5,0,0,0,9,6,0,0,0,9,7,0,0,0,9,8,0,0,0,9,9,0,0,0,9,10,0,0,0,9,11,0,0,0,9,12,0,0,0,9,13,0,0,0,5,4,0,0,0,20,71,97,109,101,67,111,110,116,114,111,108,108,101,114,43,83,99,111,114,101,2,0,0,0,10,115,99,111,114,101,86,97,108,117,101,4,116,105,109,101,0,1,8,2,0,0,0,153,0,0,0,6,14,0,0,0,19,49,48,47,48,51,47,50,48,50,51,32,49,53,58,51,56,58,53,54,1,5,0,0,0,4,0,0,0,17,0,0,0,6,15,0,0,0,19,49,48,47,48,51,47,50,48,50,51,32,49,53,58,51,57,58,53,48,1,6,0,0,0,4,0,0,0,16,0,0,0,6,16,0,0,0,19,49,48,47,48,51,47,50,48,50,51,32,49,55,58,53,51,58,50,50,1,7,0,0,0,4,0,0,0,14,0,0,0,6,17,0,0,0,19,49,48,47,48,51,47,50,48,50,51,32,49,55,58,53,49,58,51,49,1,8,0,0,0,4,0,0,0,12,0,0,0,6,18,0,0,0,19,49,48,47,48,51,47,50,48,50,51,32,49,55,58,50,55,58,48,55,1,9,0,0,0,4,0,0,0,11,0,0,0,6,19,0,0,0,19,49,48,47,48,51,47,50,48,50,51,32,49,53,58,51,51,58,53,48,1,10,0,0,0,4,0,0,0,11,0,0,0,6,20,0,0,0,19,49,48,47,48,51,47,50,48,50,51,32,49,54,58,50,49,58,52,55,1,11,0,0,0,4,0,0,0,11,0,0,0,6,21,0,0,0,19,49,48,47,48,51,47,50,48,50,51,32,49,55,58,51,54,58,50,56,1,12,0,0,0,4,0,0,0,9,0,0,0,6,22,0,0,0,19,49,48,47,48,51,47,50,48,50,51,32,49,55,58,51,48,58,49,56,1,13,0,0,0,4,0,0,0,8,0,0,0,6,23,0,0,0,19,49,48,47,48,51,47,50,48,50,51,32,49,54,58,50,49,58,50,54,11]}]}]}]}
{"currentUserIndex":0,"storedUsers":[{"username":"testkonijn","avatar":{"instanceID":0},"playtime":0.0,"courses":[{"entries":[{"key":"courseIndex","bytes":[0,1,0,0,0,255,255,255,255,1,0,0,0,0,0,0,0,12,2,0,0,0,70,65,115,115,101,109,98,108,121,45,67,83,104,97,114,112,44,32,86,101,114,115,105,111,110,61,48,46,48,46,48,46,48,44,32,67,117,108,116,117,114,101,61,110,101,117,116,114,97,108,44,32,80,117,98,108,105,99,75,101,121,84,111,107,101,110,61,110,117,108,108,5,1,0,0,0,11,67,111,117,114,115,101,73,110,100,101,120,1,0,0,0,7,118,97,108,117,101,95,95,0,8,2,0,0,0,0,0,0,0,11]},{"key":"courseProgress","bytes":[0,1,0,0,0,255,255,255,255,1,0,0,0,0,0,0,0,4,1,0,0,0,13,83,121,115,116,101,109,46,83,105,110,103,108,101,1,0,0,0,7,109,95,118,97,108,117,101,0,11,205,204,76,62,11]}]}],"minigames":[{"entries":[{"key":"minigameIndex","bytes":[0,1,0,0,0,255,255,255,255,1,0,0,0,0,0,0,0,12,2,0,0,0,70,65,115,115,101,109,98,108,121,45,67,83,104,97,114,112,44,32,86,101,114,115,105,111,110,61,48,46,48,46,48,46,48,44,32,67,117,108,116,117,114,101,61,110,101,117,116,114,97,108,44,32,80,117,98,108,105,99,75,101,121,84,111,107,101,110,61,110,117,108,108,5,1,0,0,0,13,77,105,110,105,103,97,109,101,73,110,100,101,120,1,0,0,0,7,118,97,108,117,101,95,95,0,8,2,0,0,0,0,0,0,0,11]},{"key":"highscore","bytes":[0,1,0,0,0,255,255,255,255,1,0,0,0,0,0,0,0,4,1,0,0,0,12,83,121,115,116,101,109,46,73,110,116,51,50,1,0,0,0,7,109,95,118,97,108,117,101,0,8,0,0,0,0,11]},{"key":"scores","bytes":[0,1,0,0,0,255,255,255,255,1,0,0,0,0,0,0,0,12,2,0,0,0,70,65,115,115,101,109,98,108,121,45,67,83,104,97,114,112,44,32,86,101,114,115,105,111,110,61,48,46,48,46,48,46,48,44,32,67,117,108,116,117,114,101,61,110,101,117,116,114,97,108,44,32,80,117,98,108,105,99,75,101,121,84,111,107,101,110,61,110,117,108,108,4,1,0,0,0,129,1,83,121,115,116,101,109,46,67,111,108,108,101,99,116,105,111,110,115,46,71,101,110,101,114,105,99,46,76,105,115,116,96,49,91,91,71,97,109,101,67,111,110,116,114,111,108,108,101,114,43,83,99,111,114,101,44,32,65,115,115,101,109,98,108,121,45,67,83,104,97,114,112,44,32,86,101,114,115,105,111,110,61,48,46,48,46,48,46,48,44,32,67,117,108,116,117,114,101,61,110,101,117,116,114,97,108,44,32,80,117,98,108,105,99,75,101,121,84,111,107,101,110,61,110,117,108,108,93,93,3,0,0,0,6,95,105,116,101,109,115,5,95,115,105,122,101,8,95,118,101,114,115,105,111,110,4,0,0,22,71,97,109,101,67,111,110,116,114,111,108,108,101,114,43,83,99,111,114,101,91,93,2,0,0,0,8,8,9,3,0,0,0,10,0,0,0,10,0,0,0,7,3,0,0,0,0,1,0,0,0,10,0,0,0,4,20,71,97,109,101,67,111,110,116,114,111,108,108,101,114,43,83,99,111,114,101,2,0,0,0,9,4,0,0,0,9,5,0,0,0,9,6,0,0,0,9,7,0,0,0,9,8,0,0,0,9,9,0,0,0,9,10,0,0,0,9,11,0,0,0,9,12,0,0,0,9,13,0,0,0,5,4,0,0,0,20,71,97,109,101,67,111,110,116,114,111,108,108,101,114,43,83,99,111,114,101,2,0,0,0,10,115,99,111,114,101,86,97,108,117,101,4,116,105,109,101,0,1,8,2,0,0,0,162,0,0,0,6,14,0,0,0,20,51,47,49,51,47,50,48,50,51,32,53,58,49,55,58,48,49,32,80,77,1,5,0,0,0,4,0,0,0,153,0,0,0,6,15,0,0,0,19,49,48,47,48,51,47,50,48,50,51,32,49,53,58,51,56,58,53,54,1,6,0,0,0,4,0,0,0,17,0,0,0,6,16,0,0,0,19,49,48,47,48,51,47,50,48,50,51,32,49,53,58,51,57,58,53,48,1,7,0,0,0,4,0,0,0,16,0,0,0,6,17,0,0,0,19,49,48,47,48,51,47,50,48,50,51,32,49,55,58,53,51,58,50,50,1,8,0,0,0,4,0,0,0,14,0,0,0,6,18,0,0,0,19,49,48,47,48,51,47,50,48,50,51,32,49,55,58,53,49,58,51,49,1,9,0,0,0,4,0,0,0,12,0,0,0,6,19,0,0,0,19,49,48,47,48,51,47,50,48,50,51,32,49,55,58,50,55,58,48,55,1,10,0,0,0,4,0,0,0,11,0,0,0,6,20,0,0,0,19,49,48,47,48,51,47,50,48,50,51,32,49,53,58,51,51,58,53,48,1,11,0,0,0,4,0,0,0,11,0,0,0,6,21,0,0,0,19,49,48,47,48,51,47,50,48,50,51,32,49,54,58,50,49,58,52,55,1,12,0,0,0,4,0,0,0,11,0,0,0,6,22,0,0,0,19,49,48,47,48,51,47,50,48,50,51,32,49,55,58,51,54,58,50,56,1,13,0,0,0,4,0,0,0,9,0,0,0,6,23,0,0,0,19,49,48,47,48,51,47,50,48,50,51,32,49,55,58,51,48,58,49,56,11]}]}]}]}

View File

@@ -45,6 +45,6 @@ EditorBuildSettings:
path: Assets/Common/Scenes/InfoCourse.unity
guid: 5ff44b09f5858a64692f58938fd6d2ff
- enabled: 1
path: Assets/SpellingBee/Scenes/ThemeSelection.unity
path: Assets/Common/Scenes/ThemeSelection.unity
guid: 2dfa1265c9d65014c90941ac4240a977
m_configObjects: {}