You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
CrowdControl/Assets/3rd/D2D_Scripts/Utilities/CodeSugar/TweenSugar.cs

46 lines
1.4 KiB
C#

3 months ago
using D2D.Animations;
using DG.Tweening;
using UnityEngine;
namespace D2D.Utilities
{
public static class TweenSugar
{
public static void RestartTween(this GameObject target, string id)
{
target.GetComponent<DOTweenAnimation>().DORestartAllById(id);
}
private static Tweener Punch(this Transform target, PunchData data)
{
return target.DOPunchScale(data.amplitude * Vector3.one,
data.duration, data.vibrato, data.elasticity).SetEase(data.ease);
}
public static Tweener PunchUI(this Transform target)
{
return Punch(target, TweenSettings.Instance.UIPunch);
}
public static Tweener PunchGameplay(this Transform target)
{
return Punch(target, TweenSettings.Instance.GameplayPunch);
}
private static Tweener Shake(this Transform target, ShakeData data)
{
return target.DOShakePosition(data.duration, data.amplitude,
data.vibrato, data.randomness).SetEase(data.ease);
}
public static Tweener ShakeUI(this Transform target)
{
return Shake(target, TweenSettings.Instance.UIShake);
}
public static Tweener ShakeGameplay(this Transform target)
{
return Shake(target, TweenSettings.Instance.GameplayShake);
}
}
}