38 lines
1.1 KiB
C#
38 lines
1.1 KiB
C#
using ET.EventType;
|
|
using ET;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
namespace ET
|
|
{
|
|
public class OnCreateUnitEvent : AEvent<ET.EventType.OnCreateUnit>
|
|
{
|
|
public override async ETTask Run(OnCreateUnit args)
|
|
{
|
|
Unit unit = args.unit;
|
|
var zoneScene = args.zoneScene;
|
|
|
|
GameObject go = (await ResourceViewHelper.LoadPrefabAsync(args.prefabId)).gameObject;
|
|
unit.AddComponent<UnitView, GameObject>(go);
|
|
unit.AddComponent<PopupComponent>();
|
|
|
|
HudComponent.Instance.Init(unit);
|
|
|
|
if (unit.UnitType == UnitType.Player ||
|
|
unit.UnitType == UnitType.TeamMember ||
|
|
unit.UnitType == UnitType.OtherPlayer
|
|
)
|
|
{
|
|
unit.AddComponent<UnitPathComponent>();
|
|
}
|
|
|
|
if (unit.Id == zoneScene.GetComponent<GlobalVariable>().MyId)
|
|
{
|
|
unit.AddComponent<CameraComponent, float, float>(-15, 15);
|
|
}
|
|
await ETTask.CompletedTask;
|
|
}
|
|
}
|
|
}
|