UnitFactory.cs 577 B

12345678910111213141516171819
  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<PlayerDeadComponent>();
  11. player.AddComponent<BuffComponent>();
  12. Buff buff = new Buff(1);
  13. player.GetComponent<BuffComponent>().Add(buff);
  14. World.Instance.GetComponent<UnitComponent>().Add(player);
  15. return player;
  16. }
  17. }
  18. }