UnitFactory.cs 531 B

123456789101112131415161718
  1. using Model;
  2. namespace Controller
  3. {
  4. [Factory(typeof (Unit), UnitType.Player)]
  5. public class UnitPlayerFactory: IFactory<Unit>
  6. {
  7. public Unit Create(int configId)
  8. {
  9. Unit player = new Unit(configId);
  10. player.AddComponent<BuffComponent>();
  11. Buff buff = new Buff(1, player.Id);
  12. player.GetComponent<BuffComponent>().Add(buff);
  13. World.Instance.GetComponent<UnitComponent>().Add(player);
  14. return player;
  15. }
  16. }
  17. }