(client) feat:实现右键菜单
This commit is contained in:
@ -1,30 +1,46 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Base;
|
||||
using Prefab;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Managers
|
||||
{
|
||||
public class EntityManage:Utils.MonoSingleton<EntityManage>
|
||||
public class EntityManage:Utils.MonoSingleton<EntityManage>,ITick
|
||||
{
|
||||
public Dictionary<string, List<EntityPrefab>> factionEntities = new();
|
||||
|
||||
public GameObject entityLevel;
|
||||
public EntityPrefab entityPrefab;
|
||||
void Update()
|
||||
{
|
||||
// 检测鼠标左键是否按下
|
||||
if (Input.GetMouseButtonDown(0))
|
||||
{
|
||||
var ray = Camera.main.ScreenPointToRay(Input.mousePosition); // 获取从相机发出的射线
|
||||
|
||||
if (Physics.Raycast(ray, out var hit)) // 检测射线是否击中物体
|
||||
public void Tick()
|
||||
{
|
||||
foreach (var faction in factionEntities)
|
||||
{
|
||||
List<EntityPrefab> entitiesToRemove = new List<EntityPrefab>();
|
||||
|
||||
foreach (var entityPrefab in faction.Value)
|
||||
{
|
||||
Debug.Log("点击了物体: " + hit.collider.gameObject.name);
|
||||
|
||||
if (entityPrefab.entity.IsDead)
|
||||
{
|
||||
entitiesToRemove.Add(entityPrefab);
|
||||
}
|
||||
else
|
||||
{
|
||||
ITick itike = entityPrefab.entity;
|
||||
itike.Tick();
|
||||
}
|
||||
}
|
||||
|
||||
// 删除所有标记为死亡的实体
|
||||
foreach (var entityToRemove in entitiesToRemove)
|
||||
{
|
||||
faction.Value.Remove(entityToRemove);
|
||||
Destroy(entityToRemove.gameObject);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 根据给定的PawnDef生成一个实体对象。
|
||||
/// </summary>
|
||||
@ -75,8 +91,6 @@ namespace Managers
|
||||
factionEntities[factionKey] = new List<EntityPrefab>();
|
||||
}
|
||||
factionEntities[factionKey].Add(entityComponent);
|
||||
|
||||
Base.Clock.AddTick(entity.GetComponent<Entity.Entity>());
|
||||
}
|
||||
catch (System.Exception ex)
|
||||
{
|
||||
|
Reference in New Issue
Block a user