mirror of
https://github.com/RHeavenStudioPlus/HeavenStudioPlus.git
synced 2024-11-12 20:55:08 +00:00
Proper namespaces
This commit is contained in:
parent
33bd99bbc1
commit
0b383940ac
45 changed files with 1364 additions and 1264 deletions
8
Assets/Resources/Fonts/rodin.meta
Normal file
8
Assets/Resources/Fonts/rodin.meta
Normal file
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 96ed2f99a777c924f882e2f3c41b1881
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -1,13 +1,13 @@
|
|||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!21 &-1154359511425921776
|
||||
--- !u!21 &-1662932664650235619
|
||||
Material:
|
||||
serializedVersion: 6
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name: rodin_merged Material
|
||||
m_Name: rodin_lat_cy_ja_ko_spec Material
|
||||
m_Shader: {fileID: 4800000, guid: 128e987d567d4e2c824d754223b3f3b0, type: 3}
|
||||
m_ShaderKeywords:
|
||||
m_LightmapFlags: 4
|
||||
|
@ -24,7 +24,7 @@ Material:
|
|||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _MainTex:
|
||||
m_Texture: {fileID: 1363669669053061815}
|
||||
m_Texture: {fileID: 8801383763965547972}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
m_Floats:
|
||||
|
@ -53,14 +53,14 @@ MonoBehaviour:
|
|||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 71c1514a6bd24e1e882cebbe1904ce04, type: 3}
|
||||
m_Name: rodin_merged
|
||||
m_Name: rodin_lat_cy_ja_ko_spec
|
||||
m_EditorClassIdentifier:
|
||||
hashCode: 0
|
||||
material: {fileID: -1154359511425921776}
|
||||
material: {fileID: -1662932664650235619}
|
||||
materialHashCode: 0
|
||||
m_Version: 1.1.0
|
||||
m_SourceFontFileGUID: d245bd2e354835547b32cf6c1a738d45
|
||||
m_SourceFontFile_EditorRef: {fileID: 12800000, guid: d245bd2e354835547b32cf6c1a738d45, type: 3}
|
||||
m_SourceFontFileGUID: 6459e01c422d8fb469d08b74a81e6b81
|
||||
m_SourceFontFile_EditorRef: {fileID: 12800000, guid: 6459e01c422d8fb469d08b74a81e6b81, type: 3}
|
||||
m_SourceFontFile: {fileID: 0}
|
||||
m_AtlasPopulationMode: 0
|
||||
m_FaceInfo:
|
||||
|
@ -79,7 +79,7 @@ MonoBehaviour:
|
|||
m_SuperscriptSize: 0.5
|
||||
m_SubscriptOffset: -39.989998
|
||||
m_SubscriptSize: 0.5
|
||||
m_UnderlineOffset: -85.374
|
||||
m_UnderlineOffset: -104.346
|
||||
m_UnderlineThickness: 18.972
|
||||
m_StrikethroughOffset: 41.2
|
||||
m_StrikethroughThickness: 18.972
|
||||
|
@ -2717,7 +2717,7 @@ MonoBehaviour:
|
|||
m_Height: 185
|
||||
m_Scale: 1
|
||||
m_AtlasIndex: 0
|
||||
- m_Index: 466
|
||||
- m_Index: 596
|
||||
m_Metrics:
|
||||
m_Width: 93
|
||||
m_Height: 14
|
||||
|
@ -2731,7 +2731,7 @@ MonoBehaviour:
|
|||
m_Height: 14
|
||||
m_Scale: 1
|
||||
m_AtlasIndex: 0
|
||||
- m_Index: 467
|
||||
- m_Index: 597
|
||||
m_Metrics:
|
||||
m_Width: 186
|
||||
m_Height: 13
|
||||
|
@ -2745,7 +2745,7 @@ MonoBehaviour:
|
|||
m_Height: 13
|
||||
m_Scale: 1
|
||||
m_AtlasIndex: 0
|
||||
- m_Index: 470
|
||||
- m_Index: 600
|
||||
m_Metrics:
|
||||
m_Width: 25
|
||||
m_Height: 54
|
||||
|
@ -2759,7 +2759,7 @@ MonoBehaviour:
|
|||
m_Height: 54
|
||||
m_Scale: 1
|
||||
m_AtlasIndex: 0
|
||||
- m_Index: 471
|
||||
- m_Index: 601
|
||||
m_Metrics:
|
||||
m_Width: 25
|
||||
m_Height: 55
|
||||
|
@ -2773,7 +2773,7 @@ MonoBehaviour:
|
|||
m_Height: 55
|
||||
m_Scale: 1
|
||||
m_AtlasIndex: 0
|
||||
- m_Index: 472
|
||||
- m_Index: 602
|
||||
m_Metrics:
|
||||
m_Width: 25
|
||||
m_Height: 55
|
||||
|
@ -2787,7 +2787,7 @@ MonoBehaviour:
|
|||
m_Height: 55
|
||||
m_Scale: 1
|
||||
m_AtlasIndex: 0
|
||||
- m_Index: 474
|
||||
- m_Index: 604
|
||||
m_Metrics:
|
||||
m_Width: 59
|
||||
m_Height: 54
|
||||
|
@ -2801,7 +2801,7 @@ MonoBehaviour:
|
|||
m_Height: 54
|
||||
m_Scale: 1
|
||||
m_AtlasIndex: 0
|
||||
- m_Index: 475
|
||||
- m_Index: 605
|
||||
m_Metrics:
|
||||
m_Width: 58
|
||||
m_Height: 55
|
||||
|
@ -2815,7 +2815,7 @@ MonoBehaviour:
|
|||
m_Height: 55
|
||||
m_Scale: 1
|
||||
m_AtlasIndex: 0
|
||||
- m_Index: 476
|
||||
- m_Index: 606
|
||||
m_Metrics:
|
||||
m_Width: 58
|
||||
m_Height: 55
|
||||
|
@ -2829,7 +2829,7 @@ MonoBehaviour:
|
|||
m_Height: 55
|
||||
m_Scale: 1
|
||||
m_AtlasIndex: 0
|
||||
- m_Index: 477
|
||||
- m_Index: 607
|
||||
m_Metrics:
|
||||
m_Width: 90
|
||||
m_Height: 168
|
||||
|
@ -2843,7 +2843,7 @@ MonoBehaviour:
|
|||
m_Height: 168
|
||||
m_Scale: 1
|
||||
m_AtlasIndex: 0
|
||||
- m_Index: 478
|
||||
- m_Index: 608
|
||||
m_Metrics:
|
||||
m_Width: 90
|
||||
m_Height: 168
|
||||
|
@ -2857,7 +2857,7 @@ MonoBehaviour:
|
|||
m_Height: 168
|
||||
m_Scale: 1
|
||||
m_AtlasIndex: 0
|
||||
- m_Index: 479
|
||||
- m_Index: 609
|
||||
m_Metrics:
|
||||
m_Width: 43
|
||||
m_Height: 42
|
||||
|
@ -2871,7 +2871,7 @@ MonoBehaviour:
|
|||
m_Height: 42
|
||||
m_Scale: 1
|
||||
m_AtlasIndex: 0
|
||||
- m_Index: 481
|
||||
- m_Index: 611
|
||||
m_Metrics:
|
||||
m_Width: 152
|
||||
m_Height: 28
|
||||
|
@ -2885,7 +2885,7 @@ MonoBehaviour:
|
|||
m_Height: 28
|
||||
m_Scale: 1
|
||||
m_AtlasIndex: 0
|
||||
- m_Index: 482
|
||||
- m_Index: 612
|
||||
m_Metrics:
|
||||
m_Width: 169
|
||||
m_Height: 153
|
||||
|
@ -2899,7 +2899,7 @@ MonoBehaviour:
|
|||
m_Height: 153
|
||||
m_Scale: 1
|
||||
m_AtlasIndex: 0
|
||||
- m_Index: 485
|
||||
- m_Index: 615
|
||||
m_Metrics:
|
||||
m_Width: 69
|
||||
m_Height: 105
|
||||
|
@ -2913,7 +2913,7 @@ MonoBehaviour:
|
|||
m_Height: 105
|
||||
m_Scale: 1
|
||||
m_AtlasIndex: 0
|
||||
- m_Index: 486
|
||||
- m_Index: 616
|
||||
m_Metrics:
|
||||
m_Width: 69
|
||||
m_Height: 105
|
||||
|
@ -2927,7 +2927,7 @@ MonoBehaviour:
|
|||
m_Height: 105
|
||||
m_Scale: 1
|
||||
m_AtlasIndex: 0
|
||||
- m_Index: 489
|
||||
- m_Index: 619
|
||||
m_Metrics:
|
||||
m_Width: 100
|
||||
m_Height: 155
|
||||
|
@ -2941,7 +2941,7 @@ MonoBehaviour:
|
|||
m_Height: 155
|
||||
m_Scale: 1
|
||||
m_AtlasIndex: 0
|
||||
- m_Index: 490
|
||||
- m_Index: 620
|
||||
m_Metrics:
|
||||
m_Width: 124
|
||||
m_Height: 153
|
||||
|
@ -2955,7 +2955,7 @@ MonoBehaviour:
|
|||
m_Height: 153
|
||||
m_Scale: 1
|
||||
m_AtlasIndex: 0
|
||||
- m_Index: 498
|
||||
- m_Index: 628
|
||||
m_Metrics:
|
||||
m_Width: 135
|
||||
m_Height: 78
|
||||
|
@ -3724,78 +3724,78 @@ MonoBehaviour:
|
|||
m_Scale: 1
|
||||
- m_ElementType: 1
|
||||
m_Unicode: 8211
|
||||
m_GlyphIndex: 466
|
||||
m_GlyphIndex: 596
|
||||
m_Scale: 1
|
||||
- m_ElementType: 1
|
||||
m_Unicode: 8212
|
||||
m_GlyphIndex: 467
|
||||
m_GlyphIndex: 597
|
||||
m_Scale: 1
|
||||
- m_ElementType: 1
|
||||
m_Unicode: 8216
|
||||
m_GlyphIndex: 470
|
||||
m_GlyphIndex: 600
|
||||
m_Scale: 1
|
||||
- m_ElementType: 1
|
||||
m_Unicode: 8217
|
||||
m_GlyphIndex: 471
|
||||
m_GlyphIndex: 601
|
||||
m_Scale: 1
|
||||
- m_ElementType: 1
|
||||
m_Unicode: 8218
|
||||
m_GlyphIndex: 472
|
||||
m_GlyphIndex: 602
|
||||
m_Scale: 1
|
||||
- m_ElementType: 1
|
||||
m_Unicode: 8220
|
||||
m_GlyphIndex: 474
|
||||
m_GlyphIndex: 604
|
||||
m_Scale: 1
|
||||
- m_ElementType: 1
|
||||
m_Unicode: 8221
|
||||
m_GlyphIndex: 475
|
||||
m_GlyphIndex: 605
|
||||
m_Scale: 1
|
||||
- m_ElementType: 1
|
||||
m_Unicode: 8222
|
||||
m_GlyphIndex: 476
|
||||
m_GlyphIndex: 606
|
||||
m_Scale: 1
|
||||
- m_ElementType: 1
|
||||
m_Unicode: 8224
|
||||
m_GlyphIndex: 477
|
||||
m_GlyphIndex: 607
|
||||
m_Scale: 1
|
||||
- m_ElementType: 1
|
||||
m_Unicode: 8225
|
||||
m_GlyphIndex: 478
|
||||
m_GlyphIndex: 608
|
||||
m_Scale: 1
|
||||
- m_ElementType: 1
|
||||
m_Unicode: 8226
|
||||
m_GlyphIndex: 479
|
||||
m_GlyphIndex: 609
|
||||
m_Scale: 1
|
||||
- m_ElementType: 1
|
||||
m_Unicode: 8230
|
||||
m_GlyphIndex: 481
|
||||
m_GlyphIndex: 611
|
||||
m_Scale: 1
|
||||
- m_ElementType: 1
|
||||
m_Unicode: 8240
|
||||
m_GlyphIndex: 482
|
||||
m_GlyphIndex: 612
|
||||
m_Scale: 1
|
||||
- m_ElementType: 1
|
||||
m_Unicode: 8249
|
||||
m_GlyphIndex: 485
|
||||
m_GlyphIndex: 615
|
||||
m_Scale: 1
|
||||
- m_ElementType: 1
|
||||
m_Unicode: 8250
|
||||
m_GlyphIndex: 486
|
||||
m_GlyphIndex: 616
|
||||
m_Scale: 1
|
||||
- m_ElementType: 1
|
||||
m_Unicode: 8260
|
||||
m_GlyphIndex: 489
|
||||
m_GlyphIndex: 619
|
||||
m_Scale: 1
|
||||
- m_ElementType: 1
|
||||
m_Unicode: 8364
|
||||
m_GlyphIndex: 490
|
||||
m_GlyphIndex: 620
|
||||
m_Scale: 1
|
||||
- m_ElementType: 1
|
||||
m_Unicode: 8482
|
||||
m_GlyphIndex: 498
|
||||
m_GlyphIndex: 628
|
||||
m_Scale: 1
|
||||
m_AtlasTextures:
|
||||
- {fileID: 1363669669053061815}
|
||||
- {fileID: 8801383763965547972}
|
||||
m_AtlasTextureIndex: 0
|
||||
m_IsMultiAtlasTexturesEnabled: 0
|
||||
m_ClearDynamicDataOnBuild: 0
|
||||
|
@ -5341,7 +5341,7 @@ MonoBehaviour:
|
|||
m_FallbackFontAssetTable: []
|
||||
m_CreationSettings:
|
||||
sourceFontFileName:
|
||||
sourceFontFileGUID: d245bd2e354835547b32cf6c1a738d45
|
||||
sourceFontFileGUID: 6459e01c422d8fb469d08b74a81e6b81
|
||||
pointSizeSamplingMode: 0
|
||||
pointSize: 186
|
||||
padding: 12
|
||||
|
@ -5384,13 +5384,13 @@ MonoBehaviour:
|
|||
boldSpacing: 7
|
||||
italicStyle: 35
|
||||
tabSize: 10
|
||||
--- !u!28 &1363669669053061815
|
||||
--- !u!28 &8801383763965547972
|
||||
Texture2D:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name: rodin_merged Atlas
|
||||
m_Name: rodin_lat_cy_ja_ko_spec Atlas
|
||||
m_ImageContentsHash:
|
||||
serializedVersion: 2
|
||||
Hash: 00000000000000000000000000000000
|
|
@ -1,5 +1,5 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 391dfd08cb8a3cf4dbae153523abce8b
|
||||
guid: 795a65f16e097f44eb799cb2ec026fc1
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 11400000
|
BIN
Assets/Resources/Fonts/rodin/rodin_lat_cy_ja_ko_spec.ttf
Normal file
BIN
Assets/Resources/Fonts/rodin/rodin_lat_cy_ja_ko_spec.ttf
Normal file
Binary file not shown.
|
@ -1,5 +1,5 @@
|
|||
fileFormatVersion: 2
|
||||
guid: d245bd2e354835547b32cf6c1a738d45
|
||||
guid: 6459e01c422d8fb469d08b74a81e6b81
|
||||
TrueTypeFontImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 4
|
||||
|
@ -10,7 +10,8 @@ TrueTypeFontImporter:
|
|||
includeFontData: 1
|
||||
fontNames:
|
||||
- nintendo_NTLG-DB_001
|
||||
fallbackFontReferences: []
|
||||
fallbackFontReferences:
|
||||
- {fileID: 12800000, guid: d245bd2e354835547b32cf6c1a738d45, type: 3}
|
||||
customCharacters:
|
||||
fontRenderingMode: 0
|
||||
ascentCalculationMode: 1
|
Binary file not shown.
|
@ -1,11 +0,0 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class CommonAnimEvents : MonoBehaviour
|
||||
{
|
||||
public void Destroy()
|
||||
{
|
||||
Destroy(this.gameObject);
|
||||
}
|
||||
}
|
|
@ -4,164 +4,167 @@ using UnityEngine;
|
|||
|
||||
using Starpelly;
|
||||
|
||||
[RequireComponent(typeof(AudioSource))]
|
||||
public class Conductor : MonoBehaviour
|
||||
namespace RhythmHeavenMania
|
||||
{
|
||||
//Song beats per minute
|
||||
//This is determined by the song you're trying to sync up to
|
||||
public float songBpm;
|
||||
|
||||
//The number of seconds for each song beat
|
||||
public float secPerBeat;
|
||||
|
||||
//Current song position, in seconds
|
||||
public float songPosition;
|
||||
|
||||
//Current song position, in beats
|
||||
public float songPositionInBeats;
|
||||
|
||||
//How many seconds have passed since the song started
|
||||
public float dspSongTime;
|
||||
|
||||
//an AudioSource attached to this GameObject that will play the music.
|
||||
public AudioSource musicSource;
|
||||
|
||||
//The offset to the first beat of the song in seconds
|
||||
public float firstBeatOffset;
|
||||
|
||||
//the number of beats in each loop
|
||||
public float beatsPerLoop;
|
||||
|
||||
//the total number of loops completed since the looping clip first started
|
||||
public int completedLoops = 0;
|
||||
|
||||
//The current position of the song within the loop in beats.
|
||||
public float loopPositionInBeats;
|
||||
|
||||
//The current relative position of the song within the loop measured between 0 and 1.
|
||||
public float loopPositionInAnalog;
|
||||
|
||||
//Conductor instance
|
||||
public static Conductor instance;
|
||||
|
||||
//Pause times
|
||||
private int pauseTime = 0;
|
||||
|
||||
public float beatThreshold;
|
||||
|
||||
void Awake()
|
||||
[RequireComponent(typeof(AudioSource))]
|
||||
public class Conductor : MonoBehaviour
|
||||
{
|
||||
instance = this;
|
||||
}
|
||||
//Song beats per minute
|
||||
//This is determined by the song you're trying to sync up to
|
||||
public float songBpm;
|
||||
|
||||
void Start()
|
||||
{
|
||||
//Load the AudioSource attached to the Conductor GameObject
|
||||
musicSource = GetComponent<AudioSource>();
|
||||
//The number of seconds for each song beat
|
||||
public float secPerBeat;
|
||||
|
||||
//Calculate the number of seconds in each beat
|
||||
secPerBeat = 60f / songBpm;
|
||||
//Current song position, in seconds
|
||||
public float songPosition;
|
||||
|
||||
//Record the time when the music starts
|
||||
dspSongTime = (float)musicSource.time;
|
||||
//Current song position, in beats
|
||||
public float songPositionInBeats;
|
||||
|
||||
//Start the music
|
||||
// musicSource.Play();
|
||||
}
|
||||
//How many seconds have passed since the song started
|
||||
public float dspSongTime;
|
||||
|
||||
void Update()
|
||||
{
|
||||
Conductor.instance.musicSource.pitch = Time.timeScale;
|
||||
//an AudioSource attached to this GameObject that will play the music.
|
||||
public AudioSource musicSource;
|
||||
|
||||
/*if (Input.GetKeyDown(KeyCode.Space))
|
||||
//The offset to the first beat of the song in seconds
|
||||
public float firstBeatOffset;
|
||||
|
||||
//the number of beats in each loop
|
||||
public float beatsPerLoop;
|
||||
|
||||
//the total number of loops completed since the looping clip first started
|
||||
public int completedLoops = 0;
|
||||
|
||||
//The current position of the song within the loop in beats.
|
||||
public float loopPositionInBeats;
|
||||
|
||||
//The current relative position of the song within the loop measured between 0 and 1.
|
||||
public float loopPositionInAnalog;
|
||||
|
||||
//Conductor instance
|
||||
public static Conductor instance;
|
||||
|
||||
//Pause times
|
||||
private int pauseTime = 0;
|
||||
|
||||
public float beatThreshold;
|
||||
|
||||
void Awake()
|
||||
{
|
||||
pauseTime++;
|
||||
if (pauseTime == 1)
|
||||
musicSource.Pause();
|
||||
else if (pauseTime > 1) { musicSource.UnPause(); pauseTime = 0; }
|
||||
}*/
|
||||
instance = this;
|
||||
}
|
||||
|
||||
//determine how many seconds since the song started
|
||||
songPosition = (float)(musicSource.time - dspSongTime - firstBeatOffset);
|
||||
|
||||
//determine how many beats since the song started
|
||||
songPositionInBeats = songPosition / secPerBeat;
|
||||
|
||||
//calculate the loop position
|
||||
if (songPositionInBeats >= (completedLoops + 1) * beatsPerLoop)
|
||||
completedLoops++;
|
||||
loopPositionInBeats = songPositionInBeats - completedLoops * beatsPerLoop;
|
||||
|
||||
loopPositionInAnalog = loopPositionInBeats / beatsPerLoop;
|
||||
}
|
||||
|
||||
public float GetLoopPositionFromBeat(float startBeat, float length)
|
||||
{
|
||||
float final = Starpelly.Mathp.Normalize(songPositionInBeats, startBeat, startBeat + length);
|
||||
|
||||
return final;
|
||||
}
|
||||
|
||||
public bool InThreshold(float beat)
|
||||
{
|
||||
//Check if the beat sent falls within beatThreshold
|
||||
//Written to handle the looping
|
||||
if (beat <= beatThreshold + 1)
|
||||
void Start()
|
||||
{
|
||||
//Debug.Log("Case 1, beat is close to 1");
|
||||
if (loopPositionInBeats > beat + beatThreshold)
|
||||
//Load the AudioSource attached to the Conductor GameObject
|
||||
musicSource = GetComponent<AudioSource>();
|
||||
|
||||
//Calculate the number of seconds in each beat
|
||||
secPerBeat = 60f / songBpm;
|
||||
|
||||
//Record the time when the music starts
|
||||
dspSongTime = (float)musicSource.time;
|
||||
|
||||
//Start the music
|
||||
// musicSource.Play();
|
||||
}
|
||||
|
||||
void Update()
|
||||
{
|
||||
Conductor.instance.musicSource.pitch = Time.timeScale;
|
||||
|
||||
/*if (Input.GetKeyDown(KeyCode.Space))
|
||||
{
|
||||
if (loopPositionInBeats >= (beat + songPositionInBeats - 1) + beatThreshold)
|
||||
pauseTime++;
|
||||
if (pauseTime == 1)
|
||||
musicSource.Pause();
|
||||
else if (pauseTime > 1) { musicSource.UnPause(); pauseTime = 0; }
|
||||
}*/
|
||||
|
||||
//determine how many seconds since the song started
|
||||
songPosition = (float)(musicSource.time - dspSongTime - firstBeatOffset);
|
||||
|
||||
//determine how many beats since the song started
|
||||
songPositionInBeats = songPosition / secPerBeat;
|
||||
|
||||
//calculate the loop position
|
||||
if (songPositionInBeats >= (completedLoops + 1) * beatsPerLoop)
|
||||
completedLoops++;
|
||||
loopPositionInBeats = songPositionInBeats - completedLoops * beatsPerLoop;
|
||||
|
||||
loopPositionInAnalog = loopPositionInBeats / beatsPerLoop;
|
||||
}
|
||||
|
||||
public float GetLoopPositionFromBeat(float startBeat, float length)
|
||||
{
|
||||
float final = Starpelly.Mathp.Normalize(songPositionInBeats, startBeat, startBeat + length);
|
||||
|
||||
return final;
|
||||
}
|
||||
|
||||
public bool InThreshold(float beat)
|
||||
{
|
||||
//Check if the beat sent falls within beatThreshold
|
||||
//Written to handle the looping
|
||||
if (beat <= beatThreshold + 1)
|
||||
{
|
||||
//Debug.Log("Case 1, beat is close to 1");
|
||||
if (loopPositionInBeats > beat + beatThreshold)
|
||||
{
|
||||
//Debug.Log("LoopPos just below loop point");
|
||||
return true;
|
||||
if (loopPositionInBeats >= (beat + songPositionInBeats - 1) + beatThreshold)
|
||||
{
|
||||
//Debug.Log("LoopPos just below loop point");
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
//Debug.Log("LoopPos not within beat threshold");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//Debug.Log("LoopPos not within beat threshold");
|
||||
//Debug.Log("Case 1, loopPos between loop point and beat threshold");
|
||||
}
|
||||
}
|
||||
else
|
||||
else if (beat < (songPositionInBeats + 1 - beatThreshold))
|
||||
{
|
||||
//Debug.Log("Case 1, loopPos between loop point and beat threshold");
|
||||
}
|
||||
}
|
||||
else if (beat < (songPositionInBeats + 1 - beatThreshold))
|
||||
{
|
||||
//Debug.Log("Case 2, beat is far from loop point.");
|
||||
if (loopPositionInBeats >= beat - beatThreshold && loopPositionInBeats <= beat + beatThreshold)
|
||||
{
|
||||
//Debug.Log("LoopPos within threshold");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else if (beat >= (songPositionInBeats + 1 - beatThreshold))
|
||||
{
|
||||
//Debug.Log("Case 3, beat is close to loop point");
|
||||
if (loopPositionInBeats < beat)
|
||||
{
|
||||
if (loopPositionInBeats >= beat - beatThreshold)
|
||||
//Debug.Log("Case 2, beat is far from loop point.");
|
||||
if (loopPositionInBeats >= beat - beatThreshold && loopPositionInBeats <= beat + beatThreshold)
|
||||
{
|
||||
//Debug.Log("LoopPos just below beat");
|
||||
return true;
|
||||
}
|
||||
else if (loopPositionInBeats < (beat - songPositionInBeats + 1) - beatThreshold)
|
||||
{
|
||||
//Debug.Log("LoopPos just above loop point");
|
||||
//Debug.Log("LoopPos within threshold");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else
|
||||
else if (beat >= (songPositionInBeats + 1 - beatThreshold))
|
||||
{
|
||||
//Debug.Log("LoopPos just above beat");
|
||||
return true;
|
||||
}
|
||||
//Debug.Log("Case 3, beat is close to loop point");
|
||||
if (loopPositionInBeats < beat)
|
||||
{
|
||||
if (loopPositionInBeats >= beat - beatThreshold)
|
||||
{
|
||||
//Debug.Log("LoopPos just below beat");
|
||||
return true;
|
||||
}
|
||||
else if (loopPositionInBeats < (beat - songPositionInBeats + 1) - beatThreshold)
|
||||
{
|
||||
//Debug.Log("LoopPos just above loop point");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//Debug.Log("LoopPos just above beat");
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogError("Strange Case. Where is this beat? This should never happen");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogError("Strange Case. Where is this beat? This should never happen");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
|
@ -1,38 +0,0 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class ForkLifter : MonoBehaviour
|
||||
{
|
||||
public static ForkLifter instance;
|
||||
|
||||
GameManager GameManager;
|
||||
|
||||
[Header("Objects")]
|
||||
public Animator handAnim;
|
||||
public GameObject flickedObject;
|
||||
public SpriteRenderer peaPreview;
|
||||
|
||||
public Sprite[] peaSprites;
|
||||
public Sprite[] peaHitSprites;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
instance = this;
|
||||
}
|
||||
|
||||
private void Start()
|
||||
{
|
||||
GameManager = GameManager.instance;
|
||||
}
|
||||
|
||||
public void Flick(float beat, int type)
|
||||
{
|
||||
Jukebox.PlayOneShot("flick");
|
||||
handAnim.Play("Hand_Flick", 0, 0);
|
||||
GameObject fo = Instantiate(flickedObject);
|
||||
fo.GetComponent<Pea>().startBeat = beat;
|
||||
fo.GetComponent<Pea>().type = type;
|
||||
fo.SetActive(true);
|
||||
}
|
||||
}
|
|
@ -1,58 +0,0 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using UnityEngine;
|
||||
|
||||
public class ForkLifterHand : MonoBehaviour
|
||||
{
|
||||
public SpriteRenderer fastSprite;
|
||||
|
||||
public Sprite[] fastSprites;
|
||||
|
||||
List<GameManager.Event> allPlayerActions;
|
||||
|
||||
public static ForkLifterHand instance { get; set; }
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
instance = this;
|
||||
}
|
||||
|
||||
public void CheckNextFlick()
|
||||
{
|
||||
allPlayerActions = GameManager.instance.Events.FindAll(c => c.eventName != "gulp" && c.eventName != "sigh" && c.eventName != "prepare");
|
||||
|
||||
if (GameManager.instance.currentEventPlayer < allPlayerActions.Count)
|
||||
{
|
||||
switch (allPlayerActions[GameManager.instance.currentEventPlayer].eventName)
|
||||
{
|
||||
case "pea":
|
||||
ForkLifter.instance.peaPreview.sprite = ForkLifter.instance.peaSprites[0];
|
||||
fastSprite.sprite = fastSprites[0];
|
||||
break;
|
||||
case "topbun":
|
||||
fastSprite.sprite = fastSprites[0];
|
||||
ForkLifter.instance.peaPreview.sprite = ForkLifter.instance.peaSprites[1];
|
||||
break;
|
||||
case "burger":
|
||||
fastSprite.sprite = fastSprites[1];
|
||||
ForkLifter.instance.peaPreview.sprite = ForkLifter.instance.peaSprites[2];
|
||||
break;
|
||||
case "bottombun":
|
||||
fastSprite.sprite = fastSprites[0];
|
||||
ForkLifter.instance.peaPreview.sprite = ForkLifter.instance.peaSprites[3];
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ForkLifter.instance.peaPreview.sprite = null;
|
||||
}
|
||||
}
|
||||
|
||||
public void Prepare()
|
||||
{
|
||||
Jukebox.PlayOneShot("flickPrepare");
|
||||
GetComponent<Animator>().Play("Hand_Prepare");
|
||||
}
|
||||
}
|
|
@ -1,312 +0,0 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
using DG.Tweening;
|
||||
|
||||
public class ForkLifterPlayer : MonoBehaviour
|
||||
{
|
||||
[Header("Objects")]
|
||||
public GameObject fork;
|
||||
public Sprite peaSprite;
|
||||
public Sprite hitFX;
|
||||
public Sprite hitFXG;
|
||||
public Sprite hitFXMiss;
|
||||
public Sprite hitFX2;
|
||||
public Transform early, perfect, late;
|
||||
|
||||
[SerializeField]
|
||||
private BoxCollider2D col;
|
||||
|
||||
private Animator anim;
|
||||
|
||||
public List<Eligible> EligibleHits = new List<Eligible>();
|
||||
private int currentHitInList = 0;
|
||||
|
||||
public static ForkLifterPlayer instance { get; set; }
|
||||
|
||||
public float timescale = 1;
|
||||
|
||||
private int currentEarlyPeasOnFork;
|
||||
private int currentPerfectPeasOnFork;
|
||||
private int currentLatePeasOnFork;
|
||||
|
||||
private bool isEating = false;
|
||||
|
||||
// Burger shit
|
||||
|
||||
private bool topbun, middleburger, bottombun;
|
||||
|
||||
// -----------
|
||||
|
||||
[System.Serializable]
|
||||
public class Eligible
|
||||
{
|
||||
public Pea pea;
|
||||
public bool early;
|
||||
public bool perfect;
|
||||
public bool late;
|
||||
}
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
instance = this;
|
||||
}
|
||||
|
||||
private void Start()
|
||||
{
|
||||
anim = GetComponent<Animator>();
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
Time.timeScale = timescale;
|
||||
|
||||
if (Input.GetMouseButtonDown(0) || Input.GetKeyDown(KeyCode.Z) || Input.GetKeyDown(KeyCode.Space))
|
||||
{
|
||||
Stab();
|
||||
}
|
||||
|
||||
if (EligibleHits.Count == 0)
|
||||
{
|
||||
currentHitInList = 0;
|
||||
}
|
||||
|
||||
if (Input.GetKeyDown(KeyCode.A))
|
||||
{
|
||||
Conductor.instance.musicSource.time += 3;
|
||||
}
|
||||
else if (Input.GetKeyDown(KeyCode.S))
|
||||
{
|
||||
Conductor.instance.musicSource.time -= 3;
|
||||
GameManager.instance.SetCurrentEventToClosest();
|
||||
}
|
||||
}
|
||||
|
||||
public void Eat()
|
||||
{
|
||||
if (currentEarlyPeasOnFork != 0 || currentPerfectPeasOnFork != 0 || currentLatePeasOnFork != 0)
|
||||
{
|
||||
anim.Play("Player_Eat", 0, 0);
|
||||
isEating = true;
|
||||
}
|
||||
}
|
||||
|
||||
public void EatConfirm()
|
||||
{
|
||||
if (topbun && middleburger && bottombun)
|
||||
{
|
||||
Jukebox.PlayOneShot("burger");
|
||||
}
|
||||
else
|
||||
{
|
||||
if (currentEarlyPeasOnFork > 0 || currentLatePeasOnFork > 0)
|
||||
{
|
||||
Jukebox.PlayOneShot($"cough_{Random.Range(1, 3)}");
|
||||
}
|
||||
else
|
||||
{
|
||||
Jukebox.PlayOneShot("gulp");
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < early.transform.childCount; i++)
|
||||
{
|
||||
Destroy(early.transform.GetChild(i).gameObject);
|
||||
}
|
||||
for (int i = 0; i < perfect.transform.childCount; i++)
|
||||
{
|
||||
Destroy(perfect.transform.GetChild(i).gameObject);
|
||||
}
|
||||
for (int i = 0; i < late.transform.childCount; i++)
|
||||
{
|
||||
Destroy(late.transform.GetChild(i).gameObject);
|
||||
}
|
||||
currentEarlyPeasOnFork = 0;
|
||||
currentPerfectPeasOnFork = 0;
|
||||
currentLatePeasOnFork = 0;
|
||||
|
||||
isEating = false;
|
||||
|
||||
topbun = false; middleburger = false; bottombun = false;
|
||||
}
|
||||
|
||||
public void Stab()
|
||||
{
|
||||
if (isEating) return;
|
||||
bool canHit = (EligibleHits.Count > 0) && (currentHitInList < EligibleHits.Count);
|
||||
|
||||
if (canHit)
|
||||
{
|
||||
GameObject pea = new GameObject();
|
||||
|
||||
if (EligibleHits[currentHitInList].perfect)
|
||||
{
|
||||
pea.transform.parent = perfect.transform;
|
||||
pea.transform.localScale = Vector2.one;
|
||||
|
||||
pea.transform.localPosition = Vector3.zero;
|
||||
|
||||
for (int i = 0; i < perfect.transform.childCount; i++)
|
||||
{
|
||||
perfect.transform.GetChild(i).transform.localPosition = new Vector3(0, (-1.67f - (0.15724f * i)) + 0.15724f * currentPerfectPeasOnFork);
|
||||
}
|
||||
|
||||
SpriteRenderer psprite = pea.AddComponent<SpriteRenderer>();
|
||||
psprite.sprite = ForkLifter.instance.peaHitSprites[EligibleHits[currentHitInList].pea.type];
|
||||
psprite.sortingOrder = 20;
|
||||
switch (EligibleHits[currentHitInList].pea.type)
|
||||
{
|
||||
case 0:
|
||||
psprite.sortingOrder = 101;
|
||||
break;
|
||||
case 1:
|
||||
psprite.sortingOrder = 104;
|
||||
break;
|
||||
case 2:
|
||||
psprite.sortingOrder = 103;
|
||||
break;
|
||||
case 3:
|
||||
psprite.sortingOrder = 102;
|
||||
break;
|
||||
}
|
||||
|
||||
GameObject hitFXo = new GameObject();
|
||||
hitFXo.transform.localPosition = new Vector3(1.9969f, -3.7026f);
|
||||
hitFXo.transform.localScale = new Vector3(3.142196f, 3.142196f);
|
||||
SpriteRenderer hfxs = hitFXo.AddComponent<SpriteRenderer>();
|
||||
hfxs.sprite = hitFX;
|
||||
hfxs.sortingOrder = 100;
|
||||
hfxs.DOColor(new Color(1, 1, 1, 0), 0.05f).OnComplete(delegate { Destroy(hitFXo); });
|
||||
|
||||
FastEffectHit(EligibleHits[currentHitInList].pea.type);
|
||||
|
||||
Jukebox.PlayOneShot("stab");
|
||||
|
||||
currentPerfectPeasOnFork++;
|
||||
|
||||
if (EligibleHits[currentHitInList].pea.type == 1)
|
||||
{
|
||||
topbun = true;
|
||||
}
|
||||
else if (EligibleHits[currentHitInList].pea.type == 2)
|
||||
{
|
||||
middleburger = true;
|
||||
}
|
||||
else if (EligibleHits[currentHitInList].pea.type == 3)
|
||||
{
|
||||
bottombun = true;
|
||||
}
|
||||
|
||||
RemovePea();
|
||||
|
||||
GoForAPerfect.instance.Hit();
|
||||
GameProfiler.instance.IncreaseScore();
|
||||
}
|
||||
else if (EligibleHits[currentHitInList].early)
|
||||
{
|
||||
pea.transform.parent = early.transform;
|
||||
pea.transform.localScale = Vector2.one;
|
||||
|
||||
pea.transform.localPosition = Vector3.zero;
|
||||
pea.transform.localRotation = Quaternion.Euler(0, 0, 90);
|
||||
|
||||
for (int i = 0; i < early.transform.childCount; i++)
|
||||
{
|
||||
early.transform.GetChild(i).transform.localPosition = new Vector3(0, (-1.67f - (0.15724f * i)) + 0.15724f * currentEarlyPeasOnFork);
|
||||
}
|
||||
|
||||
SpriteRenderer psprite = pea.AddComponent<SpriteRenderer>();
|
||||
psprite.sprite = ForkLifter.instance.peaHitSprites[EligibleHits[currentHitInList].pea.type];
|
||||
psprite.sortingOrder = 20;
|
||||
HitFXMiss(new Vector2(1.0424f, -4.032f), new Vector2(1.129612f, 1.129612f));
|
||||
HitFXMiss(new Vector2(0.771f, -3.016f), new Vector2(1.71701f, 1.71701f));
|
||||
HitFXMiss(new Vector2(2.598f, -2.956f), new Vector2(1.576043f, 1.576043f));
|
||||
HitFXMiss(new Vector2(2.551f, -3.609f), new Vector2(1.200788f, 1.200788f));
|
||||
|
||||
FastEffectHit(EligibleHits[currentHitInList].pea.type);
|
||||
|
||||
Jukebox.PlayOneShot("miss");
|
||||
|
||||
currentEarlyPeasOnFork++;
|
||||
|
||||
RemovePea();
|
||||
|
||||
GoForAPerfect.instance.Miss();
|
||||
}
|
||||
else if (EligibleHits[currentHitInList].late)
|
||||
{
|
||||
pea.transform.parent = late.transform;
|
||||
pea.transform.localScale = Vector2.one;
|
||||
|
||||
pea.transform.localPosition = Vector3.zero;
|
||||
pea.transform.localRotation = Quaternion.Euler(0, 0, 90);
|
||||
|
||||
for (int i = 0; i < late.transform.childCount; i++)
|
||||
{
|
||||
late.transform.GetChild(i).transform.localPosition = new Vector3(0, (-1.67f - (0.15724f * i)) + 0.15724f * currentLatePeasOnFork);
|
||||
}
|
||||
|
||||
SpriteRenderer psprite = pea.AddComponent<SpriteRenderer>();
|
||||
psprite.sprite = ForkLifter.instance.peaHitSprites[EligibleHits[currentHitInList].pea.type];
|
||||
psprite.sortingOrder = 20;
|
||||
HitFXMiss(new Vector2(1.0424f, -4.032f), new Vector2(1.129612f, 1.129612f));
|
||||
HitFXMiss(new Vector2(0.771f, -3.016f), new Vector2(1.71701f, 1.71701f));
|
||||
HitFXMiss(new Vector2(2.598f, -2.956f), new Vector2(1.576043f, 1.576043f));
|
||||
HitFXMiss(new Vector2(2.551f, -3.609f), new Vector2(1.200788f, 1.200788f));
|
||||
|
||||
FastEffectHit(EligibleHits[currentHitInList].pea.type);
|
||||
|
||||
Jukebox.PlayOneShot("miss");
|
||||
|
||||
currentLatePeasOnFork++;
|
||||
|
||||
RemovePea();
|
||||
|
||||
GoForAPerfect.instance.Miss();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Jukebox.PlayOneShot("stabnohit");
|
||||
}
|
||||
|
||||
anim.Play("Player_Stab", 0, 0);
|
||||
}
|
||||
|
||||
private void FastEffectHit(int type)
|
||||
{
|
||||
GameObject hitFX2o = new GameObject();
|
||||
hitFX2o.transform.localPosition = new Vector3(0.11f, -2.15f);
|
||||
hitFX2o.transform.localScale = new Vector3(5.401058f, 1.742697f);
|
||||
hitFX2o.transform.localRotation = Quaternion.Euler(0, 0, -38.402f);
|
||||
SpriteRenderer hfx2s = hitFX2o.AddComponent<SpriteRenderer>();
|
||||
if (type == 2)
|
||||
hfx2s.sprite = hitFXG;
|
||||
else
|
||||
hfx2s.sprite = hitFX2;
|
||||
hfx2s.sortingOrder = -5;
|
||||
hfx2s.DOColor(new Color(1, 1, 1, 0), 0.07f).OnComplete(delegate { Destroy(hitFX2o); });
|
||||
}
|
||||
|
||||
private void HitFXMiss(Vector2 pos, Vector2 size)
|
||||
{
|
||||
GameObject hitFXo = new GameObject();
|
||||
hitFXo.transform.localPosition = new Vector3(pos.x, pos.y);
|
||||
hitFXo.transform.localScale = new Vector3(size.x, size.y);
|
||||
SpriteRenderer hfxs = hitFXo.AddComponent<SpriteRenderer>();
|
||||
hfxs.sprite = hitFXMiss;
|
||||
hfxs.sortingOrder = 100;
|
||||
hfxs.DOColor(new Color(1, 1, 1, 0), 0.05f).OnComplete(delegate { Destroy(hitFXo); });
|
||||
}
|
||||
|
||||
private void RemovePea()
|
||||
{
|
||||
if (currentHitInList < EligibleHits.Count)
|
||||
{
|
||||
Destroy(EligibleHits[currentHitInList].pea.gameObject);
|
||||
EligibleHits.Remove(EligibleHits[currentHitInList]);
|
||||
currentHitInList++;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,112 +0,0 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class Pea : MonoBehaviour
|
||||
{
|
||||
[Header("Latency")]
|
||||
public float earlyTime;
|
||||
public float perfectTime;
|
||||
public float lateTime;
|
||||
public float endTime;
|
||||
|
||||
private Animator anim;
|
||||
|
||||
public float startBeat;
|
||||
|
||||
private bool inList = false;
|
||||
|
||||
public int type;
|
||||
|
||||
private ForkLifterPlayer.Eligible e = new ForkLifterPlayer.Eligible();
|
||||
|
||||
public int estate, pstate, lstate, endstate;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
anim = GetComponent<Animator>();
|
||||
Jukebox.PlayOneShot("zoom");
|
||||
GetComponentInChildren<SpriteRenderer>().sprite = ForkLifter.instance.peaSprites[type];
|
||||
|
||||
e = new ForkLifterPlayer.Eligible();
|
||||
e.pea = this;
|
||||
|
||||
for (int i = 0; i < transform.GetChild(0).childCount; i++)
|
||||
{
|
||||
transform.GetChild(0).GetChild(i).GetComponent<SpriteRenderer>().sprite = transform.GetChild(0).GetComponent<SpriteRenderer>().sprite;
|
||||
}
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
float normalizedBeat = (Conductor.instance.GetLoopPositionFromBeat(startBeat, 2.5f));
|
||||
anim.Play("Flicked_Object", -1, normalizedBeat);
|
||||
anim.speed = 0;
|
||||
|
||||
// Early State
|
||||
if (normalizedBeat > earlyTime && normalizedBeat < perfectTime && estate <= 1)
|
||||
{
|
||||
estate++;
|
||||
MakeEligible(true, false, false);
|
||||
}
|
||||
// Perfect State
|
||||
else if (normalizedBeat > perfectTime && normalizedBeat < lateTime && pstate <= 1)
|
||||
{
|
||||
pstate++;
|
||||
MakeEligible(false, true, false);
|
||||
}
|
||||
// Late State
|
||||
else if (normalizedBeat > lateTime && normalizedBeat < endTime && lstate <= 1)
|
||||
{
|
||||
lstate++;
|
||||
MakeEligible(false, false, true);
|
||||
}
|
||||
else if (normalizedBeat < earlyTime || normalizedBeat > endTime)
|
||||
{
|
||||
MakeInEligible();
|
||||
}
|
||||
|
||||
if (normalizedBeat > endTime && endstate <= 1)
|
||||
{
|
||||
endstate++;
|
||||
Jukebox.PlayOneShot("disappointed");
|
||||
GoForAPerfect.instance.Miss();
|
||||
}
|
||||
|
||||
if (normalizedBeat > 1.35f)
|
||||
{
|
||||
MakeInEligible();
|
||||
Destroy(this.gameObject);
|
||||
}
|
||||
}
|
||||
|
||||
public void MakeEligible(bool early, bool perfect, bool late)
|
||||
{
|
||||
// print($"{early}, {perfect}, {late}");
|
||||
|
||||
if (!inList)
|
||||
{
|
||||
e.early = early;
|
||||
e.perfect = perfect;
|
||||
e.late = late;
|
||||
|
||||
ForkLifterPlayer.instance.EligibleHits.Add(e);
|
||||
inList = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
ForkLifterPlayer.Eligible es = ForkLifterPlayer.instance.EligibleHits[ForkLifterPlayer.instance.EligibleHits.IndexOf(e)];
|
||||
es.early = early;
|
||||
es.perfect = perfect;
|
||||
es.late = late;
|
||||
}
|
||||
}
|
||||
|
||||
public void MakeInEligible()
|
||||
{
|
||||
if (!inList) return;
|
||||
|
||||
ForkLifterPlayer.instance.EligibleHits.Remove(e);
|
||||
inList = false;
|
||||
}
|
||||
}
|
|
@ -7,176 +7,182 @@ using UnityEngine;
|
|||
using Starpelly;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
public class GameManager : MonoBehaviour
|
||||
using RhythmHeavenMania.Games.ForkLifter;
|
||||
using RhythmHeavenMania.Util;
|
||||
|
||||
namespace RhythmHeavenMania
|
||||
{
|
||||
public static GameManager instance;
|
||||
|
||||
public List<Event> Events = new List<Event>();
|
||||
public List<float> AutoPlay = new List<float>();
|
||||
public List<Event> allPlayerActions = new List<Event>();
|
||||
|
||||
public int currentEvent, currentEventAutoplay, currentEventPlayer;
|
||||
|
||||
public TextAsset txt;
|
||||
|
||||
public bool autoplay = false;
|
||||
|
||||
public float startOffset;
|
||||
|
||||
[Serializable]
|
||||
public class Event : ICloneable
|
||||
public class GameManager : MonoBehaviour
|
||||
{
|
||||
public float spawnTime;
|
||||
public string eventName;
|
||||
public static GameManager instance;
|
||||
|
||||
public object Clone()
|
||||
public List<Event> Events = new List<Event>();
|
||||
public List<float> AutoPlay = new List<float>();
|
||||
public List<Event> allPlayerActions = new List<Event>();
|
||||
|
||||
public int currentEvent, currentEventAutoplay, currentEventPlayer;
|
||||
|
||||
public TextAsset txt;
|
||||
|
||||
public bool autoplay = false;
|
||||
|
||||
public float startOffset;
|
||||
|
||||
[Serializable]
|
||||
public class Event : ICloneable
|
||||
{
|
||||
return this.MemberwiseClone();
|
||||
}
|
||||
}
|
||||
public float spawnTime;
|
||||
public string eventName;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
instance = this;
|
||||
}
|
||||
|
||||
private void Start()
|
||||
{
|
||||
SortEventsList();
|
||||
|
||||
string json = txt.text;
|
||||
Events = JsonConvert.DeserializeObject<List<Event>>(json);
|
||||
|
||||
SortEventsList();
|
||||
|
||||
allPlayerActions = Events.FindAll(c => c.eventName != "gulp" && c.eventName != "sigh" && c.eventName != "prepare" && c.eventName != "end");
|
||||
AutoPlay = allPlayerActions.Select(c => c.spawnTime + 2).ToList();
|
||||
|
||||
/*List<Event> temp = new List<Event>();
|
||||
for (int i = 0; i < allPlayerActions.Count; i++)
|
||||
{
|
||||
if (i - 1 > 0)
|
||||
public object Clone()
|
||||
{
|
||||
if (Mathp.IsWithin(allPlayerActions[i - 1].spawnTime, allPlayerActions[i].spawnTime - 1f, allPlayerActions[i].spawnTime))
|
||||
{
|
||||
// do nothing lul
|
||||
continue;
|
||||
}
|
||||
}
|
||||
Event e = (Event)allPlayerActions[i].Clone();
|
||||
e.spawnTime = allPlayerActions[i].spawnTime - 1;
|
||||
e.eventName = "prepare";
|
||||
|
||||
temp.Add(e);
|
||||
}
|
||||
|
||||
string s = JsonConvert.SerializeObject(temp);
|
||||
print(s);*/
|
||||
|
||||
StartCoroutine(Begin());
|
||||
|
||||
GlobalGameManager.Init();
|
||||
}
|
||||
|
||||
private IEnumerator Begin()
|
||||
{
|
||||
yield return new WaitForSeconds(startOffset);
|
||||
Conductor.instance.musicSource.Play();
|
||||
GoForAPerfect.instance.Enable();
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if (Input.GetKeyDown(KeyCode.Q))
|
||||
ForkLifter.instance.Flick(Conductor.instance.songPositionInBeats, 0);
|
||||
if (Input.GetKeyDown(KeyCode.W))
|
||||
ForkLifter.instance.Flick(Conductor.instance.songPositionInBeats, 1);
|
||||
if (Input.GetKeyDown(KeyCode.E))
|
||||
ForkLifter.instance.Flick(Conductor.instance.songPositionInBeats, 2);
|
||||
if (Input.GetKeyDown(KeyCode.R))
|
||||
ForkLifter.instance.Flick(Conductor.instance.songPositionInBeats, 3);
|
||||
|
||||
if (Events.Count < 1)
|
||||
return;
|
||||
|
||||
List<float> floats = Events.Select(c => c.spawnTime).ToList();
|
||||
|
||||
if (currentEvent < Events.Count && currentEvent >= 0)
|
||||
{
|
||||
if (Conductor.instance.songPositionInBeats >= floats[currentEvent])
|
||||
{
|
||||
|
||||
switch (Events[currentEvent].eventName)
|
||||
{
|
||||
case "pea":
|
||||
currentEventPlayer++;
|
||||
ForkLifter.instance.Flick(Events[currentEvent].spawnTime, 0);
|
||||
break;
|
||||
case "topbun":
|
||||
currentEventPlayer++;
|
||||
ForkLifter.instance.Flick(Events[currentEvent].spawnTime, 1);
|
||||
break;
|
||||
case "burger":
|
||||
currentEventPlayer++;
|
||||
ForkLifter.instance.Flick(Events[currentEvent].spawnTime, 2);
|
||||
break;
|
||||
case "bottombun":
|
||||
currentEventPlayer++;
|
||||
ForkLifter.instance.Flick(Events[currentEvent].spawnTime, 3);
|
||||
break;
|
||||
case "gulp":
|
||||
ForkLifterPlayer.instance.Eat();
|
||||
break;
|
||||
case "sigh":
|
||||
Jukebox.PlayOneShot("sigh");
|
||||
break;
|
||||
case "prepare":
|
||||
ForkLifterHand.instance.Prepare();
|
||||
break;
|
||||
case "end":
|
||||
GlobalGameManager.LoadScene(2, 0.45f);
|
||||
break;
|
||||
|
||||
}
|
||||
currentEvent++;
|
||||
return this.MemberwiseClone();
|
||||
}
|
||||
}
|
||||
|
||||
if (autoplay)
|
||||
private void Awake()
|
||||
{
|
||||
if (currentEventAutoplay < AutoPlay.Count && currentEventAutoplay >= 0)
|
||||
{
|
||||
if (Conductor.instance.songPositionInBeats >= AutoPlay[currentEventAutoplay])
|
||||
{
|
||||
ForkLifterPlayer.instance.Stab();
|
||||
currentEventAutoplay++;
|
||||
}
|
||||
}
|
||||
instance = this;
|
||||
}
|
||||
}
|
||||
|
||||
public void SortEventsList()
|
||||
{
|
||||
Events.Sort((x, y) => x.spawnTime.CompareTo(y.spawnTime));
|
||||
}
|
||||
|
||||
public void SetCurrentEventToClosest()
|
||||
{
|
||||
if (Events.Count > 0)
|
||||
private void Start()
|
||||
{
|
||||
SortEventsList();
|
||||
|
||||
string json = txt.text;
|
||||
Events = JsonConvert.DeserializeObject<List<Event>>(json);
|
||||
|
||||
SortEventsList();
|
||||
|
||||
allPlayerActions = Events.FindAll(c => c.eventName != "gulp" && c.eventName != "sigh" && c.eventName != "prepare" && c.eventName != "end");
|
||||
AutoPlay = allPlayerActions.Select(c => c.spawnTime + 2).ToList();
|
||||
|
||||
/*List<Event> temp = new List<Event>();
|
||||
for (int i = 0; i < allPlayerActions.Count; i++)
|
||||
{
|
||||
if (i - 1 > 0)
|
||||
{
|
||||
if (Mathp.IsWithin(allPlayerActions[i - 1].spawnTime, allPlayerActions[i].spawnTime - 1f, allPlayerActions[i].spawnTime))
|
||||
{
|
||||
// do nothing lul
|
||||
continue;
|
||||
}
|
||||
}
|
||||
Event e = (Event)allPlayerActions[i].Clone();
|
||||
e.spawnTime = allPlayerActions[i].spawnTime - 1;
|
||||
e.eventName = "prepare";
|
||||
|
||||
temp.Add(e);
|
||||
}
|
||||
|
||||
string s = JsonConvert.SerializeObject(temp);
|
||||
print(s);*/
|
||||
|
||||
StartCoroutine(Begin());
|
||||
|
||||
GlobalGameManager.Init();
|
||||
}
|
||||
|
||||
private IEnumerator Begin()
|
||||
{
|
||||
yield return new WaitForSeconds(startOffset);
|
||||
Conductor.instance.musicSource.Play();
|
||||
GoForAPerfect.instance.Enable();
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if (Input.GetKeyDown(KeyCode.Q))
|
||||
ForkLifter.instance.Flick(Conductor.instance.songPositionInBeats, 0);
|
||||
if (Input.GetKeyDown(KeyCode.W))
|
||||
ForkLifter.instance.Flick(Conductor.instance.songPositionInBeats, 1);
|
||||
if (Input.GetKeyDown(KeyCode.E))
|
||||
ForkLifter.instance.Flick(Conductor.instance.songPositionInBeats, 2);
|
||||
if (Input.GetKeyDown(KeyCode.R))
|
||||
ForkLifter.instance.Flick(Conductor.instance.songPositionInBeats, 3);
|
||||
|
||||
if (Events.Count < 1)
|
||||
return;
|
||||
|
||||
List<float> floats = Events.Select(c => c.spawnTime).ToList();
|
||||
currentEvent = floats.IndexOf(Mathp.GetClosestInList(floats, Conductor.instance.songPositionInBeats));
|
||||
|
||||
if (currentEvent < Events.Count && currentEvent >= 0)
|
||||
{
|
||||
if (Conductor.instance.songPositionInBeats >= floats[currentEvent])
|
||||
{
|
||||
|
||||
switch (Events[currentEvent].eventName)
|
||||
{
|
||||
case "pea":
|
||||
currentEventPlayer++;
|
||||
ForkLifter.instance.Flick(Events[currentEvent].spawnTime, 0);
|
||||
break;
|
||||
case "topbun":
|
||||
currentEventPlayer++;
|
||||
ForkLifter.instance.Flick(Events[currentEvent].spawnTime, 1);
|
||||
break;
|
||||
case "burger":
|
||||
currentEventPlayer++;
|
||||
ForkLifter.instance.Flick(Events[currentEvent].spawnTime, 2);
|
||||
break;
|
||||
case "bottombun":
|
||||
currentEventPlayer++;
|
||||
ForkLifter.instance.Flick(Events[currentEvent].spawnTime, 3);
|
||||
break;
|
||||
case "gulp":
|
||||
ForkLifterPlayer.instance.Eat();
|
||||
break;
|
||||
case "sigh":
|
||||
Jukebox.PlayOneShot("sigh");
|
||||
break;
|
||||
case "prepare":
|
||||
ForkLifterHand.instance.Prepare();
|
||||
break;
|
||||
case "end":
|
||||
GlobalGameManager.LoadScene(2, 0.45f);
|
||||
break;
|
||||
|
||||
}
|
||||
currentEvent++;
|
||||
}
|
||||
}
|
||||
|
||||
if (autoplay)
|
||||
{
|
||||
if (currentEventAutoplay < AutoPlay.Count && currentEventAutoplay >= 0)
|
||||
{
|
||||
if (Conductor.instance.songPositionInBeats >= AutoPlay[currentEventAutoplay])
|
||||
{
|
||||
ForkLifterPlayer.instance.Stab();
|
||||
currentEventAutoplay++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (AutoPlay.Count > 0)
|
||||
|
||||
public void SortEventsList()
|
||||
{
|
||||
currentEvent = AutoPlay.IndexOf(Mathp.GetClosestInList(AutoPlay, Conductor.instance.songPositionInBeats));
|
||||
currentEventPlayer = AutoPlay.IndexOf(Mathp.GetClosestInList(AutoPlay, Conductor.instance.songPositionInBeats));
|
||||
Events.Sort((x, y) => x.spawnTime.CompareTo(y.spawnTime));
|
||||
}
|
||||
|
||||
public void SetCurrentEventToClosest()
|
||||
{
|
||||
if (Events.Count > 0)
|
||||
{
|
||||
List<float> floats = Events.Select(c => c.spawnTime).ToList();
|
||||
currentEvent = floats.IndexOf(Mathp.GetClosestInList(floats, Conductor.instance.songPositionInBeats));
|
||||
}
|
||||
if (AutoPlay.Count > 0)
|
||||
{
|
||||
currentEvent = AutoPlay.IndexOf(Mathp.GetClosestInList(AutoPlay, Conductor.instance.songPositionInBeats));
|
||||
currentEventPlayer = AutoPlay.IndexOf(Mathp.GetClosestInList(AutoPlay, Conductor.instance.songPositionInBeats));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void OnGUI()
|
||||
{
|
||||
// GUI.Box(new Rect(0, 0, 300, 50), $"SongPosInBeats: {Conductor.instance.songPositionInBeats}");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void OnGUI()
|
||||
{
|
||||
// GUI.Box(new Rect(0, 0, 300, 50), $"SongPosInBeats: {Conductor.instance.songPositionInBeats}");
|
||||
}
|
||||
}
|
||||
}
|
|
@ -2,33 +2,36 @@ using System.Collections;
|
|||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class GameProfiler : MonoBehaviour
|
||||
namespace RhythmHeavenMania
|
||||
{
|
||||
public float score = 0;
|
||||
public int totalHits = 0;
|
||||
|
||||
public bool perfect = false;
|
||||
|
||||
public static GameProfiler instance { get; set; }
|
||||
|
||||
private void Awake()
|
||||
public class GameProfiler : MonoBehaviour
|
||||
{
|
||||
instance = this;
|
||||
DontDestroyOnLoad(this.gameObject);
|
||||
}
|
||||
private void Start()
|
||||
{
|
||||
perfect = true;
|
||||
}
|
||||
public float score = 0;
|
||||
public int totalHits = 0;
|
||||
|
||||
public void IncreaseScore()
|
||||
{
|
||||
totalHits++;
|
||||
score = GetPercent(totalHits, GameManager.instance.allPlayerActions.Count);
|
||||
}
|
||||
public bool perfect = false;
|
||||
|
||||
public float GetPercent(float value, float totalValue)
|
||||
{
|
||||
return (value / totalValue) * 100;
|
||||
public static GameProfiler instance { get; set; }
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
instance = this;
|
||||
DontDestroyOnLoad(this.gameObject);
|
||||
}
|
||||
private void Start()
|
||||
{
|
||||
perfect = true;
|
||||
}
|
||||
|
||||
public void IncreaseScore()
|
||||
{
|
||||
totalHits++;
|
||||
score = GetPercent(totalHits, GameManager.instance.allPlayerActions.Count);
|
||||
}
|
||||
|
||||
public float GetPercent(float value, float totalValue)
|
||||
{
|
||||
return (value / totalValue) * 100;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
8
Assets/Scripts/Games.meta
Normal file
8
Assets/Scripts/Games.meta
Normal file
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: cc7b4daee555e974cac4bcee60f9e6f0
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
44
Assets/Scripts/Games/ForkLifter/ForkLifter.cs
Normal file
44
Assets/Scripts/Games/ForkLifter/ForkLifter.cs
Normal file
|
@ -0,0 +1,44 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
using RhythmHeavenMania.Util;
|
||||
|
||||
namespace RhythmHeavenMania.Games.ForkLifter
|
||||
{
|
||||
public class ForkLifter : MonoBehaviour
|
||||
{
|
||||
public static ForkLifter instance;
|
||||
|
||||
GameManager GameManager;
|
||||
|
||||
[Header("Objects")]
|
||||
public Animator handAnim;
|
||||
public GameObject flickedObject;
|
||||
public SpriteRenderer peaPreview;
|
||||
|
||||
public Sprite[] peaSprites;
|
||||
public Sprite[] peaHitSprites;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
instance = this;
|
||||
}
|
||||
|
||||
private void Start()
|
||||
{
|
||||
GameManager = GameManager.instance;
|
||||
}
|
||||
|
||||
public void Flick(float beat, int type)
|
||||
{
|
||||
Jukebox.PlayOneShot("flick");
|
||||
handAnim.Play("Hand_Flick", 0, 0);
|
||||
GameObject fo = Instantiate(flickedObject);
|
||||
fo.GetComponent<Pea>().startBeat = beat;
|
||||
fo.GetComponent<Pea>().type = type;
|
||||
fo.SetActive(true);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
63
Assets/Scripts/Games/ForkLifter/ForkLifterHand.cs
Normal file
63
Assets/Scripts/Games/ForkLifter/ForkLifterHand.cs
Normal file
|
@ -0,0 +1,63 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using UnityEngine;
|
||||
|
||||
using RhythmHeavenMania.Util;
|
||||
|
||||
namespace RhythmHeavenMania.Games.ForkLifter
|
||||
{
|
||||
public class ForkLifterHand : MonoBehaviour
|
||||
{
|
||||
public SpriteRenderer fastSprite;
|
||||
|
||||
public Sprite[] fastSprites;
|
||||
|
||||
List<GameManager.Event> allPlayerActions;
|
||||
|
||||
public static ForkLifterHand instance { get; set; }
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
instance = this;
|
||||
}
|
||||
|
||||
public void CheckNextFlick()
|
||||
{
|
||||
allPlayerActions = GameManager.instance.Events.FindAll(c => c.eventName != "gulp" && c.eventName != "sigh" && c.eventName != "prepare");
|
||||
|
||||
if (GameManager.instance.currentEventPlayer < allPlayerActions.Count)
|
||||
{
|
||||
switch (allPlayerActions[GameManager.instance.currentEventPlayer].eventName)
|
||||
{
|
||||
case "pea":
|
||||
ForkLifter.instance.peaPreview.sprite = ForkLifter.instance.peaSprites[0];
|
||||
fastSprite.sprite = fastSprites[0];
|
||||
break;
|
||||
case "topbun":
|
||||
fastSprite.sprite = fastSprites[0];
|
||||
ForkLifter.instance.peaPreview.sprite = ForkLifter.instance.peaSprites[1];
|
||||
break;
|
||||
case "burger":
|
||||
fastSprite.sprite = fastSprites[1];
|
||||
ForkLifter.instance.peaPreview.sprite = ForkLifter.instance.peaSprites[2];
|
||||
break;
|
||||
case "bottombun":
|
||||
fastSprite.sprite = fastSprites[0];
|
||||
ForkLifter.instance.peaPreview.sprite = ForkLifter.instance.peaSprites[3];
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ForkLifter.instance.peaPreview.sprite = null;
|
||||
}
|
||||
}
|
||||
|
||||
public void Prepare()
|
||||
{
|
||||
Jukebox.PlayOneShot("flickPrepare");
|
||||
GetComponent<Animator>().Play("Hand_Prepare");
|
||||
}
|
||||
}
|
||||
}
|
317
Assets/Scripts/Games/ForkLifter/ForkLifterPlayer.cs
Normal file
317
Assets/Scripts/Games/ForkLifter/ForkLifterPlayer.cs
Normal file
|
@ -0,0 +1,317 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
using DG.Tweening;
|
||||
|
||||
using RhythmHeavenMania.Util;
|
||||
|
||||
namespace RhythmHeavenMania.Games.ForkLifter
|
||||
{
|
||||
public class ForkLifterPlayer : MonoBehaviour
|
||||
{
|
||||
[Header("Objects")]
|
||||
public GameObject fork;
|
||||
public Sprite peaSprite;
|
||||
public Sprite hitFX;
|
||||
public Sprite hitFXG;
|
||||
public Sprite hitFXMiss;
|
||||
public Sprite hitFX2;
|
||||
public Transform early, perfect, late;
|
||||
|
||||
[SerializeField]
|
||||
private BoxCollider2D col;
|
||||
|
||||
private Animator anim;
|
||||
|
||||
public List<Eligible> EligibleHits = new List<Eligible>();
|
||||
private int currentHitInList = 0;
|
||||
|
||||
public static ForkLifterPlayer instance { get; set; }
|
||||
|
||||
public float timescale = 1;
|
||||
|
||||
private int currentEarlyPeasOnFork;
|
||||
private int currentPerfectPeasOnFork;
|
||||
private int currentLatePeasOnFork;
|
||||
|
||||
private bool isEating = false;
|
||||
|
||||
// Burger shit
|
||||
|
||||
private bool topbun, middleburger, bottombun;
|
||||
|
||||
// -----------
|
||||
|
||||
[System.Serializable]
|
||||
public class Eligible
|
||||
{
|
||||
public Pea pea;
|
||||
public bool early;
|
||||
public bool perfect;
|
||||
public bool late;
|
||||
}
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
instance = this;
|
||||
}
|
||||
|
||||
private void Start()
|
||||
{
|
||||
anim = GetComponent<Animator>();
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
Time.timeScale = timescale;
|
||||
|
||||
if (Input.GetMouseButtonDown(0) || Input.GetKeyDown(KeyCode.Z) || Input.GetKeyDown(KeyCode.Space))
|
||||
{
|
||||
Stab();
|
||||
}
|
||||
|
||||
if (EligibleHits.Count == 0)
|
||||
{
|
||||
currentHitInList = 0;
|
||||
}
|
||||
|
||||
if (Input.GetKeyDown(KeyCode.A))
|
||||
{
|
||||
Conductor.instance.musicSource.time += 3;
|
||||
}
|
||||
else if (Input.GetKeyDown(KeyCode.S))
|
||||
{
|
||||
Conductor.instance.musicSource.time -= 3;
|
||||
GameManager.instance.SetCurrentEventToClosest();
|
||||
}
|
||||
}
|
||||
|
||||
public void Eat()
|
||||
{
|
||||
if (currentEarlyPeasOnFork != 0 || currentPerfectPeasOnFork != 0 || currentLatePeasOnFork != 0)
|
||||
{
|
||||
anim.Play("Player_Eat", 0, 0);
|
||||
isEating = true;
|
||||
}
|
||||
}
|
||||
|
||||
public void EatConfirm()
|
||||
{
|
||||
if (topbun && middleburger && bottombun)
|
||||
{
|
||||
Jukebox.PlayOneShot("burger");
|
||||
}
|
||||
else
|
||||
{
|
||||
if (currentEarlyPeasOnFork > 0 || currentLatePeasOnFork > 0)
|
||||
{
|
||||
Jukebox.PlayOneShot($"cough_{Random.Range(1, 3)}");
|
||||
}
|
||||
else
|
||||
{
|
||||
Jukebox.PlayOneShot("gulp");
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < early.transform.childCount; i++)
|
||||
{
|
||||
Destroy(early.transform.GetChild(i).gameObject);
|
||||
}
|
||||
for (int i = 0; i < perfect.transform.childCount; i++)
|
||||
{
|
||||
Destroy(perfect.transform.GetChild(i).gameObject);
|
||||
}
|
||||
for (int i = 0; i < late.transform.childCount; i++)
|
||||
{
|
||||
Destroy(late.transform.GetChild(i).gameObject);
|
||||
}
|
||||
currentEarlyPeasOnFork = 0;
|
||||
currentPerfectPeasOnFork = 0;
|
||||
currentLatePeasOnFork = 0;
|
||||
|
||||
isEating = false;
|
||||
|
||||
topbun = false; middleburger = false; bottombun = false;
|
||||
}
|
||||
|
||||
public void Stab()
|
||||
{
|
||||
if (isEating) return;
|
||||
bool canHit = (EligibleHits.Count > 0) && (currentHitInList < EligibleHits.Count);
|
||||
|
||||
if (canHit)
|
||||
{
|
||||
GameObject pea = new GameObject();
|
||||
|
||||
if (EligibleHits[currentHitInList].perfect)
|
||||
{
|
||||
pea.transform.parent = perfect.transform;
|
||||
pea.transform.localScale = Vector2.one;
|
||||
|
||||
pea.transform.localPosition = Vector3.zero;
|
||||
|
||||
for (int i = 0; i < perfect.transform.childCount; i++)
|
||||
{
|
||||
perfect.transform.GetChild(i).transform.localPosition = new Vector3(0, (-1.67f - (0.15724f * i)) + 0.15724f * currentPerfectPeasOnFork);
|
||||
}
|
||||
|
||||
SpriteRenderer psprite = pea.AddComponent<SpriteRenderer>();
|
||||
psprite.sprite = ForkLifter.instance.peaHitSprites[EligibleHits[currentHitInList].pea.type];
|
||||
psprite.sortingOrder = 20;
|
||||
switch (EligibleHits[currentHitInList].pea.type)
|
||||
{
|
||||
case 0:
|
||||
psprite.sortingOrder = 101;
|
||||
break;
|
||||
case 1:
|
||||
psprite.sortingOrder = 104;
|
||||
break;
|
||||
case 2:
|
||||
psprite.sortingOrder = 103;
|
||||
break;
|
||||
case 3:
|
||||
psprite.sortingOrder = 102;
|
||||
break;
|
||||
}
|
||||
|
||||
GameObject hitFXo = new GameObject();
|
||||
hitFXo.transform.localPosition = new Vector3(1.9969f, -3.7026f);
|
||||
hitFXo.transform.localScale = new Vector3(3.142196f, 3.142196f);
|
||||
SpriteRenderer hfxs = hitFXo.AddComponent<SpriteRenderer>();
|
||||
hfxs.sprite = hitFX;
|
||||
hfxs.sortingOrder = 100;
|
||||
hfxs.DOColor(new Color(1, 1, 1, 0), 0.05f).OnComplete(delegate { Destroy(hitFXo); });
|
||||
|
||||
FastEffectHit(EligibleHits[currentHitInList].pea.type);
|
||||
|
||||
Jukebox.PlayOneShot("stab");
|
||||
|
||||
currentPerfectPeasOnFork++;
|
||||
|
||||
if (EligibleHits[currentHitInList].pea.type == 1)
|
||||
{
|
||||
topbun = true;
|
||||
}
|
||||
else if (EligibleHits[currentHitInList].pea.type == 2)
|
||||
{
|
||||
middleburger = true;
|
||||
}
|
||||
else if (EligibleHits[currentHitInList].pea.type == 3)
|
||||
{
|
||||
bottombun = true;
|
||||
}
|
||||
|
||||
RemovePea();
|
||||
|
||||
GoForAPerfect.instance.Hit();
|
||||
GameProfiler.instance.IncreaseScore();
|
||||
}
|
||||
else if (EligibleHits[currentHitInList].early)
|
||||
{
|
||||
pea.transform.parent = early.transform;
|
||||
pea.transform.localScale = Vector2.one;
|
||||
|
||||
pea.transform.localPosition = Vector3.zero;
|
||||
pea.transform.localRotation = Quaternion.Euler(0, 0, 90);
|
||||
|
||||
for (int i = 0; i < early.transform.childCount; i++)
|
||||
{
|
||||
early.transform.GetChild(i).transform.localPosition = new Vector3(0, (-1.67f - (0.15724f * i)) + 0.15724f * currentEarlyPeasOnFork);
|
||||
}
|
||||
|
||||
SpriteRenderer psprite = pea.AddComponent<SpriteRenderer>();
|
||||
psprite.sprite = ForkLifter.instance.peaHitSprites[EligibleHits[currentHitInList].pea.type];
|
||||
psprite.sortingOrder = 20;
|
||||
HitFXMiss(new Vector2(1.0424f, -4.032f), new Vector2(1.129612f, 1.129612f));
|
||||
HitFXMiss(new Vector2(0.771f, -3.016f), new Vector2(1.71701f, 1.71701f));
|
||||
HitFXMiss(new Vector2(2.598f, -2.956f), new Vector2(1.576043f, 1.576043f));
|
||||
HitFXMiss(new Vector2(2.551f, -3.609f), new Vector2(1.200788f, 1.200788f));
|
||||
|
||||
FastEffectHit(EligibleHits[currentHitInList].pea.type);
|
||||
|
||||
Jukebox.PlayOneShot("miss");
|
||||
|
||||
currentEarlyPeasOnFork++;
|
||||
|
||||
RemovePea();
|
||||
|
||||
GoForAPerfect.instance.Miss();
|
||||
}
|
||||
else if (EligibleHits[currentHitInList].late)
|
||||
{
|
||||
pea.transform.parent = late.transform;
|
||||
pea.transform.localScale = Vector2.one;
|
||||
|
||||
pea.transform.localPosition = Vector3.zero;
|
||||
pea.transform.localRotation = Quaternion.Euler(0, 0, 90);
|
||||
|
||||
for (int i = 0; i < late.transform.childCount; i++)
|
||||
{
|
||||
late.transform.GetChild(i).transform.localPosition = new Vector3(0, (-1.67f - (0.15724f * i)) + 0.15724f * currentLatePeasOnFork);
|
||||
}
|
||||
|
||||
SpriteRenderer psprite = pea.AddComponent<SpriteRenderer>();
|
||||
psprite.sprite = ForkLifter.instance.peaHitSprites[EligibleHits[currentHitInList].pea.type];
|
||||
psprite.sortingOrder = 20;
|
||||
HitFXMiss(new Vector2(1.0424f, -4.032f), new Vector2(1.129612f, 1.129612f));
|
||||
HitFXMiss(new Vector2(0.771f, -3.016f), new Vector2(1.71701f, 1.71701f));
|
||||
HitFXMiss(new Vector2(2.598f, -2.956f), new Vector2(1.576043f, 1.576043f));
|
||||
HitFXMiss(new Vector2(2.551f, -3.609f), new Vector2(1.200788f, 1.200788f));
|
||||
|
||||
FastEffectHit(EligibleHits[currentHitInList].pea.type);
|
||||
|
||||
Jukebox.PlayOneShot("miss");
|
||||
|
||||
currentLatePeasOnFork++;
|
||||
|
||||
RemovePea();
|
||||
|
||||
GoForAPerfect.instance.Miss();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Jukebox.PlayOneShot("stabnohit");
|
||||
}
|
||||
|
||||
anim.Play("Player_Stab", 0, 0);
|
||||
}
|
||||
|
||||
private void FastEffectHit(int type)
|
||||
{
|
||||
GameObject hitFX2o = new GameObject();
|
||||
hitFX2o.transform.localPosition = new Vector3(0.11f, -2.15f);
|
||||
hitFX2o.transform.localScale = new Vector3(5.401058f, 1.742697f);
|
||||
hitFX2o.transform.localRotation = Quaternion.Euler(0, 0, -38.402f);
|
||||
SpriteRenderer hfx2s = hitFX2o.AddComponent<SpriteRenderer>();
|
||||
if (type == 2)
|
||||
hfx2s.sprite = hitFXG;
|
||||
else
|
||||
hfx2s.sprite = hitFX2;
|
||||
hfx2s.sortingOrder = -5;
|
||||
hfx2s.DOColor(new Color(1, 1, 1, 0), 0.07f).OnComplete(delegate { Destroy(hitFX2o); });
|
||||
}
|
||||
|
||||
private void HitFXMiss(Vector2 pos, Vector2 size)
|
||||
{
|
||||
GameObject hitFXo = new GameObject();
|
||||
hitFXo.transform.localPosition = new Vector3(pos.x, pos.y);
|
||||
hitFXo.transform.localScale = new Vector3(size.x, size.y);
|
||||
SpriteRenderer hfxs = hitFXo.AddComponent<SpriteRenderer>();
|
||||
hfxs.sprite = hitFXMiss;
|
||||
hfxs.sortingOrder = 100;
|
||||
hfxs.DOColor(new Color(1, 1, 1, 0), 0.05f).OnComplete(delegate { Destroy(hitFXo); });
|
||||
}
|
||||
|
||||
private void RemovePea()
|
||||
{
|
||||
if (currentHitInList < EligibleHits.Count)
|
||||
{
|
||||
Destroy(EligibleHits[currentHitInList].pea.gameObject);
|
||||
EligibleHits.Remove(EligibleHits[currentHitInList]);
|
||||
currentHitInList++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
117
Assets/Scripts/Games/ForkLifter/Pea.cs
Normal file
117
Assets/Scripts/Games/ForkLifter/Pea.cs
Normal file
|
@ -0,0 +1,117 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
using RhythmHeavenMania.Util;
|
||||
|
||||
namespace RhythmHeavenMania.Games.ForkLifter
|
||||
{
|
||||
public class Pea : MonoBehaviour
|
||||
{
|
||||
[Header("Latency")]
|
||||
public float earlyTime;
|
||||
public float perfectTime;
|
||||
public float lateTime;
|
||||
public float endTime;
|
||||
|
||||
private Animator anim;
|
||||
|
||||
public float startBeat;
|
||||
|
||||
private bool inList = false;
|
||||
|
||||
public int type;
|
||||
|
||||
private ForkLifterPlayer.Eligible e = new ForkLifterPlayer.Eligible();
|
||||
|
||||
public int estate, pstate, lstate, endstate;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
anim = GetComponent<Animator>();
|
||||
Jukebox.PlayOneShot("zoom");
|
||||
GetComponentInChildren<SpriteRenderer>().sprite = ForkLifter.instance.peaSprites[type];
|
||||
|
||||
e = new ForkLifterPlayer.Eligible();
|
||||
e.pea = this;
|
||||
|
||||
for (int i = 0; i < transform.GetChild(0).childCount; i++)
|
||||
{
|
||||
transform.GetChild(0).GetChild(i).GetComponent<SpriteRenderer>().sprite = transform.GetChild(0).GetComponent<SpriteRenderer>().sprite;
|
||||
}
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
float normalizedBeat = (Conductor.instance.GetLoopPositionFromBeat(startBeat, 2.5f));
|
||||
anim.Play("Flicked_Object", -1, normalizedBeat);
|
||||
anim.speed = 0;
|
||||
|
||||
// Early State
|
||||
if (normalizedBeat > earlyTime && normalizedBeat < perfectTime && estate <= 1)
|
||||
{
|
||||
estate++;
|
||||
MakeEligible(true, false, false);
|
||||
}
|
||||
// Perfect State
|
||||
else if (normalizedBeat > perfectTime && normalizedBeat < lateTime && pstate <= 1)
|
||||
{
|
||||
pstate++;
|
||||
MakeEligible(false, true, false);
|
||||
}
|
||||
// Late State
|
||||
else if (normalizedBeat > lateTime && normalizedBeat < endTime && lstate <= 1)
|
||||
{
|
||||
lstate++;
|
||||
MakeEligible(false, false, true);
|
||||
}
|
||||
else if (normalizedBeat < earlyTime || normalizedBeat > endTime)
|
||||
{
|
||||
MakeInEligible();
|
||||
}
|
||||
|
||||
if (normalizedBeat > endTime && endstate <= 1)
|
||||
{
|
||||
endstate++;
|
||||
Jukebox.PlayOneShot("disappointed");
|
||||
GoForAPerfect.instance.Miss();
|
||||
}
|
||||
|
||||
if (normalizedBeat > 1.35f)
|
||||
{
|
||||
MakeInEligible();
|
||||
Destroy(this.gameObject);
|
||||
}
|
||||
}
|
||||
|
||||
public void MakeEligible(bool early, bool perfect, bool late)
|
||||
{
|
||||
// print($"{early}, {perfect}, {late}");
|
||||
|
||||
if (!inList)
|
||||
{
|
||||
e.early = early;
|
||||
e.perfect = perfect;
|
||||
e.late = late;
|
||||
|
||||
ForkLifterPlayer.instance.EligibleHits.Add(e);
|
||||
inList = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
ForkLifterPlayer.Eligible es = ForkLifterPlayer.instance.EligibleHits[ForkLifterPlayer.instance.EligibleHits.IndexOf(e)];
|
||||
es.early = early;
|
||||
es.perfect = perfect;
|
||||
es.late = late;
|
||||
}
|
||||
}
|
||||
|
||||
public void MakeInEligible()
|
||||
{
|
||||
if (!inList) return;
|
||||
|
||||
ForkLifterPlayer.instance.EligibleHits.Remove(e);
|
||||
inList = false;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -5,88 +5,92 @@ using UnityEngine.SceneManagement;
|
|||
using UnityEngine.UI;
|
||||
using DG.Tweening;
|
||||
|
||||
public class GlobalGameManager : MonoBehaviour
|
||||
namespace RhythmHeavenMania
|
||||
{
|
||||
public static GlobalGameManager instance { get; set; }
|
||||
|
||||
public static int loadedScene;
|
||||
public int lastLoadedScene;
|
||||
public static float fadeDuration;
|
||||
|
||||
public GameObject loadScenePrefab;
|
||||
public GameObject hourGlass;
|
||||
|
||||
public static string levelLocation;
|
||||
public static bool officialLevel;
|
||||
|
||||
public enum Scenes : int
|
||||
public class GlobalGameManager : MonoBehaviour
|
||||
{
|
||||
SplashScreen = 0,
|
||||
Menu = 1,
|
||||
Editor = 2,
|
||||
Game = 3
|
||||
}
|
||||
public static GlobalGameManager instance { get; set; }
|
||||
|
||||
[RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.SubsystemRegistration)]
|
||||
public static void Init()
|
||||
{
|
||||
BasicCheck();
|
||||
public static int loadedScene;
|
||||
public int lastLoadedScene;
|
||||
public static float fadeDuration;
|
||||
|
||||
loadedScene = 0;
|
||||
fadeDuration = 0;
|
||||
}
|
||||
public GameObject loadScenePrefab;
|
||||
public GameObject hourGlass;
|
||||
|
||||
public void Awake()
|
||||
{
|
||||
Init();
|
||||
DontDestroyOnLoad(this.gameObject);
|
||||
instance = this;
|
||||
Starpelly.OS.Windows.ChangeWindowTitle($"Rhythm Heaven Mania DEMO");
|
||||
}
|
||||
public static string levelLocation;
|
||||
public static bool officialLevel;
|
||||
|
||||
public static GameObject CreateFade()
|
||||
{
|
||||
GameObject fade = new GameObject();
|
||||
DontDestroyOnLoad(fade);
|
||||
fade.transform.localScale = new Vector3(4000, 4000);
|
||||
SpriteRenderer sr = fade.AddComponent<SpriteRenderer>();
|
||||
sr.sprite = Resources.Load<Sprite>("Sprites/GeneralPurpose/Square");
|
||||
sr.sortingOrder = 20000;
|
||||
fade.layer = 5;
|
||||
return fade;
|
||||
}
|
||||
|
||||
|
||||
public static void BasicCheck()
|
||||
{
|
||||
if (FindGGM() == null)
|
||||
public enum Scenes : int
|
||||
{
|
||||
GameObject GlobalGameManager = new GameObject("GlobalGameManager");
|
||||
GlobalGameManager.name = "GlobalGameManager";
|
||||
GlobalGameManager.AddComponent<GlobalGameManager>();
|
||||
SplashScreen = 0,
|
||||
Menu = 1,
|
||||
Editor = 2,
|
||||
Game = 3
|
||||
}
|
||||
|
||||
[RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.SubsystemRegistration)]
|
||||
public static void Init()
|
||||
{
|
||||
BasicCheck();
|
||||
|
||||
loadedScene = 0;
|
||||
fadeDuration = 0;
|
||||
}
|
||||
|
||||
public void Awake()
|
||||
{
|
||||
Init();
|
||||
DontDestroyOnLoad(this.gameObject);
|
||||
instance = this;
|
||||
Starpelly.OS.Windows.ChangeWindowTitle($"Rhythm Heaven Mania DEMO");
|
||||
}
|
||||
|
||||
public static GameObject CreateFade()
|
||||
{
|
||||
GameObject fade = new GameObject();
|
||||
DontDestroyOnLoad(fade);
|
||||
fade.transform.localScale = new Vector3(4000, 4000);
|
||||
SpriteRenderer sr = fade.AddComponent<SpriteRenderer>();
|
||||
sr.sprite = Resources.Load<Sprite>("Sprites/GeneralPurpose/Square");
|
||||
sr.sortingOrder = 20000;
|
||||
fade.layer = 5;
|
||||
return fade;
|
||||
}
|
||||
|
||||
|
||||
public static void BasicCheck()
|
||||
{
|
||||
if (FindGGM() == null)
|
||||
{
|
||||
GameObject GlobalGameManager = new GameObject("GlobalGameManager");
|
||||
GlobalGameManager.name = "GlobalGameManager";
|
||||
GlobalGameManager.AddComponent<GlobalGameManager>();
|
||||
}
|
||||
}
|
||||
|
||||
public static GameObject FindGGM()
|
||||
{
|
||||
if (GameObject.Find("GlobalGameManager") != null)
|
||||
return GameObject.Find("GlobalGameManager");
|
||||
else
|
||||
return null;
|
||||
}
|
||||
|
||||
public static void LoadScene(int sceneIndex, float duration = 0.35f)
|
||||
{
|
||||
print("bruh");
|
||||
BasicCheck();
|
||||
loadedScene = sceneIndex;
|
||||
fadeDuration = duration;
|
||||
|
||||
// DOTween.Clear(true);
|
||||
// SceneManager.LoadScene(sceneIndex);
|
||||
|
||||
GameObject fade = CreateFade();
|
||||
fade.GetComponent<SpriteRenderer>().color = new Color(0, 0, 0, 0);
|
||||
fade.GetComponent<SpriteRenderer>().DOColor(Color.black, fadeDuration).OnComplete(() => { SceneManager.LoadScene(loadedScene); fade.GetComponent<SpriteRenderer>().DOColor(new Color(0, 0, 0, 0), fadeDuration).OnComplete(() => { Destroy(fade); }); });
|
||||
}
|
||||
}
|
||||
|
||||
public static GameObject FindGGM()
|
||||
{
|
||||
if (GameObject.Find("GlobalGameManager") != null)
|
||||
return GameObject.Find("GlobalGameManager");
|
||||
else
|
||||
return null;
|
||||
}
|
||||
|
||||
public static void LoadScene(int sceneIndex, float duration = 0.35f)
|
||||
{
|
||||
print("bruh");
|
||||
BasicCheck();
|
||||
loadedScene = sceneIndex;
|
||||
fadeDuration = duration;
|
||||
|
||||
// DOTween.Clear(true);
|
||||
// SceneManager.LoadScene(sceneIndex);
|
||||
|
||||
GameObject fade = CreateFade();
|
||||
fade.GetComponent<SpriteRenderer>().color = new Color(0, 0, 0, 0);
|
||||
fade.GetComponent<SpriteRenderer>().DOColor(Color.black, fadeDuration).OnComplete(() => { SceneManager.LoadScene(loadedScene); fade.GetComponent<SpriteRenderer>().DOColor(new Color(0, 0, 0, 0), fadeDuration).OnComplete(() => { Destroy(fade); }); });
|
||||
}
|
||||
}
|
||||
}
|
70
Assets/Scripts/GoForAPerfect.cs
Normal file
70
Assets/Scripts/GoForAPerfect.cs
Normal file
|
@ -0,0 +1,70 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
using RhythmHeavenMania.Util;
|
||||
|
||||
namespace RhythmHeavenMania
|
||||
{
|
||||
public class GoForAPerfect : MonoBehaviour
|
||||
{
|
||||
public static GoForAPerfect instance { get; set; }
|
||||
|
||||
private Animator pAnim;
|
||||
|
||||
private bool active = false;
|
||||
|
||||
public bool perfect;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
instance = this;
|
||||
}
|
||||
|
||||
private void Start()
|
||||
{
|
||||
pAnim = transform.GetChild(0).GetChild(0).GetComponent<Animator>();
|
||||
perfect = true;
|
||||
}
|
||||
|
||||
public void Hit()
|
||||
{
|
||||
if (!active) return;
|
||||
pAnim.Play("PerfectIcon_Hit", 0, 0);
|
||||
}
|
||||
|
||||
public void Miss()
|
||||
{
|
||||
if (!active) return;
|
||||
perfect = false;
|
||||
|
||||
GameProfiler.instance.perfect = false;
|
||||
|
||||
transform.GetChild(0).GetChild(1).gameObject.SetActive(false);
|
||||
this.GetComponent<Animator>().Play("GoForAPerfect_Miss");
|
||||
Jukebox.PlayOneShot("perfectMiss");
|
||||
}
|
||||
|
||||
public void Enable()
|
||||
{
|
||||
SetActive();
|
||||
transform.GetChild(0).gameObject.SetActive(true);
|
||||
}
|
||||
|
||||
public void Disable()
|
||||
{
|
||||
SetInactive();
|
||||
transform.GetChild(0).gameObject.SetActive(false);
|
||||
}
|
||||
|
||||
public void SetActive()
|
||||
{
|
||||
active = true;
|
||||
}
|
||||
public void SetInactive()
|
||||
{
|
||||
active = false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -1,49 +0,0 @@
|
|||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class Jukebox
|
||||
{
|
||||
public enum AudioType
|
||||
{
|
||||
OGG,
|
||||
WAV
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This is me just idiot-proofing.
|
||||
/// </summary>
|
||||
public static void BasicCheck()
|
||||
{
|
||||
if (FindJukebox() == null)
|
||||
{
|
||||
GameObject Jukebox = new GameObject("Jukebox");
|
||||
Jukebox.AddComponent<AudioSource>();
|
||||
Jukebox.tag = "Jukebox";
|
||||
}
|
||||
}
|
||||
|
||||
public static GameObject FindJukebox()
|
||||
{
|
||||
if (GameObject.FindGameObjectWithTag("Jukebox") != null)
|
||||
return GameObject.FindGameObjectWithTag("Jukebox");
|
||||
else
|
||||
return null;
|
||||
}
|
||||
|
||||
public static void SetVolume(float volume)
|
||||
{
|
||||
BasicCheck();
|
||||
FindJukebox().GetComponent<AudioSource>().volume = volume;
|
||||
}
|
||||
|
||||
public static void PlayOneShot(string name)
|
||||
{
|
||||
GameObject oneShot = new GameObject("oneShot");
|
||||
AudioSource aus = oneShot.AddComponent<AudioSource>();
|
||||
aus.playOnAwake = false;
|
||||
Sound snd = oneShot.AddComponent<Sound>();
|
||||
snd.clip = Resources.Load<AudioClip>($"Sfx/{name}");
|
||||
}
|
||||
}
|
|
@ -1,24 +0,0 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class Sound : MonoBehaviour
|
||||
{
|
||||
public AudioClip clip;
|
||||
public float pitch;
|
||||
|
||||
private AudioSource audioSource;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
audioSource = GetComponent<AudioSource>();
|
||||
audioSource.PlayOneShot(clip);
|
||||
StartCoroutine(play());
|
||||
}
|
||||
|
||||
private IEnumerator play()
|
||||
{
|
||||
yield return new WaitForSeconds(clip.length);
|
||||
Destroy(this.gameObject);
|
||||
}
|
||||
}
|
|
@ -1,64 +0,0 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class GoForAPerfect : MonoBehaviour
|
||||
{
|
||||
public static GoForAPerfect instance { get; set; }
|
||||
|
||||
private Animator pAnim;
|
||||
|
||||
private bool active = false;
|
||||
|
||||
public bool perfect;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
instance = this;
|
||||
}
|
||||
|
||||
private void Start()
|
||||
{
|
||||
pAnim = transform.GetChild(0).GetChild(0).GetComponent<Animator>();
|
||||
perfect = true;
|
||||
}
|
||||
|
||||
public void Hit()
|
||||
{
|
||||
if (!active) return;
|
||||
pAnim.Play("PerfectIcon_Hit", 0, 0);
|
||||
}
|
||||
|
||||
public void Miss()
|
||||
{
|
||||
if (!active) return;
|
||||
perfect = false;
|
||||
|
||||
GameProfiler.instance.perfect = false;
|
||||
|
||||
transform.GetChild(0).GetChild(1).gameObject.SetActive(false);
|
||||
this.GetComponent<Animator>().Play("GoForAPerfect_Miss");
|
||||
Jukebox.PlayOneShot("perfectMiss");
|
||||
}
|
||||
|
||||
public void Enable()
|
||||
{
|
||||
SetActive();
|
||||
transform.GetChild(0).gameObject.SetActive(true);
|
||||
}
|
||||
|
||||
public void Disable()
|
||||
{
|
||||
SetInactive();
|
||||
transform.GetChild(0).gameObject.SetActive(false);
|
||||
}
|
||||
|
||||
public void SetActive()
|
||||
{
|
||||
active = true;
|
||||
}
|
||||
public void SetInactive()
|
||||
{
|
||||
active = false;
|
||||
}
|
||||
}
|
|
@ -2,34 +2,38 @@ using System.Collections;
|
|||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class Prologue : MonoBehaviour
|
||||
namespace RhythmHeavenMania
|
||||
{
|
||||
[SerializeField] private float waitSeconds;
|
||||
|
||||
public GameObject Holder;
|
||||
public GameObject pressAny;
|
||||
|
||||
bool inPrologue = false;
|
||||
|
||||
private void Update()
|
||||
public class Prologue : MonoBehaviour
|
||||
{
|
||||
if (Input.anyKeyDown && !inPrologue)
|
||||
[SerializeField] private float waitSeconds;
|
||||
|
||||
public GameObject Holder;
|
||||
public GameObject pressAny;
|
||||
|
||||
bool inPrologue = false;
|
||||
|
||||
private void Update()
|
||||
{
|
||||
pressAny.SetActive(false);
|
||||
Holder.SetActive(true);
|
||||
StartCoroutine(Wait());
|
||||
inPrologue = true;
|
||||
if (Input.anyKeyDown && !inPrologue)
|
||||
{
|
||||
pressAny.SetActive(false);
|
||||
Holder.SetActive(true);
|
||||
StartCoroutine(Wait());
|
||||
inPrologue = true;
|
||||
}
|
||||
}
|
||||
|
||||
IEnumerator Wait()
|
||||
{
|
||||
transform.GetChild(0).gameObject.SetActive(false);
|
||||
yield return new WaitForSeconds(1);
|
||||
transform.GetChild(0).gameObject.SetActive(true);
|
||||
yield return new WaitForSeconds(waitSeconds);
|
||||
transform.GetChild(0).gameObject.SetActive(false);
|
||||
yield return new WaitForSeconds(2);
|
||||
UnityEngine.SceneManagement.SceneManager.LoadScene(1);
|
||||
}
|
||||
}
|
||||
|
||||
IEnumerator Wait()
|
||||
{
|
||||
transform.GetChild(0).gameObject.SetActive(false);
|
||||
yield return new WaitForSeconds(1);
|
||||
transform.GetChild(0).gameObject.SetActive(true);
|
||||
yield return new WaitForSeconds(waitSeconds);
|
||||
transform.GetChild(0).gameObject.SetActive(false);
|
||||
yield return new WaitForSeconds(2);
|
||||
UnityEngine.SceneManagement.SceneManager.LoadScene(1);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -5,135 +5,141 @@ using UnityEngine.UI;
|
|||
using TMPro;
|
||||
using DG.Tweening;
|
||||
|
||||
public class Rating : MonoBehaviour
|
||||
using RhythmHeavenMania.Util;
|
||||
|
||||
namespace RhythmHeavenMania
|
||||
{
|
||||
public GameObject Title;
|
||||
public GameObject Desc;
|
||||
public GameObject Rank;
|
||||
public GameObject Epilogue;
|
||||
public GameObject Perfect;
|
||||
|
||||
public GameObject RankingHolder;
|
||||
|
||||
public GameObject Fade;
|
||||
|
||||
private string rank;
|
||||
private int rankId;
|
||||
|
||||
public Sprite[] epilogueSprites;
|
||||
public Image epilogueImage;
|
||||
|
||||
public TMP_Text epilogueText;
|
||||
|
||||
private void Start()
|
||||
public class Rating : MonoBehaviour
|
||||
{
|
||||
float score = GameProfiler.instance.score;
|
||||
TMP_Text desc = Desc.GetComponent<TMP_Text>();
|
||||
public GameObject Title;
|
||||
public GameObject Desc;
|
||||
public GameObject Rank;
|
||||
public GameObject Epilogue;
|
||||
public GameObject Perfect;
|
||||
|
||||
if (GameProfiler.instance.perfect)
|
||||
public GameObject RankingHolder;
|
||||
|
||||
public GameObject Fade;
|
||||
|
||||
private string rank;
|
||||
private int rankId;
|
||||
|
||||
public Sprite[] epilogueSprites;
|
||||
public Image epilogueImage;
|
||||
|
||||
public TMP_Text epilogueText;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
Perfect.SetActive(true);
|
||||
Jukebox.PlayOneShot("Rankings/ranking_perfect");
|
||||
StartCoroutine(PerfectIE());
|
||||
float score = GameProfiler.instance.score;
|
||||
TMP_Text desc = Desc.GetComponent<TMP_Text>();
|
||||
|
||||
if (GameProfiler.instance.perfect)
|
||||
{
|
||||
Perfect.SetActive(true);
|
||||
Jukebox.PlayOneShot("Rankings/ranking_perfect");
|
||||
StartCoroutine(PerfectIE());
|
||||
}
|
||||
else
|
||||
{
|
||||
if (score < 59)
|
||||
{
|
||||
// try again
|
||||
desc.text = "Your fork technique was rather uncouth. \nYour consecutive stabs needed work.";
|
||||
rank = "Rankings/ranking_tryagain";
|
||||
rankId = 2;
|
||||
}
|
||||
else if (score >= 59 && score < 79)
|
||||
{
|
||||
// ok
|
||||
desc.text = "Eh. Good enough.";
|
||||
rank = "Rankings/ranking_ok";
|
||||
rankId = 1;
|
||||
}
|
||||
else if (score >= 79)
|
||||
{
|
||||
// superb
|
||||
desc.text = "Your fork technique was quite elegant. \nYour consecutive stabs were excellent. \nYour triple-stab technique was sublime.";
|
||||
rank = "Rankings/ranking_superb";
|
||||
rankId = 0;
|
||||
}
|
||||
|
||||
StartCoroutine(ShowRank());
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
private IEnumerator ShowRank()
|
||||
{
|
||||
if (score < 59)
|
||||
// Title
|
||||
yield return new WaitForSeconds(0.5f);
|
||||
|
||||
Jukebox.PlayOneShot("Rankings/ranking_title_show");
|
||||
Title.SetActive(true);
|
||||
|
||||
// Desc
|
||||
yield return new WaitForSeconds(2f);
|
||||
|
||||
Jukebox.PlayOneShot("Rankings/ranking_desc_show");
|
||||
Desc.SetActive(true);
|
||||
|
||||
// Rating
|
||||
yield return new WaitForSeconds(2f);
|
||||
|
||||
Jukebox.PlayOneShot(rank);
|
||||
Rank.transform.GetChild(rankId).gameObject.SetActive(true);
|
||||
|
||||
// Epilogue
|
||||
yield return new WaitForSeconds(5f);
|
||||
Fade.GetComponent<Image>().DOColor(Color.black, 0.75f).OnComplete(delegate
|
||||
{
|
||||
// try again
|
||||
desc.text = "Your fork technique was rather uncouth. \nYour consecutive stabs needed work.";
|
||||
rank = "Rankings/ranking_tryagain";
|
||||
rankId = 2;
|
||||
}
|
||||
else if (score >= 59 && score < 79)
|
||||
StartCoroutine(ShowEpilogue());
|
||||
});
|
||||
}
|
||||
|
||||
private IEnumerator ShowEpilogue()
|
||||
{
|
||||
epilogueImage.sprite = epilogueSprites[rankId];
|
||||
switch (rankId)
|
||||
{
|
||||
// ok
|
||||
desc.text = "Eh. Good enough.";
|
||||
rank = "Rankings/ranking_ok";
|
||||
rankId = 1;
|
||||
}
|
||||
else if (score >= 79)
|
||||
{
|
||||
// superb
|
||||
desc.text = "Your fork technique was quite elegant. \nYour consecutive stabs were excellent. \nYour triple-stab technique was sublime.";
|
||||
rank = "Rankings/ranking_superb";
|
||||
rankId = 0;
|
||||
case 2:
|
||||
epilogueText.text = "Blood sugar...so...low...";
|
||||
break;
|
||||
case 1:
|
||||
epilogueText.text = "I could eat two more dinners!";
|
||||
break;
|
||||
case 0:
|
||||
epilogueText.text = "So full! So satisfied!";
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
StartCoroutine(ShowRank());
|
||||
yield return new WaitForSeconds(1);
|
||||
Fade.GetComponent<Image>().color = new Color(0, 0, 0, 0);
|
||||
RankingHolder.SetActive(false);
|
||||
Epilogue.SetActive(true);
|
||||
|
||||
switch (rankId)
|
||||
{
|
||||
case 0:
|
||||
Jukebox.PlayOneShot("Rankings/epilogue_superb");
|
||||
break;
|
||||
case 1:
|
||||
Jukebox.PlayOneShot("Rankings/epilogue_ok");
|
||||
break;
|
||||
case 2:
|
||||
Jukebox.PlayOneShot("Rankings/epilogue_tryagain");
|
||||
break;
|
||||
}
|
||||
|
||||
yield return new WaitForSeconds(8);
|
||||
GlobalGameManager.LoadScene(0);
|
||||
}
|
||||
|
||||
private IEnumerator PerfectIE()
|
||||
{
|
||||
yield return new WaitForSeconds(8);
|
||||
GlobalGameManager.LoadScene(0);
|
||||
}
|
||||
}
|
||||
|
||||
private IEnumerator ShowRank()
|
||||
{
|
||||
// Title
|
||||
yield return new WaitForSeconds(0.5f);
|
||||
|
||||
Jukebox.PlayOneShot("Rankings/ranking_title_show");
|
||||
Title.SetActive(true);
|
||||
|
||||
// Desc
|
||||
yield return new WaitForSeconds(2f);
|
||||
|
||||
Jukebox.PlayOneShot("Rankings/ranking_desc_show");
|
||||
Desc.SetActive(true);
|
||||
|
||||
// Rating
|
||||
yield return new WaitForSeconds(2f);
|
||||
|
||||
Jukebox.PlayOneShot(rank);
|
||||
Rank.transform.GetChild(rankId).gameObject.SetActive(true);
|
||||
|
||||
// Epilogue
|
||||
yield return new WaitForSeconds(5f);
|
||||
Fade.GetComponent<Image>().DOColor(Color.black, 0.75f).OnComplete(delegate
|
||||
{
|
||||
StartCoroutine(ShowEpilogue());
|
||||
});
|
||||
}
|
||||
|
||||
private IEnumerator ShowEpilogue()
|
||||
{
|
||||
epilogueImage.sprite = epilogueSprites[rankId];
|
||||
switch (rankId)
|
||||
{
|
||||
case 2:
|
||||
epilogueText.text = "Blood sugar...so...low...";
|
||||
break;
|
||||
case 1:
|
||||
epilogueText.text = "I could eat two more dinners!";
|
||||
break;
|
||||
case 0:
|
||||
epilogueText.text = "So full! So satisfied!";
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
yield return new WaitForSeconds(1);
|
||||
Fade.GetComponent<Image>().color = new Color(0, 0, 0, 0);
|
||||
RankingHolder.SetActive(false);
|
||||
Epilogue.SetActive(true);
|
||||
|
||||
switch (rankId)
|
||||
{
|
||||
case 0:
|
||||
Jukebox.PlayOneShot("Rankings/epilogue_superb");
|
||||
break;
|
||||
case 1:
|
||||
Jukebox.PlayOneShot("Rankings/epilogue_ok");
|
||||
break;
|
||||
case 2:
|
||||
Jukebox.PlayOneShot("Rankings/epilogue_tryagain");
|
||||
break;
|
||||
}
|
||||
|
||||
yield return new WaitForSeconds(8);
|
||||
GlobalGameManager.LoadScene(0);
|
||||
}
|
||||
|
||||
private IEnumerator PerfectIE()
|
||||
{
|
||||
yield return new WaitForSeconds(8);
|
||||
GlobalGameManager.LoadScene(0);
|
||||
}
|
||||
}
|
||||
}
|
8
Assets/Scripts/Util.meta
Normal file
8
Assets/Scripts/Util.meta
Normal file
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 23db959b7a4cf21438c0b20d9b30b688
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
15
Assets/Scripts/Util/CommonAnimEvents.cs
Normal file
15
Assets/Scripts/Util/CommonAnimEvents.cs
Normal file
|
@ -0,0 +1,15 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace RhythmHeavenMania.Util
|
||||
{
|
||||
public class CommonAnimEvents : MonoBehaviour
|
||||
{
|
||||
public void Destroy()
|
||||
{
|
||||
Destroy(this.gameObject);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
53
Assets/Scripts/Util/Jukebox.cs
Normal file
53
Assets/Scripts/Util/Jukebox.cs
Normal file
|
@ -0,0 +1,53 @@
|
|||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace RhythmHeavenMania.Util
|
||||
{
|
||||
public class Jukebox
|
||||
{
|
||||
public enum AudioType
|
||||
{
|
||||
OGG,
|
||||
WAV
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This is me just idiot-proofing.
|
||||
/// </summary>
|
||||
public static void BasicCheck()
|
||||
{
|
||||
if (FindJukebox() == null)
|
||||
{
|
||||
GameObject Jukebox = new GameObject("Jukebox");
|
||||
Jukebox.AddComponent<AudioSource>();
|
||||
Jukebox.tag = "Jukebox";
|
||||
}
|
||||
}
|
||||
|
||||
public static GameObject FindJukebox()
|
||||
{
|
||||
if (GameObject.FindGameObjectWithTag("Jukebox") != null)
|
||||
return GameObject.FindGameObjectWithTag("Jukebox");
|
||||
else
|
||||
return null;
|
||||
}
|
||||
|
||||
public static void SetVolume(float volume)
|
||||
{
|
||||
BasicCheck();
|
||||
FindJukebox().GetComponent<AudioSource>().volume = volume;
|
||||
}
|
||||
|
||||
public static void PlayOneShot(string name)
|
||||
{
|
||||
GameObject oneShot = new GameObject("oneShot");
|
||||
AudioSource aus = oneShot.AddComponent<AudioSource>();
|
||||
aus.playOnAwake = false;
|
||||
Sound snd = oneShot.AddComponent<Sound>();
|
||||
snd.clip = Resources.Load<AudioClip>($"Sfx/{name}");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
27
Assets/Scripts/Util/Sound.cs
Normal file
27
Assets/Scripts/Util/Sound.cs
Normal file
|
@ -0,0 +1,27 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace RhythmHeavenMania.Util
|
||||
{
|
||||
public class Sound : MonoBehaviour
|
||||
{
|
||||
public AudioClip clip;
|
||||
public float pitch;
|
||||
|
||||
private AudioSource audioSource;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
audioSource = GetComponent<AudioSource>();
|
||||
audioSource.PlayOneShot(clip);
|
||||
StartCoroutine(play());
|
||||
}
|
||||
|
||||
private IEnumerator play()
|
||||
{
|
||||
yield return new WaitForSeconds(clip.length);
|
||||
Destroy(this.gameObject);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,18 +1,21 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class WTF : MonoBehaviour
|
||||
{
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
|
||||
}
|
||||
// this is a script for testing
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
namespace RhythmHeavenMania.Tests
|
||||
{
|
||||
public class WTF : MonoBehaviour
|
||||
{
|
||||
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
8
Assets/Shaders.meta
Normal file
8
Assets/Shaders.meta
Normal file
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 2ba8fd574a5948a4b9c3bb56e0c57a2d
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Loading…
Reference in a new issue