Autoplay began

This commit is contained in:
Braedon
2022-01-22 22:40:53 -05:00
parent 1ed2291844
commit 2b88703e3f
39 changed files with 1579 additions and 306 deletions

View File

@ -20,7 +20,7 @@ namespace RhythmHeavenMania.Games.KarateMan
public GameObject BulbHit;
public bool hitBarrel = false;
private Coroutine kickC;
public Coroutine kickC;
private float barrelBeat;
@ -33,6 +33,8 @@ namespace RhythmHeavenMania.Games.KarateMan
private int currentComboHitInList;
private int comboIndex;
public float comboNormalizedBeat = 0;
public static KarateJoe instance { get; set; }
private void Start()
@ -45,7 +47,7 @@ namespace RhythmHeavenMania.Games.KarateMan
{
if (inCombo)
{
float normalizedBeat = Conductor.instance.GetLoopPositionFromBeat(comboBeat, 1);
comboNormalizedBeat = Conductor.instance.GetLoopPositionFromBeat(comboBeat, 1);
if (hitCombo)
{
@ -53,10 +55,10 @@ namespace RhythmHeavenMania.Games.KarateMan
}
else
{
normalizedBeat += 1;
comboNormalizedBeat += 1;
}
if (normalizedBeat >= 1 && comboIndex < 1)
if (comboNormalizedBeat >= 1 && comboIndex < 1)
{
if (hitCombo)
{
@ -72,7 +74,7 @@ namespace RhythmHeavenMania.Games.KarateMan
comboIndex++;
AnimPlay("PunchLeft");
}
else if (normalizedBeat >= 1.25f && comboIndex < 2)
else if (comboNormalizedBeat >= 1.25f && comboIndex < 2)
{
if (hitCombo)
{
@ -88,7 +90,7 @@ namespace RhythmHeavenMania.Games.KarateMan
comboIndex++;
AnimPlay("PunchRight");
}
else if (normalizedBeat >= 1.5f && comboIndex < 3)
else if (comboNormalizedBeat >= 1.5f && comboIndex < 3)
{
if (hitCombo)
{
@ -100,7 +102,7 @@ namespace RhythmHeavenMania.Games.KarateMan
comboIndex++;
AnimPlay("ComboCrouch");
}
else if (normalizedBeat >= 1.75f && comboIndex < 4)
else if (comboNormalizedBeat >= 1.75f && comboIndex < 4)
{
if (hitCombo)
{
@ -116,7 +118,7 @@ namespace RhythmHeavenMania.Games.KarateMan
comboIndex++;
AnimPlay("ComboKick");
}
else if (normalizedBeat >= 2f && comboIndex < 5)
else if (comboNormalizedBeat >= 2f && comboIndex < 5)
{
if (hitCombo)
{
@ -128,13 +130,13 @@ namespace RhythmHeavenMania.Games.KarateMan
comboIndex++;
AnimPlay("ComboCrouchPunch");
}
else if (normalizedBeat >= 2.05f)
else if (comboNormalizedBeat >= 2.05f)
{
if (hitCombo)
{
if (PlayerInput.AltPressedUp())
{
ComboPow();
// ComboPow(null);
}
}
else
@ -147,75 +149,47 @@ namespace RhythmHeavenMania.Games.KarateMan
}
else
{
if (!inCombo)
if (PlayerInput.AltPressed())
{
Combo();
Combo(null);
}
}
if (hitBarrel)
{
if (PlayerInput.PressedUp())
{
if (kickC != null) StopCoroutine(kickC);
hitBarrel = false;
AnimPlay("Kick");
}
if (Conductor.instance.songPositionInBeats > barrelBeat + 3)
{
if (kickC != null) StopCoroutine(kickC);
hitBarrel = false;
// should be inebetween for this
AnimPlay("Idle");
}
}
else
if (!hitBarrel)
{
if (PlayerInput.Pressed() && !inCombo)
{
Swing();
Swing(null);
}
}
}
private void Combo()
public void Combo(Pot p)
{
var EligibleHits = KarateMan.instance.EligibleCombos;
bool canHit = (EligibleHits.Count > 0) && (currentComboHitInList < EligibleHits.Count);
if (canHit)
{
if (KarateMan.instance.EligibleCombos[currentComboHitInList].perfect)
{
comboBeat = EligibleHits[currentComboHitInList].createBeat;
hitCombo = true;
// Debug.Break();
}
else
{
comboBeat = Conductor.instance.songPositionInBeats;
hitCombo = false;
}
}
else
if (p == null)
{
comboBeat = Conductor.instance.songPositionInBeats;
hitCombo = false;
}
else
{
comboBeat = p.createBeat;
hitCombo = true;
}
inCombo = true;
}
private void ComboPow()
public void ComboPow(Pot p, bool overrideState = false)
{
if (!hitCombo || !inCombo || !hitCombo && !inCombo) return;
anim.Play("Pow", 0, 0);
if (currentComboPots[comboPotIndex].state.perfect)
/*if (currentComboPots[comboPotIndex].state.perfect)
{
BarrelDestroy(currentComboPots[comboPotIndex], true);
// BarrelDestroy(currentComboPots[comboPotIndex], true);
HitEffectF(currentComboPots[comboPotIndex].Holder.transform.localPosition);
Destroy(currentComboPots[comboPotIndex].gameObject);
Jukebox.PlayOneShotGame("karateman/comboHit4");
@ -224,6 +198,21 @@ namespace RhythmHeavenMania.Games.KarateMan
{
Jukebox.PlayOneShot("miss");
currentComboPots[comboPotIndex].Miss();
}*/
if (p != null)
{
if (p.state.perfect || overrideState)
{
p.BarrelDestroy(true);
HitEffectF(p.Holder.transform.localPosition);
Destroy(p.gameObject);
Jukebox.PlayOneShotGame("karateman/comboHit4");
}
else if (p.state.notPerfect())
{
p.Miss();
}
}
ResetCombo();
@ -239,7 +228,7 @@ namespace RhythmHeavenMania.Games.KarateMan
currentComboPots.Clear();
}
private IEnumerator PrepareKick()
public IEnumerator PrepareKick()
{
barrelBeat = Conductor.instance.songPositionInBeats;
hitBarrel = true;
@ -247,70 +236,43 @@ namespace RhythmHeavenMania.Games.KarateMan
AnimPlay("KickPrepare");
}
private void Swing()
public void ResetKick()
{
var EligibleHits = KarateMan.instance.EligibleHits;
bool canHit = (EligibleHits.Count > 0) && (currentHitInList < EligibleHits.Count);
if (kickC != null)
{
StopCoroutine(kickC);
}
hitBarrel = false;
}
public void Swing(Pot p)
{
bool punchLeft = true;
int events = KarateMan.instance.MultipleEventsAtOnce();
for (int pt = 0; pt < events; pt++)
if (p == null)
{
if (canHit)
{
Pot p = EligibleHits[currentHitInList].gameObject.GetComponent<Pot>();
if (p.type == 2 || p.type == 3 || p.type == 4)
{
punchLeft = false;
}
else
{
punchLeft = true;
}
if (KarateMan.instance.EligibleHits[currentHitInList].perfect)
{
Jukebox.PlayOneShotGame(p.hitSnd);
p.Hit();
HitEffectF(HitEffect.transform.localPosition);
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;
case 4:
if (kickC != null) StopCoroutine(kickC);
kickC = StartCoroutine(PrepareKick());
BarrelDestroy(p, false);
break;
}
}
else
{
Jukebox.PlayOneShot("miss");
p.Miss();
}
p.isEligible = false;
p.RemoveObject(currentHitInList);
}
}
if (!canHit)
Jukebox.PlayOneShotGame("karateman/swingNoHit");
}
else
{
if (p.type == 2 || p.type == 3 || p.type == 4)
{
punchLeft = false;
}
else
{
punchLeft = true;
}
if (p.type == 4)
{
if (kickC != null) StopCoroutine(kickC);
kickC = StartCoroutine(PrepareKick());
}
if (!p.combo)
HitEffectF(HitEffect.transform.localPosition);
}
if (punchLeft)
AnimPlay("PunchLeft");
@ -332,71 +294,5 @@ namespace RhythmHeavenMania.Games.KarateMan
anim.Play(name, 0, 0);
anim.speed = 1;
}
private void BarrelDestroy(Pot p, bool combo)
{
for (int i = 0; i < 8; i++)
{
GameObject be = new GameObject();
be.transform.localPosition = p.Holder.transform.localPosition;
be.transform.parent = this.transform.parent;
be.transform.localScale = p.Holder.transform.localScale;
BarrelDestroyEffect bde = be.AddComponent<BarrelDestroyEffect>();
Vector3 pos = be.transform.localPosition;
SpriteRenderer sprite = be.AddComponent<SpriteRenderer>();
bde.shadow = Instantiate(p.Shadow, transform.parent);
bde.shadow.transform.position = p.Shadow.transform.position;
bde.shadow.transform.localScale = p.Shadow.transform.lossyScale;
bde.index = i;
bde.combo = combo;
switch (i)
{
case 0:
be.transform.localPosition = new Vector3(pos.x, pos.y + 1.25f);
sprite.sortingOrder = 35;
bde.spriteIndex = 3;
break;
case 1:
be.transform.localPosition = new Vector3(pos.x, pos.y + -0.55f);
sprite.sortingOrder = 31;
bde.spriteIndex = 3;
break;
case 2:
be.transform.localPosition = new Vector3(pos.x - 0.8f, pos.y + 0.45f);
sprite.sortingOrder = 32;
bde.spriteIndex = 0;
break;
case 3:
be.transform.localPosition = new Vector3(pos.x - 0.5f, pos.y + 0.45f);
sprite.sortingOrder = 33;
bde.spriteIndex = 1;
break;
case 4:
be.transform.localPosition = new Vector3(pos.x, pos.y + 0.45f);
sprite.sortingOrder = 34;
bde.spriteIndex = 2;
break;
case 5:
be.transform.localPosition = new Vector3(pos.x + 0.5f, pos.y + 0.45f);
sprite.sortingOrder = 33;
sprite.flipX = true;
bde.spriteIndex = 1;
break;
case 6:
be.transform.localPosition = new Vector3(pos.x + 0.8f, pos.y + 0.45f);
sprite.sortingOrder = 32;
sprite.flipX = true;
bde.spriteIndex = 0;
break;
case 7:
be.transform.localPosition = new Vector3(pos.x, pos.y + 1.25f);
sprite.sortingOrder = 39;
bde.spriteIndex = 4;
break;
}
}
}
}
}