NLDClient-yudde/ProjectNLD/Assets/Code/Scripts/Gameplay/Fight/Protect/BeProtectUnit.cs

55 lines
1.8 KiB
C#

using Cysharp.Threading.Tasks;
using Gameplay.Character;
using Gameplay.Fight.Protect.Anim;
using Gameplay.Fight.Protect.Data;
using Gameplay.Performance;
using Gameplay.Unit;
using Gameplay.Unit.Data;
using PhxhSDK;
using UnityEngine;
namespace Gameplay.Fight.Protect
{
public class BeProtectUnit : GameUnit
{
public BeProtectDataConfig configData;
public BeProtectUnitAnim anim;
public BeProtectUnit(uint id,
int troopId, BeProtectDataConfig configData) : base(id, troopId, EGameUnitType.BeProtect)
{
this.configData = configData;
commonData.canControl = false;
commonData.standLevel = configData.rawConfig.StandCrossLevel;
commonData.crossLevel = configData.rawConfig.MoveCrossLevel;
}
public async UniTask CreateAsync()
{
GameUnitManager.instance.RecordLoadPath(configData.modelPath);
var sampleObj = await AssetManager.Instance.LoadAssetAsync<GameObject>(configData.modelPath);
if (sampleObj == null)
{
DebugUtil.LogError("加载BeProtectUnit失败: {0}", configData.modelPath);
return;
}
if (Node == null) return;
var parent = Node.GameObject.transform;
var go = Object.Instantiate(sampleObj, parent, true);
go.transform.ResetLocals();
Node.GameObject.SetLayerEx(Node.GameObject.layer);
anim = new BeProtectUnitAnim(go);
// 设置后处理
var obj = Node.GameObject;
var isEnemy = commonData.troopId != ETroopsId.Self;
OutlineManager.instance.AutoAddFromObj(obj, isEnemy);
PerformanceManager.instance.HandleCreateUnit(obj);
}
}
}