mirror of
https://github.com/RHeavenStudioPlus/HeavenStudioPlus.git
synced 2024-11-26 19:43:01 +00:00
Merge pull request #22 from CarsonKompon/tap-trial-real-inputs
Playable Tap Trial
This commit is contained in:
commit
c59f5e6222
6 changed files with 268 additions and 29 deletions
|
@ -113,7 +113,7 @@ Transform:
|
|||
m_LocalScale: {x: 2.166603, y: 2.22111, z: 1}
|
||||
m_Children: []
|
||||
m_Father: {fileID: 2907041458994465612}
|
||||
m_RootOrder: 4
|
||||
m_RootOrder: 5
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!212 &2108081423830504772
|
||||
SpriteRenderer:
|
||||
|
@ -236,6 +236,19 @@ MonoBehaviour:
|
|||
m_Script: {fileID: 11500000, guid: 6892e03a2f2994b48a4b076fdfae805d, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
inList: 0
|
||||
lastState: 0
|
||||
state:
|
||||
gameObject: {fileID: 0}
|
||||
early: 0
|
||||
perfect: 0
|
||||
late: 0
|
||||
createBeat: 0
|
||||
eligibleHitsList: []
|
||||
aceTimes: 0
|
||||
isEligible: 0
|
||||
triggersAutoplay: 1
|
||||
nextBeat: 0
|
||||
--- !u!1 &335036550381843476
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
|
@ -564,6 +577,62 @@ SpriteRenderer:
|
|||
m_WasSpriteAssigned: 1
|
||||
m_MaskInteraction: 0
|
||||
m_SpriteSortPoint: 0
|
||||
--- !u!1 &1588738713562392816
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 5208471493270040557}
|
||||
- component: {fileID: 6245594884647355465}
|
||||
m_Layer: 0
|
||||
m_Name: Tap
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 0
|
||||
--- !u!4 &5208471493270040557
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1588738713562392816}
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_Children: []
|
||||
m_Father: {fileID: 6495189186508343095}
|
||||
m_RootOrder: 0
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!114 &6245594884647355465
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1588738713562392816}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 01f0b70cc14be2e47998a680099e7986, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
inList: 0
|
||||
lastState: 0
|
||||
state:
|
||||
gameObject: {fileID: 0}
|
||||
early: 0
|
||||
perfect: 0
|
||||
late: 0
|
||||
createBeat: 0
|
||||
eligibleHitsList: []
|
||||
aceTimes: 0
|
||||
isEligible: 0
|
||||
triggersAutoplay: 1
|
||||
startBeat: 0
|
||||
--- !u!1 &2036719006303025046
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
|
@ -876,6 +945,7 @@ Transform:
|
|||
- {fileID: 2447600723971154318}
|
||||
- {fileID: 6128063303297303287}
|
||||
- {fileID: 7656869706203293275}
|
||||
- {fileID: 6495189186508343095}
|
||||
- {fileID: 6660332389952895749}
|
||||
- {fileID: 7667021380834212371}
|
||||
- {fileID: 7618359020666823781}
|
||||
|
@ -897,6 +967,7 @@ MonoBehaviour:
|
|||
EligibleHits: []
|
||||
firstEnable: 0
|
||||
player: {fileID: 3802388599767290996}
|
||||
tap: {fileID: 1588738713562392816}
|
||||
--- !u!1 &3076910857648561258
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
|
@ -926,7 +997,7 @@ Transform:
|
|||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_Children: []
|
||||
m_Father: {fileID: 2907041458994465612}
|
||||
m_RootOrder: 5
|
||||
m_RootOrder: 6
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!212 &8011646622740663204
|
||||
SpriteRenderer:
|
||||
|
@ -1666,7 +1737,7 @@ Transform:
|
|||
m_LocalScale: {x: 2.136603, y: 2.2011096, z: 1}
|
||||
m_Children: []
|
||||
m_Father: {fileID: 2907041458994465612}
|
||||
m_RootOrder: 3
|
||||
m_RootOrder: 4
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!212 &6120332165088402499
|
||||
SpriteRenderer:
|
||||
|
@ -2164,3 +2235,34 @@ SpriteRenderer:
|
|||
m_WasSpriteAssigned: 1
|
||||
m_MaskInteraction: 0
|
||||
m_SpriteSortPoint: 0
|
||||
--- !u!1 &8537406413473122392
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 6495189186508343095}
|
||||
m_Layer: 0
|
||||
m_Name: Beats
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!4 &6495189186508343095
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 8537406413473122392}
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_Children:
|
||||
- {fileID: 5208471493270040557}
|
||||
m_Father: {fileID: 2907041458994465612}
|
||||
m_RootOrder: 3
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
|
|
22
Assets/Resources/Sfx/games/tapTrial/tonk.wav.meta
Normal file
22
Assets/Resources/Sfx/games/tapTrial/tonk.wav.meta
Normal file
|
@ -0,0 +1,22 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 432d91ac343eb7249aa719c1cc69dca1
|
||||
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:
|
62
Assets/Scripts/Games/TapTrial/Tap.cs
Normal file
62
Assets/Scripts/Games/TapTrial/Tap.cs
Normal file
|
@ -0,0 +1,62 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
using RhythmHeavenMania.Util;
|
||||
|
||||
namespace RhythmHeavenMania.Games.TapTrial
|
||||
{
|
||||
public class Tap : PlayerActionObject
|
||||
{
|
||||
public float startBeat;
|
||||
|
||||
public int type;
|
||||
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
PlayerActionInit(this.gameObject, startBeat);
|
||||
}
|
||||
|
||||
public override void OnAce()
|
||||
{
|
||||
Hit(true);
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
if (Conductor.instance.GetPositionFromBeat(startBeat, 2) >= 1)
|
||||
CleanUp();
|
||||
|
||||
float normalizedBeat = Conductor.instance.GetPositionFromBeat(startBeat, 1f);
|
||||
StateCheck(normalizedBeat);
|
||||
|
||||
if(PlayerInput.Pressed())
|
||||
{
|
||||
if(state.perfect)
|
||||
{
|
||||
Hit(true);
|
||||
}
|
||||
else if(state.notPerfect())
|
||||
{
|
||||
Hit(false);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void Hit(bool hit)
|
||||
{
|
||||
TapTrial.instance.player.Tap(hit, type);
|
||||
|
||||
if (hit)
|
||||
CleanUp();
|
||||
}
|
||||
|
||||
public void CleanUp()
|
||||
{
|
||||
Destroy(this.gameObject);
|
||||
}
|
||||
}
|
||||
}
|
11
Assets/Scripts/Games/TapTrial/Tap.cs.meta
Normal file
11
Assets/Scripts/Games/TapTrial/Tap.cs.meta
Normal file
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 01f0b70cc14be2e47998a680099e7986
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -10,6 +10,7 @@ namespace RhythmHeavenMania.Games.TapTrial
|
|||
{
|
||||
[Header("References")]
|
||||
public TapTrialPlayer player;
|
||||
public GameObject tap;
|
||||
|
||||
public static TapTrial instance { get; set; }
|
||||
|
||||
|
@ -22,19 +23,10 @@ namespace RhythmHeavenMania.Games.TapTrial
|
|||
|
||||
public void Tap(float beat)
|
||||
{
|
||||
MultiSound.Play(new MultiSound.Sound[]
|
||||
{
|
||||
new MultiSound.Sound("tapTrial/ook", beat),
|
||||
new MultiSound.Sound("tapTrial/tap", beat + 1.0f),
|
||||
});
|
||||
Jukebox.PlayOneShotGame("tapTrial/ook");
|
||||
player.anim.Play("TapPrepare", 0, 0);
|
||||
|
||||
GameObject beatAction = new GameObject();
|
||||
beatAction.transform.SetParent(this.transform);
|
||||
BeatAction.New(beatAction, new List<BeatAction.Action>()
|
||||
{
|
||||
new BeatAction.Action(beat + 0.0f, delegate { player.anim.Play("TapPrepare", 0, 0); }),
|
||||
new BeatAction.Action(beat + 1.0f, delegate { player.anim.Play("Tap", 0, 0); }),
|
||||
});
|
||||
CreateTap(beat);
|
||||
}
|
||||
|
||||
public void DoubleTap(float beat)
|
||||
|
@ -42,18 +34,17 @@ namespace RhythmHeavenMania.Games.TapTrial
|
|||
MultiSound.Play(new MultiSound.Sound[]
|
||||
{
|
||||
new MultiSound.Sound("tapTrial/ookook", beat),
|
||||
new MultiSound.Sound("tapTrial/ookook", beat + 0.5f),
|
||||
new MultiSound.Sound("tapTrial/tap", beat + 1.0f),
|
||||
new MultiSound.Sound("tapTrial/tap", beat + 1.5f),
|
||||
new MultiSound.Sound("tapTrial/ookook", beat + 0.5f)
|
||||
});
|
||||
|
||||
player.anim.Play("DoubleTapPrepare", 0, 0);
|
||||
|
||||
GameObject beatAction = new GameObject();
|
||||
beatAction.transform.SetParent(this.transform);
|
||||
BeatAction.New(beatAction, new List<BeatAction.Action>()
|
||||
{
|
||||
new BeatAction.Action(beat + 0.0f, delegate { player.anim.Play("DoubleTapPrepare", 0, 0); }),
|
||||
new BeatAction.Action(beat + 1.0f, delegate { player.anim.Play("DoubleTap", 0, 0); }),
|
||||
new BeatAction.Action(beat + 1.5f, delegate { player.anim.Play("DoubleTap", 0, 0); }),
|
||||
new BeatAction.Action(beat + 0.0f, delegate { CreateTap(beat, 1); }),
|
||||
new BeatAction.Action(beat + 0.5f, delegate { CreateTap(beat + 0.5f, 1); }),
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -62,20 +53,19 @@ namespace RhythmHeavenMania.Games.TapTrial
|
|||
MultiSound.Play(new MultiSound.Sound[]
|
||||
{
|
||||
new MultiSound.Sound("tapTrial/ooki1", beat),
|
||||
new MultiSound.Sound("tapTrial/ooki2", beat + 0.5f),
|
||||
new MultiSound.Sound("tapTrial/tap", beat + 2.0f),
|
||||
new MultiSound.Sound("tapTrial/tap", beat + 2.5f),
|
||||
new MultiSound.Sound("tapTrial/tap", beat + 3.0f),
|
||||
new MultiSound.Sound("tapTrial/ooki2", beat + 0.5f)
|
||||
});
|
||||
|
||||
player.anim.Play("PosePrepare", 0, 0);
|
||||
player.tripleOffset = 0;
|
||||
|
||||
GameObject beatAction = new GameObject();
|
||||
beatAction.transform.SetParent(this.transform);
|
||||
BeatAction.New(beatAction, new List<BeatAction.Action>()
|
||||
{
|
||||
new BeatAction.Action(beat + 0.0f, delegate { player.anim.Play("PosePrepare", 0, 0); }),
|
||||
new BeatAction.Action(beat + 2.0f, delegate { player.anim.Play("Tap", 0, 0); }),
|
||||
new BeatAction.Action(beat + 2.5f, delegate { player.anim.Play("DoubleTap", 0, 0); }),
|
||||
new BeatAction.Action(beat + 3.0f, delegate { player.anim.Play("Tap", 0, 0); }),
|
||||
new BeatAction.Action(beat + 1.0f, delegate { CreateTap(beat + 1.0f, 2); }),
|
||||
new BeatAction.Action(beat + 1.5f, delegate { CreateTap(beat + 1.5f, 2); }),
|
||||
new BeatAction.Action(beat + 2.0f, delegate { CreateTap(beat + 2.0f, 2); }),
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -88,5 +78,15 @@ namespace RhythmHeavenMania.Games.TapTrial
|
|||
{
|
||||
|
||||
}
|
||||
|
||||
public void CreateTap(float beat, int type = 0)
|
||||
{
|
||||
GameObject _tap = Instantiate(tap);
|
||||
_tap.transform.parent = tap.transform.parent;
|
||||
_tap.SetActive(true);
|
||||
Tap t = _tap.GetComponent<Tap>();
|
||||
t.startBeat = beat;
|
||||
t.type = type;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,5 +1,7 @@
|
|||
using UnityEngine;
|
||||
|
||||
using RhythmHeavenMania.Util;
|
||||
|
||||
namespace RhythmHeavenMania.Games.TapTrial
|
||||
{
|
||||
public class TapTrialPlayer : MonoBehaviour
|
||||
|
@ -7,9 +9,49 @@ namespace RhythmHeavenMania.Games.TapTrial
|
|||
[Header("References")]
|
||||
[System.NonSerialized] public Animator anim;
|
||||
|
||||
public float nextBeat;
|
||||
public int tripleOffset = 0;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
anim = GetComponent<Animator>();
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
float normalizedBeat = Conductor.instance.GetPositionFromMargin(nextBeat, 1f);
|
||||
|
||||
|
||||
if (PlayerInput.Pressed())
|
||||
{
|
||||
Tap(false, 0);
|
||||
}
|
||||
}
|
||||
|
||||
public void Tap(bool hit, int type)
|
||||
{
|
||||
if (hit)
|
||||
Jukebox.PlayOneShotGame("tapTrial/tap");
|
||||
else
|
||||
Jukebox.PlayOneShotGame("tapTrial/tonk");
|
||||
|
||||
|
||||
switch (type)
|
||||
{
|
||||
case 0:
|
||||
anim.Play("Tap", 0, 0);
|
||||
break;
|
||||
case 1:
|
||||
anim.Play("DoubleTap", 0, 0);
|
||||
break;
|
||||
case 2:
|
||||
if(tripleOffset % 2 == 0)
|
||||
anim.Play("DoubleTap", 0, 0);
|
||||
else
|
||||
anim.Play("Tap", 0, 0);
|
||||
tripleOffset++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue