Space-Smash-Out/Assets/Plugins/PrimeTween/Demo/Scripts/Wheels.cs
Jakob Feldmann 64162cb4a1 feat: whole project restructuring
This can be seen as the initial state of the project after the released demo.

The changes include:
- New ship models
- Singleton manager structure to keep project scaleable in the future
     - Managing players, their settings, character choices, statistics, match setups, controls etc. in a separate decoupled scene
- Main menu with transitions to the arena scene
- Beginnings of a custom audio solution
- Logging with Log4Net

It is really a complete overhaul of the projects structure and management.
2024-04-01 23:06:39 +02:00

38 lines
1.4 KiB
C#

#if PRIME_TWEEN_INSTALLED
using PrimeTween;
using UnityEngine;
namespace PrimeTweenDemo {
public class Wheels : Animatable {
[SerializeField] Demo demo;
[SerializeField] Transform[] wheels;
bool isAnimating;
Sequence sequence;
public override void OnClick() {
demo.AnimateAll(!isAnimating);
}
public override Sequence Animate(bool _isAnimating) {
isAnimating = _isAnimating;
// Spinning wheels is an infinite animation, and we should not return it as result of this method.
// Instead, we should wrap the SpinWheelsInfinitely() call inside the empty Sequence. This way, the SpinWheelsInfinitely() call can be grouped and chained with other tweens and sequences.
return Sequence.Create().ChainCallback(this, target => target.SpinWheelsInfinitely());
}
void SpinWheelsInfinitely() {
if (isAnimating) {
sequence.Complete();
sequence = Sequence.Create(-1);
foreach (var wheel in wheels) {
sequence.Group(Tween.LocalEulerAngles(wheel, Vector3.zero, new Vector3(360, 0), 1, Ease.Linear));
}
} else {
if (sequence.isAlive) {
sequence.SetRemainingCycles(0);
}
}
}
}
}
#endif