1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465 |
- package me.hammerle.supersnuvi.entity;
- import me.hammerle.supersnuvi.entity.components.DefaultHealth;
- import me.hammerle.supersnuvi.entity.components.DefaultMovement;
- import me.hammerle.supersnuvi.entity.components.DefaultEnergy;
- import me.hammerle.supersnuvi.entity.components.StoneMovement;
- import me.hammerle.supersnuvi.entity.components.ai.HumanController;
- import me.hammerle.supersnuvi.entity.components.ai.LondonerController;
- import me.hammerle.supersnuvi.gamelogic.Level;
- import me.hammerle.supersnuvi.tiles.Tile;
- import me.hammerle.supersnuvi.entity.components.IDeath;
- import me.hammerle.supersnuvi.entity.components.ItemCollector;
- import me.hammerle.supersnuvi.entity.components.NoHealth;
- import me.hammerle.supersnuvi.entity.components.ai.StoneController;
- import me.hammerle.supersnuvi.util.CollisionBox;
- public final class EntityBuilder
- {
- public static Entity buildHero(Level level, float x, float y)
- {
- Entity hero = new Entity(level, x, y, new CollisionBox(0.0f, 5.0f, 29.0f, 64.0f));
- hero.controller = new HumanController(hero);
- hero.health = new DefaultHealth(hero, (ent) -> ent.getLevel().scheduleReset(), 100.0f, null, null, null);
- hero.energy = new DefaultEnergy(hero, 100.0f);
- hero.move = new DefaultMovement(hero, 12.0f, 0.0f, 50.0f);
- hero.itemCollector = ItemCollector.HERO;
- return hero;
- }
-
- public static Entity buildLondoner(Level level, float x, float y, boolean evil)
- {
- float w = Tile.SIZE;
- float h = Tile.SIZE * 2;
- Entity hero = new Entity(level, x, y, new CollisionBox(0.0f, 0.0f, w * 0.4375f, h * 0.703125f));
- //hero.controller = new FollowHeroController(hero, 2);
- hero.controller = new LondonerController(hero, evil);
- hero.health = new DefaultHealth(hero, IDeath.NULL, 100.0f, null, null, null);
- hero.energy = new DefaultEnergy(hero, 100.0f);
- hero.move = new DefaultMovement(hero, 3f, 3f, 24.0f);
- //hero.itemCollector = new HeroItemCollector(hero);
- return hero;
- }
-
- public static Entity buildCrumblingStone(Level level, float x, float y)
- {
- Entity stone = new Entity(level, x, y, new CollisionBox(0.0f, 0.0f, Tile.SIZE, Tile.SIZE * 10f));
- stone.controller = new StoneController(stone);
- stone.move = new StoneMovement(stone);
- stone.health = new NoHealth(stone);
- return stone;
- }
-
- public static Entity fromId(int id, Level level, float x, float y)
- {
- switch(id)
- {
- case 1:
- return buildLondoner(level, x, y, true);
- case 2:
- return buildLondoner(level, x, y, false);
- }
- return null;
- }
- }
|