using System.Collections; using System.Collections.Generic; using UnityEngine; using DG.Tweening; public class PuzzleCardAnimItem : MonoBehaviour { private Sequence seq; private bool stopAnim; // Start is called before the first frame update void Start() { if(stopAnim)return; float currValue = Random.Range(0.01f,0.05f); float currAngle = Random.Range(5,10); float currTime = Random.Range(0.5f,1f); if(Random.value<0.5f)currAngle = -currAngle; seq = DOTween.Sequence(); seq.Join(transform.DOScale(Vector3.one*(0.4f+currValue),currTime)); seq.Join(transform.DORotate(new Vector3(0,0,currAngle),currTime)); seq.Append(transform.DOScale(Vector3.one*(0.4f-currValue),currTime)); seq.Append(transform.DORotate(new Vector3(0,0,-currAngle),currTime)); seq.SetLoops(-1, LoopType.Yoyo); } public void Show(bool statu) { gameObject.SetActive(statu); } public void MoveTo(PuzzleCardItem cardItem) { stopAnim = true; Show(true); if(seq!=null)seq.Kill(); transform.DOScale(Vector3.one*(0.4f),1f); transform.DORotate(Vector3.zero,1f); transform.DOMove(cardItem.transform.position,1f); } }