using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.Experimental.GlobalIllumination; public class InitEnenyData : MonoBehaviour { public static InitEnenyData instance; [Header("路径点集合")] public List mywaypoints = new List(); 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]; } }