mirror of
https://github.com/RHeavenStudio/HeavenStudio.git
synced 2025-06-12 08:37:37 +02:00
combo input
This commit is contained in:
@ -14,8 +14,14 @@ namespace HeavenStudio.Games.Scripts_KarateMan
|
||||
public GameEvent bop = new GameEvent();
|
||||
|
||||
float lastPunchTime = Single.MinValue;
|
||||
float lastComboMissTime = Single.MinValue;
|
||||
public bool inCombo = false;
|
||||
int inComboId = -1;
|
||||
int shouldComboId = -1;
|
||||
public void SetComboId(int id) { inComboId = id; }
|
||||
public void SetShouldComboId(int id) { shouldComboId = id; }
|
||||
public int GetComboId() { return inComboId; }
|
||||
public int GetShouldComboId() { return shouldComboId; }
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
@ -25,12 +31,31 @@ namespace HeavenStudio.Games.Scripts_KarateMan
|
||||
private void Update()
|
||||
{
|
||||
var cond = Conductor.instance;
|
||||
if (cond.ReportBeat(ref bop.lastReportedBeat, bop.startBeat % 1, false) && cond.songPositionInBeats > bop.startBeat)
|
||||
if (cond.ReportBeat(ref bop.lastReportedBeat, bop.startBeat % 1, false) && cond.songPositionInBeats > bop.startBeat && !inCombo)
|
||||
{
|
||||
anim.Play("Beat", -1, 0);
|
||||
}
|
||||
|
||||
if (PlayerInput.Pressed(true))
|
||||
if (inCombo && shouldComboId == -2)
|
||||
{
|
||||
float missProg = cond.GetPositionFromBeat(lastComboMissTime, 3.25f);
|
||||
if (missProg >= 0f && missProg < 1f)
|
||||
{
|
||||
anim.DoScaledAnimation("LowKickMiss", lastComboMissTime, 3.25f);
|
||||
}
|
||||
else if (missProg >= 1f)
|
||||
{
|
||||
anim.speed = 1f;
|
||||
bop.startBeat = lastComboMissTime + 3.25f;
|
||||
lastComboMissTime = Single.MinValue;
|
||||
inCombo = false;
|
||||
inComboId = -1;
|
||||
shouldComboId = -1;
|
||||
Debug.Log("Getup");
|
||||
}
|
||||
}
|
||||
|
||||
if (PlayerInput.Pressed(true) && !inCombo)
|
||||
{
|
||||
if (!KarateManNew.instance.IsExpectingInputNow())
|
||||
{
|
||||
@ -38,22 +63,45 @@ namespace HeavenStudio.Games.Scripts_KarateMan
|
||||
Jukebox.PlayOneShotGame("karateman/swingNoHit", forcePlay: true);
|
||||
}
|
||||
}
|
||||
else if (PlayerInput.AltPressed() && !inCombo)
|
||||
{
|
||||
if (!KarateManNew.instance.IsExpectingInputNow())
|
||||
{
|
||||
//start a forced-fail combo sequence
|
||||
float beat = cond.songPositionInBeats;
|
||||
BeatAction.New(gameObject, new List<BeatAction.Action>()
|
||||
{
|
||||
new BeatAction.Action(beat, delegate { Punch(1); inCombo = true; inComboId = -1; shouldComboId = -1;}),
|
||||
new BeatAction.Action(beat + 0.25f, delegate { Punch(2); }),
|
||||
new BeatAction.Action(beat + 0.5f, delegate { ComboSequence(0); }),
|
||||
new BeatAction.Action(beat + 0.75f, delegate { shouldComboId = -2; ComboMiss(beat + 0.75f); }),
|
||||
});
|
||||
|
||||
MultiSound.Play(new MultiSound.Sound[]
|
||||
{
|
||||
new MultiSound.Sound("karateman/swingNoHit", beat),
|
||||
new MultiSound.Sound("karateman/swingNoHit_Alt", beat + 0.25f),
|
||||
new MultiSound.Sound("karateman/swingNoHit_Alt", beat + 0.5f),
|
||||
new MultiSound.Sound("karateman/comboMiss", beat + 0.75f),
|
||||
}, forcePlay: true);
|
||||
}
|
||||
}
|
||||
else if (PlayerInput.AltPressedUp())
|
||||
{
|
||||
if (!KarateManNew.instance.IsExpectingInputNow())
|
||||
{
|
||||
if (inComboId != -1 && !KarateManNew.instance.IsExpectingInputNow())
|
||||
{
|
||||
//let go too early, make joe spin later
|
||||
inComboId = -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void Punch(int forceHand = 0)
|
||||
public bool Punch(int forceHand = 0)
|
||||
{
|
||||
var cond = Conductor.instance;
|
||||
bool straight = false;
|
||||
switch (forceHand)
|
||||
{
|
||||
case 0:
|
||||
@ -61,6 +109,7 @@ namespace HeavenStudio.Games.Scripts_KarateMan
|
||||
{
|
||||
lastPunchTime = Single.MinValue;
|
||||
anim.Play("Straight", -1, 0);
|
||||
straight = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -73,9 +122,38 @@ namespace HeavenStudio.Games.Scripts_KarateMan
|
||||
break;
|
||||
case 2:
|
||||
anim.Play("Straight", -1, 0);
|
||||
straight = true;
|
||||
break;
|
||||
}
|
||||
bop.startBeat = cond.songPositionInBeats + 0.5f;
|
||||
return straight; //returns what hand was used to punch the object
|
||||
}
|
||||
|
||||
public void ComboSequence(int seq)
|
||||
{
|
||||
var cond = Conductor.instance;
|
||||
switch (seq)
|
||||
{
|
||||
case 0:
|
||||
anim.Play("LowJab", -1, 0);
|
||||
break;
|
||||
case 1:
|
||||
anim.Play("LowKick", -1, 0);
|
||||
break;
|
||||
case 2:
|
||||
anim.Play("BackHand", -1, 0);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
bop.startBeat = cond.songPositionInBeats + 1f;
|
||||
}
|
||||
|
||||
public void ComboMiss(float beat)
|
||||
{
|
||||
var cond = Conductor.instance;
|
||||
lastComboMissTime = beat;
|
||||
bop.startBeat = beat + 3.25f;
|
||||
}
|
||||
}
|
||||
}
|
@ -98,18 +98,23 @@ namespace HeavenStudio.Games.Scripts_KarateMan
|
||||
break;
|
||||
case ItemType.ComboPot2:
|
||||
path = 1;
|
||||
BeatAction.New(gameObject, new List<BeatAction.Action>() { new BeatAction.Action(startBeat + 1f, delegate { JoeComboSequence(); }) });
|
||||
break;
|
||||
case ItemType.ComboPot3:
|
||||
path = 2;
|
||||
BeatAction.New(gameObject, new List<BeatAction.Action>() { new BeatAction.Action(startBeat + 1f, delegate { JoeComboSequence(); }) });
|
||||
break;
|
||||
case ItemType.ComboPot4:
|
||||
path = 3;
|
||||
//if the button isn't held anymore make Joe spin
|
||||
BeatAction.New(gameObject, new List<BeatAction.Action>() { new BeatAction.Action(startBeat + 1f, delegate { JoeComboSequence(); }) });
|
||||
break;
|
||||
case ItemType.ComboPot5:
|
||||
path = 4;
|
||||
BeatAction.New(gameObject, new List<BeatAction.Action>() { new BeatAction.Action(startBeat + 1f, delegate { JoeComboSequence(); }) });
|
||||
break;
|
||||
case ItemType.ComboBarrel:
|
||||
KarateManNew.instance.ScheduleInput(startBeat, 1f, InputType.STANDARD_ALT_UP, ComboEndJustOrNg, ComboEndThrough, ComboEndOut);
|
||||
path = 5;
|
||||
//check for button release
|
||||
break;
|
||||
@ -166,6 +171,59 @@ namespace HeavenStudio.Games.Scripts_KarateMan
|
||||
}
|
||||
}
|
||||
|
||||
void JoeComboSequence()
|
||||
{
|
||||
var joe = KarateManNew.instance.Joe;
|
||||
if (joe.GetShouldComboId() != comboId || !joe.inCombo) return;
|
||||
switch (type)
|
||||
{
|
||||
case ItemType.ComboPot2:
|
||||
joe.Punch(2);
|
||||
if (joe.GetComboId() != comboId)
|
||||
Jukebox.PlayOneShotGame("karateman/swingNoHit_Alt", forcePlay: true);
|
||||
else
|
||||
{
|
||||
Jukebox.PlayOneShotGame("karateman/comboHit1", forcePlay: true);
|
||||
status = FlyStatus.Hit;
|
||||
}
|
||||
break;
|
||||
case ItemType.ComboPot3:
|
||||
joe.ComboSequence(0);
|
||||
if (joe.GetComboId() != comboId) {}
|
||||
else
|
||||
{
|
||||
Jukebox.PlayOneShotGame("karateman/comboHit2", forcePlay: true);
|
||||
status = FlyStatus.Hit;
|
||||
}
|
||||
break;
|
||||
case ItemType.ComboPot4:
|
||||
//if the button isn't held anymore make Joe spin
|
||||
if (joe.GetComboId() != comboId) {
|
||||
joe.ComboMiss(startBeat + 1f);
|
||||
Jukebox.PlayOneShotGame("karateman/comboMiss", forcePlay: true);
|
||||
joe.SetShouldComboId(-2);
|
||||
}
|
||||
else
|
||||
{
|
||||
joe.ComboSequence(1);
|
||||
Jukebox.PlayOneShotGame("karateman/comboHit3", forcePlay: true);
|
||||
status = FlyStatus.Hit;
|
||||
}
|
||||
break;
|
||||
case ItemType.ComboPot5:
|
||||
joe.ComboSequence(2);
|
||||
if (joe.GetComboId() != comboId) {}
|
||||
else
|
||||
{
|
||||
Jukebox.PlayOneShotGame("karateman/comboHit3", forcePlay: true);
|
||||
status = FlyStatus.Hit;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public void ItemJustOrNg(PlayerActionEvent caller, float state)
|
||||
{
|
||||
if (status == FlyStatus.Fly) {
|
||||
@ -201,15 +259,18 @@ namespace HeavenStudio.Games.Scripts_KarateMan
|
||||
|
||||
public void ComboStartJustOrNg(PlayerActionEvent caller, float state)
|
||||
{
|
||||
if (status == FlyStatus.Fly) {
|
||||
KarateManNew.instance.Joe.Punch(1);
|
||||
KarateManNew.instance.Joe.SetComboId(comboId);
|
||||
var joe = KarateManNew.instance.Joe;
|
||||
if (status == FlyStatus.Fly && !joe.inCombo) {
|
||||
joe.inCombo = true;
|
||||
joe.Punch(1);
|
||||
joe.SetComboId(comboId);
|
||||
joe.SetShouldComboId(comboId);
|
||||
if (state <= -1f || state >= 1f) {
|
||||
Jukebox.PlayOneShot("miss");
|
||||
status = FlyStatus.NG;
|
||||
}
|
||||
else {
|
||||
Jukebox.PlayOneShotGame("karateman/potHit", forcePlay: true);
|
||||
Jukebox.PlayOneShotGame("karateman/comboHit1", forcePlay: true);
|
||||
status = FlyStatus.Hit;
|
||||
}
|
||||
}
|
||||
@ -222,5 +283,27 @@ namespace HeavenStudio.Games.Scripts_KarateMan
|
||||
{
|
||||
//hitting a combo start object with the normal input
|
||||
}
|
||||
|
||||
public void ComboEndJustOrNg(PlayerActionEvent caller, float state)
|
||||
{
|
||||
var joe = KarateManNew.instance.Joe;
|
||||
if (status == FlyStatus.Fly && joe.inCombo && joe.GetComboId() == comboId) {
|
||||
joe.inCombo = false;
|
||||
joe.SetComboId(-1);
|
||||
joe.SetShouldComboId(-1);
|
||||
//UpperCut
|
||||
if (state <= -1f || state >= 1f) {
|
||||
Jukebox.PlayOneShot("miss");
|
||||
status = FlyStatus.NG;
|
||||
}
|
||||
else {
|
||||
Jukebox.PlayOneShotGame("karateman/comboHit4", forcePlay: true);
|
||||
status = FlyStatus.Hit;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void ComboEndOut(PlayerActionEvent caller) {}
|
||||
public void ComboEndThrough(PlayerActionEvent caller) {}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user