UnitFactory.cs 560 B

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