EntityBuilder.java 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. package me.hammerle.supersnuvi.entity;
  2. import me.hammerle.supersnuvi.entity.components.DefaultHealth;
  3. import me.hammerle.supersnuvi.entity.components.DefaultMovement;
  4. import me.hammerle.supersnuvi.entity.components.DefaultEnergy;
  5. import me.hammerle.supersnuvi.entity.components.StoneMovement;
  6. import me.hammerle.supersnuvi.entity.components.ai.HumanController;
  7. import me.hammerle.supersnuvi.entity.components.ai.LondonerController;
  8. import me.hammerle.supersnuvi.gamelogic.Level;
  9. import me.hammerle.supersnuvi.tiles.Tile;
  10. import me.hammerle.supersnuvi.entity.components.IDeath;
  11. import me.hammerle.supersnuvi.entity.components.ItemCollector;
  12. import me.hammerle.supersnuvi.entity.components.NoHealth;
  13. import me.hammerle.supersnuvi.entity.components.ai.StoneController;
  14. import me.hammerle.supersnuvi.util.CollisionBox;
  15. public final class EntityBuilder
  16. {
  17. public static Entity buildHero(Level level, float x, float y)
  18. {
  19. Entity hero = new Entity(level, x, y, new CollisionBox(0.0f, 5.0f, 29.0f, 64.0f));
  20. hero.controller = new HumanController(hero);
  21. hero.health = new DefaultHealth(hero, (ent) -> ent.getLevel().scheduleReset(), 100.0f, null, null, null);
  22. hero.energy = new DefaultEnergy(hero, 100.0f);
  23. hero.move = new DefaultMovement(hero, 12.0f, 0.0f, 50.0f);
  24. hero.itemCollector = ItemCollector.HERO;
  25. return hero;
  26. }
  27. public static Entity buildLondoner(Level level, float x, float y, boolean evil)
  28. {
  29. float w = Tile.SIZE;
  30. float h = Tile.SIZE * 2;
  31. Entity hero = new Entity(level, x, y, new CollisionBox(0.0f, 0.0f, w * 0.4375f, h * 0.703125f));
  32. //hero.controller = new FollowHeroController(hero, 2);
  33. hero.controller = new LondonerController(hero, evil);
  34. hero.health = new DefaultHealth(hero, IDeath.NULL, 100.0f, null, null, null);
  35. hero.energy = new DefaultEnergy(hero, 100.0f);
  36. hero.move = new DefaultMovement(hero, 3f, 3f, 24.0f);
  37. //hero.itemCollector = new HeroItemCollector(hero);
  38. return hero;
  39. }
  40. public static Entity buildCrumblingStone(Level level, float x, float y)
  41. {
  42. Entity stone = new Entity(level, x, y, new CollisionBox(0.0f, 0.0f, Tile.SIZE, Tile.SIZE * 10f));
  43. stone.controller = new StoneController(stone);
  44. stone.move = new StoneMovement(stone);
  45. stone.health = new NoHealth(stone);
  46. return stone;
  47. }
  48. public static Entity fromId(int id, Level level, float x, float y)
  49. {
  50. switch(id)
  51. {
  52. case 1:
  53. return buildLondoner(level, x, y, true);
  54. case 2:
  55. return buildLondoner(level, x, y, false);
  56. }
  57. return null;
  58. }
  59. }