2023-04-23 20:17:21 +00:00
|
|
|
using System.Collections;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using UnityEngine;
|
|
|
|
using HeavenStudio.Util;
|
|
|
|
|
|
|
|
namespace HeavenStudio.Games.Scripts_BoardMeeting
|
|
|
|
{
|
|
|
|
public class BMExecutive : MonoBehaviour
|
|
|
|
{
|
|
|
|
public BoardMeeting game;
|
|
|
|
public bool player;
|
|
|
|
public Animator anim;
|
|
|
|
bool canBop = true;
|
|
|
|
int smileCounter = 0;
|
|
|
|
public bool spinning;
|
|
|
|
bool preparing;
|
|
|
|
Sound rollLoop = null;
|
|
|
|
|
|
|
|
private void Awake()
|
|
|
|
{
|
|
|
|
anim = GetComponent<Animator>();
|
|
|
|
game = BoardMeeting.instance;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void Prepare()
|
|
|
|
{
|
|
|
|
if (spinning) return;
|
|
|
|
preparing = true;
|
|
|
|
anim.DoScaledAnimationAsync("Prepare", 0.5f);
|
|
|
|
canBop = false;
|
|
|
|
}
|
|
|
|
|
2023-04-26 12:43:35 +00:00
|
|
|
public void Spin(string soundToPlay = "A", bool forceStart = false)
|
2023-04-23 20:17:21 +00:00
|
|
|
{
|
|
|
|
if (spinning) return;
|
|
|
|
spinning = true;
|
|
|
|
preparing = false;
|
2023-04-26 12:43:35 +00:00
|
|
|
string animToPlay = game.firstSpinner.anim.GetCurrentAnimatorStateInfo(0).IsName("Spin") ? "Spin" : "LoopSpin";
|
|
|
|
if (this == game.firstSpinner) anim.DoUnscaledAnimation("Spin", 0);
|
|
|
|
else anim.DoUnscaledAnimation(forceStart ? "Spin" : animToPlay, forceStart ? 0 : game.firstSpinner.anim.GetCurrentAnimatorStateInfo(0).normalizedTime);
|
2023-04-23 20:17:21 +00:00
|
|
|
canBop = false;
|
2023-06-10 19:13:29 +00:00
|
|
|
SoundByte.PlayOneShotGame("boardMeeting/rollPrepare" + soundToPlay);
|
2023-04-23 20:17:21 +00:00
|
|
|
float offset = 0;
|
|
|
|
switch (soundToPlay)
|
|
|
|
{
|
|
|
|
case "A":
|
|
|
|
case "B":
|
|
|
|
offset = 0.01041666666f;
|
|
|
|
break;
|
|
|
|
case "C":
|
|
|
|
case "Player":
|
|
|
|
offset = 0.02083333333f;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
offset = 0;
|
|
|
|
break;
|
|
|
|
}
|
2023-06-10 19:13:29 +00:00
|
|
|
rollLoop = SoundByte.PlayOneShotGame("boardMeeting/roll" + soundToPlay, Conductor.instance.songPositionInBeatsAsDouble + 0.5f - Conductor.instance.GetRestFromRealTime(offset), 1, 1, true);
|
2023-04-23 20:17:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public void Stop(bool hit = true)
|
|
|
|
{
|
|
|
|
if (!spinning) return;
|
|
|
|
spinning = false;
|
|
|
|
anim.DoScaledAnimationAsync(hit ? "Stop" : "Miss", hit ? 0.5f : 0.25f);
|
|
|
|
if (rollLoop != null)
|
|
|
|
{
|
|
|
|
rollLoop.KillLoop(0);
|
|
|
|
rollLoop = null;
|
|
|
|
}
|
|
|
|
|
|
|
|
BeatAction.New(game.gameObject, new List<BeatAction.Action>()
|
|
|
|
{
|
2023-06-10 19:13:29 +00:00
|
|
|
new BeatAction.Action(Conductor.instance.songPositionInBeatsAsDouble + 1.5f, delegate { canBop = true; })
|
2023-04-23 20:17:21 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
public void Bop()
|
|
|
|
{
|
|
|
|
if (!canBop || spinning || !anim.IsAnimationNotPlaying() || preparing) return;
|
|
|
|
if (smileCounter > 0)
|
|
|
|
{
|
|
|
|
anim.DoScaledAnimationAsync("SmileBop", 0.5f);
|
|
|
|
smileCounter--;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
anim.DoScaledAnimationAsync("Bop", 0.5f);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
public void Smile()
|
|
|
|
{
|
|
|
|
if (spinning) return;
|
|
|
|
if (!preparing) anim.Play("SmileIdle");
|
|
|
|
smileCounter = 2;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|