Resolve WES-113 "Write tests"
This commit is contained in:
committed by
Dries Van Schuylenbergh
parent
96fb3c89c3
commit
f6e6afe340
19
Assets/Common/Scripts/CommonScripts.asmdef
Normal file
19
Assets/Common/Scripts/CommonScripts.asmdef
Normal file
@@ -0,0 +1,19 @@
|
||||
{
|
||||
"name": "CommonScripts",
|
||||
"rootNamespace": "",
|
||||
"references": [
|
||||
"GUID:6055be8ebefd69e48b49212b09b47b2f",
|
||||
"GUID:63c63e721f65ebb7d871cb9ef49f4752",
|
||||
"GUID:1631ed2680c61245b8211d943c1639a8",
|
||||
"GUID:df9d7b70293a2e14d9d3a018c3956f7a"
|
||||
],
|
||||
"includePlatforms": [],
|
||||
"excludePlatforms": [],
|
||||
"allowUnsafeCode": false,
|
||||
"overrideReferences": false,
|
||||
"precompiledReferences": [],
|
||||
"autoReferenced": true,
|
||||
"defineConstraints": [],
|
||||
"versionDefines": [],
|
||||
"noEngineReferences": false
|
||||
}
|
||||
7
Assets/Common/Scripts/CommonScripts.asmdef.meta
Normal file
7
Assets/Common/Scripts/CommonScripts.asmdef.meta
Normal file
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3444c67d5a3a93e5a95a48906078c372
|
||||
AssemblyDefinitionImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -107,7 +107,7 @@ public class MinigameActivityScreen : MonoBehaviour
|
||||
int index = minigameList.currentMinigameIndex;
|
||||
Minigame minigame = minigameList.minigames[index];
|
||||
|
||||
List<Tuple<string, Sprite, GameController.Score>> allScores = new List<Tuple<string, Sprite, GameController.Score>>();
|
||||
List<Tuple<string, Sprite, Score>> allScores = new List<Tuple<string, Sprite, Score>>();
|
||||
foreach (User user in userList.GetUsers())
|
||||
{
|
||||
// Get user's progress for this minigame
|
||||
@@ -115,10 +115,10 @@ public class MinigameActivityScreen : MonoBehaviour
|
||||
if (progress != null)
|
||||
{
|
||||
// Add scores to dictionary
|
||||
List<GameController.Score> scores = progress.Get<List<GameController.Score>>("scores");
|
||||
foreach (GameController.Score score in scores)
|
||||
List<Score> scores = progress.Get<List<Score>>("scores");
|
||||
foreach (Score score in scores)
|
||||
{
|
||||
allScores.Add(new Tuple<string, Sprite, GameController.Score>(user.username, user.avatar, score));
|
||||
allScores.Add(new Tuple<string, Sprite, Score>(user.username, user.avatar, score));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -127,11 +127,11 @@ public class MinigameActivityScreen : MonoBehaviour
|
||||
allScores.Sort((a, b) => b.Item3.scoreValue.CompareTo(a.Item3.scoreValue));
|
||||
|
||||
// Instantiate scoreboard entries
|
||||
foreach (Tuple<string, Sprite, GameController.Score> tup in allScores.Take(3))
|
||||
foreach (Tuple<string, Sprite, Score> tup in allScores.Take(3))
|
||||
{
|
||||
string username = tup.Item1;
|
||||
Sprite sprite = tup.Item2;
|
||||
GameController.Score score = tup.Item3;
|
||||
Score score = tup.Item3;
|
||||
|
||||
GameObject instance = GameObject.Instantiate(prefab, userContainer);
|
||||
instance.transform.Find("Title").GetComponent<TMP_Text>().text = username;
|
||||
|
||||
@@ -1,10 +0,0 @@
|
||||
|
||||
/// <summary>
|
||||
/// Enum for easy indexing and checking if a minigame is of a certain kind
|
||||
/// </summary>
|
||||
public enum MinigameIndex
|
||||
{
|
||||
SPELLING_BEE,
|
||||
HANGMAN,
|
||||
JUST_SIGN
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 44a1fb926248fe240bed2d5c3820630b
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,104 +0,0 @@
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.SceneManagement;
|
||||
|
||||
/// <summary>
|
||||
/// SystemController singleton
|
||||
/// </summary>
|
||||
public class SystemController
|
||||
{
|
||||
/// <summary>
|
||||
/// The instance controlling the singleton
|
||||
/// </summary>
|
||||
private static SystemController instance = null;
|
||||
|
||||
/// <summary>
|
||||
/// Stack of the loaded scenes, used to easily go back to previous scenes
|
||||
/// </summary>
|
||||
private Stack<int> sceneStack = new Stack<int>();
|
||||
|
||||
/// <summary>
|
||||
/// Get the instance loaded by the singleton
|
||||
/// </summary>
|
||||
/// <returns>SystemController instance</returns>
|
||||
public static SystemController GetInstance()
|
||||
{
|
||||
// Create a new instance if non exists
|
||||
if (instance == null)
|
||||
{
|
||||
instance = new SystemController();
|
||||
instance.sceneStack.Push(SceneManager.GetActiveScene().buildIndex);
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Load the scene and push on the stack
|
||||
/// </summary>
|
||||
/// <param name="scenePath">Path of the scene</param>
|
||||
public void LoadNextScene(string scenePath)
|
||||
{
|
||||
LoadNextScene(SceneUtility.GetBuildIndexByScenePath(scenePath));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Load the scene and push on the stack
|
||||
/// </summary>
|
||||
/// <param name="sceneIndex">Buildindex of the scene</param>
|
||||
public void LoadNextScene(int sceneIndex)
|
||||
{
|
||||
sceneStack.Push(sceneIndex);
|
||||
SceneManager.LoadScene(sceneIndex);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Swap the current scene with the new scene on the stack
|
||||
/// </summary>
|
||||
/// <param name="scenePath">Path of the scene</param>
|
||||
public void SwapScene(string scenePath)
|
||||
{
|
||||
SwapScene(SceneUtility.GetBuildIndexByScenePath(scenePath));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Swap the current scene with the new scene on the stack
|
||||
/// </summary>
|
||||
/// <param name="sceneIndex">Buildindex of the scene</param>
|
||||
public void SwapScene(int sceneIndex)
|
||||
{
|
||||
sceneStack.Pop();
|
||||
LoadNextScene(sceneIndex);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Go back to the previous scene and unload the current scene
|
||||
/// </summary>
|
||||
public void BackToPreviousScene()
|
||||
{
|
||||
sceneStack.Pop();
|
||||
|
||||
if (sceneStack.Count > 0) SceneManager.LoadScene(sceneStack.Peek());
|
||||
else Application.Quit();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Go back to a specific scene, unloading all the scenes on the way
|
||||
/// </summary>
|
||||
/// <param name="scenePath">Path of the scene</param>
|
||||
public void BackToScene(string scenePath)
|
||||
{
|
||||
BackToScene(SceneUtility.GetBuildIndexByScenePath(scenePath));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Go back to a specific scene, unloading all the scene on the way
|
||||
/// </summary>
|
||||
/// <param name="sceneIndex">Buildindex of the scene</param>
|
||||
public void BackToScene(int sceneIndex)
|
||||
{
|
||||
while (0 < sceneStack.Count && sceneStack.Peek() != sceneIndex) sceneStack.Pop();
|
||||
|
||||
if (sceneStack.Count > 0) SceneManager.LoadScene(sceneStack.Peek());
|
||||
else Application.Quit();
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e901944427bb1104a881881efebd3737
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user