public static void Init() { if (_instance == null) { GameObject go = new GameObject("DanceFloorUpdater"); _instance = go.AddComponent <DanceFloorUpdater>(); } }
public static void PlayPattern(DanceFloor floor, Func <int, int[]> pattern, int[] ts, float time, float offset = 0, Action <int[]> call = null) { call ??= floor.ChangeFloor; float dTime = time / ts.Length; for (int i = 0; i < ts.Length; i++) { int t = ts[i]; DanceFloorUpdater.Register(i * dTime + offset, () => call.Invoke(pattern.Invoke(t))); } }
public DanceFloor(AudioSource musicSource) { _musicSource = musicSource; DanceFloorUpdater.Init(); for (int i = 0; i < 10; i++) { for (int j = 0; j < 10; j++) { _squares[10 * i + j] = new DanceSquare(i, j); } } }