123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081 |
- package me.hammerle.supersnuvi.tiles;
- import me.hammerle.supersnuvi.entity.Entity;
- import me.hammerle.supersnuvi.util.BlockDataStorage;
- import me.hammerle.supersnuvi.util.CollisionBox;
- import me.hammerle.supersnuvi.util.CollisionObject;
- import me.hammerle.supersnuvi.util.Face;
- import me.hammerle.supersnuvi.util.SoundUtils;
- import me.hammerle.supersnuvi.gamelogic.Level;
- public class BottledSoulTile extends BaseCollisionTile
- {
- private final BlockDataStorage states = new BlockDataStorage();
- private final int score;
-
- public BottledSoulTile(int score)
- {
- super(0.0625f * (score - 1), 0.0625f, 0.0625f * score, 0.125f,
- Tile.SIZE * 0.2f, Tile.SIZE * 0.2f, Tile.SIZE * 0.8f, Tile.SIZE * 0.8f);
- super.setCollisionBox(CollisionBox.createScaledTileBox(0.2f, 0.2f, 0.8f, 0.8f));
- this.score = score;
- }
- @Override
- public void onEntityCollide(Entity ent, int x, int y, Face face, Level l)
- {
- if(ent.getItemCollector().canCollect())
- {
- if(states.add(x, y, l))
- {
- l.getTileUpdater().add(l.getData().getBackgroundIndex(), x, y);
- if(ent.getItemCollector().isHero())
- {
- SoundUtils.playSound(SoundUtils.Sound.COLLECT);
- l.addBottles(score);
- }
- ent.getHealth().addHealthPercent(0.143f * score);
- }
- }
- }
-
- @Override
- public CollisionObject getCollisionBox(int x, int y, Level l)
- {
- if(states.contains(x, y, l))
- {
- return CollisionObject.NULL_BOX;
- }
- return super.getCollisionBox(x, y, l);
- }
- @Override
- public boolean shouldAiUseCollisionBox(int x, int y, Level l)
- {
- return false;
- }
-
- @Override
- public boolean shouldRender(int x, int y, Level l)
- {
- return !states.contains(x, y, l);
- }
-
- @Override
- public void reset(Level l)
- {
- states.clear(l);
- }
-
- @Override
- public void reset(int x, int y, Level l)
- {
- states.clear(x, y, l);
- }
-
- @Override
- public int getBottleScore()
- {
- return score;
- }
- }
|