void CreateMoveQueue() { int index = (int)startPoint; movePath = new MovePaht(mPath[index]); MovePaht next = movePath; //ιζΆι if (!isClockwise) { for (int i = index + 1; i < mPath.Count; i++) { next.next = new MovePaht(mPath[i]); next = next.next; } for (int i = 0; i < index; i++) { next.next = new MovePaht(mPath[i]); next = next.next; } } else { for (int i = index - 1; i >= 0; i--) { next.next = new MovePaht(mPath[i]); next = next.next; } for (int i = mPath.Count - 1; i > index; i--) { next.next = new MovePaht(mPath[i]); next = next.next; } } if (isLoop) { next.next = movePath; } moveGameObject.SetActive(true); target.anchoredPosition = movePath.points; MoveByPath(movePath.next); }
void MoveByPath(MovePaht path) { if (path == null) { return; } float duration = Mathf.Abs(Vector2.Distance(target.anchoredPosition, path.points)) / this.speed; Vector3 pos = path.points; pos.z += offset.z; Tween tween = moveGameObject.transform.DOLocalMove(pos, duration); tween.SetEase(animationCure); tween.OnComplete(() => { MoveByPath(path.next); }); }