Karate Man Kick started

This commit is contained in:
Starpelly
2022-01-01 13:54:17 -05:00
parent fc3cb73bdf
commit 2c2d43ac17
22 changed files with 2706 additions and 41 deletions

View File

@ -15,7 +15,6 @@ namespace RhythmHeavenMania.Games.KarateMan
public GameObject Sprite;
[SerializeField] private GameObject Shadow;
public bool isThrown;
public bool isHit = false;
@ -26,12 +25,17 @@ namespace RhythmHeavenMania.Games.KarateMan
public AnimationCurve hitCurve;
public AnimationCurve hitCurveX;
public AnimationCurve missCurve;
public int type;
public string hitSnd;
private float hitLength;
private float lastRot;
public bool kick;
private void Start()
{
PlayerActionInit(this.gameObject);
@ -65,33 +69,69 @@ namespace RhythmHeavenMania.Games.KarateMan
lastPos = Holder.transform.localPosition;
lastShadowX = Shadow.transform.localPosition.x;
lastRot = Holder.transform.GetChild(0).eulerAngles.z;
}
else if (isHit)
if (!isHit && !isThrown)
{
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));
float normalizedBeatAnim = Conductor.instance.GetLoopPositionFromBeat(hitBeat, 1.5f);
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;
Holder.transform.localPosition = new Vector3(Mathf.Lerp(lastPos.x, 0.9f, normalizedBeatAnim), Mathf.Lerp(lastPos.y, -3.43f, missCurve.Evaluate(normalizedBeatAnim)));
Holder.transform.GetChild(0).transform.eulerAngles = new Vector3(0, 0, Mathf.Lerp(lastRot, lastRot - 523.203f, normalizedBeatAnim));
Shadow.transform.localPosition = new Vector3(Mathf.Lerp(lastShadowX, 0.9f, normalizedBeatAnim), Shadow.transform.localPosition.y);
}
if (kick == false)
{
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()
{
if (!kick)
{
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;
}
else if (kick)
{
Instantiate(KarateMan.instance.Bomb, this.transform.parent).SetActive(true);
Destroy(this.gameObject);
}
}
public void Miss()
{
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;
isHit = false;
isThrown = false;
isHit = true;
anim.enabled = false;
Sprite.GetComponent<SpriteRenderer>().sortingOrder = 49;
}
}