49 lines
1.4 KiB
C#
49 lines
1.4 KiB
C#
using BlueWater.Tycoons;
|
|
using DG.Tweening;
|
|
using TMPro;
|
|
using UnityEngine;
|
|
|
|
namespace BlueWater.Uis
|
|
{
|
|
public class PayMoneyUi : MonoBehaviour
|
|
{
|
|
[SerializeField]
|
|
private RectTransform _rect;
|
|
|
|
[SerializeField]
|
|
private TMP_Text _text;
|
|
|
|
[SerializeField]
|
|
private ParticleSystem _payMoneyParticle;
|
|
|
|
[SerializeField]
|
|
private float _offsetY = 1f;
|
|
|
|
[SerializeField]
|
|
private float _duration = 2f;
|
|
|
|
[SerializeField]
|
|
private float _shakeAmount = 0.1f;
|
|
|
|
[SerializeField]
|
|
private int _shakeVibrato = 4;
|
|
|
|
public void Initialize(int gold)
|
|
{
|
|
TycoonManager.Instance.TycoonStatus.CurrentGold += gold;
|
|
_text.text = gold.ToString("N0");
|
|
|
|
_rect.localRotation = Quaternion.identity;
|
|
var endPosition = _rect.localPosition + new Vector3(0, _offsetY, 0);
|
|
var payMoneyParticle = Instantiate(_payMoneyParticle, transform.position,
|
|
_payMoneyParticle.transform.rotation);
|
|
payMoneyParticle.Play();
|
|
|
|
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));
|
|
}
|
|
}
|
|
} |