2024-11-21 00:04:33 +08:00
|
|
|
|
using DG.Tweening;
|
|
|
|
|
using System.Collections;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using UnityEngine;
|
2024-11-22 17:48:26 +08:00
|
|
|
|
using UnityEngine.UI;
|
2024-11-21 00:04:33 +08:00
|
|
|
|
public class OtherMove : MonoBehaviour
|
|
|
|
|
{
|
|
|
|
|
public Transform objectToMove; // Ҫ<>ƶ<EFBFBD><C6B6>Ķ<EFBFBD><C4B6><EFBFBD>
|
|
|
|
|
public Transform[] pathPoints; // ·<><C2B7><EFBFBD>ϵĵ<CFB5><C4B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
public float duration = 5f; // <20>ƶ<EFBFBD><C6B6>ij<EFBFBD><C4B3><EFBFBD>ʱ<EFBFBD><CAB1>
|
|
|
|
|
public bool isLooping = false; // <20>Ƿ<EFBFBD>ѭ<EFBFBD><D1AD>·<EFBFBD><C2B7>
|
|
|
|
|
int startIndex = 0;
|
|
|
|
|
int endIndex = 0;
|
2024-11-21 09:38:16 +08:00
|
|
|
|
|
2024-11-21 00:04:33 +08:00
|
|
|
|
public float Speed;
|
|
|
|
|
public Transform EndPos;
|
2024-11-21 09:38:16 +08:00
|
|
|
|
public Transform posGroup;
|
2024-11-21 00:04:33 +08:00
|
|
|
|
|
2024-11-21 12:03:01 +08:00
|
|
|
|
public Transform JumpPos;
|
|
|
|
|
|
2024-11-21 00:04:33 +08:00
|
|
|
|
|
|
|
|
|
public Transform OutParent;
|
|
|
|
|
|
|
|
|
|
public Transform ReturnPos;//<2F><><EFBFBD>ص<EFBFBD>λ<EFBFBD><CEBB>
|
|
|
|
|
|
2024-11-21 09:38:16 +08:00
|
|
|
|
|
2024-11-21 00:04:33 +08:00
|
|
|
|
|
|
|
|
|
public AllHouseContro allHouseContro;
|
|
|
|
|
|
2024-11-22 17:48:26 +08:00
|
|
|
|
private Vector3 originalScale;
|
|
|
|
|
|
2024-11-21 09:38:16 +08:00
|
|
|
|
|
|
|
|
|
|
2024-11-21 12:03:01 +08:00
|
|
|
|
private void Awake()
|
2024-11-21 00:04:33 +08:00
|
|
|
|
{
|
2024-11-22 17:48:26 +08:00
|
|
|
|
originalScale=transform.localScale;
|
2024-11-21 00:04:33 +08:00
|
|
|
|
Speed = 2f;
|
2024-11-21 09:38:16 +08:00
|
|
|
|
objectToMove = transform;
|
|
|
|
|
allHouseContro=GameObject.Find("Canvas/Bg").GetComponent<AllHouseContro>();
|
|
|
|
|
posGroup=GameObject.Find("Canvas/Bg/Posgroup").transform;
|
|
|
|
|
if (posGroup != null)
|
|
|
|
|
{
|
|
|
|
|
// <20><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӽڵ<D3BD>
|
|
|
|
|
pathPoints = posGroup.GetComponentsInChildren<Transform>();
|
2024-11-21 00:04:33 +08:00
|
|
|
|
|
2024-11-21 09:38:16 +08:00
|
|
|
|
// ȥ<><C8A5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֻҪ<D6BB>ӽڵ㣩
|
|
|
|
|
pathPoints = System.Array.FindAll(pathPoints, t => t != posGroup);
|
2024-11-21 00:04:33 +08:00
|
|
|
|
|
2024-11-22 17:48:26 +08:00
|
|
|
|
//Debug.Log("<22>ӽڵ<D3BD><DAB5>Ѵ<EFBFBD><D1B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>"+ pathPoints.Length);
|
2024-11-21 09:38:16 +08:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2024-11-22 17:48:26 +08:00
|
|
|
|
//Debug.LogError("<22><><EFBFBD><EFBFBD><EFBFBD>丸<EFBFBD><E4B8B8><EFBFBD>壡");
|
2024-11-21 09:38:16 +08:00
|
|
|
|
}
|
|
|
|
|
OutParent= GameObject.Find("Canvas/Bg").transform ;
|
2024-11-21 12:03:01 +08:00
|
|
|
|
JumpPos = GameObject.Find("Canvas/Bg/Posgroup/pos (3)").transform;
|
2024-11-21 00:04:33 +08:00
|
|
|
|
}
|
|
|
|
|
public void MoveOutParent()
|
|
|
|
|
{
|
|
|
|
|
// <20><>¼ԭʼ<D4AD>ĸ<EFBFBD><C4B8><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// <20><> childObject <20><>Ϊ<EFBFBD>µ<EFBFBD> parentObject <20><><EFBFBD>ӽڵ㣬<DAB5><E3A3AC><EFBFBD>ŵ<EFBFBD><C5B5><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB>λ<EFBFBD><CEBB>
|
|
|
|
|
objectToMove.SetParent(OutParent);
|
|
|
|
|
objectToMove.SetAsLastSibling();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
public void MoveInParent(Transform Parent)
|
|
|
|
|
{
|
|
|
|
|
objectToMove.SetParent(Parent);
|
|
|
|
|
objectToMove.SetAsFirstSibling();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void SetParentToHouse()
|
|
|
|
|
{
|
2024-11-21 09:38:16 +08:00
|
|
|
|
foreach (HouseBtn house in allHouseContro.HouseBtnList)
|
|
|
|
|
{
|
|
|
|
|
if (EndPos==house.post.transform)
|
|
|
|
|
{
|
|
|
|
|
MoveInParent(house.transform);
|
|
|
|
|
}
|
|
|
|
|
}
|
2024-11-21 00:04:33 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void ReturnStartPos()//<2F>ص<EFBFBD><D8B5><EFBFBD>ʼ<EFBFBD><CABC>
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2024-11-21 12:03:01 +08:00
|
|
|
|
public bool JudagePos1()
|
|
|
|
|
{
|
|
|
|
|
if (EndPos == JumpPos)
|
|
|
|
|
{
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2024-11-21 00:04:33 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void StartMove()
|
|
|
|
|
{
|
|
|
|
|
|
2024-11-22 17:48:26 +08:00
|
|
|
|
//Debug.Log("<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ţ<EFBFBD>ƶ<EFBFBD>");
|
2024-11-21 00:04:33 +08:00
|
|
|
|
// <20><>ȡ·<C8A1><C2B7><EFBFBD>е<EFBFBD><D0B5><EFBFBD><EFBFBD>е<EFBFBD><D0B5><EFBFBD>λ<EFBFBD><CEBB>
|
2024-11-22 17:48:26 +08:00
|
|
|
|
//Debug.Log("·<><C2B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>"+ pathPoints.Length);
|
2024-11-21 00:04:33 +08:00
|
|
|
|
for (int i = 0; i < pathPoints.Length; i++)
|
|
|
|
|
{
|
2024-11-22 17:48:26 +08:00
|
|
|
|
//Debug.Log("<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD><D0B6>յ<EFBFBD>");
|
2024-11-21 00:04:33 +08:00
|
|
|
|
if (objectToMove.GetComponent<PlayerMovePos>().StartPos == pathPoints[i])
|
|
|
|
|
{
|
|
|
|
|
startIndex = i;
|
|
|
|
|
//Debug.Log("Startindex"+i);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (EndPos == pathPoints[i])
|
|
|
|
|
{
|
|
|
|
|
endIndex = i;
|
|
|
|
|
//Debug.Log("Endindex" + i);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (endIndex > startIndex)
|
|
|
|
|
{
|
2024-11-22 17:48:26 +08:00
|
|
|
|
//Debug.Log("<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ţ<EFBFBD><C5A3><EFBFBD><EFBFBD>·<EFBFBD><C2B7>");
|
2024-11-21 09:38:16 +08:00
|
|
|
|
|
2024-11-21 00:04:33 +08:00
|
|
|
|
duration = (endIndex - startIndex) / Speed;
|
2024-11-21 09:38:16 +08:00
|
|
|
|
|
2024-11-21 00:04:33 +08:00
|
|
|
|
|
|
|
|
|
Vector3[] waypoints = new Vector3[endIndex - startIndex + 1];
|
|
|
|
|
for (int i = startIndex, j = 0; j < pathPoints.Length && i <= endIndex; i++, j++)
|
|
|
|
|
{
|
2024-11-22 17:48:26 +08:00
|
|
|
|
if (!JudagePos1() && pathPoints[i] == JumpPos&&GetComponent<PlayerMovePos>().StartPos != JumpPos)
|
2024-11-21 12:03:01 +08:00
|
|
|
|
{
|
|
|
|
|
waypoints[j] = pathPoints[i - 1].position;
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
}
|
2024-11-21 00:04:33 +08:00
|
|
|
|
waypoints[j] = pathPoints[i].position;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
OnMove(waypoints);
|
|
|
|
|
}
|
|
|
|
|
else if (endIndex < startIndex)
|
|
|
|
|
{
|
2024-11-21 09:38:16 +08:00
|
|
|
|
|
2024-11-21 00:04:33 +08:00
|
|
|
|
duration = (startIndex - endIndex) / Speed;
|
2024-11-21 09:38:16 +08:00
|
|
|
|
|
2024-11-21 00:04:33 +08:00
|
|
|
|
//duration = (startIndex-endIndex) / Speed;
|
|
|
|
|
Vector3[] waypoints = new Vector3[startIndex - endIndex + 1];
|
|
|
|
|
for (int i = startIndex, j = 0; j < pathPoints.Length && i >= endIndex; i--, j++)
|
|
|
|
|
{
|
2024-11-22 17:48:26 +08:00
|
|
|
|
if (!JudagePos1() && pathPoints[i] == JumpPos&&GetComponent<PlayerMovePos>().StartPos!=JumpPos)
|
2024-11-21 12:03:01 +08:00
|
|
|
|
{
|
|
|
|
|
waypoints[j] = pathPoints[i + 1].position;
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
}
|
2024-11-21 00:04:33 +08:00
|
|
|
|
|
|
|
|
|
waypoints[j] = pathPoints[i].position;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
OnMove(waypoints);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void AfterMove()
|
|
|
|
|
{
|
2024-11-22 17:48:26 +08:00
|
|
|
|
//Debug.Log("<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ţ<EFBFBD><C5A3><EFBFBD><EFBFBD><EFBFBD>յ<EFBFBD>");
|
2024-11-21 00:04:33 +08:00
|
|
|
|
RectTransform rectTransform = objectToMove.GetComponent<RectTransform>();
|
2024-11-22 17:48:26 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//objectToMove.DOMoveY(objectToMove.position.y + 100, 0.5f).OnComplete(() => {
|
|
|
|
|
Zoomout();
|
2024-11-21 17:27:26 +08:00
|
|
|
|
rectTransform.DOAnchorPosY(rectTransform.anchoredPosition.y + 80f, 0.5f).SetEase(Ease.Linear)
|
2024-11-21 00:04:33 +08:00
|
|
|
|
.OnComplete(() => {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SetParentToHouse();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
objectToMove.GetComponent<PlayerMovePos>().StartPos = EndPos;
|
|
|
|
|
|
|
|
|
|
|
2024-11-22 12:15:36 +08:00
|
|
|
|
|
2024-11-21 00:04:33 +08:00
|
|
|
|
|
2024-11-21 17:27:26 +08:00
|
|
|
|
|
|
|
|
|
// rectTransform.anchoredPosition = new Vector2(rectTransform.anchoredPosition.x + Random.Range(-100, 100), rectTransform.anchoredPosition.y);
|
|
|
|
|
float range = Random.Range(-100, 100);
|
|
|
|
|
// <20>ж<EFBFBD><D0B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD>Ҫ<EFBFBD><D2AA>ת
|
|
|
|
|
if (range>0&& objectToMove.GetComponent<PlayerMovePos>().IsLeft)
|
|
|
|
|
{
|
|
|
|
|
objectToMove.GetComponent<PlayerMovePos>().IsLeft = false;
|
|
|
|
|
// <20><>ת<EFBFBD><D7AA><EFBFBD><EFBFBD>ʹ<EFBFBD><CAB9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ࣨ<EFBFBD><E0A3A8>Y<EFBFBD><59><EFBFBD><EFBFBD>ת180<38>ȣ<EFBFBD>
|
|
|
|
|
Rotate();
|
|
|
|
|
}
|
|
|
|
|
else if (range<0 && !objectToMove.GetComponent<PlayerMovePos>().IsLeft)
|
|
|
|
|
{
|
|
|
|
|
objectToMove.GetComponent<PlayerMovePos>().IsLeft = true;
|
|
|
|
|
Rotate();
|
|
|
|
|
}
|
2024-11-22 12:15:36 +08:00
|
|
|
|
rectTransform.DOAnchorPosX(rectTransform.anchoredPosition.x + range, 1f).SetEase(Ease.Linear).OnComplete(() => { objectToMove.GetComponent<PlayerMovePos>().PlayAni.SetInteger("State", 0); });
|
2024-11-21 17:27:26 +08:00
|
|
|
|
|
2024-11-21 00:04:33 +08:00
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//});
|
|
|
|
|
}
|
|
|
|
|
|
2024-11-22 12:15:36 +08:00
|
|
|
|
public void AfterReMove()
|
|
|
|
|
{
|
2024-11-22 17:48:26 +08:00
|
|
|
|
//Debug.Log("<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ţ<EFBFBD><C5A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
|
2024-11-22 12:15:36 +08:00
|
|
|
|
RectTransform rectTransform = objectToMove.GetComponent<RectTransform>();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//objectToMove.DOMoveY(objectToMove.position.y + 100, 0.5f).OnComplete(() => {
|
|
|
|
|
rectTransform.DOAnchorPosY(rectTransform.anchoredPosition.y+Random.Range(-200,-20), 0.5f).SetEase(Ease.Linear)
|
|
|
|
|
.OnComplete(() => {
|
|
|
|
|
|
2024-11-22 17:48:26 +08:00
|
|
|
|
objectToMove.GetComponent<PlayerMovePos>().StartPos = EndPos;
|
2024-11-22 12:15:36 +08:00
|
|
|
|
// rectTransform.anchoredPosition = new Vector2(rectTransform.anchoredPosition.x + Random.Range(-100, 100), rectTransform.anchoredPosition.y);
|
|
|
|
|
float range = Random.Range(-350, 350);
|
|
|
|
|
// <20>ж<EFBFBD><D0B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD>Ҫ<EFBFBD><D2AA>ת
|
|
|
|
|
if (range > 0 && objectToMove.GetComponent<PlayerMovePos>().IsLeft)
|
|
|
|
|
{
|
|
|
|
|
objectToMove.GetComponent<PlayerMovePos>().IsLeft = false;
|
|
|
|
|
// <20><>ת<EFBFBD><D7AA><EFBFBD><EFBFBD>ʹ<EFBFBD><CAB9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ࣨ<EFBFBD><E0A3A8>Y<EFBFBD><59><EFBFBD><EFBFBD>ת180<38>ȣ<EFBFBD>
|
|
|
|
|
Rotate();
|
|
|
|
|
}
|
|
|
|
|
else if (range < 0 && !objectToMove.GetComponent<PlayerMovePos>().IsLeft)
|
|
|
|
|
{
|
|
|
|
|
objectToMove.GetComponent<PlayerMovePos>().IsLeft = true;
|
|
|
|
|
Rotate();
|
|
|
|
|
}
|
|
|
|
|
rectTransform.DOAnchorPosX(rectTransform.anchoredPosition.x + range, 1f).SetEase(Ease.Linear).OnComplete(() => { objectToMove.GetComponent<PlayerMovePos>().PlayAni.SetInteger("State", 0); });
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void ReTurnStartPosMove()
|
|
|
|
|
{
|
|
|
|
|
|
2024-11-22 17:48:26 +08:00
|
|
|
|
//Debug.Log("<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ţ<EFBFBD>ƶ<EFBFBD>");
|
2024-11-22 12:15:36 +08:00
|
|
|
|
// <20><>ȡ·<C8A1><C2B7><EFBFBD>е<EFBFBD><D0B5><EFBFBD><EFBFBD>е<EFBFBD><D0B5><EFBFBD>λ<EFBFBD><CEBB>
|
2024-11-26 14:07:07 +08:00
|
|
|
|
//Debug.Log("·<><C2B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>" + pathPoints.Length);
|
2024-11-22 12:15:36 +08:00
|
|
|
|
for (int i = 0; i < pathPoints.Length; i++)
|
|
|
|
|
{
|
2024-11-22 17:48:26 +08:00
|
|
|
|
//Debug.Log("<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD><D0B6>յ<EFBFBD>");
|
2024-11-22 12:15:36 +08:00
|
|
|
|
if (objectToMove.GetComponent<PlayerMovePos>().StartPos == pathPoints[i])
|
|
|
|
|
{
|
|
|
|
|
startIndex = i;
|
|
|
|
|
//Debug.Log("Startindex"+i);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (EndPos == pathPoints[i])
|
|
|
|
|
{
|
|
|
|
|
endIndex = i;
|
|
|
|
|
//Debug.Log("Endindex" + i);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (endIndex > startIndex)
|
|
|
|
|
{
|
2024-11-22 17:48:26 +08:00
|
|
|
|
//Debug.Log("<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ţ<EFBFBD><C5A3><EFBFBD><EFBFBD>·<EFBFBD><C2B7>");
|
2024-11-22 12:15:36 +08:00
|
|
|
|
|
|
|
|
|
duration = (endIndex - startIndex) / Speed;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Vector3[] waypoints = new Vector3[endIndex - startIndex + 1];
|
|
|
|
|
for (int i = startIndex, j = 0; j < pathPoints.Length && i <= endIndex; i++, j++)
|
|
|
|
|
{
|
2024-11-22 17:48:26 +08:00
|
|
|
|
if (!JudagePos1() && pathPoints[i] == JumpPos && GetComponent<PlayerMovePos>().StartPos != JumpPos)
|
2024-11-22 12:15:36 +08:00
|
|
|
|
{
|
|
|
|
|
waypoints[j] = pathPoints[i - 1].position;
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
waypoints[j] = pathPoints[i].position;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
OnReMove(waypoints);
|
|
|
|
|
}
|
|
|
|
|
else if (endIndex < startIndex)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
duration = (startIndex - endIndex) / Speed;
|
|
|
|
|
|
|
|
|
|
//duration = (startIndex-endIndex) / Speed;
|
|
|
|
|
Vector3[] waypoints = new Vector3[startIndex - endIndex + 1];
|
|
|
|
|
for (int i = startIndex, j = 0; j < pathPoints.Length && i >= endIndex; i--, j++)
|
|
|
|
|
{
|
2024-11-22 17:48:26 +08:00
|
|
|
|
if (!JudagePos1() && pathPoints[i] == JumpPos && GetComponent<PlayerMovePos>().StartPos != JumpPos)
|
2024-11-22 12:15:36 +08:00
|
|
|
|
{
|
|
|
|
|
waypoints[j] = pathPoints[i + 1].position;
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
waypoints[j] = pathPoints[i].position;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
OnReMove(waypoints);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2024-11-21 00:04:33 +08:00
|
|
|
|
|
2024-11-22 17:48:26 +08:00
|
|
|
|
public void Zoomout()//<2F><>С
|
|
|
|
|
{
|
|
|
|
|
Image image = GetComponent<Image>();
|
|
|
|
|
image.rectTransform.DOScale(0.9f, 0.5f).SetEase(Ease.Linear);
|
|
|
|
|
}
|
|
|
|
|
public void ReplySize()//<2F>ָ<EFBFBD><D6B8><EFBFBD>С
|
|
|
|
|
{
|
|
|
|
|
Image image = GetComponent<Image>();
|
|
|
|
|
image.rectTransform.DOScale(originalScale, 0.5f).SetEase(Ease.Linear);
|
|
|
|
|
}
|
2024-11-21 00:04:33 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void Rotate()
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
Vector3 currentRotation = objectToMove.localEulerAngles;
|
|
|
|
|
currentRotation.y += 180f;
|
|
|
|
|
objectToMove.localEulerAngles = currentRotation;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void OnMove(Vector3[] waypoints)
|
|
|
|
|
{
|
2024-11-22 17:48:26 +08:00
|
|
|
|
|
2024-11-21 00:04:33 +08:00
|
|
|
|
objectToMove.GetComponent<PlayerMovePos>().PlayAni.SetInteger("State", 1);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
MoveOutParent();
|
|
|
|
|
Tween pathTween = objectToMove.DOPath(waypoints, duration, PathType.Linear)
|
|
|
|
|
.SetEase(Ease.Linear) // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Թ<EFBFBD><D4B9><EFBFBD>Ч<EFBFBD><D0A7>
|
|
|
|
|
.SetLoops(isLooping ? -1 : 0)
|
|
|
|
|
.OnWaypointChange((index) =>
|
|
|
|
|
{
|
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD>嵽<EFBFBD><E5B5BD>ij<EFBFBD><C4B3>·<EFBFBD><C2B7><EFBFBD><EFBFBD>ʱ<EFBFBD>ص<EFBFBD>
|
|
|
|
|
if (index < waypoints.Length - 1)
|
|
|
|
|
{
|
|
|
|
|
Vector3 currentWaypoint = waypoints[index];
|
|
|
|
|
Vector3 nextWaypoint = waypoints[index + 1];
|
2024-11-21 09:38:16 +08:00
|
|
|
|
|
2024-11-21 00:04:33 +08:00
|
|
|
|
// <20>ж<EFBFBD><D0B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD>Ҫ<EFBFBD><D2AA>ת
|
|
|
|
|
if (nextWaypoint.x < currentWaypoint.x && !objectToMove.GetComponent<PlayerMovePos>().IsLeft)
|
|
|
|
|
{
|
|
|
|
|
objectToMove.GetComponent<PlayerMovePos>().IsLeft = true;
|
|
|
|
|
// <20><>ת<EFBFBD><D7AA><EFBFBD><EFBFBD>ʹ<EFBFBD><CAB9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ࣨ<EFBFBD><E0A3A8>Y<EFBFBD><59><EFBFBD><EFBFBD>ת180<38>ȣ<EFBFBD>
|
|
|
|
|
Rotate();
|
|
|
|
|
}
|
|
|
|
|
else if (nextWaypoint.x > currentWaypoint.x && objectToMove.GetComponent<PlayerMovePos>().IsLeft)
|
|
|
|
|
{
|
|
|
|
|
objectToMove.GetComponent<PlayerMovePos>().IsLeft = false;
|
|
|
|
|
Rotate();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2024-11-21 09:38:16 +08:00
|
|
|
|
|
2024-11-21 00:04:33 +08:00
|
|
|
|
})
|
|
|
|
|
.OnComplete(AfterMove);
|
|
|
|
|
}
|
2024-11-22 12:15:36 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void OnReMove(Vector3[] waypoints)
|
|
|
|
|
{
|
2024-11-22 17:48:26 +08:00
|
|
|
|
|
2024-11-22 12:15:36 +08:00
|
|
|
|
objectToMove.GetComponent<PlayerMovePos>().PlayAni.SetInteger("State", 1);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
MoveOutParent();
|
2024-11-22 17:48:26 +08:00
|
|
|
|
ReplySize();//<2F>ָ<EFBFBD><D6B8><EFBFBD>С
|
2024-11-22 12:15:36 +08:00
|
|
|
|
Tween pathTween = objectToMove.DOPath(waypoints, duration, PathType.Linear)
|
|
|
|
|
.SetEase(Ease.Linear) // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Թ<EFBFBD><D4B9><EFBFBD>Ч<EFBFBD><D0A7>
|
|
|
|
|
.SetLoops(isLooping ? -1 : 0)
|
|
|
|
|
.OnWaypointChange((index) =>
|
|
|
|
|
{
|
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD>嵽<EFBFBD><E5B5BD>ij<EFBFBD><C4B3>·<EFBFBD><C2B7><EFBFBD><EFBFBD>ʱ<EFBFBD>ص<EFBFBD>
|
|
|
|
|
if (index < waypoints.Length - 1)
|
|
|
|
|
{
|
|
|
|
|
Vector3 currentWaypoint = waypoints[index];
|
|
|
|
|
Vector3 nextWaypoint = waypoints[index + 1];
|
|
|
|
|
|
|
|
|
|
// <20>ж<EFBFBD><D0B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD>Ҫ<EFBFBD><D2AA>ת
|
|
|
|
|
if (nextWaypoint.x < currentWaypoint.x && !objectToMove.GetComponent<PlayerMovePos>().IsLeft)
|
|
|
|
|
{
|
|
|
|
|
objectToMove.GetComponent<PlayerMovePos>().IsLeft = true;
|
|
|
|
|
// <20><>ת<EFBFBD><D7AA><EFBFBD><EFBFBD>ʹ<EFBFBD><CAB9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ࣨ<EFBFBD><E0A3A8>Y<EFBFBD><59><EFBFBD><EFBFBD>ת180<38>ȣ<EFBFBD>
|
|
|
|
|
Rotate();
|
|
|
|
|
}
|
|
|
|
|
else if (nextWaypoint.x > currentWaypoint.x && objectToMove.GetComponent<PlayerMovePos>().IsLeft)
|
|
|
|
|
{
|
|
|
|
|
objectToMove.GetComponent<PlayerMovePos>().IsLeft = false;
|
|
|
|
|
Rotate();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
})
|
|
|
|
|
.OnComplete(AfterReMove);
|
|
|
|
|
}
|
2024-11-21 00:04:33 +08:00
|
|
|
|
}
|