2022-07-28 23:12:21 +00:00
|
|
|
using System;
|
|
|
|
using System.Collections;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
|
|
using HeavenStudio;
|
|
|
|
using HeavenStudio.Util;
|
|
|
|
|
|
|
|
namespace HeavenStudio.Games.Scripts_KarateMan
|
|
|
|
{
|
2022-07-29 19:06:22 +00:00
|
|
|
public class KarateManJoe : MonoBehaviour
|
2022-07-28 23:12:21 +00:00
|
|
|
{
|
|
|
|
public Animator anim;
|
|
|
|
public GameEvent bop = new GameEvent();
|
|
|
|
|
|
|
|
float lastPunchTime = Single.MinValue;
|
2022-07-29 02:09:48 +00:00
|
|
|
float lastComboMissTime = Single.MinValue;
|
2022-07-29 16:18:17 +00:00
|
|
|
float lastUpperCutTime = Single.MinValue;
|
2022-07-29 02:09:48 +00:00
|
|
|
public bool inCombo = false;
|
2022-07-29 19:06:22 +00:00
|
|
|
public bool lockedInCombo = false;
|
2022-07-28 23:12:21 +00:00
|
|
|
int inComboId = -1;
|
2022-07-29 02:09:48 +00:00
|
|
|
int shouldComboId = -1;
|
2022-07-28 23:12:21 +00:00
|
|
|
public void SetComboId(int id) { inComboId = id; }
|
2022-07-29 02:09:48 +00:00
|
|
|
public void SetShouldComboId(int id) { shouldComboId = id; }
|
|
|
|
public int GetComboId() { return inComboId; }
|
|
|
|
public int GetShouldComboId() { return shouldComboId; }
|
2022-07-28 23:12:21 +00:00
|
|
|
|
2022-07-30 02:25:48 +00:00
|
|
|
public bool wantKick = false;
|
|
|
|
public bool inKick = false;
|
|
|
|
float lastChargeTime = Single.MinValue;
|
|
|
|
|
|
|
|
bool inSpecial { get { return inCombo || inKick; } }
|
|
|
|
|
2022-07-28 23:12:21 +00:00
|
|
|
private void Awake()
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
private void Update()
|
|
|
|
{
|
|
|
|
var cond = Conductor.instance;
|
2022-07-29 02:09:48 +00:00
|
|
|
if (cond.ReportBeat(ref bop.lastReportedBeat, bop.startBeat % 1, false) && cond.songPositionInBeats > bop.startBeat && !inCombo)
|
2022-07-28 23:12:21 +00:00
|
|
|
{
|
|
|
|
anim.Play("Beat", -1, 0);
|
|
|
|
}
|
|
|
|
|
2022-07-29 02:09:48 +00:00
|
|
|
if (inCombo && shouldComboId == -2)
|
|
|
|
{
|
2022-07-29 16:18:17 +00:00
|
|
|
float missProg = cond.GetPositionFromBeat(lastComboMissTime, 3f);
|
2022-07-29 02:09:48 +00:00
|
|
|
if (missProg >= 0f && missProg < 1f)
|
|
|
|
{
|
2022-07-29 16:18:17 +00:00
|
|
|
anim.DoScaledAnimation("LowKickMiss", lastComboMissTime, 3f);
|
2022-07-30 02:25:48 +00:00
|
|
|
bop.startBeat = lastComboMissTime + 3f;
|
2022-07-29 02:09:48 +00:00
|
|
|
}
|
|
|
|
else if (missProg >= 1f)
|
|
|
|
{
|
|
|
|
anim.speed = 1f;
|
2022-07-29 16:18:17 +00:00
|
|
|
bop.startBeat = lastComboMissTime + 3f;
|
2022-07-29 02:09:48 +00:00
|
|
|
lastComboMissTime = Single.MinValue;
|
|
|
|
inCombo = false;
|
|
|
|
inComboId = -1;
|
|
|
|
shouldComboId = -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-07-30 02:25:48 +00:00
|
|
|
if (inKick)
|
|
|
|
{
|
|
|
|
float chargeProg = cond.GetPositionFromBeat(lastChargeTime, 2.75f);
|
|
|
|
if (chargeProg >= 0f && chargeProg < 1f)
|
|
|
|
{
|
|
|
|
anim.DoScaledAnimation("ManCharge", lastChargeTime, 2.75f);
|
|
|
|
bop.startBeat = lastChargeTime + 2.75f;
|
|
|
|
}
|
|
|
|
else if (chargeProg >= 1f)
|
|
|
|
{
|
|
|
|
anim.speed = 1f;
|
|
|
|
bop.startBeat = lastChargeTime + 2.75f;
|
|
|
|
lastChargeTime = Single.MinValue;
|
|
|
|
inKick = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (PlayerInput.Pressed(true) && !inSpecial)
|
2022-07-28 23:12:21 +00:00
|
|
|
{
|
2022-07-29 19:06:22 +00:00
|
|
|
if (!KarateMan.instance.IsExpectingInputNow())
|
2022-07-28 23:12:21 +00:00
|
|
|
{
|
|
|
|
Punch(1);
|
|
|
|
Jukebox.PlayOneShotGame("karateman/swingNoHit", forcePlay: true);
|
|
|
|
}
|
|
|
|
}
|
2022-07-30 02:25:48 +00:00
|
|
|
else if (PlayerInput.AltPressed() && !inSpecial)
|
2022-07-29 02:09:48 +00:00
|
|
|
{
|
2022-07-29 19:06:22 +00:00
|
|
|
if (!KarateMan.instance.IsExpectingInputNow())
|
2022-07-29 02:09:48 +00:00
|
|
|
{
|
|
|
|
//start a forced-fail combo sequence
|
2022-07-29 16:18:17 +00:00
|
|
|
ForceFailCombo(cond.songPositionInBeats);
|
2022-07-29 02:09:48 +00:00
|
|
|
}
|
|
|
|
}
|
2022-07-28 23:12:21 +00:00
|
|
|
else if (PlayerInput.AltPressedUp())
|
|
|
|
{
|
2022-07-29 19:06:22 +00:00
|
|
|
if (!KarateMan.instance.IsExpectingInputNow())
|
2022-07-28 23:12:21 +00:00
|
|
|
{
|
2022-07-29 19:06:22 +00:00
|
|
|
if (inComboId != -1 && !lockedInCombo)
|
2022-07-28 23:12:21 +00:00
|
|
|
{
|
|
|
|
inComboId = -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2022-07-30 02:25:48 +00:00
|
|
|
|
|
|
|
if ((!GameManager.instance.autoplay) && (PlayerInput.PressedUp(true) && wantKick && !PlayerInput.Pressing(true)))
|
|
|
|
{
|
|
|
|
//stopped holding, don't charge
|
|
|
|
wantKick = false;
|
|
|
|
}
|
2022-07-28 23:12:21 +00:00
|
|
|
}
|
|
|
|
|
2022-07-29 02:09:48 +00:00
|
|
|
public bool Punch(int forceHand = 0)
|
2022-07-28 23:12:21 +00:00
|
|
|
{
|
2022-07-29 19:06:22 +00:00
|
|
|
if (GameManager.instance.currentGame != "karateman") return false;
|
2022-07-28 23:12:21 +00:00
|
|
|
var cond = Conductor.instance;
|
2022-07-29 02:09:48 +00:00
|
|
|
bool straight = false;
|
2022-07-28 23:12:21 +00:00
|
|
|
switch (forceHand)
|
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
if (cond.songPositionInBeats - lastPunchTime < 0.25f + (Minigame.LateTime() - 1f))
|
|
|
|
{
|
|
|
|
lastPunchTime = Single.MinValue;
|
2022-07-30 02:25:48 +00:00
|
|
|
anim.DoScaledAnimationAsync("Straight", 0.5f);
|
2022-07-29 02:09:48 +00:00
|
|
|
straight = true;
|
2022-07-28 23:12:21 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
lastPunchTime = cond.songPositionInBeats;
|
2022-07-30 02:25:48 +00:00
|
|
|
anim.DoScaledAnimationAsync("Jab", 0.5f);
|
2022-07-28 23:12:21 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 1:
|
2022-07-30 02:25:48 +00:00
|
|
|
anim.DoScaledAnimationAsync("Jab", 0.5f);
|
2022-07-28 23:12:21 +00:00
|
|
|
break;
|
|
|
|
case 2:
|
2022-07-30 02:25:48 +00:00
|
|
|
anim.DoScaledAnimationAsync("Straight", 0.5f);
|
2022-07-29 02:09:48 +00:00
|
|
|
straight = true;
|
2022-07-28 23:12:21 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
bop.startBeat = cond.songPositionInBeats + 0.5f;
|
2022-07-29 02:09:48 +00:00
|
|
|
return straight; //returns what hand was used to punch the object
|
|
|
|
}
|
|
|
|
|
|
|
|
public void ComboSequence(int seq)
|
|
|
|
{
|
2022-07-29 19:06:22 +00:00
|
|
|
if (GameManager.instance.currentGame != "karateman") return;
|
2022-07-29 02:09:48 +00:00
|
|
|
var cond = Conductor.instance;
|
2022-07-29 16:18:17 +00:00
|
|
|
bop.startBeat = cond.songPositionInBeats + 1f;
|
2022-07-29 02:09:48 +00:00
|
|
|
switch (seq)
|
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
anim.Play("LowJab", -1, 0);
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
anim.Play("LowKick", -1, 0);
|
|
|
|
break;
|
|
|
|
case 2:
|
2022-07-29 16:18:17 +00:00
|
|
|
anim.DoScaledAnimationAsync("BackHand", 0.5f);
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
anim.DoScaledAnimationAsync("UpperCut", 0.5f);
|
2022-07-29 19:06:22 +00:00
|
|
|
lockedInCombo = false;
|
2022-07-29 16:18:17 +00:00
|
|
|
break;
|
|
|
|
case 4:
|
|
|
|
anim.Play("ToReady", -1, 0);
|
|
|
|
bop.startBeat = cond.songPositionInBeats + 0.5f;
|
2022-07-29 19:06:22 +00:00
|
|
|
lockedInCombo = false;
|
2022-07-29 02:09:48 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public void ComboMiss(float beat)
|
|
|
|
{
|
|
|
|
var cond = Conductor.instance;
|
|
|
|
lastComboMissTime = beat;
|
2022-07-29 16:18:17 +00:00
|
|
|
bop.startBeat = beat + 3f;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void ForceFailCombo(float beat)
|
|
|
|
{
|
|
|
|
if (inCombo) return;
|
|
|
|
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);
|
2022-07-28 23:12:21 +00:00
|
|
|
}
|
2022-07-30 02:25:48 +00:00
|
|
|
|
|
|
|
public void StartKickCharge(float beat)
|
|
|
|
{
|
|
|
|
wantKick = true;
|
|
|
|
BeatAction.New(gameObject, new List<BeatAction.Action>()
|
|
|
|
{
|
|
|
|
new BeatAction.Action(beat, delegate {
|
|
|
|
if (wantKick)
|
|
|
|
{
|
|
|
|
wantKick = false;
|
|
|
|
inKick = true;
|
|
|
|
lastChargeTime = beat;
|
|
|
|
bop.startBeat = beat + 2.75f;
|
|
|
|
}
|
|
|
|
})
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
public void Kick(float beat)
|
|
|
|
{
|
|
|
|
if (!inKick) return;
|
|
|
|
inKick = false;
|
|
|
|
bop.startBeat = beat + 2f;
|
|
|
|
}
|
2022-07-28 23:12:21 +00:00
|
|
|
}
|
|
|
|
}
|