mirror of
https://github.com/RHeavenStudio/HeavenStudio.git
synced 2025-06-12 13:27:41 +02:00
Karate Man animation fixes
This commit is contained in:
13
Assets/Scripts/Destroy.cs
Normal file
13
Assets/Scripts/Destroy.cs
Normal file
@ -0,0 +1,13 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class Destroy : MonoBehaviour
|
||||
{
|
||||
public float time;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
Destroy(this.gameObject, time);
|
||||
}
|
||||
}
|
11
Assets/Scripts/Destroy.cs.meta
Normal file
11
Assets/Scripts/Destroy.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 54588eb7ee0680643aeaf61dcf609903
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -97,8 +97,10 @@ namespace RhythmHeavenMania
|
||||
}),
|
||||
new MiniGame("karateman", "F6C135", new List<GameAction>()
|
||||
{
|
||||
new GameAction("bop", delegate { print("bop"); }, true ),
|
||||
new GameAction("pot", delegate { KarateMan.instance.Shoot(currentBeat); }, true ),
|
||||
new GameAction("bop", delegate { KarateMan.instance.Bop(); }, true ),
|
||||
new GameAction("pot", delegate { KarateMan.instance.Shoot(currentBeat, 0); }, true ),
|
||||
new GameAction("bulb", delegate { KarateMan.instance.Shoot(currentBeat, 1); }, true ),
|
||||
new GameAction("rock", delegate { KarateMan.instance.Shoot(currentBeat, 2); }, true ),
|
||||
// new GameAction("cameraZoom", delegate { Spaceball.instance.CameraZoom(currentBeat, currentLength, currentValA); } ),
|
||||
})
|
||||
};
|
||||
|
@ -8,10 +8,17 @@ namespace RhythmHeavenMania.Games.KarateMan
|
||||
{
|
||||
public class KarateJoe : MonoBehaviour
|
||||
{
|
||||
private Animator anim;
|
||||
public Animator anim;
|
||||
|
||||
private int currentHitInList = 0;
|
||||
|
||||
public GameObject HitEffect;
|
||||
|
||||
[Header("Particles")]
|
||||
public ParticleSystem HitParticle;
|
||||
public ParticleSystem RockParticle;
|
||||
public GameObject BulbHit;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
anim = GetComponent<Animator>();
|
||||
@ -30,24 +37,63 @@ namespace RhythmHeavenMania.Games.KarateMan
|
||||
var EligibleHits = KarateMan.instance.EligibleHits;
|
||||
bool canHit = (EligibleHits.Count > 0) && (currentHitInList < EligibleHits.Count);
|
||||
|
||||
bool punchLeft = true;
|
||||
|
||||
if (canHit)
|
||||
{
|
||||
Pot p = EligibleHits[currentHitInList].gameObject.GetComponent<Pot>();
|
||||
|
||||
if (p.type == 2)
|
||||
{
|
||||
punchLeft = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
punchLeft = true;
|
||||
}
|
||||
|
||||
if (KarateMan.instance.EligibleHits[currentHitInList].perfect)
|
||||
{
|
||||
Jukebox.PlayOneShotGame("karateman/potHit");
|
||||
Jukebox.PlayOneShotGame(p.hitSnd);
|
||||
p.Hit();
|
||||
|
||||
GameObject hit = Instantiate(HitEffect);
|
||||
hit.transform.parent = HitEffect.transform.parent;
|
||||
hit.SetActive(true);
|
||||
|
||||
switch (p.type)
|
||||
{
|
||||
case 0:
|
||||
HitParticle.Play();
|
||||
break;
|
||||
case 1:
|
||||
GameObject bulbHit = Instantiate(BulbHit);
|
||||
bulbHit.transform.parent = BulbHit.transform.parent;
|
||||
bulbHit.SetActive(true);
|
||||
Destroy(bulbHit, 0.7f);
|
||||
break;
|
||||
case 2:
|
||||
RockParticle.Play();
|
||||
break;
|
||||
}
|
||||
|
||||
Destroy(hit, 0.04f);
|
||||
}
|
||||
else
|
||||
{
|
||||
Jukebox.PlayOneShot("miss");
|
||||
}
|
||||
EligibleHits[currentHitInList].gameObject.GetComponent<Pot>().enabled = false;
|
||||
EligibleHits[currentHitInList].gameObject.GetComponent<Pot>().RemoveObject(currentHitInList, EligibleHits);
|
||||
p.isEligible = false;
|
||||
p.RemoveObject(currentHitInList, EligibleHits);
|
||||
}
|
||||
else
|
||||
{
|
||||
Jukebox.PlayOneShotGame("karateman/swingNoHit");
|
||||
}
|
||||
anim.Play("PunchLeft", 0, 0);
|
||||
if (punchLeft)
|
||||
anim.Play("PunchLeft", 0, 0);
|
||||
else
|
||||
anim.Play("PunchRight", 0, 0);
|
||||
}
|
||||
}
|
||||
}
|
@ -9,22 +9,51 @@ namespace RhythmHeavenMania.Games.KarateMan
|
||||
public class KarateMan : Minigame
|
||||
{
|
||||
public GameObject Pot;
|
||||
public KarateJoe KarateJoe;
|
||||
|
||||
public static KarateMan instance { get; set; }
|
||||
|
||||
public Sprite[] ObjectSprites;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
instance = this;
|
||||
}
|
||||
|
||||
public void Shoot(float beat)
|
||||
public void Shoot(float beat, int type)
|
||||
{
|
||||
GameObject pot = Instantiate(Pot);
|
||||
pot.transform.parent = Pot.transform.parent;
|
||||
pot.SetActive(true);
|
||||
pot.GetComponent<Pot>().startBeat = beat;
|
||||
|
||||
Jukebox.PlayOneShotGame("karateman/objectOut");
|
||||
Pot p = pot.GetComponent<Pot>();
|
||||
|
||||
pot.SetActive(true);
|
||||
p.startBeat = beat;
|
||||
p.createBeat = beat;
|
||||
p.isThrown = true;
|
||||
p.type = type;
|
||||
p.Sprite.GetComponent<SpriteRenderer>().sprite = ObjectSprites[type];
|
||||
|
||||
switch (type)
|
||||
{
|
||||
case 0:
|
||||
Jukebox.PlayOneShotGame("karateman/objectOut");
|
||||
p.hitSnd = "karateman/potHit";
|
||||
break;
|
||||
case 1:
|
||||
Jukebox.PlayOneShotGame("karateman/lightbulbOut");
|
||||
p.hitSnd = "karateman/lightbulbHit";
|
||||
break;
|
||||
case 2:
|
||||
Jukebox.PlayOneShotGame("karateman/objectOut");
|
||||
p.hitSnd = "karateman/rockHit";
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public void Bop()
|
||||
{
|
||||
KarateJoe.anim.Play("Bop", 0, 0);
|
||||
}
|
||||
}
|
||||
}
|
@ -7,10 +7,30 @@ namespace RhythmHeavenMania.Games.KarateMan
|
||||
public class Pot : PlayerActionObject
|
||||
{
|
||||
public float startBeat;
|
||||
private Animator anim;
|
||||
public float createBeat;
|
||||
[HideInInspector] public Animator anim;
|
||||
|
||||
[SerializeField]
|
||||
private GameObject Sprite;
|
||||
public GameObject Holder;
|
||||
private GameObject newHolder;
|
||||
public GameObject Sprite;
|
||||
[SerializeField] private GameObject Shadow;
|
||||
|
||||
|
||||
public bool isThrown;
|
||||
public bool isHit = false;
|
||||
|
||||
public float hitBeat;
|
||||
|
||||
private Vector3 lastPos;
|
||||
private float lastShadowX;
|
||||
|
||||
public AnimationCurve hitCurve;
|
||||
public AnimationCurve hitCurveX;
|
||||
|
||||
public int type;
|
||||
public string hitSnd;
|
||||
|
||||
private float hitLength;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
@ -18,17 +38,61 @@ namespace RhythmHeavenMania.Games.KarateMan
|
||||
anim = GetComponent<Animator>();
|
||||
|
||||
Sprite.transform.eulerAngles = new Vector3(0, 0, Random.Range(0, 360));
|
||||
isEligible = true;
|
||||
|
||||
if (type == 2)
|
||||
hitLength = 23.45f;
|
||||
else
|
||||
hitLength = 16f;
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
float normalizedBeatAnim = Conductor.instance.GetLoopPositionFromBeat(startBeat, 2.15f);
|
||||
anim.Play("PotThrow", 0, normalizedBeatAnim);
|
||||
anim.speed = 0;
|
||||
float time2Destroy = Conductor.instance.GetLoopPositionFromBeat(createBeat, 4);
|
||||
|
||||
float normalizedBeat = Conductor.instance.GetLoopPositionFromBeat(startBeat, 1);
|
||||
if (time2Destroy >= 1)
|
||||
Destroy(this.gameObject);
|
||||
|
||||
StateCheck(normalizedBeat, KarateMan.instance.EligibleHits);
|
||||
if (isThrown)
|
||||
{
|
||||
float normalizedBeatAnim = Conductor.instance.GetLoopPositionFromBeat(startBeat, 2.15f);
|
||||
anim.Play("PotThrow", 0, normalizedBeatAnim);
|
||||
anim.speed = 0;
|
||||
|
||||
float normalizedBeat = Conductor.instance.GetLoopPositionFromBeat(startBeat, 1);
|
||||
|
||||
StateCheck(normalizedBeat, KarateMan.instance.EligibleHits);
|
||||
|
||||
lastPos = Holder.transform.localPosition;
|
||||
lastShadowX = Shadow.transform.localPosition.x;
|
||||
}
|
||||
else if (isHit)
|
||||
{
|
||||
float normalizedBeatAnim = Conductor.instance.GetLoopPositionFromBeat(hitBeat, 1.15f);
|
||||
var y = Mathf.Lerp(lastPos.y, -3.27f, hitCurve.Evaluate(normalizedBeatAnim));
|
||||
var x = Mathf.Lerp(lastPos.x, hitLength, hitCurveX.Evaluate(normalizedBeatAnim));
|
||||
newHolder.transform.localPosition = new Vector3(transform.localPosition.x, Mathf.Lerp(0, 0.55f, Conductor.instance.GetLoopPositionFromBeat(hitBeat, 0.45f)));
|
||||
Holder.transform.localPosition = new Vector3(x, y);
|
||||
Shadow.transform.localPosition = new Vector3(Mathf.Lerp(lastShadowX, hitLength, hitCurveX.Evaluate(normalizedBeatAnim)), Shadow.transform.localPosition.y);
|
||||
// anim.Play("PotHit", 0, normalizedBeatAnim);
|
||||
// anim.speed = 0;
|
||||
}
|
||||
}
|
||||
|
||||
public void Hit()
|
||||
{
|
||||
newHolder = new GameObject();
|
||||
newHolder.transform.parent = this.gameObject.transform;
|
||||
Holder.transform.parent = newHolder.transform;
|
||||
Holder.transform.GetChild(0).gameObject.AddComponent<Rotate>().rotateSpeed = -7 * Conductor.instance.songBpm;
|
||||
|
||||
hitBeat = Conductor.instance.songPositionInBeats;
|
||||
|
||||
anim.enabled = false;
|
||||
isThrown = false;
|
||||
isHit = true;
|
||||
|
||||
Sprite.GetComponent<SpriteRenderer>().sortingOrder = 49;
|
||||
}
|
||||
}
|
||||
}
|
@ -9,6 +9,7 @@ namespace RhythmHeavenMania.Games
|
||||
public bool inList = false;
|
||||
public int lastState;
|
||||
private Minigame.Eligible e = new Minigame.Eligible();
|
||||
public bool isEligible;
|
||||
|
||||
public void PlayerActionInit(GameObject g)
|
||||
{
|
||||
@ -18,6 +19,7 @@ namespace RhythmHeavenMania.Games
|
||||
// could possibly add support for custom early, perfect, and end times if needed.
|
||||
public void StateCheck(float normalizedBeat, List<Minigame.Eligible> eligibleHitsList)
|
||||
{
|
||||
if (!isEligible) return;
|
||||
if (normalizedBeat > Minigame.EarlyTime() && normalizedBeat < Minigame.PerfectTime() && lastState == 0)
|
||||
{
|
||||
MakeEligible(true, false, false, eligibleHitsList);
|
||||
|
Reference in New Issue
Block a user