HeavenStudio/Assets/Scripts/Games/SneakySpirits/SneakySpiritsGhost.cs
minenice55 60d29f19c6
Timekeeping Improvements and Small Optimizations (#544)
* make BeatActions coroutines instead of componentrs

* pooled scheduled sounds

implement S' entity seek

* remove debug prints from last two changes

* implement absolute time tracking

implement DSP time resyncing

* optimize GameManager

* update TMPro

* update IDE packages

* fix dsp sync making the drift worse

* fix issue with the JSL dll

* relocate debug print

* make scheduled pitch setter functional

* any cpu
2023-09-11 22:28:04 +00:00

33 lines
1 KiB
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using HeavenStudio.Util;
namespace HeavenStudio.Games.Scripts_SneakySpirits
{
public class SneakySpiritsGhost : MonoBehaviour
{
private SneakySpirits game;
private Animator anim;
void Awake()
{
anim = GetComponent<Animator>();
game = SneakySpirits.instance;
}
public void Init(double spawnBeat, float length)
{
if (length == 0) length = 1;
BeatAction.New(game, new List<BeatAction.Action>()
{
new BeatAction.Action(spawnBeat, delegate { anim.DoScaledAnimationAsync("Move", (1 / length) * Conductor.instance.SongPitch); }),
new BeatAction.Action(spawnBeat + (length * 0.5f), delegate { anim.DoScaledAnimationAsync("MoveDown", (1 / length) * Conductor.instance.SongPitch); }),
new BeatAction.Action(spawnBeat + length, delegate { Destroy(gameObject); }),
});
}
}
}