using System; using UnityEngine; namespace ET { public static class UnitFactory { public static Unit Create(Scene scene, long id, UnitType unitType) { UnitComponent unitComponent = scene.GetComponent(); switch (unitType) { case UnitType.Player: { Unit unit = unitComponent.AddChildWithId(id, 1001); unit.AddComponent(); unit.Position = new Vector3(-10, 0, -10); NumericComponent numericComponent = unit.AddComponent(); numericComponent.Set(NumericType.Speed, 6f); // 速度是6米每秒 numericComponent.Set(NumericType.AOI, 15000); // 视野15米 unitComponent.Add(unit); // 加入aoi unit.AddComponent(9 * 1000, unit.Position); return unit; } default: throw new Exception($"not such unit type: {unitType}"); } } } }