2021-12-29 06:52:48 +00:00
|
|
|
using System.Collections;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
|
|
using RhythmHeavenMania.Util;
|
|
|
|
|
|
|
|
namespace RhythmHeavenMania.Games.KarateMan
|
|
|
|
{
|
|
|
|
public class KarateJoe : MonoBehaviour
|
|
|
|
{
|
2021-12-30 08:26:18 +00:00
|
|
|
public Animator anim;
|
2021-12-29 06:52:48 +00:00
|
|
|
|
|
|
|
private int currentHitInList = 0;
|
|
|
|
|
2021-12-30 08:26:18 +00:00
|
|
|
public GameObject HitEffect;
|
|
|
|
|
|
|
|
[Header("Particles")]
|
|
|
|
public ParticleSystem HitParticle;
|
|
|
|
public ParticleSystem RockParticle;
|
|
|
|
public GameObject BulbHit;
|
|
|
|
|
2022-01-02 12:09:15 +00:00
|
|
|
public bool hitBarrel = false;
|
2022-01-23 03:40:53 +00:00
|
|
|
public Coroutine kickC;
|
2022-01-02 12:09:15 +00:00
|
|
|
|
|
|
|
private float barrelBeat;
|
|
|
|
|
2022-01-20 01:48:52 +00:00
|
|
|
private bool inCombo;
|
|
|
|
private bool hitCombo;
|
|
|
|
private float comboBeat;
|
|
|
|
|
|
|
|
public List<Pot> currentComboPots = new List<Pot>();
|
|
|
|
private int comboPotIndex;
|
|
|
|
private int currentComboHitInList;
|
|
|
|
private int comboIndex;
|
|
|
|
|
2022-01-23 03:40:53 +00:00
|
|
|
public float comboNormalizedBeat = 0;
|
|
|
|
|
2022-01-02 12:09:15 +00:00
|
|
|
public static KarateJoe instance { get; set; }
|
|
|
|
|
2021-12-29 06:52:48 +00:00
|
|
|
private void Start()
|
|
|
|
{
|
2022-01-02 12:09:15 +00:00
|
|
|
instance = this;
|
2021-12-29 06:52:48 +00:00
|
|
|
anim = GetComponent<Animator>();
|
|
|
|
}
|
|
|
|
|
|
|
|
private void Update()
|
|
|
|
{
|
2022-01-20 01:48:52 +00:00
|
|
|
if (inCombo)
|
|
|
|
{
|
2022-01-23 03:40:53 +00:00
|
|
|
comboNormalizedBeat = Conductor.instance.GetLoopPositionFromBeat(comboBeat, 1);
|
2022-01-20 01:48:52 +00:00
|
|
|
|
|
|
|
if (hitCombo)
|
|
|
|
{
|
|
|
|
if (currentComboPots[comboPotIndex] == null) return;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2022-01-23 03:40:53 +00:00
|
|
|
comboNormalizedBeat += 1;
|
2022-01-20 01:48:52 +00:00
|
|
|
}
|
|
|
|
|
2022-01-23 03:40:53 +00:00
|
|
|
if (comboNormalizedBeat >= 1 && comboIndex < 1)
|
2022-01-20 01:48:52 +00:00
|
|
|
{
|
|
|
|
if (hitCombo)
|
|
|
|
{
|
|
|
|
currentComboPots[comboPotIndex].Hit();
|
2022-01-20 07:26:53 +00:00
|
|
|
HitEffectF(currentComboPots[comboPotIndex].Holder.transform.localPosition);
|
2022-01-20 01:48:52 +00:00
|
|
|
comboPotIndex++;
|
|
|
|
Jukebox.PlayOneShotGame("karateman/comboHit1");
|
|
|
|
}
|
2022-01-21 01:24:30 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
Jukebox.PlayOneShotGame("karateman/swingNoHit");
|
|
|
|
}
|
2022-01-20 01:48:52 +00:00
|
|
|
comboIndex++;
|
2022-01-21 07:09:32 +00:00
|
|
|
AnimPlay("PunchLeft");
|
2022-01-20 01:48:52 +00:00
|
|
|
}
|
2022-01-23 03:40:53 +00:00
|
|
|
else if (comboNormalizedBeat >= 1.25f && comboIndex < 2)
|
2022-01-20 01:48:52 +00:00
|
|
|
{
|
|
|
|
if (hitCombo)
|
|
|
|
{
|
|
|
|
currentComboPots[comboPotIndex].Hit();
|
2022-01-20 07:26:53 +00:00
|
|
|
HitEffectF(currentComboPots[comboPotIndex].Holder.transform.localPosition);
|
2022-01-20 01:48:52 +00:00
|
|
|
comboPotIndex++;
|
|
|
|
Jukebox.PlayOneShotGame("karateman/comboHit1");
|
|
|
|
}
|
2022-01-21 01:24:30 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
Jukebox.PlayOneShotGame("karateman/swingNoHit_Alt");
|
|
|
|
}
|
2022-01-20 01:48:52 +00:00
|
|
|
comboIndex++;
|
2022-01-21 07:09:32 +00:00
|
|
|
AnimPlay("PunchRight");
|
2022-01-20 01:48:52 +00:00
|
|
|
}
|
2022-01-23 03:40:53 +00:00
|
|
|
else if (comboNormalizedBeat >= 1.5f && comboIndex < 3)
|
2022-01-20 01:48:52 +00:00
|
|
|
{
|
|
|
|
if (hitCombo)
|
|
|
|
{
|
|
|
|
currentComboPots[comboPotIndex].Hit();
|
2022-01-20 07:26:53 +00:00
|
|
|
HitEffectF(currentComboPots[comboPotIndex].Holder.transform.localPosition);
|
2022-01-20 01:48:52 +00:00
|
|
|
comboPotIndex++;
|
|
|
|
Jukebox.PlayOneShotGame("karateman/comboHit2");
|
|
|
|
}
|
|
|
|
comboIndex++;
|
2022-01-21 07:09:32 +00:00
|
|
|
AnimPlay("ComboCrouch");
|
2022-01-20 01:48:52 +00:00
|
|
|
}
|
2022-01-23 03:40:53 +00:00
|
|
|
else if (comboNormalizedBeat >= 1.75f && comboIndex < 4)
|
2022-01-20 01:48:52 +00:00
|
|
|
{
|
|
|
|
if (hitCombo)
|
|
|
|
{
|
|
|
|
currentComboPots[comboPotIndex].Hit();
|
2022-01-20 07:26:53 +00:00
|
|
|
HitEffectF(currentComboPots[comboPotIndex].Holder.transform.localPosition);
|
2022-01-20 01:48:52 +00:00
|
|
|
comboPotIndex++;
|
|
|
|
Jukebox.PlayOneShotGame("karateman/comboHit3");
|
|
|
|
}
|
2022-01-21 01:24:30 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
Jukebox.PlayOneShotGame("karateman/comboMiss");
|
|
|
|
}
|
2022-01-20 01:48:52 +00:00
|
|
|
comboIndex++;
|
2022-01-21 07:09:32 +00:00
|
|
|
AnimPlay("ComboKick");
|
2022-01-20 01:48:52 +00:00
|
|
|
}
|
2022-01-23 03:40:53 +00:00
|
|
|
else if (comboNormalizedBeat >= 2f && comboIndex < 5)
|
2022-01-20 01:48:52 +00:00
|
|
|
{
|
|
|
|
if (hitCombo)
|
|
|
|
{
|
|
|
|
currentComboPots[comboPotIndex].Hit();
|
2022-01-20 07:26:53 +00:00
|
|
|
HitEffectF(currentComboPots[comboPotIndex].Holder.transform.localPosition);
|
2022-01-20 01:48:52 +00:00
|
|
|
comboPotIndex++;
|
|
|
|
Jukebox.PlayOneShotGame("karateman/comboHit3");
|
|
|
|
}
|
|
|
|
comboIndex++;
|
2022-01-21 07:09:32 +00:00
|
|
|
AnimPlay("ComboCrouchPunch");
|
2022-01-20 01:48:52 +00:00
|
|
|
}
|
2022-01-23 03:40:53 +00:00
|
|
|
else if (comboNormalizedBeat >= 2.05f)
|
2022-01-20 01:48:52 +00:00
|
|
|
{
|
|
|
|
if (hitCombo)
|
|
|
|
{
|
|
|
|
if (PlayerInput.AltPressedUp())
|
|
|
|
{
|
2022-01-23 03:40:53 +00:00
|
|
|
// ComboPow(null);
|
2022-01-20 01:48:52 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// fail anim
|
2022-01-21 07:09:32 +00:00
|
|
|
AnimPlay("ComboMiss");
|
2022-01-20 07:26:53 +00:00
|
|
|
ResetCombo();
|
2022-01-20 01:48:52 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2022-01-23 03:40:53 +00:00
|
|
|
if (!inCombo)
|
2022-01-20 01:48:52 +00:00
|
|
|
if (PlayerInput.AltPressed())
|
|
|
|
{
|
2022-01-23 03:40:53 +00:00
|
|
|
Combo(null);
|
2022-01-20 01:48:52 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-01-23 03:40:53 +00:00
|
|
|
if (!hitBarrel)
|
2022-01-02 12:09:15 +00:00
|
|
|
{
|
2022-01-20 01:48:52 +00:00
|
|
|
if (PlayerInput.Pressed() && !inCombo)
|
2022-01-02 12:09:15 +00:00
|
|
|
{
|
2022-01-23 03:40:53 +00:00
|
|
|
Swing(null);
|
2022-01-02 12:09:15 +00:00
|
|
|
}
|
2021-12-29 06:52:48 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-01-23 03:40:53 +00:00
|
|
|
public void Combo(Pot p)
|
2022-01-20 01:48:52 +00:00
|
|
|
{
|
2022-01-23 03:40:53 +00:00
|
|
|
if (p == null)
|
2022-01-20 01:48:52 +00:00
|
|
|
{
|
2022-01-23 03:40:53 +00:00
|
|
|
comboBeat = Conductor.instance.songPositionInBeats;
|
|
|
|
hitCombo = false;
|
2022-01-20 01:48:52 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2022-01-23 03:40:53 +00:00
|
|
|
comboBeat = p.createBeat;
|
|
|
|
hitCombo = true;
|
2022-01-20 01:48:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
inCombo = true;
|
|
|
|
}
|
|
|
|
|
2022-01-23 03:40:53 +00:00
|
|
|
public void ComboPow(Pot p, bool overrideState = false)
|
2022-01-20 01:48:52 +00:00
|
|
|
{
|
|
|
|
if (!hitCombo || !inCombo || !hitCombo && !inCombo) return;
|
|
|
|
|
|
|
|
anim.Play("Pow", 0, 0);
|
|
|
|
|
2022-01-23 03:40:53 +00:00
|
|
|
/*if (currentComboPots[comboPotIndex].state.perfect)
|
2022-01-20 01:48:52 +00:00
|
|
|
{
|
2022-01-23 03:40:53 +00:00
|
|
|
// BarrelDestroy(currentComboPots[comboPotIndex], true);
|
2022-01-20 07:26:53 +00:00
|
|
|
HitEffectF(currentComboPots[comboPotIndex].Holder.transform.localPosition);
|
2022-01-20 01:48:52 +00:00
|
|
|
Destroy(currentComboPots[comboPotIndex].gameObject);
|
|
|
|
Jukebox.PlayOneShotGame("karateman/comboHit4");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
Jukebox.PlayOneShot("miss");
|
|
|
|
currentComboPots[comboPotIndex].Miss();
|
2022-01-23 03:40:53 +00:00
|
|
|
}*/
|
|
|
|
|
|
|
|
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();
|
|
|
|
}
|
2022-01-20 01:48:52 +00:00
|
|
|
}
|
|
|
|
|
2022-01-20 07:26:53 +00:00
|
|
|
ResetCombo();
|
|
|
|
}
|
|
|
|
|
|
|
|
private void ResetCombo()
|
|
|
|
{
|
2022-01-20 01:48:52 +00:00
|
|
|
hitCombo = false;
|
|
|
|
inCombo = false;
|
|
|
|
comboPotIndex = 0;
|
|
|
|
comboIndex = 0;
|
|
|
|
currentComboHitInList = 0;
|
|
|
|
currentComboPots.Clear();
|
|
|
|
}
|
|
|
|
|
2022-01-23 03:40:53 +00:00
|
|
|
public IEnumerator PrepareKick()
|
2022-01-02 12:09:15 +00:00
|
|
|
{
|
|
|
|
barrelBeat = Conductor.instance.songPositionInBeats;
|
|
|
|
hitBarrel = true;
|
|
|
|
yield return new WaitForSeconds(0.17f);
|
2022-01-21 07:09:32 +00:00
|
|
|
AnimPlay("KickPrepare");
|
2022-01-02 12:09:15 +00:00
|
|
|
}
|
|
|
|
|
2022-01-23 03:40:53 +00:00
|
|
|
public void ResetKick()
|
2021-12-29 06:52:48 +00:00
|
|
|
{
|
2022-01-23 03:40:53 +00:00
|
|
|
if (kickC != null)
|
|
|
|
{
|
|
|
|
StopCoroutine(kickC);
|
|
|
|
}
|
|
|
|
hitBarrel = false;
|
|
|
|
}
|
2021-12-29 06:52:48 +00:00
|
|
|
|
2022-01-23 03:40:53 +00:00
|
|
|
public void Swing(Pot p)
|
|
|
|
{
|
2021-12-30 08:26:18 +00:00
|
|
|
bool punchLeft = true;
|
|
|
|
|
2022-01-23 03:40:53 +00:00
|
|
|
if (p == null)
|
2022-01-17 05:00:26 +00:00
|
|
|
{
|
2022-01-23 03:40:53 +00:00
|
|
|
Jukebox.PlayOneShotGame("karateman/swingNoHit");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (p.type == 2 || p.type == 3 || p.type == 4)
|
2021-12-29 06:52:48 +00:00
|
|
|
{
|
2022-01-23 03:40:53 +00:00
|
|
|
punchLeft = false;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
punchLeft = true;
|
|
|
|
}
|
2022-01-17 05:00:26 +00:00
|
|
|
|
2022-01-23 03:40:53 +00:00
|
|
|
if (p.type == 4)
|
|
|
|
{
|
|
|
|
if (kickC != null) StopCoroutine(kickC);
|
|
|
|
kickC = StartCoroutine(PrepareKick());
|
2021-12-29 06:52:48 +00:00
|
|
|
}
|
2022-01-17 19:23:18 +00:00
|
|
|
|
2022-01-23 03:40:53 +00:00
|
|
|
if (!p.combo)
|
|
|
|
HitEffectF(HitEffect.transform.localPosition);
|
|
|
|
}
|
2022-01-17 19:23:18 +00:00
|
|
|
|
|
|
|
if (punchLeft)
|
2022-01-21 07:09:32 +00:00
|
|
|
AnimPlay("PunchLeft");
|
2022-01-17 19:23:18 +00:00
|
|
|
else
|
2022-01-21 07:09:32 +00:00
|
|
|
AnimPlay("PunchRight");
|
2021-12-29 06:52:48 +00:00
|
|
|
}
|
2022-01-03 15:15:48 +00:00
|
|
|
|
|
|
|
public void HitEffectF(Vector3 pos)
|
|
|
|
{
|
|
|
|
GameObject hit = Instantiate(HitEffect);
|
|
|
|
hit.transform.parent = HitEffect.transform.parent;
|
|
|
|
hit.transform.localPosition = pos;
|
|
|
|
hit.SetActive(true);
|
2022-01-19 05:40:49 +00:00
|
|
|
Destroy(hit, 0.06f);
|
2022-01-03 15:15:48 +00:00
|
|
|
}
|
2022-01-20 01:48:52 +00:00
|
|
|
|
2022-01-21 07:09:32 +00:00
|
|
|
public void AnimPlay(string name)
|
|
|
|
{
|
|
|
|
anim.Play(name, 0, 0);
|
|
|
|
anim.speed = 1;
|
|
|
|
}
|
2021-12-29 06:52:48 +00:00
|
|
|
}
|
|
|
|
}
|