protected virtual IEnumerator MoveToRoutine(RectTransform Slot) { OnStartMoveSlot(); yield return(null); Vector2 Pos = Slot.position; Vector2 Dir = (Pos - (Vector2)transform.position).normalized * 18; while (Vector2.Distance(transform.position, Pos) > Dir.magnitude + 0.1f) { transform.position += (Vector3)Dir; OnUpdateMoveSlot(); yield return(null); } transform.position = Slot.transform.position; if (ZoneAt != null && Data.Category != CardCategory.Obstacle) { transform.SetSiblingIndex(ZoneAt.GetIndex(this)); } yield return(null); OnArriveMoveSlot(); }
protected virtual IEnumerator MoveToRoutine(Vector2 Pos) { OnStartMoveSlot(); yield return(null); Vector2 Dir = (Pos - (Vector2)transform.position).normalized * 18; while (Vector2.Distance((Vector2)transform.position, Pos) > Dir.magnitude + 0.1f) { transform.position += (Vector3)Dir; OnUpdateMoveSlot(); yield return(null); } transform.position = Pos; if (ZoneAt != null) { transform.SetSiblingIndex(ZoneAt.GetIndex(this)); } yield return(null); OnArriveMoveSlot(); }