HeavenStudioPlus/Assets/Scripts/Games/KarateMan/Bomb.cs

82 lines
2.2 KiB
C#
Raw Normal View History

2022-01-01 18:54:17 +00:00
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using RhythmHeavenMania.Util;
2022-01-01 18:54:17 +00:00
namespace RhythmHeavenMania.Games.KarateMan
{
public class Bomb : PlayerActionObject
2022-01-01 18:54:17 +00:00
{
private Animator anim;
private float startBeat;
private float hitBeat;
public bool kicked;
private bool eligible;
2022-01-01 18:54:17 +00:00
private void Start()
{
anim = GetComponent<Animator>();
startBeat = Conductor.instance.songPositionInBeats;
eligible = true;
2022-01-01 18:54:17 +00:00
}
private void Update()
{
if (!kicked)
2022-01-01 18:54:17 +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;
float normalizedBeat = Conductor.instance.GetLoopPositionFromBeat(startBeat, 0.75f);
StateCheckNoList(normalizedBeat);
if (normalizedBeat > 1.5f)
{
eligible = false;
// explode animation
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
{
float normalizedBeatAnim = Conductor.instance.GetLoopPositionFromBeat(hitBeat, 3f);
anim.Play("BombHit", 0, normalizedBeatAnim);
2022-01-01 18:54:17 +00:00
anim.speed = 0;
if (normalizedBeatAnim > 1)
{
Destroy(this.gameObject);
}
2022-01-01 18:54:17 +00:00
}
}
public void Hit()
{
Jukebox.PlayOneShotGame("karateman/bombKick");
hitBeat = Conductor.instance.songPositionInBeats;
kicked = true;
2022-01-01 18:54:17 +00:00
}
}
}