mirror of
https://github.com/RHeavenStudio/HeavenStudio.git
synced 2025-06-12 13:07:40 +02:00
hit effect start, kick charge
This commit is contained in:
12
Assets/Scripts/Games/KarateMan/KarateManHitMark.cs
Normal file
12
Assets/Scripts/Games/KarateMan/KarateManHitMark.cs
Normal file
@ -0,0 +1,12 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace HeavenStudio.Games.Scripts_KarateMan
|
||||
{
|
||||
public class KarateManHitMark : MonoBehaviour
|
||||
{
|
||||
void KillHitMark()
|
||||
{
|
||||
Destroy(gameObject);
|
||||
}
|
||||
}
|
||||
}
|
11
Assets/Scripts/Games/KarateMan/KarateManHitMark.cs.meta
Normal file
11
Assets/Scripts/Games/KarateMan/KarateManHitMark.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d73c427be556896499214ab4666ff3b3
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -25,6 +25,12 @@ namespace HeavenStudio.Games.Scripts_KarateMan
|
||||
public int GetComboId() { return inComboId; }
|
||||
public int GetShouldComboId() { return shouldComboId; }
|
||||
|
||||
public bool wantKick = false;
|
||||
public bool inKick = false;
|
||||
float lastChargeTime = Single.MinValue;
|
||||
|
||||
bool inSpecial { get { return inCombo || inKick; } }
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
|
||||
@ -44,6 +50,7 @@ namespace HeavenStudio.Games.Scripts_KarateMan
|
||||
if (missProg >= 0f && missProg < 1f)
|
||||
{
|
||||
anim.DoScaledAnimation("LowKickMiss", lastComboMissTime, 3f);
|
||||
bop.startBeat = lastComboMissTime + 3f;
|
||||
}
|
||||
else if (missProg >= 1f)
|
||||
{
|
||||
@ -56,7 +63,24 @@ namespace HeavenStudio.Games.Scripts_KarateMan
|
||||
}
|
||||
}
|
||||
|
||||
if (PlayerInput.Pressed(true) && !inCombo)
|
||||
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)
|
||||
{
|
||||
if (!KarateMan.instance.IsExpectingInputNow())
|
||||
{
|
||||
@ -64,7 +88,7 @@ namespace HeavenStudio.Games.Scripts_KarateMan
|
||||
Jukebox.PlayOneShotGame("karateman/swingNoHit", forcePlay: true);
|
||||
}
|
||||
}
|
||||
else if (PlayerInput.AltPressed() && !inCombo)
|
||||
else if (PlayerInput.AltPressed() && !inSpecial)
|
||||
{
|
||||
if (!KarateMan.instance.IsExpectingInputNow())
|
||||
{
|
||||
@ -82,6 +106,12 @@ namespace HeavenStudio.Games.Scripts_KarateMan
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ((!GameManager.instance.autoplay) && (PlayerInput.PressedUp(true) && wantKick && !PlayerInput.Pressing(true)))
|
||||
{
|
||||
//stopped holding, don't charge
|
||||
wantKick = false;
|
||||
}
|
||||
}
|
||||
|
||||
public bool Punch(int forceHand = 0)
|
||||
@ -95,20 +125,20 @@ namespace HeavenStudio.Games.Scripts_KarateMan
|
||||
if (cond.songPositionInBeats - lastPunchTime < 0.25f + (Minigame.LateTime() - 1f))
|
||||
{
|
||||
lastPunchTime = Single.MinValue;
|
||||
anim.Play("Straight", -1, 0);
|
||||
anim.DoScaledAnimationAsync("Straight", 0.5f);
|
||||
straight = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
lastPunchTime = cond.songPositionInBeats;
|
||||
anim.Play("Jab", -1, 0);
|
||||
anim.DoScaledAnimationAsync("Jab", 0.5f);
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
anim.Play("Jab", -1, 0);
|
||||
anim.DoScaledAnimationAsync("Jab", 0.5f);
|
||||
break;
|
||||
case 2:
|
||||
anim.Play("Straight", -1, 0);
|
||||
anim.DoScaledAnimationAsync("Straight", 0.5f);
|
||||
straight = true;
|
||||
break;
|
||||
}
|
||||
@ -172,5 +202,29 @@ namespace HeavenStudio.Games.Scripts_KarateMan
|
||||
new MultiSound.Sound("karateman/comboMiss", beat + 0.75f),
|
||||
}, forcePlay: true);
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
@ -2,6 +2,8 @@ using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
using NaughtyBezierCurves;
|
||||
|
||||
using HeavenStudio.Util;
|
||||
|
||||
namespace HeavenStudio.Games.Scripts_KarateMan
|
||||
@ -15,6 +17,8 @@ namespace HeavenStudio.Games.Scripts_KarateMan
|
||||
public GameObject Shadow;
|
||||
public GameObject ShadowInstance;
|
||||
|
||||
public GameObject HitMark;
|
||||
|
||||
public string awakeAnim;
|
||||
FlyStatus status = FlyStatus.Fly;
|
||||
Color effectTint = Color.white;
|
||||
@ -57,6 +61,9 @@ namespace HeavenStudio.Games.Scripts_KarateMan
|
||||
public float[] HitPositionOffset;
|
||||
public Vector3[] StartPositionOffset;
|
||||
public float[] ItemSlipRt;
|
||||
public BezierCurve3D[] ItemCurves;
|
||||
public BezierCurve3D CurrentCurve;
|
||||
public float curveTargetBeat;
|
||||
|
||||
public SpriteRenderer BulbLight;
|
||||
|
||||
@ -131,8 +138,7 @@ namespace HeavenStudio.Games.Scripts_KarateMan
|
||||
path = 5;
|
||||
break;
|
||||
case ItemType.KickBarrel:
|
||||
//todo: needs own action for spawning the bomb
|
||||
KarateMan.instance.ScheduleInput(startBeat, 1f, InputType.STANDARD_DOWN | InputType.DIRECTION_DOWN, ItemJustOrNg, ItemThrough, ItemOut);
|
||||
KarateMan.instance.ScheduleInput(startBeat, 1f, InputType.STANDARD_DOWN | InputType.DIRECTION_DOWN, KickChargeJustOrNg, ItemThrough, ItemOut);
|
||||
KarateMan.instance.ScheduleUserInput(startBeat, 1f, InputType.STANDARD_ALT_DOWN, ItemWrongAction, ItemOut, ItemOut);
|
||||
path = 1;
|
||||
comboId = -1;
|
||||
@ -161,7 +167,6 @@ namespace HeavenStudio.Games.Scripts_KarateMan
|
||||
{
|
||||
var cond = Conductor.instance;
|
||||
float floorHeight = HitPosition[0].position.y;
|
||||
ShadowInstance.transform.position = new Vector3(transform.position.x, floorHeight - 0.5f, transform.position.z);
|
||||
switch (status)
|
||||
{
|
||||
case FlyStatus.Fly:
|
||||
@ -177,10 +182,24 @@ namespace HeavenStudio.Games.Scripts_KarateMan
|
||||
}
|
||||
break;
|
||||
case FlyStatus.Hit:
|
||||
//TEMPORARY
|
||||
GameObject.Destroy(ShadowInstance.gameObject);
|
||||
GameObject.Destroy(gameObject);
|
||||
return;
|
||||
prog = cond.GetPositionFromBeat(startBeat, curveTargetBeat);
|
||||
if (cond.songPositionInBeats >= startBeat + 2f || CurrentCurve == null) {
|
||||
GameObject.Destroy(ShadowInstance.gameObject);
|
||||
GameObject.Destroy(gameObject);
|
||||
return;
|
||||
}
|
||||
else {
|
||||
if (prog <= 1f)
|
||||
{
|
||||
transform.position = CurrentCurve.GetPoint(prog);
|
||||
transform.rotation = Quaternion.Euler(0, 0, transform.rotation.eulerAngles.z + (-180f * Time.deltaTime * (1/cond.pitchedSecPerBeat)));
|
||||
}
|
||||
else
|
||||
{
|
||||
transform.position = CurrentCurve.GetPoint(1f);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case FlyStatus.NG:
|
||||
//TEMPORARY
|
||||
GameObject.Destroy(ShadowInstance.gameObject);
|
||||
@ -189,45 +208,82 @@ namespace HeavenStudio.Games.Scripts_KarateMan
|
||||
case FlyStatus.HitWeak:
|
||||
break;
|
||||
}
|
||||
ShadowInstance.transform.position = new Vector3(transform.position.x, floorHeight - 0.5f, transform.position.z);
|
||||
}
|
||||
|
||||
void CreateHitMark(bool useLocalPos = false)
|
||||
{
|
||||
GameObject hitMark = GameObject.Instantiate(HitMark, KarateMan.instance.ItemHolder);
|
||||
if (useLocalPos)
|
||||
hitMark.transform.localPosition = transform.position;
|
||||
else
|
||||
hitMark.transform.position = HitPosition[path].position;
|
||||
|
||||
hitMark.SetActive(true);
|
||||
}
|
||||
|
||||
//handles hitsound and particles
|
||||
void ItemHitEffect()
|
||||
void ItemHitEffect(bool straight = false)
|
||||
{
|
||||
startBeat = Conductor.instance.songPositionInBeats;
|
||||
CreateHitMark(type == ItemType.KickBomb);
|
||||
switch (type)
|
||||
{
|
||||
case ItemType.Bulb:
|
||||
CurrentCurve = ItemCurves[straight ? 1 : 0];
|
||||
curveTargetBeat = 2f;
|
||||
Jukebox.PlayOneShotGame("karateman/lightbulbHit", forcePlay: true);
|
||||
break;
|
||||
case ItemType.Rock:
|
||||
CurrentCurve = ItemCurves[1];
|
||||
curveTargetBeat = 2f;
|
||||
Jukebox.PlayOneShotGame("karateman/rockHit", forcePlay: true);
|
||||
break;
|
||||
case ItemType.Ball:
|
||||
CurrentCurve = ItemCurves[1];
|
||||
curveTargetBeat = 2f;
|
||||
Jukebox.PlayOneShotGame("karateman/soccerHit", forcePlay: true);
|
||||
break;
|
||||
case ItemType.Cooking:
|
||||
CurrentCurve = ItemCurves[1];
|
||||
curveTargetBeat = 2f;
|
||||
Jukebox.PlayOneShotGame("karateman/cookingPot", forcePlay: true);
|
||||
//todo: pot lid
|
||||
break;
|
||||
case ItemType.Alien:
|
||||
CurrentCurve = ItemCurves[1];
|
||||
curveTargetBeat = 2f;
|
||||
Jukebox.PlayOneShotGame("karateman/alienHit", forcePlay: true);
|
||||
break;
|
||||
case ItemType.TacoBell:
|
||||
CurrentCurve = ItemCurves[1];
|
||||
curveTargetBeat = 2f;
|
||||
Jukebox.PlayOneShotGame("karateman/rockHit", forcePlay: true);
|
||||
Jukebox.PlayOneShotGame("karateman/tacobell", forcePlay: true);
|
||||
break;
|
||||
case ItemType.ComboPot1:
|
||||
CurrentCurve = ItemCurves[straight ? 1 : 0];
|
||||
curveTargetBeat = 2f;
|
||||
Jukebox.PlayOneShotGame("karateman/comboHit1", forcePlay: true);
|
||||
break;
|
||||
case ItemType.ComboPot2:
|
||||
CurrentCurve = ItemCurves[0];
|
||||
curveTargetBeat = 2f;
|
||||
Jukebox.PlayOneShotGame("karateman/comboHit1", forcePlay: true);
|
||||
break;
|
||||
case ItemType.ComboPot3:
|
||||
CurrentCurve = ItemCurves[2];
|
||||
curveTargetBeat = 1f;
|
||||
Jukebox.PlayOneShotGame("karateman/comboHit2", forcePlay: true);
|
||||
break;
|
||||
case ItemType.ComboPot4:
|
||||
CurrentCurve = ItemCurves[3];
|
||||
curveTargetBeat = 1f;
|
||||
Jukebox.PlayOneShotGame("karateman/comboHit3", forcePlay: true);
|
||||
break;
|
||||
case ItemType.ComboPot5:
|
||||
CurrentCurve = ItemCurves[4];
|
||||
curveTargetBeat = 1f;
|
||||
Jukebox.PlayOneShotGame("karateman/comboHit3", forcePlay: true);
|
||||
break;
|
||||
case ItemType.ComboBarrel:
|
||||
@ -237,6 +293,8 @@ namespace HeavenStudio.Games.Scripts_KarateMan
|
||||
Jukebox.PlayOneShotGame("karateman/barrelBreak", forcePlay: true);
|
||||
break;
|
||||
default:
|
||||
CurrentCurve = ItemCurves[straight ? 1 : 0];
|
||||
curveTargetBeat = 2f;
|
||||
Jukebox.PlayOneShotGame("karateman/potHit", forcePlay: true);
|
||||
break;
|
||||
}
|
||||
@ -316,13 +374,13 @@ namespace HeavenStudio.Games.Scripts_KarateMan
|
||||
if (GameManager.instance.currentGame != "karateman") return;
|
||||
var joe = KarateMan.instance.Joe;
|
||||
if (status == FlyStatus.Fly && !joe.inCombo) {
|
||||
joe.Punch(ItemPunchHand());
|
||||
bool straight = joe.Punch(ItemPunchHand());
|
||||
if (state <= -1f || state >= 1f) {
|
||||
Jukebox.PlayOneShot("miss");
|
||||
status = FlyStatus.NG;
|
||||
}
|
||||
else {
|
||||
ItemHitEffect();
|
||||
ItemHitEffect(straight);
|
||||
status = FlyStatus.Hit;
|
||||
}
|
||||
}
|
||||
@ -365,7 +423,7 @@ namespace HeavenStudio.Games.Scripts_KarateMan
|
||||
{
|
||||
if (GameManager.instance.currentGame != "karateman") return;
|
||||
var joe = KarateMan.instance.Joe;
|
||||
if (status == FlyStatus.Fly && !joe.inCombo) {
|
||||
if (status == FlyStatus.Fly && !(joe.inKick || joe.wantKick || joe.inCombo)) {
|
||||
joe.inCombo = true;
|
||||
joe.Punch(1);
|
||||
joe.SetComboId(comboId);
|
||||
@ -393,13 +451,13 @@ namespace HeavenStudio.Games.Scripts_KarateMan
|
||||
//WHEN SCORING THIS IS A MISS
|
||||
var joe = KarateMan.instance.Joe;
|
||||
if (status == FlyStatus.Fly && !joe.inCombo) {
|
||||
joe.Punch(ItemPunchHand());
|
||||
bool straight = joe.Punch(ItemPunchHand());
|
||||
if (state <= -1f || state >= 1f) {
|
||||
Jukebox.PlayOneShot("miss");
|
||||
status = FlyStatus.NG;
|
||||
}
|
||||
else {
|
||||
ItemHitEffect();
|
||||
ItemHitEffect(straight);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -452,5 +510,39 @@ namespace HeavenStudio.Games.Scripts_KarateMan
|
||||
if (GameManager.instance.currentGame != "karateman") return;
|
||||
KarateMan.instance.Joe.ForceFailCombo(Conductor.instance.songPositionInBeats);
|
||||
}
|
||||
|
||||
public void KickChargeJustOrNg(PlayerActionEvent caller, float state)
|
||||
{
|
||||
if (GameManager.instance.currentGame != "karateman") return;
|
||||
var joe = KarateMan.instance.Joe;
|
||||
if (status == FlyStatus.Fly && !(joe.inKick || joe.wantKick || joe.inCombo)) {
|
||||
joe.Punch(ItemPunchHand());
|
||||
if (state <= -1f || state >= 1f) {
|
||||
Jukebox.PlayOneShot("miss");
|
||||
status = FlyStatus.NG;
|
||||
}
|
||||
else {
|
||||
//spawn the bomb
|
||||
joe.StartKickCharge(startBeat + 1.25f);
|
||||
ItemHitEffect();
|
||||
status = FlyStatus.Hit;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void KickChargeOut(PlayerActionEvent caller) {}
|
||||
|
||||
public void KickChargeThrough(PlayerActionEvent caller)
|
||||
{
|
||||
if (GameManager.instance.currentGame != "karateman") return;
|
||||
if (status != FlyStatus.Fly || gameObject == null) return;
|
||||
BeatAction.New(gameObject, new List<BeatAction.Action>()
|
||||
{
|
||||
new BeatAction.Action(startBeat + 2f, delegate {
|
||||
//TODO: play miss sound
|
||||
//deduct flow if applicable
|
||||
})
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user