Added Tap, Double Tap, and Triple Tap to Tap Trial

All perfectly playable :)
Hopefully this is up to standards with the other games I just wanted to do this to prove to myself that I could LOL
This commit is contained in:
Carson Kompon 2022-02-28 12:17:50 -05:00
parent 9c30238ba6
commit 94f0c09d71
5 changed files with 234 additions and 33 deletions

View File

@ -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}

View 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);
}
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 01f0b70cc14be2e47998a680099e7986
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -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;
}
}
}

View File

@ -9,6 +9,9 @@ namespace RhythmHeavenMania.Games.TapTrial
[Header("References")]
[System.NonSerialized] public Animator anim;
public float nextBeat;
public int tripleOffset = 0;
private void Start()
{
anim = GetComponent<Animator>();
@ -16,16 +19,39 @@ namespace RhythmHeavenMania.Games.TapTrial
private void Update()
{
float normalizedBeat = Conductor.instance.GetPositionFromMargin(nextBeat, 1f);
if (PlayerInput.Pressed())
{
Tap(false);
Tap(false, 0);
}
}
public void Tap(bool hit)
public void Tap(bool hit, int type)
{
Jukebox.PlayOneShotGame("tapTrial/tonk");
anim.Play("Tap", 0, 0);
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;
}
}
}
}