Resolve WES-95 "User progress"
This commit is contained in:
58
Assets/Common/Interfaces/Course.cs
Normal file
58
Assets/Common/Interfaces/Course.cs
Normal file
@@ -0,0 +1,58 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Video;
|
||||
|
||||
/// <summary>
|
||||
/// Class for holding all (static) data about a certain course
|
||||
/// </summary>
|
||||
[CreateAssetMenu(menuName = "Create new Scriptable/Course")]
|
||||
public class Course : ScriptableObject
|
||||
{
|
||||
/// <summary>
|
||||
/// Small class to hold information about a single learnable (e.g., a word or a letter)
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public class Learnable
|
||||
{
|
||||
/// <summary>
|
||||
/// Name of the word/letter to learn
|
||||
/// </summary>
|
||||
public string name;
|
||||
|
||||
/// <summary>
|
||||
/// Sprite of this word/letter
|
||||
/// </summary>
|
||||
public Sprite image;
|
||||
|
||||
/// <summary>
|
||||
/// Example video clip
|
||||
/// </summary>
|
||||
public VideoClip clip;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Index of the course
|
||||
/// </summary>
|
||||
public CourseIndex index;
|
||||
|
||||
/// <summary>
|
||||
/// The course title
|
||||
/// </summary>
|
||||
public string title;
|
||||
|
||||
/// <summary>
|
||||
/// A short description of the course
|
||||
/// </summary>
|
||||
public string description;
|
||||
|
||||
/// <summary>
|
||||
/// Reference to the course thumbnail
|
||||
/// </summary>
|
||||
public Sprite thumbnail;
|
||||
|
||||
/// <summary>
|
||||
/// List of all learnable words/letters
|
||||
/// </summary>
|
||||
public List<Learnable> learnables = new List<Learnable>();
|
||||
}
|
||||
11
Assets/Common/Interfaces/Course.cs.meta
Normal file
11
Assets/Common/Interfaces/Course.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f6b23e64e6ffb12459ed4f37d7305852
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
29
Assets/Common/Interfaces/CourseList.cs
Normal file
29
Assets/Common/Interfaces/CourseList.cs
Normal file
@@ -0,0 +1,29 @@
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
/// <summary>
|
||||
/// Keep track of all courses
|
||||
/// </summary>
|
||||
[CreateAssetMenu(menuName = "Create new Scriptable/CourseList")]
|
||||
public class CourseList : ScriptableObject
|
||||
{
|
||||
/// <summary>
|
||||
/// Index of the active/to be loaded/current course
|
||||
/// </summary>
|
||||
public int currentCourseIndex = 0;
|
||||
|
||||
/// <summary>
|
||||
/// List of all installed courses
|
||||
/// </summary>
|
||||
public List<Course> courses = new List<Course>();
|
||||
|
||||
/// <summary>
|
||||
/// Get a course by CourseIndex
|
||||
/// </summary>
|
||||
/// <param name="courseIndex">CourseIndex of the course, each unique course has a unique CourseIndex</param>
|
||||
/// <returns>Course associated with this index, null if no course was found</returns>
|
||||
public Course GetCourseByIndex(CourseIndex courseIndex)
|
||||
{
|
||||
return courses.Find((c) => c.index == courseIndex);
|
||||
}
|
||||
}
|
||||
11
Assets/Common/Interfaces/CourseList.cs.meta
Normal file
11
Assets/Common/Interfaces/CourseList.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 96fe8874f9754b545ae25fb826312ebc
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -17,4 +17,14 @@ public class MinigameList : ScriptableObject
|
||||
/// List of all installed minigames
|
||||
/// </summary>
|
||||
public List<Minigame> minigames = new List<Minigame>();
|
||||
|
||||
/// <summary>
|
||||
/// Get a minigame by MinigameIndex
|
||||
/// </summary>
|
||||
/// <param name="minigameIndex">MinigameIndex of the minigame, each unique minigame has a unique MinigameIndex</param>
|
||||
/// <returns>Minigame associated with this index, null if no minigame was found</returns>
|
||||
public Minigame GetMinigameByIndex(MinigameIndex minigameIndex)
|
||||
{
|
||||
return minigames.Find((m) => m.index == minigameIndex);
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
using System;
|
||||
|
||||
/// <summary>
|
||||
/// Score class TODO: Move to separate file
|
||||
/// Score class
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public class Score
|
||||
|
||||
@@ -544,7 +544,7 @@ GameObject:
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 0
|
||||
m_IsActive: 1
|
||||
--- !u!224 &1769699556132214506
|
||||
RectTransform:
|
||||
m_ObjectHideFlags: 0
|
||||
@@ -561,10 +561,10 @@ RectTransform:
|
||||
m_Father: {fileID: 1935285004959629519}
|
||||
m_RootOrder: 0
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
m_AnchorMin: {x: 0, y: 1}
|
||||
m_AnchorMax: {x: 0, y: 1}
|
||||
m_AnchoredPosition: {x: 200, y: -120}
|
||||
m_SizeDelta: {x: 380, y: 50}
|
||||
m_AnchorMin: {x: 0, y: 0}
|
||||
m_AnchorMax: {x: 0, y: 0}
|
||||
m_AnchoredPosition: {x: 0, y: 0}
|
||||
m_SizeDelta: {x: 0, y: 50}
|
||||
m_Pivot: {x: 0.5, y: 1}
|
||||
--- !u!222 &3111431685034357011
|
||||
CanvasRenderer:
|
||||
|
||||
@@ -111,11 +111,11 @@ public class MinigameActivityScreen : MonoBehaviour
|
||||
foreach (User user in userList.GetUsers())
|
||||
{
|
||||
// Get user's progress for this minigame
|
||||
progress = user.minigames.Find((p) => p != null && p.Get<MinigameIndex>("minigameIndex") == minigame.index);
|
||||
progress = user.GetMinigameProgress(minigame.index);
|
||||
if (progress != null)
|
||||
{
|
||||
// Add scores to dictionary
|
||||
List<Score> scores = progress.Get<List<Score>>("scores");
|
||||
List<Score> scores = progress.Get<List<Score>>("highestScores");
|
||||
foreach (Score score in scores)
|
||||
{
|
||||
allScores.Add(new Tuple<string, Sprite, Score>(user.username, user.avatar, score));
|
||||
|
||||
Reference in New Issue
Block a user