1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071 |
- package me.hammerle.supersnuvi.tiles;
- import me.hammerle.supersnuvi.entity.Entity;
- import me.hammerle.supersnuvi.util.BlockDataStorage;
- 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);
- this.score = score;
- }
- @Override
- public void onEntityCollide(Entity ent, int x, int y, Face face, Level l)
- {
- if(ent.getItemCollector().canCollect() && 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 boolean isColliding(float minX, float minY, float maxX, float maxY, int x, int y, Level l)
- {
- return !states.contains(x, y, l) && super.isColliding(minX, minY, maxX, maxY, 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;
- }
- }
|