|
|
@ -20,7 +20,7 @@ public class CardSmall : MonoBehaviour |
|
|
public float time; |
|
|
public float time; |
|
|
|
|
|
|
|
|
[Header("速度")] |
|
|
[Header("速度")] |
|
|
public float speed = 2f; |
|
|
public float speed = 8f; |
|
|
public float rotationSpeed = 2f; |
|
|
public float rotationSpeed = 2f; |
|
|
[Header("曲线")] |
|
|
[Header("曲线")] |
|
|
public LineRenderer lineRender; |
|
|
public LineRenderer lineRender; |
|
|
@ -41,10 +41,10 @@ public class CardSmall : MonoBehaviour |
|
|
time = 0; |
|
|
time = 0; |
|
|
while (isMove ) |
|
|
while (isMove ) |
|
|
{ |
|
|
{ |
|
|
this.transform.position = Vector3.Lerp(linePath[i], linePath[i + 1], time += Time.deltaTime * speed); |
|
|
transform.position = Vector3.Lerp(linePath[i], linePath[i + 1], time += Time.deltaTime * speed); |
|
|
|
|
|
|
|
|
Vector3 direction = linePath[i + 1] - linePath[i]; |
|
|
Vector3 direction = linePath[i + 1] - linePath[i]; |
|
|
float angle = Vector3.SignedAngle(transform.up, direction, -transform.forward); |
|
|
float angle = Vector3.SignedAngle(CardActiveSort .Instance .transform .InverseTransformDirection( transform.up), direction, CardActiveSort.Instance.transform.InverseTransformDirection (- transform.forward)); |
|
|
transform.eulerAngles = Vector3.Lerp(transform.eulerAngles, new Vector3(0, 0, angle), Time.deltaTime * rotationSpeed); |
|
|
transform.eulerAngles = Vector3.Lerp(transform.eulerAngles, new Vector3(0, 0, angle), Time.deltaTime * rotationSpeed); |
|
|
|
|
|
|
|
|
if (Vector3.Distance(this.transform.position, linePath[i + 1]) < 0.05) |
|
|
if (Vector3.Distance(this.transform.position, linePath[i + 1]) < 0.05) |
|
|
@ -56,6 +56,8 @@ public class CardSmall : MonoBehaviour |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
yield return new WaitForSeconds(0.5f); |
|
|
|
|
|
TurnMaster.Instance.continueTurn = true; |
|
|
Destroy(this.gameObject); |
|
|
Destroy(this.gameObject); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@ -66,11 +68,12 @@ public class CardSmall : MonoBehaviour |
|
|
while (isMove) |
|
|
while (isMove) |
|
|
{ |
|
|
{ |
|
|
|
|
|
|
|
|
transform.localPosition = Vector3.Lerp(lineStart, lineEnd, time += Time.deltaTime * speed); |
|
|
transform.localPosition = Vector3.Lerp(transform.localPosition, lineEnd,Time.deltaTime * speed); |
|
|
|
|
|
|
|
|
if (Vector3.Distance(transform.localPosition, lineEnd) < 0.01f) |
|
|
if (Vector3.Distance(transform.localPosition, lineEnd) < 0.5f) |
|
|
{ |
|
|
{ |
|
|
isMove = false; |
|
|
isMove = false; |
|
|
|
|
|
transform.localPosition = lineEnd; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
Vector3 targetPoint = CardActiveSort.Instance.targrtPoint; |
|
|
Vector3 targetPoint = CardActiveSort.Instance.targrtPoint; |
|
|
@ -97,7 +100,7 @@ public class CardSmall : MonoBehaviour |
|
|
|
|
|
|
|
|
lineStart =transform.position + new Vector3(0, 0, -0.05f); |
|
|
lineStart =transform.position + new Vector3(0, 0, -0.05f); |
|
|
lineEnd = gameObject.transform.position + new Vector3(0, 0, -0.05f); |
|
|
lineEnd = gameObject.transform.position + new Vector3(0, 0, -0.05f); |
|
|
lineMiddel = lineStart + new Vector3(-3f, 6f, -1f); |
|
|
lineMiddel = lineStart + new Vector3(-3f, 6f, 3f); |
|
|
CalculatePath(); |
|
|
CalculatePath(); |
|
|
|
|
|
|
|
|
StartCoroutine(moveCardFollowLineWithToUsedCard()); |
|
|
StartCoroutine(moveCardFollowLineWithToUsedCard()); |
|
|
@ -106,9 +109,9 @@ public class CardSmall : MonoBehaviour |
|
|
{ |
|
|
{ |
|
|
mainCaera = GameManager.Instance.mainCamera; |
|
|
mainCaera = GameManager.Instance.mainCamera; |
|
|
|
|
|
|
|
|
lineStart = transform.localPosition + new Vector3(395f, 0, 0); |
|
|
lineStart = transform.InverseTransformPoint( TurnMaster.Instance.cardDeckNumberText.transform.position) ; |
|
|
lineEnd = endPoint; |
|
|
lineEnd = endPoint; |
|
|
|
|
|
this.transform.position = TurnMaster.Instance.cardDeckNumberText.transform.position; |
|
|
StartCoroutine(moveCardFollowLineWithDrawCards()); |
|
|
StartCoroutine(moveCardFollowLineWithDrawCards()); |
|
|
} |
|
|
} |
|
|
#region 计算贝塞尔曲线的拟合点
|
|
|
#region 计算贝塞尔曲线的拟合点
|
|
|
|