public void RunActions(BeatKeeper parent) { // Run actions OnRepeat?.Invoke(parent, this); // Run action before resetting event OnOnce?.Invoke(parent, this); OnOnce = null; // Setup for the next beat double cacheToSetLastTrigger = NextTrigger; while (IsOnBeat(parent)) { NextTrigger += Interval.ConvertBeat(parent.regularBeat); // Check if next trigger exceeds music length if (NextTrigger > parent.music.clip.length) { // Reset the next trigger to the start of the music NextTrigger = parent.firstBeat; } } LastTrigger = cacheToSetLastTrigger; //Debug.Log($"Last: {LastTrigger}, Next: {NextTrigger}"); }
void SpawnEnemy(BeatKeeper source, BeatKeeper.BeatStats stats) { int randomIndex = Random.Range(0, spawnEnemyPrefabs.Length); Turret spawnPrefab = spawnEnemyPrefabs[randomIndex]; EnemySpawner.Spawn(spawnerPrefab, spawnPrefab, GetRandomSpawnLocation()); }
public BeatStats(BeatKeeper parent, Interval interval) { // Setup interval Interval = interval; LastTrigger = parent.firstBeat; NextTrigger = (parent.firstBeat + Interval.ConvertBeat(parent.regularBeat)); }
void SpawnEnemy(BeatKeeper keeper, BeatKeeper.BeatStats on) { if (Game.IsReady && Game.Player.IsAlive && isActiveAndEnabled) { Turret instance = Singleton.Get <PoolingManager>().GetInstance(spawnEnemy, spawnLocation.position, spawnLocation.rotation); instance.IsSecondaryColor = (Random.value > 0.5f); } Destroy(); }
public bool IsOnBeat(BeatKeeper parent) { bool returnFlag = false; if ((NextTrigger > LastTrigger) && (parent.music.time > NextTrigger)) { returnFlag = true; } else if ((Math.Abs(NextTrigger - parent.firstBeat) < Mathf.Epsilon) && (parent.music.time < LastTrigger)) { returnFlag = true; } return(returnFlag); }