99 lines
2.0 KiB
C#
99 lines
2.0 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using UnityEngine.Rendering;
|
|
|
|
|
|
|
|
|
|
|
|
public class SpawnMonster : Base
|
|
{
|
|
public static SpawnMonster intance;
|
|
|
|
|
|
private void Awake()
|
|
{
|
|
intance = this;
|
|
}
|
|
|
|
void Start()
|
|
{
|
|
Base.GlobalObj.GetComponent<gameGlobal>().OnGamePlay += this.StartSpawning;
|
|
}
|
|
|
|
|
|
/*public void UpdateNodeList()
|
|
{
|
|
// 获取所有带有 SortingGroup 组件的敌人对象
|
|
List<GameObject> gameObjectsList = new List<GameObject>();
|
|
|
|
foreach (GameObject go in Enemys)
|
|
{
|
|
// 获取该物体上的 SortingGroup 组件
|
|
if (go != null)
|
|
{
|
|
SortingGroup sortingGroup = go.GetComponent<SortingGroup>();
|
|
if (sortingGroup != null && go.activeSelf)
|
|
{
|
|
// 添加到列表中
|
|
gameObjectsList.Add(go);
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
// 按照 y 轴排序
|
|
gameObjectsList.Sort((a, b) => a.transform.position.y.CompareTo(b.transform.position.y));
|
|
|
|
// 设置 SortingGroup 和子 Canvas 的 sortingOrder
|
|
for (int i = 0; i < gameObjectsList.Count; i++)
|
|
{
|
|
SortingGroup sortingGroup = gameObjectsList[i].GetComponent<SortingGroup>();
|
|
if (sortingGroup != null)
|
|
{
|
|
// 计算排序顺序
|
|
int order = gameObjectsList.Count - i + 2;
|
|
sortingGroup.sortingOrder = order;
|
|
|
|
// 获取子 Canvas 并设置其 sortingOrder
|
|
Canvas canvas = gameObjectsList[i].GetComponentInChildren<Canvas>();
|
|
if (canvas != null)
|
|
{
|
|
canvas.sortingOrder = order;
|
|
}
|
|
}
|
|
}
|
|
}*/
|
|
|
|
|
|
|
|
void Update()
|
|
{
|
|
|
|
}
|
|
|
|
|
|
public void StartSpawning()
|
|
{
|
|
|
|
}
|
|
|
|
void GenerateEnemy()
|
|
{
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void OnDisable()
|
|
{
|
|
Base.GlobalObj.GetComponent<gameGlobal>().OnGamePlay -= this.StartSpawning;
|
|
}
|
|
}
|
|
|
|
|
|
|