NLDClient-yudde/ProjectNLD/Assets/Code/Scripts/Gameplay/Character/Character.GameObject.cs

67 lines
1.9 KiB
C#
Raw Normal View History

2023-08-22 19:08:45 +08:00
using Cysharp.Threading.Tasks;
2023-10-19 15:00:19 +08:00
using Gameplay.Emoji;
2023-08-22 19:08:45 +08:00
using Gameplay.Level;
2023-10-19 15:00:19 +08:00
using Gameplay.Performance;
2024-02-20 13:45:32 +08:00
using Gameplay.Unit;
using PhxhSDK;
2023-08-22 19:08:45 +08:00
using UnityEngine;
namespace Gameplay.Character
{
public partial class Character
{
public Transform leftHandTrans;
public Transform rightHandTrans;
2024-02-20 13:45:32 +08:00
public async UniTask CreateAsync()
2023-08-22 19:08:45 +08:00
{
2024-02-20 13:45:32 +08:00
var modelPath = runtimeData.configData.modelPath;
GameUnitManager.instance.RecordLoadPath(modelPath);
2024-02-20 14:33:52 +08:00
await AssetManager.Instance.PostPreload<GameObject>(modelPath);
2024-02-20 13:45:32 +08:00
var obj = Load(runtimeData.configData.modelPath);
2023-10-19 15:00:19 +08:00
PerformanceManager.instance.HandleCreateUnit(obj);
2023-08-22 19:08:45 +08:00
await _OnObjLoaded(obj);
}
private async UniTask _OnObjLoaded(GameObject obj)
{
var isEnemy = troopId != ETroopsId.Self;
2023-10-19 15:00:19 +08:00
emojiManager = EmojiManager.inst.InitCharacter(this);
2023-10-30 12:09:55 +08:00
// emoji 会替换outline所以要在emoji之后
OutlineManager.instance.AutoAddFromObj(obj, isEnemy);
leftHandTrans = Skeleton.GetBone("Grip_point02");
rightHandTrans = Skeleton.GetBone("Grip_point01");
2023-10-30 12:09:55 +08:00
2023-08-22 19:08:45 +08:00
cAnim = new CharacterAnim(this);
await cAnim.Init();
weapon = new Weapon.ViewWeapon(this);
}
protected override void UpdateGameObjectName()
{
SetName($"Character_{GetID()}");
DebugUtil.Log(Node.GameObject.name);
}
protected override void OnDispose()
{
base.OnDispose();
2023-10-27 13:59:26 +08:00
emojiManager.Dispose();
2023-08-22 19:08:45 +08:00
SelecterView.Instance.UnSelect(Node);
2024-02-20 15:17:22 +08:00
_fullFSM = null;
_upFSM = null;
_downFSM = null;
weapon = null;
cAnim = null;
fightData = null;
aliveData = null;
runtimeData = null;
2023-08-22 19:08:45 +08:00
}
}
}