UnitFactory.cs 636 B

123456789101112131415161718192021222324
  1. using Common.Base;
  2. using Common.Factory;
  3. namespace Model
  4. {
  5. public static class UnitFactory
  6. {
  7. public static Unit Create(UnitType unitType, int configId)
  8. {
  9. return World.Instance.GetComponent<FactoryComponent>().Create<Unit>((int) unitType, configId);
  10. }
  11. }
  12. [FactoryAttribute(typeof (Unit), (int) UnitType.Player)]
  13. public class UnitPlayerFactory: IFactory
  14. {
  15. public Entity Create(int configId)
  16. {
  17. Unit player = new Unit(configId);
  18. player.AddComponent<BuffComponent>();
  19. return player;
  20. }
  21. }
  22. }