2021-12-28 07:38:55 +00:00
|
|
|
using System.Collections;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using UnityEngine;
|
|
|
|
|
2022-03-14 14:21:05 +00:00
|
|
|
namespace HeavenStudio.Games.Scripts_Spaceball
|
2021-12-28 07:38:55 +00:00
|
|
|
{
|
|
|
|
public class Alien : MonoBehaviour
|
|
|
|
{
|
|
|
|
private Animator anim;
|
|
|
|
|
|
|
|
private float showBeat = 0;
|
|
|
|
private bool isShowing = false;
|
|
|
|
|
2022-03-26 02:08:46 +00:00
|
|
|
private void Awake()
|
2021-12-28 07:38:55 +00:00
|
|
|
{
|
|
|
|
anim = GetComponent<Animator>();
|
|
|
|
anim.Play("AlienIdle", 0, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
private void Update()
|
|
|
|
{
|
2022-01-07 11:36:23 +00:00
|
|
|
if (Conductor.instance.isPlaying && !isShowing)
|
2021-12-28 07:38:55 +00:00
|
|
|
{
|
2022-02-03 22:20:26 +00:00
|
|
|
anim.Play("AlienSwing", 0, Conductor.instance.GetLoopPositionFromBeat(0, 1f));
|
2021-12-28 07:38:55 +00:00
|
|
|
anim.speed = 0;
|
|
|
|
}
|
2022-01-07 11:36:23 +00:00
|
|
|
else if (!Conductor.instance.isPlaying)
|
2021-12-28 07:38:55 +00:00
|
|
|
{
|
|
|
|
anim.Play("AlienIdle", 0, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (isShowing)
|
|
|
|
{
|
2022-02-03 22:20:26 +00:00
|
|
|
float normalizedBeat = Conductor.instance.GetPositionFromBeat(showBeat, 1f);
|
2021-12-28 07:38:55 +00:00
|
|
|
anim.Play("AlienShow", 0, normalizedBeat);
|
|
|
|
anim.speed = 0;
|
|
|
|
|
|
|
|
if (normalizedBeat >= 2)
|
|
|
|
{
|
|
|
|
isShowing = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public void Show(float showBeat)
|
|
|
|
{
|
|
|
|
isShowing = true;
|
|
|
|
this.showBeat = showBeat;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|