revival/game/Assets/Scripts/Character/TimeHat.cs

45 lines
1.1 KiB
C#
Raw Normal View History

2021-05-18 18:40:00 +02:00
using System.Collections;
using System.Collections.Generic;
using DG.Tweening;
using DG.Tweening.Core;
using Ktyl.Util;
using UnityEngine;
public class TimeHat : MonoBehaviour
{
[SerializeField] private SerialFloat _freezeDuration;
[SerializeField] private Transform _orbGraphics;
[SerializeField] private float _animDuration = 0.3f;
private Vector3 _activeScale;
// Start is called before the first frame update
void Start()
{
_activeScale = _orbGraphics.localScale;
_orbGraphics.localScale = Vector3.zero;
}
public void Trigger()
{
_orbGraphics
.DOScale(_activeScale, _animDuration)
.SetEase(Ease.OutCirc);
var t = 0f;
DOTween.To(
() => t,
_ => { },
1f,
_freezeDuration)
.OnComplete(Reset);
}
public void Reset()
{
_orbGraphics
.DOScale(Vector3.one * Mathf.Epsilon, _animDuration)
.SetEase(Ease.InCirc);
}
}