HeavenStudioPlus/Assets/Scripts/Games/FreezeFrame/Car.cs
playinful 45cbe1972b Mostly Bugfixes (#823)
UI tweaks:
- Removed "Clear Photo Cache" GameAction, added "Clear Previous Photos" parameter to the Car cues
- Rolled Move T.J., Rotate T.J., and Scale T.J. GameActions into a single GameAction
- Legacy functions still exist for remixes created on previous nightly builds

Bugs fixed:
- Fixed a bug where the spacing of slow cars would be incorrect after a game switch
- Made particles scale with tempo
  - Added functionality for respecting Rate over Distance in ParticleSystemHelpers
- Fixed a bug where the photo cache was not cleared after stopping playback of a remix.
- Fixed a bug where, upon showing photos, if the remix playback was stopped before the photos were removed from the screen, they would remain on the screen until playback started over.
- Removed an unnecessary call to Debug.Log that had been left in by mistake.
- Fixed a bug where cars' idle animations would play too slowly and at inconsistent timings.

Other refactorings:
- Created a "Car" MonoBehavior attached to both the NearCar and FarCar prefabs that handles the movement of cars, removing the need for the "QueuedCars" property of FreezeFrame.
- Added a failsafe in the ShowCrowd function for if the user indicates a crowd index that does not currently exist.
- Converted one SoundByte.PlayOneShot call into a MultiSound.Sound object.
2024-04-05 01:27:59 +00:00

48 lines
No EOL
1.4 KiB
C#

using System.Collections;
using System.Collections.Generic;
using System.Runtime.Serialization;
using HeavenStudio.Common;
using HeavenStudio.Games.Scripts_WizardsWaltz;
using UnityEngine;
using HeavenStudio.Util;
namespace HeavenStudio.Games.Scripts_FreezeFrame
{
public class Car : MonoBehaviour
{
[SerializeField] Animator _Animator;
[SerializeField] ParticleSystem _ParticleSystem;
public double Beat;
public string AnimName;
public float Length;
public void Setup(double beat, string animName, float length)
{
Beat = beat;
AnimName = animName;
Length = length;
_ParticleSystem.PlayScaledAsync(0.5f, true);
_Animator.DoScaledAnimationFromBeatAsync("Idle", 0.5f, 0f, 0);
}
void Update()
{
if (_Animator == null)
return;
float normalizedBeatFromStart = Conductor.instance.GetPositionFromBeat(0, 1);
_Animator.DoNormalizedAnimation("Idle", normalizedBeatFromStart * 4 % 1, animLayer: 0);
if (AnimName is null or "")
return;
float normalizedBeat = Conductor.instance.GetPositionFromBeat(Beat, Length);
_Animator.DoNormalizedAnimation(AnimName, normalizedBeat, animLayer: 1);
if (Conductor.instance.songPositionAsDouble > Beat + Length + 3)
Destroy(this);
}
}
}