Cute_demon_attacks/meng_yao/Assets/script/A_Fight/InitEnenyData.cs
2024-12-12 23:04:13 +08:00

41 lines
1.0 KiB
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Experimental.GlobalIllumination;
public class InitEnenyData : MonoBehaviour
{
public static InitEnenyData instance;
[Header("路径点集合")] public List<waypoints> mywaypoints = new List<waypoints>();
private void Awake()
{
instance = this;
// Debug.Log(mywaypoints.Count);
}
// 返回一个随机选择的路径点集合
public waypoints GetRandomWaypoints()
{
// 检查列表是否为空,避免数组越界错误
if (mywaypoints.Count == 0)
{
Debug.LogError("路径点集合为空!");
return null; // 或者返回一个默认值
}
// 如果只有一个路径点集合,直接返回
if (mywaypoints.Count == 1)
{
return mywaypoints[0];
}
// 随机选择一个索引,范围是 [0, mywaypoints.Count - 1]
int randomIndex = Random.Range(0, mywaypoints.Count);
// 返回随机选择的路径点集合
return mywaypoints[randomIndex];
}
}