HeavenStudio/Assets/Scripts/Games/BuiltToScaleDS/Blocks.cs

99 lines
2.6 KiB
C#
Raw Normal View History

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System;
2022-03-14 14:21:05 +00:00
namespace HeavenStudio.Games.Scripts_BuiltToScaleDS
{
2022-03-14 14:21:05 +00:00
using HeavenStudio.Util;
public class Blocks : PlayerActionObject
{
public float createBeat;
public float createLength;
public Animator anim;
private bool moving = true;
private BuiltToScaleDS game;
private void Awake()
{
game = BuiltToScaleDS.instance;
}
private void Update()
{
if (!moving) return;
var windupBeat = createBeat + (createLength * 4f);
var hitBeat = windupBeat + createLength;
var currentBeat = Conductor.instance.songPositionInBeats;
var shooterState = game.shooterAnim.GetCurrentAnimatorStateInfo(0);
if (currentBeat > windupBeat && currentBeat < hitBeat
&& !shooterState.IsName("Windup")
&& game.shooterAnim.IsAnimationNotPlaying())
{
game.shooterAnim.Play("Windup", 0, 0);
}
float stateBeat = Conductor.instance.GetPositionFromMargin(hitBeat, 2f);
StateCheck(stateBeat);
if (PlayerInput.Pressed())
{
if (state.perfect)
{
Ace();
}
else if (state.notPerfect())
{
Miss();
}
}
if (moving)
{
var sinkBeat = hitBeat + (createLength * 2f);
if (currentBeat < sinkBeat)
{
game.SetBlockTime(this, createBeat, createLength);
}
else
{
moving = false;
Jukebox.PlayOneShotGame("builtToScaleDS/Sink");
}
}
}
void Ace()
{
moving = false;
game.shootingThisFrame = true;
game.Shoot();
game.SpawnObject(BuiltToScaleDS.BTSObject.HitPieces);
Destroy(gameObject);
Jukebox.PlayOneShotGame("builtToScaleDS/Hit");
}
void Miss()
{
moving = false;
game.shootingThisFrame = true;
game.Shoot();
game.SpawnObject(BuiltToScaleDS.BTSObject.MissPieces);
Destroy(gameObject);
2022-02-17 02:59:46 +00:00
Jukebox.PlayOneShotGame("builtToScaleDS/Crumble");
}
public override void OnAce()
{
Ace();
}
}
}