Space-Smash-Out/Assets/Plugins/PrimeTween/Demo/Scripts/SlidingDoor.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

39 lines
1.2 KiB
C#

#if PRIME_TWEEN_INSTALLED
using PrimeTween;
using UnityEngine;
namespace PrimeTweenDemo {
public class SlidingDoor : Animatable {
[SerializeField] Transform animationAnchor;
[SerializeField] Vector3 openedPos, midPos, closedPos;
Demo demo;
bool isClosed;
Sequence sequence;
void Awake() {
demo = FindObjectOfType<Demo>();
UnityEngine.Assertions.Assert.IsNotNull(demo);
}
public override void OnClick() {
if (!demo.animateAllSequence.isAlive) {
Animate(!isClosed);
}
}
public override Sequence Animate(bool _isClosed) {
if (isClosed == _isClosed) {
return Sequence.Create();
}
isClosed = _isClosed;
if (sequence.isAlive) {
sequence.Stop();
}
var tweenSettings = new TweenSettings(0.4f, Ease.OutBack, endDelay: 0.1f);
sequence = Tween.LocalPosition(animationAnchor, midPos, tweenSettings)
.Chain(Tween.LocalPosition(animationAnchor, _isClosed ? closedPos : openedPos, tweenSettings));
return sequence;
}
}
}
#endif