Integrate minigame and courses

This commit is contained in:
Dries Van Schuylenbergh
2023-03-08 19:07:57 +00:00
parent 7e98fea538
commit 852a17b0b4
56 changed files with 1431 additions and 1300 deletions

View File

@@ -155,8 +155,9 @@ MonoBehaviour:
player: {fileID: 993952931}
button: {fileID: 1159630774}
pauseSprite: {fileID: 21300000, guid: 43db869a07cf51f45a411b6e4a417743, type: 3}
word_image: {fileID: 2145235737}
wordImage: {fileID: 2145235737}
title: {fileID: 388014849}
userList: {fileID: 11400000, guid: 072bec636a40f7e4e93b0ac624a3bda2, type: 2}
courselist: {fileID: 11400000, guid: a7ab583094b7897468bbca9243717608, type: 2}
--- !u!4 &118887550
Transform:
@@ -166,7 +167,7 @@ Transform:
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 118887548}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 1009.74774, y: 545.9465, z: -3.3333964}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
@@ -1081,7 +1082,7 @@ Transform:
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 993952930}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 341.03647, y: 173.12453, z: -3.6324117}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
@@ -1748,7 +1749,7 @@ Transform:
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1485779444}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 1018.7385, y: 488.39554, z: 0.26466587}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []

View File

@@ -13,4 +13,4 @@ MonoBehaviour:
m_Name: CourseList
m_EditorClassIdentifier:
courses:
- {fileID: 11400000, guid: c1c54aeff4d069a41b2799b2dd26498f, type: 2}
- {fileID: 11400000, guid: 300921292bfd5564b8ce70b834c3f334, type: 2}

View File

@@ -1,28 +0,0 @@
%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: f6b23e64e6ffb12459ed4f37d7305852, type: 3}
m_Name: Course_0
m_EditorClassIdentifier:
title: Course_0
description: This is a dummy course used for testing.
thumbnail: {fileID: 21300000, guid: ac9b0ab2b71d2f14593726feaffa6b6e, type: 3}
progress: 0
images:
- {fileID: 21300000, guid: 9da6e6e67d226734aa34575722c59389, type: 3}
- {fileID: 21300000, guid: 6a1a8ea5d7cae95449c449abcfa51640, type: 3}
- {fileID: 21300000, guid: 2defbdfec73217847bb2a9c687668006, type: 3}
- {fileID: 21300000, guid: 8a664ceb4c0d45a40aa7545537b03798, type: 3}
videos:
- {fileID: 32900000, guid: bf0807dbf3931c846951ab6ce07286f7, type: 3}
- {fileID: 32900000, guid: 2a387512265e5e747bd69194d90a9c76, type: 3}
- {fileID: 32900000, guid: c64e80628c275574aa425e17639b1c19, type: 3}
- {fileID: 32900000, guid: e201d74a82223164684a7771abbbcfe0, type: 3}

View File

@@ -0,0 +1,31 @@
%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: f6b23e64e6ffb12459ed4f37d7305852, type: 3}
m_Name: Fingerspelling
m_EditorClassIdentifier:
index: 0
title: Fingerspelling
description: Learn the basics of fingerspelling
thumbnail: {fileID: 21300000, guid: f2344cd67769733ceb363a41e1d88a65, type: 3}
learnables:
- name: A
image: {fileID: 21300000, guid: fceabadca8d3ed2cdbf652d2826639ea, type: 3}
clip: {fileID: 32900000, guid: 219638b5c33528443a0a1bc0946ed68e, type: 3}
- name: B
image: {fileID: 21300000, guid: c2620dd626ef0921cb6a5f2d2b1fbea8, type: 3}
clip: {fileID: 32900000, guid: 01bb71617b10fe4429a03f2127286a90, type: 3}
- name: C
image: {fileID: 21300000, guid: 68ac0fd4dcce2b9c09ac3ff5c2604ef2, type: 3}
clip: {fileID: 32900000, guid: 5fc69105a51e8dc498ec01e5068b4d3d, type: 3}
- name: D
image: {fileID: 21300000, guid: d3f490003d163ac7b99ccfbee2025738, type: 3}
clip: {fileID: 32900000, guid: 126ae1ab33f626b49bbafe6595619a5f, type: 3}

View File

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

View File

@@ -1,16 +1,35 @@
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Video;
[CreateAssetMenu(fileName="New Course", menuName="course")]
[CreateAssetMenu(menuName = "Create new Scriptable/Course")]
public class Course : ScriptableObject
{
public string title;
public string description;
public Sprite thumbnail;
public int progress;
[Serializable]
// Small class to hold information about a single learnable (e.g., a word or a letter)
public class Learnable
{
// Name of the word/letter to learn
public string name;
// Sprite of this word/letter
public Sprite image;
// Example video clip
public VideoClip clip;
}
public Sprite[] images;
public VideoClip[] videos;
[Header("Course info")]
// Course index
public CourseIndex index;
// Course title
public string title;
// Short desciption of the course
public string description;
// Thumbnail of the course
public Sprite thumbnail;
[Header("Learnable words")]
// List of learnable words/letters
public List<Learnable> learnables = new List<Learnable>();
}

View File

@@ -2,8 +2,8 @@ using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public static class CourseIndex
// TODO: add other courses
public enum CourseIndex
{
// Start is called before the first frame update
public static int index = 0;
FINGERSPELLING
}

View File

@@ -2,8 +2,14 @@ using System.Collections;
using System.Collections.Generic;
using UnityEngine;
[CreateAssetMenu(fileName="New CourseList", menuName="CourseList")]
[CreateAssetMenu(menuName = "Create new Scriptable/CourseList")]
public class CourseList : ScriptableObject
{
public Course[] courses;
[Header("Current Course")]
// Index of the current course
public int currentCourseIndex = 0;
[Header("Courses")]
// List of courses
public List<Course> courses = new List<Course>();
}

View File

@@ -1,40 +1,76 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Video; // To alter video
using UnityEngine.UI; // For general image + button jobs
using TMPro; // For text
using UnityEngine.Video;
using UnityEngine.UI;
using TMPro;
using UnityEditor;
public class StartPause : MonoBehaviour
{
[Header("UI References")]
// Reference to instructional video player
public VideoPlayer player;
// Reference to pause button
public Button button;
// Reference to sprite for the pause button
public Sprite pauseSprite;
public Image word_image;
// Reference to the image for displaying the current words sprite
public Image wordImage;
// Reference to the text object for displaying the current word
public TextMeshProUGUI title;
[Header("User")]
// Reference to user list to get current user
public UserList userList;
// The current user
private User user;
// Current user progress for this course
private Progress progress = null;
[Header("Course")]
// ScriptableObject with list of all courses
public CourseList courselist;
// Reference to Course ScriptableObject
private Course course;
private int word_i = 0;
// Index of the current word/letter in the course.learnables list
private int currentWordIndex = 0;
// In my example, i have 4 videos/images
private int max_words = 4;
private int maxWords = 4;
// Number of correct words so far
// (can be modified to a list or something like that to give better feedback)
private int correctWords = 0;
// Start is called before the first frame update
public void Awake()
{
course = courselist.courses[CourseIndex.index];
// Setting up course
course = courselist.courses[courselist.currentCourseIndex];
// Create entry in current user for keeping track of progress
user = userList.users[userList.currentUserIndex];
progress = user.courses.Find((p) => p != null && p.Get<CourseIndex>("courseIndex") == course.index);
if (progress == null)
{
progress = new Progress();
progress.AddOrUpdate<CourseIndex>("courseIndex", CourseIndex.FINGERSPELLING);
progress.AddOrUpdate<float>("courseProgress", -1.0f);
user.courses.Add(progress);
}
EditorUtility.SetDirty(user);
// Setup UI
button.image.sprite = pauseSprite;
title.text = course.name;
next_video();
next_image();
NextVideo();
NextImage();
}
// These two functions generate video and image from files
private void next_video(){
player.clip = course.videos[word_i];
private void NextVideo()
{
player.clip = course.learnables[currentWordIndex].clip;
// This loads first frame, so that it can be used as a sort-of preview for the video
player.Play();
player.Pause();
@@ -45,11 +81,9 @@ public class StartPause : MonoBehaviour
}
// This doesn't work
private void next_image(){
Sprite tex = course.images[word_i];
word_image.sprite = tex;
private void NextImage()
{
wordImage.sprite = course.learnables[currentWordIndex].image;
}
// Activate by pressing the center of the screen
@@ -74,10 +108,32 @@ public class StartPause : MonoBehaviour
}
// Press next-sign button for next word
public void NextSign(){
word_i++;
word_i %= max_words;
next_video();
next_image();
public void NextSign()
{
// Goto the next word/letter
currentWordIndex++;
// TODO: fix correct word count
correctWords++;
progress.AddOrUpdate<float>("courseProgress", (float)correctWords / (float)maxWords);
EditorUtility.SetDirty(user);
// Update UI if course is not finished yet
if (currentWordIndex < maxWords)
{
NextVideo();
NextImage();
}
// Finish course and record progress
else
{
FinishCourse();
}
}
public void FinishCourse()
{
// TODO: update progress (maybe this can also be at the `NextSign()`-method)
progress.AddOrUpdate<float>("courseProgress", correctWords / maxWords);
}
}

View File

@@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: c64e80628c275574aa425e17639b1c19
guid: 219638b5c33528443a0a1bc0946ed68e
VideoClipImporter:
externalObjects: {}
serializedVersion: 2

View File

@@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: e201d74a82223164684a7771abbbcfe0
guid: 01bb71617b10fe4429a03f2127286a90
VideoClipImporter:
externalObjects: {}
serializedVersion: 2

View File

@@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: bf0807dbf3931c846951ab6ce07286f7
guid: 5fc69105a51e8dc498ec01e5068b4d3d
VideoClipImporter:
externalObjects: {}
serializedVersion: 2

View File

@@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: 2a387512265e5e747bd69194d90a9c76
guid: 126ae1ab33f626b49bbafe6595619a5f
VideoClipImporter:
externalObjects: {}
serializedVersion: 2