mycj_demo/mycj/Assets/Script/npcInit.cs
2024-12-02 09:37:47 +08:00

49 lines
1.0 KiB
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class npcInit : MonoBehaviour
{
[Header("预制体")]
public GameObject npcPrefab;
[Header("路径")]
public List<Transform> path = new List<Transform>();
[Header("需要的总时间")]
public float moveNeedTimer;
// Start is called before the first frame update
void Start()
{
Penal.instance.Daojishi(5f);
StartCoroutine(getmouse());
}
// Update is called once per frame
void Update()
{
}
void GetMouse()
{
GameObject go = Instantiate(npcPrefab, this.transform);
go.transform.position = path[0].transform.position;
go.GetComponent<npcMove>().Init(path, moveNeedTimer);
}
IEnumerator getmouse()
{
yield return new WaitForSeconds(5f);
int index = 0;
while (index<=4)
{
GetMouse();
index++;
yield return new WaitForSeconds(3f);
}
}
}