using System; using Code.Audio; using Code.GameplayServices; using LitMotion; using LitMotion.Extensions; using UnityEngine; namespace Code.PassingObjects { public class Coin : PassingObject { [SerializeField] private int countOnActivate; private MotionHandle _movementAnim; private MotionHandle _rotationAnim; private void OnTriggerEnter(Collider other) { PlayerScoreService.Instance.AddScore(countOnActivate); AudioManager.Instance.PlayCoin(); PassingObjectsManager.Instance.KillChild(this); } private void Start() { _rotationAnim = LMotion.Create(Quaternion.Euler(0,0,0), Quaternion.Euler(0,180,0), 2) .WithLoops(123) .BindToRotation(transform); _movementAnim = LMotion.Create(0.5f, 1.5f, 2) .WithLoops(123, LoopType.Yoyo) .BindToPositionY(transform); } private void OnDestroy() { _rotationAnim.Cancel(); _movementAnim.Cancel(); } } }