36 lines
953 B
C#
36 lines
953 B
C#
using DG.Tweening;
|
|
using TMPro;
|
|
using UnityEngine;
|
|
|
|
namespace BlueWater
|
|
{
|
|
public class PumpingMessage : MonoBehaviour
|
|
{
|
|
[SerializeField]
|
|
private RectTransform _rect;
|
|
|
|
[SerializeField]
|
|
private TMP_Text _text;
|
|
|
|
[SerializeField]
|
|
private float _offsetY = 1f;
|
|
|
|
[SerializeField]
|
|
private float _duration = 2f;
|
|
|
|
public void Initialize(int addedLiquid)
|
|
{
|
|
_text.text = $"+{addedLiquid}ml";
|
|
|
|
_rect.localRotation = Quaternion.identity;
|
|
var endPosition = _rect.localPosition + new Vector3(0, _offsetY, 0);
|
|
|
|
var tween = DOTween.Sequence().SetAutoKill(true);
|
|
tween.Append(_rect.DOLocalMoveY(endPosition.y, _duration).SetEase(Ease.InOutSine));
|
|
tween.Join(_rect.DOScale(Vector3.zero, _duration).SetEase(Ease.InBack));
|
|
|
|
tween.OnComplete(() => Destroy(gameObject));
|
|
}
|
|
}
|
|
}
|