| 123456789101112131415161718192021222324252627282930 |
- using UnityEngine;
- namespace ET
- {
- public static class UnitFactory
- {
- public static Unit Create(Entity domain, UnitInfo unitInfo)
- {
- UnitComponent unitComponent = domain.GetComponent<UnitComponent>();
- Unit unit = unitComponent.AddChildWithId<Unit, int>(unitInfo.UnitId, unitInfo.ConfigId);
- unitComponent.Add(unit);
-
- unit.Position = new Vector3(unitInfo.X, unitInfo.Y, unitInfo.Z);
-
- unit.AddComponent<MoveComponent>();
- NumericComponent numericComponent = unit.AddComponent<NumericComponent>();
- for (int i = 0; i < unitInfo.Ks.Count; ++i)
- {
- numericComponent.Set((NumericType)unitInfo.Ks[i], unitInfo.Vs[i]);
- }
- unit.AddComponent<ObjectWait>();
- unit.AddComponent<XunLuoPathComponent>();
-
- Game.EventSystem.Publish(new EventType.AfterUnitCreate() {Unit = unit});
- return unit;
- }
- }
- }
|