2022-01-01 18:54:17 +00:00
|
|
|
using System.Collections;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using UnityEngine;
|
|
|
|
|
2022-01-02 12:09:15 +00:00
|
|
|
using RhythmHeavenMania.Util;
|
|
|
|
|
2022-01-01 18:54:17 +00:00
|
|
|
namespace RhythmHeavenMania.Games.KarateMan
|
|
|
|
{
|
2022-01-02 12:09:15 +00:00
|
|
|
public class Bomb : PlayerActionObject
|
2022-01-01 18:54:17 +00:00
|
|
|
{
|
|
|
|
private Animator anim;
|
|
|
|
|
|
|
|
private float startBeat;
|
|
|
|
private float hitBeat;
|
|
|
|
|
2022-01-02 12:09:15 +00:00
|
|
|
public bool kicked;
|
|
|
|
private bool eligible;
|
2022-01-01 18:54:17 +00:00
|
|
|
|
2022-01-03 15:15:48 +00:00
|
|
|
public GameObject RotHolder;
|
|
|
|
private Vector3 lastRot;
|
|
|
|
|
2022-01-01 18:54:17 +00:00
|
|
|
private void Start()
|
|
|
|
{
|
|
|
|
anim = GetComponent<Animator>();
|
|
|
|
|
|
|
|
startBeat = Conductor.instance.songPositionInBeats;
|
2022-01-02 12:09:15 +00:00
|
|
|
eligible = true;
|
2022-01-01 18:54:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
private void Update()
|
|
|
|
{
|
2022-01-02 12:09:15 +00:00
|
|
|
if (!kicked)
|
2022-01-01 18:54:17 +00:00
|
|
|
{
|
2022-01-02 12:09:15 +00:00
|
|
|
float normalizedBeatAnim = Conductor.instance.GetLoopPositionFromBeat(startBeat, 2.75f);
|
2022-01-01 18:54:17 +00:00
|
|
|
|
|
|
|
anim.Play("BombOut", 0, normalizedBeatAnim);
|
|
|
|
anim.speed = 0;
|
2022-01-02 12:09:15 +00:00
|
|
|
|
|
|
|
float normalizedBeat = Conductor.instance.GetLoopPositionFromBeat(startBeat, 0.75f);
|
|
|
|
|
|
|
|
StateCheckNoList(normalizedBeat);
|
|
|
|
|
|
|
|
if (normalizedBeat > 1.5f)
|
|
|
|
{
|
|
|
|
eligible = false;
|
|
|
|
// explode animation
|
2022-01-03 15:15:48 +00:00
|
|
|
if (normalizedBeat > 4)
|
2022-01-02 12:09:15 +00:00
|
|
|
Destroy(this.gameObject);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (PlayerInput.PressedUp() && eligible)
|
|
|
|
{
|
|
|
|
eligible = false;
|
|
|
|
if (state.perfect)
|
|
|
|
{
|
|
|
|
Hit();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
Jukebox.PlayOneShot("miss");
|
|
|
|
// some miss animation here or somethin
|
|
|
|
}
|
|
|
|
}
|
2022-01-01 18:54:17 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2022-01-02 12:09:15 +00:00
|
|
|
float normalizedBeatAnim = Conductor.instance.GetLoopPositionFromBeat(hitBeat, 3f);
|
|
|
|
anim.Play("BombHit", 0, normalizedBeatAnim);
|
2022-01-01 18:54:17 +00:00
|
|
|
anim.speed = 0;
|
|
|
|
|
2022-01-02 12:09:15 +00:00
|
|
|
if (normalizedBeatAnim > 1)
|
|
|
|
{
|
|
|
|
Destroy(this.gameObject);
|
|
|
|
}
|
2022-01-01 18:54:17 +00:00
|
|
|
}
|
2022-01-03 15:15:48 +00:00
|
|
|
|
|
|
|
lastRot = RotHolder.transform.eulerAngles;
|
2022-01-01 18:54:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public void Hit()
|
|
|
|
{
|
2022-01-03 15:15:48 +00:00
|
|
|
KarateJoe.instance.HitEffectF(new Vector3(0.9f, 2.0549f));
|
|
|
|
|
2022-01-02 12:09:15 +00:00
|
|
|
Jukebox.PlayOneShotGame("karateman/bombKick");
|
|
|
|
hitBeat = Conductor.instance.songPositionInBeats;
|
|
|
|
kicked = true;
|
2022-01-03 15:15:48 +00:00
|
|
|
RotHolder.transform.eulerAngles = lastRot;
|
2022-01-01 18:54:17 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|