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 KarateMan : Minigame
|
|
|
|
{
|
2022-01-01 18:54:17 +00:00
|
|
|
public GameObject Pot, Bomb;
|
2021-12-30 08:26:18 +00:00
|
|
|
public KarateJoe KarateJoe;
|
2021-12-29 06:52:48 +00:00
|
|
|
|
|
|
|
public static KarateMan instance { get; set; }
|
|
|
|
|
2021-12-30 08:26:18 +00:00
|
|
|
public Sprite[] ObjectSprites;
|
2022-01-03 15:15:48 +00:00
|
|
|
public Sprite[] BarrelSprites;
|
2021-12-30 08:26:18 +00:00
|
|
|
|
2021-12-30 12:17:22 +00:00
|
|
|
public List<BGSpriteC> BGSprites;
|
|
|
|
public SpriteRenderer BGSprite;
|
|
|
|
|
|
|
|
private bool bgEnabled;
|
2022-01-19 05:40:49 +00:00
|
|
|
private float newBeat, newBeatBop;
|
2021-12-30 12:17:22 +00:00
|
|
|
|
2022-01-03 22:42:43 +00:00
|
|
|
private float bopLength;
|
|
|
|
private float bopBeat;
|
|
|
|
|
2022-01-19 05:40:49 +00:00
|
|
|
private float bgBeat;
|
|
|
|
|
2021-12-30 12:17:22 +00:00
|
|
|
[System.Serializable]
|
|
|
|
public class BGSpriteC
|
|
|
|
{
|
|
|
|
public List<Sprite> Sprites;
|
|
|
|
}
|
|
|
|
|
2021-12-29 06:52:48 +00:00
|
|
|
private void Awake()
|
|
|
|
{
|
|
|
|
instance = this;
|
|
|
|
}
|
|
|
|
|
2021-12-30 12:17:22 +00:00
|
|
|
private void Update()
|
|
|
|
{
|
2022-01-19 05:40:49 +00:00
|
|
|
if (Conductor.instance.ReportBeat(ref newBeat))
|
2021-12-30 12:17:22 +00:00
|
|
|
{
|
2022-01-03 22:42:43 +00:00
|
|
|
if (bgEnabled)
|
2021-12-30 12:17:22 +00:00
|
|
|
{
|
2022-01-19 05:40:49 +00:00
|
|
|
if (bgBeat % 2 == 0)
|
|
|
|
{
|
2021-12-30 12:17:22 +00:00
|
|
|
BGSprite.sprite = BGSprites[0].Sprites[1];
|
2022-01-19 05:40:49 +00:00
|
|
|
}
|
2021-12-30 12:17:22 +00:00
|
|
|
else
|
2022-01-19 05:40:49 +00:00
|
|
|
{
|
2021-12-30 12:17:22 +00:00
|
|
|
BGSprite.sprite = BGSprites[0].Sprites[2];
|
2022-01-19 05:40:49 +00:00
|
|
|
}
|
|
|
|
bgBeat++;
|
2022-01-03 22:42:43 +00:00
|
|
|
}
|
2022-01-19 05:40:49 +00:00
|
|
|
}
|
2021-12-30 12:17:22 +00:00
|
|
|
|
2022-01-19 05:40:49 +00:00
|
|
|
if (Conductor.instance.ReportBeat(ref newBeatBop, bopBeat % 1))
|
|
|
|
{
|
2022-01-03 22:42:43 +00:00
|
|
|
if (Conductor.instance.songPositionInBeats >= bopBeat && Conductor.instance.songPositionInBeats < bopBeat + bopLength)
|
|
|
|
{
|
2022-01-19 05:40:49 +00:00
|
|
|
float compare = KarateJoe.anim.GetCurrentAnimatorStateInfo(0).speed;
|
|
|
|
if (KarateJoe.anim.GetCurrentAnimatorStateInfo(0).normalizedTime >= compare && !KarateJoe.anim.IsInTransition(0))
|
|
|
|
KarateJoe.anim.Play("Bop", 0, 0);
|
2021-12-30 12:17:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public void BGFXOn()
|
|
|
|
{
|
|
|
|
bgEnabled = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void BGFXOff()
|
|
|
|
{
|
|
|
|
bgEnabled = false;
|
|
|
|
BGSprite.sprite = BGSprites[0].Sprites[0];
|
|
|
|
}
|
|
|
|
|
2021-12-30 08:26:18 +00:00
|
|
|
public void Shoot(float beat, int type)
|
2021-12-29 06:52:48 +00:00
|
|
|
{
|
|
|
|
GameObject pot = Instantiate(Pot);
|
|
|
|
pot.transform.parent = Pot.transform.parent;
|
2021-12-30 08:26:18 +00:00
|
|
|
|
|
|
|
Pot p = pot.GetComponent<Pot>();
|
|
|
|
|
2021-12-29 06:52:48 +00:00
|
|
|
pot.SetActive(true);
|
2021-12-30 08:26:18 +00:00
|
|
|
p.startBeat = beat;
|
|
|
|
p.createBeat = beat;
|
|
|
|
p.isThrown = true;
|
|
|
|
p.type = type;
|
|
|
|
p.Sprite.GetComponent<SpriteRenderer>().sprite = ObjectSprites[type];
|
2021-12-29 06:52:48 +00:00
|
|
|
|
2021-12-30 08:26:18 +00:00
|
|
|
switch (type)
|
|
|
|
{
|
|
|
|
case 0:
|
2022-01-15 22:52:53 +00:00
|
|
|
if (Starpelly.Mathp.GetDecimalFromFloat(beat) == 0f)
|
|
|
|
Jukebox.PlayOneShotGame("karateman/objectOut");
|
|
|
|
else
|
|
|
|
Jukebox.PlayOneShotGame("karateman/offbeatObjectOut");
|
2021-12-30 08:26:18 +00:00
|
|
|
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;
|
2021-12-30 12:17:22 +00:00
|
|
|
case 3:
|
|
|
|
Jukebox.PlayOneShotGame("karateman/objectOut");
|
|
|
|
p.hitSnd = "karateman/soccerHit";
|
|
|
|
break;
|
2022-01-01 18:54:17 +00:00
|
|
|
case 4:
|
|
|
|
p.kick = true;
|
|
|
|
Jukebox.PlayOneShotGame("karateman/barrelOutKicks");
|
2022-01-02 12:09:15 +00:00
|
|
|
p.hitSnd = "karateman/barrelBreak";
|
|
|
|
|
|
|
|
GameObject pks = new GameObject(); pks.AddComponent<PunchKickSound>().startBeat = beat;
|
|
|
|
pks.transform.parent = this.transform.parent;
|
2022-01-01 18:54:17 +00:00
|
|
|
break;
|
2021-12-30 08:26:18 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-01-03 22:42:43 +00:00
|
|
|
public void Bop(float beat, float length)
|
2021-12-30 08:26:18 +00:00
|
|
|
{
|
2022-01-03 22:42:43 +00:00
|
|
|
bopLength = length;
|
|
|
|
bopBeat = beat;
|
2021-12-29 06:52:48 +00:00
|
|
|
}
|
2022-01-19 05:40:49 +00:00
|
|
|
|
|
|
|
public void CreateBomb(Transform parent, Vector2 scale, ref GameObject shadow)
|
|
|
|
{
|
|
|
|
GameObject bomb = Instantiate(Bomb, parent);
|
|
|
|
bomb.SetActive(true);
|
|
|
|
bomb.transform.localScale = scale;
|
|
|
|
shadow.transform.parent = bomb.transform;
|
|
|
|
shadow.transform.SetAsLastSibling();
|
|
|
|
bomb.GetComponent<Bomb>().shadow = shadow;
|
|
|
|
}
|
2021-12-29 06:52:48 +00:00
|
|
|
}
|
|
|
|
}
|