UnitFactory.cs 626 B

123456789101112131415161718192021
  1. using UnityEngine;
  2. namespace Model
  3. {
  4. public static class UnitFactory
  5. {
  6. public static Unit Create(long id)
  7. {
  8. UnitComponent unitComponent = Game.Scene.GetComponent<UnitComponent>();
  9. GameObject prefab = ((GameObject) Resources.Load("Unit")).Get<GameObject>("Skeleton");
  10. Unit unit = EntityFactory.CreateWithId<Unit>(id);
  11. unit.GameObject = UnityEngine.Object.Instantiate(prefab);
  12. unit.AddComponent<AnimatorComponent>();
  13. unit.AddComponent<MoveComponent>();
  14. unitComponent.Add(unit);
  15. return unit;
  16. }
  17. }
  18. }