61 lines
1.9 KiB
C#
61 lines
1.9 KiB
C#
using Cysharp.Threading.Tasks;
|
|
using Gameplay.Character;
|
|
using Gameplay.Performance;
|
|
using Gameplay.Unit;
|
|
using Gameplay.Unit.Data;
|
|
using Gameplay.Vehicle.Data;
|
|
using PhxhSDK;
|
|
using UnityEngine;
|
|
namespace Gameplay.Vehicle
|
|
{
|
|
public class BaseVehicle : GameUnit
|
|
{
|
|
|
|
public readonly VehicleConfigData configData;
|
|
public readonly VehicleRuntimeData runtimeData;
|
|
|
|
public VehicleAnim vAnim;
|
|
|
|
public BaseVehicle(uint id, VehicleConfigData configData,
|
|
int troopId) : base(id, troopId, EGameUnitType.Vehicle)
|
|
{
|
|
this.configData = configData;
|
|
runtimeData = new VehicleRuntimeData();
|
|
runtimeData.owner = this;
|
|
runtimeData.configData = configData;
|
|
|
|
commonData.canControl = troopId == ETroopsId.Self;
|
|
}
|
|
|
|
public async UniTask CreateAsync()
|
|
{
|
|
GameUnitManager.instance.RecordLoadPath(configData.prefabPath);
|
|
var sampleObj = await AssetManager.Instance.LoadAssetAsync<GameObject>(configData.prefabPath);
|
|
if (sampleObj == null)
|
|
{
|
|
DebugUtil.LogError("加载vehicle失败: {0}", configData.prefabPath);
|
|
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);
|
|
|
|
// 绑定动画数据
|
|
vAnim = new VehicleAnim(this);
|
|
|
|
// 设置后处理
|
|
var obj = Node.GameObject;
|
|
var isEnemy = commonData.troopId != ETroopsId.Self;
|
|
OutlineManager.instance.AutoAddFromObj(obj, isEnemy);
|
|
|
|
PerformanceManager.instance.HandleCreateUnit(obj);
|
|
}
|
|
|
|
}
|
|
}
|