39 lines
1.1 KiB
C#
39 lines
1.1 KiB
C#
|
using System.Collections;
|
|||
|
using System.Collections.Generic;
|
|||
|
using UnityEngine;
|
|||
|
using DG.Tweening;
|
|||
|
|
|||
|
|
|||
|
public class npcMove : MonoBehaviour
|
|||
|
{
|
|||
|
public List<Transform> path=new List<Transform>();
|
|||
|
public float moveNeedTimer;
|
|||
|
|
|||
|
public void Init(List<Transform> path,float moveNeedTimer)
|
|||
|
{
|
|||
|
this.path = path;
|
|||
|
this.moveNeedTimer = moveNeedTimer;
|
|||
|
|
|||
|
StartCoroutine(move());
|
|||
|
}
|
|||
|
|
|||
|
IEnumerator move()
|
|||
|
{
|
|||
|
// <20><>·<EFBFBD><C2B7><EFBFBD><EFBFBD>ת<EFBFBD><D7AA>Ϊ Vector3 <20><><EFBFBD><EFBFBD>
|
|||
|
Vector3[] pathPoints = new Vector3[this.path.Count];
|
|||
|
for (int i = 0; i < path.Count; i++)
|
|||
|
{
|
|||
|
pathPoints[i] = path[i].position;
|
|||
|
}
|
|||
|
|
|||
|
// ʹ<><CAB9> DOPath <20><><EFBFBD><EFBFBD>·<EFBFBD><C2B7><EFBFBD>ƶ<EFBFBD><C6B6><EFBFBD>Ŀ<EFBFBD><C4BF><EFBFBD>㣬<EFBFBD><E3A3AC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ת<EFBFBD>仯
|
|||
|
yield return this.transform.DOPath(pathPoints, moveNeedTimer, PathType.Linear)
|
|||
|
.SetOptions(false) // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ת
|
|||
|
.SetEase(Ease.InOutSine)
|
|||
|
.WaitForCompletion();
|
|||
|
//<2F>ƶ<EFBFBD><C6B6><EFBFBD><EFBFBD>յ<EFBFBD>
|
|||
|
PlayerInfo.instance.ChangeHp(-1);
|
|||
|
Destroy(this.gameObject);
|
|||
|
}
|
|||
|
}
|