zxl
/
CTT
forked from Cal/CTT
1
0
Fork 0
CTT/Unity/Assets/HotfixView/Event/ChangeSkinEvent.cs

37 lines
1017 B
C#
Raw Normal View History

2021-04-08 20:09:59 +08:00
using Cal.DataTable;
using ET.EventType;
using ET;
using System;
using System.Collections.Generic;
namespace ET
{
public class ChangeSkinEvent : AEvent<ChangeSkin>
{
public override async ETTask Run(ChangeSkin args)
{
long id = args.Id;
2021-04-11 19:50:39 +08:00
int skinId = args.skinId;
var zoneScene = args.zoneScene;
Unit unit = zoneScene.GetComponent<UnitComponent>().Get(id);
2021-04-08 20:09:59 +08:00
if (!unit)
{
Log.Error($"unit is invalid where id = {id}");
return;
}
SkinBase skinBase =SkinBaseCategory.Instance.Get(skinId);
if (skinBase == null)
{
Log.Error($"没有skinId = {skinId}");
return;
}
2021-04-11 19:50:39 +08:00
UnitView unitView = unit.GetComponent<UnitView>();
2021-04-08 20:09:59 +08:00
if (unitView)
{
await unitView.ChangeSkin(skinBase.PrfabId);
}
await ETTask.CompletedTask;
}
}
}