HeavenStudioPlus/Assets/Scripts/Games/WorkingDough/BGBall.cs

44 lines
1.3 KiB
C#
Raw Normal View History

using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using NaughtyBezierCurves;
using HeavenStudio.Util;
namespace HeavenStudio.Games.Scripts_WorkingDough
{
2023-06-12 12:04:32 +00:00
public class BGBall : SuperCurveObject
{
2023-06-12 12:04:32 +00:00
private double startBeat = double.MinValue;
private Path path;
2023-06-13 13:51:35 +00:00
[SerializeField] private GameObject gandw;
2023-06-12 12:04:32 +00:00
2023-06-13 13:51:35 +00:00
public void Init(double beat, bool hasGandw)
{
2023-06-12 12:04:32 +00:00
startBeat = beat;
path = WorkingDough.instance.GetPath("BGBall");
2023-06-13 13:51:35 +00:00
if (gandw != null) gandw.SetActive(hasGandw);
2023-06-12 12:04:32 +00:00
Update();
}
private void Update()
{
var cond = Conductor.instance;
2023-06-12 12:04:32 +00:00
if (cond.isPlaying && !cond.isPaused)
{
2023-06-12 12:04:32 +00:00
double beat = cond.songPositionInBeats;
if (startBeat != double.MinValue)
{
Vector3 pos = GetPathPositionFromBeat(path, Math.Max(startBeat, beat), startBeat);
transform.position = pos;
2023-06-13 13:51:35 +00:00
transform.rotation = Quaternion.Euler(0f, 0f, transform.rotation.eulerAngles.z - (-90 * Time.deltaTime * (1f / Conductor.instance.pitchedSecPerBeat)));
2023-06-12 12:04:32 +00:00
if (beat >= startBeat + 9) Destroy(gameObject);
}
}
}
}
}