Resolve WES-89 "Justsign music"
This commit is contained in:
@@ -2425,14 +2425,14 @@ MonoBehaviour:
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
m_Material: {fileID: 0}
|
||||
m_Color: {r: 1, g: 1, b: 1, a: 0.392}
|
||||
m_Color: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 0.39215687}
|
||||
m_RaycastTarget: 1
|
||||
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
|
||||
m_Maskable: 1
|
||||
m_OnCullStateChanged:
|
||||
m_PersistentCalls:
|
||||
m_Calls: []
|
||||
m_Sprite: {fileID: 10907, guid: 0000000000000000f000000000000000, type: 0}
|
||||
m_Sprite: {fileID: 0}
|
||||
m_Type: 1
|
||||
m_PreserveAspect: 0
|
||||
m_FillCenter: 1
|
||||
@@ -5178,6 +5178,7 @@ MonoBehaviour:
|
||||
feedBack: {fileID: 128049076}
|
||||
scoreDisplay: {fileID: 1627575593}
|
||||
minigame: {fileID: 11400000, guid: e726e0b93ea88465db7ee27605deb83f, type: 2}
|
||||
songList: {fileID: 11400000, guid: 4f0ce70309bb901feb28199a82a7d195, type: 2}
|
||||
hitZone: {fileID: 2012531007}
|
||||
symbolPrefab: {fileID: 4639383499500021565, guid: f3117b0203a1342a48a95904347b03c8, type: 3}
|
||||
symbolContainer: {fileID: 1768150806}
|
||||
@@ -5502,7 +5503,7 @@ MonoBehaviour:
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
m_Material: {fileID: 0}
|
||||
m_Color: {r: 1, g: 1, b: 0, a: 1}
|
||||
m_Color: {r: 0.0627451, g: 0.0627451, b: 0.0627451, a: 1}
|
||||
m_RaycastTarget: 1
|
||||
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
|
||||
m_Maskable: 1
|
||||
|
||||
18
Assets/JustSign/ScriptableObjects/Graceland.asset
Normal file
18
Assets/JustSign/ScriptableObjects/Graceland.asset
Normal file
@@ -0,0 +1,18 @@
|
||||
%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: cd3d1c3a6cf7ef07abb343f8862a7435, type: 3}
|
||||
m_Name: Graceland
|
||||
m_EditorClassIdentifier:
|
||||
firstSymbolTime: 0.5
|
||||
spawnPeriod: 2
|
||||
duration: 127
|
||||
song: {fileID: 8300000, guid: e01ded5e221494bdbaab8674c0354f64, type: 3}
|
||||
8
Assets/JustSign/ScriptableObjects/Graceland.asset.meta
Normal file
8
Assets/JustSign/ScriptableObjects/Graceland.asset.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7a55c88547b9345fe87aecd1398550c9
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 11400000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
18
Assets/JustSign/ScriptableObjects/SongList.asset
Normal file
18
Assets/JustSign/ScriptableObjects/SongList.asset
Normal file
@@ -0,0 +1,18 @@
|
||||
%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: ceeae47a3efc2206299ddf1cc31043c2, type: 3}
|
||||
m_Name: SongList
|
||||
m_EditorClassIdentifier:
|
||||
currentSongIndex: 0
|
||||
songs:
|
||||
- {fileID: 11400000, guid: 0f5b5e156c628bf189df5723ad2aab96, type: 2}
|
||||
- {fileID: 11400000, guid: 7a55c88547b9345fe87aecd1398550c9, type: 2}
|
||||
8
Assets/JustSign/ScriptableObjects/SongList.asset.meta
Normal file
8
Assets/JustSign/ScriptableObjects/SongList.asset.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4f0ce70309bb901feb28199a82a7d195
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 11400000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
18
Assets/JustSign/ScriptableObjects/SunnySafari.asset
Normal file
18
Assets/JustSign/ScriptableObjects/SunnySafari.asset
Normal file
@@ -0,0 +1,18 @@
|
||||
%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: cd3d1c3a6cf7ef07abb343f8862a7435, type: 3}
|
||||
m_Name: SunnySafari
|
||||
m_EditorClassIdentifier:
|
||||
firstSymbolTime: 1.3
|
||||
spawnPeriod: 1.99
|
||||
duration: 164
|
||||
song: {fileID: 8300000, guid: d7ca1b558b7b064cdb6f9d6c951b1522, type: 3}
|
||||
8
Assets/JustSign/ScriptableObjects/SunnySafari.asset.meta
Normal file
8
Assets/JustSign/ScriptableObjects/SunnySafari.asset.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0f5b5e156c628bf189df5723ad2aab96
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 11400000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -40,6 +40,16 @@ public class JustSignController : MonoBehaviour
|
||||
/// </summary>
|
||||
public Minigame minigame;
|
||||
|
||||
/// <summary>
|
||||
/// Reference to the list of available songs
|
||||
/// </summary>
|
||||
public SongList songList;
|
||||
|
||||
/// <summary>
|
||||
/// Reference to the currently used song
|
||||
/// </summary>
|
||||
private Song currentSong;
|
||||
|
||||
/// <summary>
|
||||
/// The zone that the player should be hitting with his or her inputs
|
||||
/// </summary>
|
||||
@@ -80,6 +90,11 @@ public class JustSignController : MonoBehaviour
|
||||
/// </summary>
|
||||
private int score;
|
||||
|
||||
/// <summary>
|
||||
/// Have the symbols started spawning or not
|
||||
/// </summary>
|
||||
private bool gameIsActive = false;
|
||||
|
||||
/// <summary>
|
||||
/// Width and height of the symbols
|
||||
/// </summary>
|
||||
@@ -146,9 +161,14 @@ public class JustSignController : MonoBehaviour
|
||||
private float lastSpawn;
|
||||
|
||||
/// <summary>
|
||||
/// Determines every how many seconds a symbol should spawn (will become music-dependent later on)
|
||||
/// Time at which the game started, needed to know when to stop
|
||||
/// </summary>
|
||||
private float spawnPeriod = 3.0f;
|
||||
private float beginTime;
|
||||
|
||||
/// <summary>
|
||||
/// Time at which the last symbol should spawn
|
||||
/// </summary>
|
||||
private float lastSymbolTime;
|
||||
|
||||
/// <summary>
|
||||
/// Start is called before the first frame update
|
||||
@@ -158,10 +178,22 @@ public class JustSignController : MonoBehaviour
|
||||
scoreDisplay.text = "Score: " + score.ToString();
|
||||
currentTheme = minigame.themeList.themes[minigame.themeList.currentThemeIndex];
|
||||
words.AddRange(currentTheme.learnables);
|
||||
//currentTheme = FindThemeByName(PlayerPrefs.GetString("themeName"));
|
||||
//words = currentTheme.words;
|
||||
lastSpawn = Time.time;
|
||||
SpawnNewSymbol();
|
||||
currentSong = songList.songs[songList.currentSongIndex];
|
||||
AudioSource.PlayClipAtPoint(currentSong.song, Vector3.zero, 1.0f);
|
||||
beginTime = Time.time;
|
||||
lastSymbolTime = beginTime + currentSong.duration - 1920.0f / moveSpeed;
|
||||
|
||||
StartCoroutine(WaitThenStart(currentSong.firstSymbolTime));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Wait for a given amount of time (specified in song) before spawning symbols
|
||||
/// </summary>
|
||||
IEnumerator WaitThenStart(float nrOfSeconds)
|
||||
{
|
||||
//yield on a new YieldInstruction that waits for nrOfSeconds seconds
|
||||
yield return new WaitForSeconds(nrOfSeconds);
|
||||
gameIsActive = true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -169,56 +201,68 @@ public class JustSignController : MonoBehaviour
|
||||
/// </summary>
|
||||
void Update()
|
||||
{
|
||||
int matchedSymbolIndex = -1;
|
||||
for (int i = 0; i < activeWords.Count; i++) {
|
||||
if (activeWords[i].ToLower() == answerField.text.ToLower()) {
|
||||
matchedSymbolIndex = i;
|
||||
}
|
||||
}
|
||||
|
||||
// Destroy the oldest symbol if the current input matches it
|
||||
if (matchedSymbolIndex >= 0) {
|
||||
int difference = Math.Abs((int) (activeSymbols[matchedSymbolIndex].transform.position.x - hitZone.transform.position.x));
|
||||
if (difference < perfectBoundary) {
|
||||
feedBack.text = "Perfect!";
|
||||
score += perfectScore;
|
||||
} else if (difference < goodBoundary) {
|
||||
feedBack.text = "Good!";
|
||||
score += goodScore;
|
||||
} else if (difference < mehBoundary) {
|
||||
feedBack.text = "Meh...";
|
||||
score += mehScore;
|
||||
} else {
|
||||
feedBack.text = "Terrible!";
|
||||
score += terribleScore;
|
||||
if (gameIsActive) {
|
||||
int matchedSymbolIndex = -1;
|
||||
for (int i = 0; i < activeWords.Count; i++) {
|
||||
if (activeWords[i].ToLower() == answerField.text.ToLower()) {
|
||||
matchedSymbolIndex = i;
|
||||
}
|
||||
}
|
||||
|
||||
DestroySymbolAt(matchedSymbolIndex);
|
||||
answerField.text = "";
|
||||
}
|
||||
// Destroy the oldest symbol if the current input matches it
|
||||
if (matchedSymbolIndex >= 0) {
|
||||
int difference = Math.Abs((int) (activeSymbols[matchedSymbolIndex].transform.position.x - hitZone.transform.position.x));
|
||||
if (difference < perfectBoundary) {
|
||||
feedBack.text = "Perfect!";
|
||||
score += perfectScore;
|
||||
} else if (difference < goodBoundary) {
|
||||
feedBack.text = "Good!";
|
||||
score += goodScore;
|
||||
} else if (difference < mehBoundary) {
|
||||
feedBack.text = "Meh...";
|
||||
score += mehScore;
|
||||
} else {
|
||||
feedBack.text = "Terrible!";
|
||||
score += terribleScore;
|
||||
}
|
||||
|
||||
// Destroy the oldest symbol if it leaves the screen
|
||||
if (activeSymbols.Count > 0) {
|
||||
if (activeSymbols[0].GetComponent<RectTransform>().localPosition.x > -trackX) {
|
||||
DestroySymbolAt(0);
|
||||
score += offscreenScore;
|
||||
DestroySymbolAt(matchedSymbolIndex);
|
||||
answerField.text = "";
|
||||
}
|
||||
}
|
||||
|
||||
// Spawn new symbol every spawn period
|
||||
float currentTime = Time.time;
|
||||
if (currentTime - lastSpawn > spawnPeriod) {
|
||||
lastSpawn = currentTime;
|
||||
SpawnNewSymbol();
|
||||
}
|
||||
// Destroy the oldest symbol if it leaves the screen
|
||||
if (activeSymbols.Count > 0) {
|
||||
if (activeSymbols[0].GetComponent<RectTransform>().localPosition.x > -trackX) {
|
||||
DestroySymbolAt(0);
|
||||
feedBack.text = "Terrible!";
|
||||
score += offscreenScore;
|
||||
}
|
||||
}
|
||||
|
||||
// Move all active symbols to the right
|
||||
foreach (GameObject symbol in activeSymbols) {
|
||||
RectTransform rectTransform = symbol.GetComponent<RectTransform>();
|
||||
rectTransform.localPosition = new Vector3(rectTransform.localPosition.x + Time.deltaTime * moveSpeed, trackY, 0);
|
||||
}
|
||||
// Spawn new symbol every spawn period
|
||||
float currentTime = Time.time;
|
||||
if (currentTime - lastSpawn > currentSong.spawnPeriod && lastSymbolTime > currentTime) {
|
||||
lastSpawn = currentTime;
|
||||
SpawnNewSymbol();
|
||||
}
|
||||
|
||||
scoreDisplay.text = "Score: " + score.ToString();
|
||||
// Check if the song has ended and activate scorescreen if it has
|
||||
if (currentTime - beginTime > currentSong.duration) {
|
||||
gameIsActive = false;
|
||||
while (activeSymbols.Count > 0) {
|
||||
DestroySymbolAt(0);
|
||||
}
|
||||
// TODO: Scoreboard
|
||||
}
|
||||
|
||||
// Move all active symbols to the right
|
||||
foreach (GameObject symbol in activeSymbols) {
|
||||
RectTransform rectTransform = symbol.GetComponent<RectTransform>();
|
||||
rectTransform.localPosition = new Vector3(rectTransform.localPosition.x + Time.deltaTime * moveSpeed, trackY, 0);
|
||||
}
|
||||
|
||||
scoreDisplay.text = "Score: " + score.ToString();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -1,13 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
<<<<<<<< HEAD:Assets/JustSign/Scripts/JustSignController.cs.meta
|
||||
guid: 9ede962218eda88668cd8032b921aada
|
||||
========
|
||||
guid: 40ff941e1b34847bdb160c6950f35aec
|
||||
>>>>>>>> development:Assets/MediaPipeUnity/Common/Scripts/KeypointManager.cs.meta
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
defaultReferences:
|
||||
- canvas: {instanceID: 0}
|
||||
- answerField: {instanceID: 0}
|
||||
- feedBack: {instanceID: 0}
|
||||
- scoreDisplay: {instanceID: 0}
|
||||
- minigame: {instanceID: 0}
|
||||
- songList: {fileID: 11400000, guid: 4f0ce70309bb901feb28199a82a7d195, type: 2}
|
||||
- hitZone: {instanceID: 0}
|
||||
- symbolPrefab: {instanceID: 0}
|
||||
- symbolContainer: {instanceID: 0}
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
|
||||
29
Assets/JustSign/Scripts/Song.cs
Normal file
29
Assets/JustSign/Scripts/Song.cs
Normal file
@@ -0,0 +1,29 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.Audio;
|
||||
|
||||
/// <summary>
|
||||
/// Class for holding all (static) data about a certain song
|
||||
/// </summary>
|
||||
[CreateAssetMenu(menuName = "Create new Scriptable/Song")]
|
||||
public class Song : ScriptableObject
|
||||
{
|
||||
/// <summary>
|
||||
/// Time at which the first symbol should enter the hit zone
|
||||
/// </summary>
|
||||
public float firstSymbolTime;
|
||||
|
||||
/// <summary>
|
||||
/// Determines every how many seconds a symbol should enter the hit zone
|
||||
/// </summary>
|
||||
public float spawnPeriod;
|
||||
|
||||
/// <summary>
|
||||
/// Duration of the song in seconds
|
||||
/// </summary>
|
||||
public int duration;
|
||||
|
||||
/// <summary>
|
||||
/// The actual audio source
|
||||
/// </summary>
|
||||
public AudioClip song;
|
||||
}
|
||||
11
Assets/JustSign/Scripts/Song.cs.meta
Normal file
11
Assets/JustSign/Scripts/Song.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: cd3d1c3a6cf7ef07abb343f8862a7435
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
19
Assets/JustSign/Scripts/SongList.cs
Normal file
19
Assets/JustSign/Scripts/SongList.cs
Normal file
@@ -0,0 +1,19 @@
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
/// <summary>
|
||||
/// Keep track of all songs
|
||||
/// </summary>
|
||||
[CreateAssetMenu(menuName = "Create new Scriptable/SongList")]
|
||||
public class SongList : ScriptableObject
|
||||
{
|
||||
/// <summary>
|
||||
/// Index of the active/to be loaded/current song
|
||||
/// </summary>
|
||||
public int currentSongIndex = 0;
|
||||
|
||||
/// <summary>
|
||||
/// List of all installed songs
|
||||
/// </summary>
|
||||
public List<Song> songs = new List<Song>();
|
||||
}
|
||||
11
Assets/JustSign/Scripts/SongList.cs.meta
Normal file
11
Assets/JustSign/Scripts/SongList.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ceeae47a3efc2206299ddf1cc31043c2
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
8
Assets/JustSign/Songs.meta
Normal file
8
Assets/JustSign/Songs.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a92b9838d20352bb8b984c2e361c7fba
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
BIN
Assets/JustSign/Songs/graceland.mp3
Normal file
BIN
Assets/JustSign/Songs/graceland.mp3
Normal file
Binary file not shown.
22
Assets/JustSign/Songs/graceland.mp3.meta
Normal file
22
Assets/JustSign/Songs/graceland.mp3.meta
Normal file
@@ -0,0 +1,22 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e01ded5e221494bdbaab8674c0354f64
|
||||
AudioImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 6
|
||||
defaultSettings:
|
||||
loadType: 0
|
||||
sampleRateSetting: 0
|
||||
sampleRateOverride: 44100
|
||||
compressionFormat: 1
|
||||
quality: 1
|
||||
conversionMode: 0
|
||||
platformSettingOverrides: {}
|
||||
forceToMono: 0
|
||||
normalize: 1
|
||||
preloadAudioData: 1
|
||||
loadInBackground: 0
|
||||
ambisonic: 0
|
||||
3D: 1
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
BIN
Assets/JustSign/Songs/sunny_safari_120bpm.mp3
Normal file
BIN
Assets/JustSign/Songs/sunny_safari_120bpm.mp3
Normal file
Binary file not shown.
22
Assets/JustSign/Songs/sunny_safari_120bpm.mp3.meta
Normal file
22
Assets/JustSign/Songs/sunny_safari_120bpm.mp3.meta
Normal file
@@ -0,0 +1,22 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d7ca1b558b7b064cdb6f9d6c951b1522
|
||||
AudioImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 6
|
||||
defaultSettings:
|
||||
loadType: 0
|
||||
sampleRateSetting: 0
|
||||
sampleRateOverride: 44100
|
||||
compressionFormat: 1
|
||||
quality: 1
|
||||
conversionMode: 0
|
||||
platformSettingOverrides: {}
|
||||
forceToMono: 0
|
||||
normalize: 1
|
||||
preloadAudioData: 1
|
||||
loadInBackground: 0
|
||||
ambisonic: 0
|
||||
3D: 1
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user