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

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