mirror of
https://github.com/RHeavenStudioPlus/HeavenStudioPlus.git
synced 2024-12-18 06:20:03 +00:00
ebeea121ed
I just moved everything that was in start to awake. There are a few other changes I made, like using init functions rather than awake in scripts that depended on something that was initialized in another script's awake (to make sure things always happen in the right order), as well as some other stuff in some specific minigames
51 lines
No EOL
1.3 KiB
C#
51 lines
No EOL
1.3 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
namespace HeavenStudio.Games.Scripts_Spaceball
|
|
{
|
|
public class Alien : MonoBehaviour
|
|
{
|
|
private Animator anim;
|
|
|
|
private float showBeat = 0;
|
|
private bool isShowing = false;
|
|
|
|
private void Awake()
|
|
{
|
|
anim = GetComponent<Animator>();
|
|
anim.Play("AlienIdle", 0, 0);
|
|
}
|
|
|
|
private void Update()
|
|
{
|
|
if (Conductor.instance.isPlaying && !isShowing)
|
|
{
|
|
anim.Play("AlienSwing", 0, Conductor.instance.GetLoopPositionFromBeat(0, 1f));
|
|
anim.speed = 0;
|
|
}
|
|
else if (!Conductor.instance.isPlaying)
|
|
{
|
|
anim.Play("AlienIdle", 0, 0);
|
|
}
|
|
|
|
if (isShowing)
|
|
{
|
|
float normalizedBeat = Conductor.instance.GetPositionFromBeat(showBeat, 1f);
|
|
anim.Play("AlienShow", 0, normalizedBeat);
|
|
anim.speed = 0;
|
|
|
|
if (normalizedBeat >= 2)
|
|
{
|
|
isShowing = false;
|
|
}
|
|
}
|
|
}
|
|
|
|
public void Show(float showBeat)
|
|
{
|
|
isShowing = true;
|
|
this.showBeat = showBeat;
|
|
}
|
|
}
|
|
} |