Main/Assets/Code/Logic/WarningFiled/WarningFiledManager.cs

129 lines
3.5 KiB
C#
Raw Normal View History

2025-01-25 04:38:09 +08:00
using Thousandto.Code.Center;
using Thousandto.Code.Logic.WarningField;
using Thousandto.Core.Asset;
using Thousandto.Core.Base;
using Thousandto.Plugins.Common.UniScene;
using System.Collections.Generic;
using UnityEngine;
namespace Thousandto.Code.Logic
{
public class WarningFiledManager:BaseSystem
{
#region//私有变量
private const string WarningRootName = "[WarningRoot]";
private static Transform _root = null;
private static GameObject _rootGo = null;
private List<WarningFiledInst> _filedList = new List<WarningFiledInst>();
#endregion
#region//属性
public static Transform Root
{
get
{
return _root;
}
}
public List<WarningFiledInst> FiledList
{
get
{
return _filedList;
}
}
#endregion
#region//构造函数
static WarningFiledManager()
{
_rootGo = new GameObject(WarningRootName);
_root = _rootGo.transform;
_root.parent = AppRoot.Transform;
//GameObject.DontDestroyOnLoad(_rootGo);
}
#endregion
#region//公有函数
//初始化处理
public void Initialize()
{
}
//卸载处理
public void Uninitialize()
{
for (int i = 0; i < _filedList.Count; ++i)
{
_filedList[i].Destroy();
}
_filedList.Clear();
}
protected override bool OnUpdate(float dt)
{
for (int i = _filedList.Count - 1; i >= 0; --i)
{
_filedList[i].Update();
if (_filedList[i].IsFinish)
{
_filedList[i].Destroy();
_filedList.RemoveAt(i);
}
}
return true;
}
//增加警示圈
public uint AddFiled(Entity host, bool syncPos, bool syncDir, SkillTargetArea areaType, float param1, float param2, float startDis, float aniTime)
{
if (host == null)
return 0;
WarningFiledInst inst = new WarningFiledInst(host, syncPos, syncDir, areaType, param1, param2, startDis, aniTime);
_filedList.Add(inst);
return inst.ID;
}
//增加警示圈
public uint AddFiled(Entity host, Vector3 pos, SkillTargetArea areaType, float param1, float param2, float startDis, float aniTime)
{
if (host == null)
return 0;
WarningFiledInst inst = new WarningFiledInst(host, pos, areaType, param1, param2, startDis, aniTime);
_filedList.Add(inst);
return inst.ID;
}
//删除警示圈
public void RemoveFiled(uint id)
{
for (int i = _filedList.Count - 1; i >= 0; --i)
{
if(_filedList[i].ID == id)
{
_filedList[i].Destroy();
_filedList.RemoveAt(i);
}
}
}
//删除警示圈
public void RemoveFiled(Entity host)
{
for (int i = _filedList.Count - 1; i >= 0; --i)
{
if (_filedList[i].Host == host)
{
_filedList[i].Destroy();
_filedList.RemoveAt(i);
}
}
}
#endregion
}
}