1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374 |
- package me.hammerle.supersnuvi.tiles;
- import java.util.HashSet;
- import me.hammerle.supersnuvi.entity.Entity;
- import me.hammerle.supersnuvi.util.CollisionBox;
- import me.hammerle.supersnuvi.util.CollisionObject;
- import me.hammerle.supersnuvi.util.Face;
- import me.hammerle.supersnuvi.util.SoundUtils;
- public class BottledSoulTile extends BaseTile
- {
- private final HashSet<Long> states;
- private final int score;
-
- public BottledSoulTile(int score)
- {
- super(0.0625f * (score - 1), 0.0625f, 0.0625f * score, 0.125f);
- states = new HashSet<>();
- 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)
- {
- if(ent.getItemCollector().canCollect())
- {
- if(states.add(getKey(x, y)))
- {
- ent.getLevel().updateTile(x, y);
- if(ent.getItemCollector().isHero())
- {
- SoundUtils.playSound(SoundUtils.Sound.COLLECT);
- ent.getLevel().increaseSouls(score);
- }
- ent.getHealth().addHealthPercent(0.143f * score);
- }
- }
- }
-
- @Override
- public CollisionObject getCollisionBox(int x, int y)
- {
- if(states.contains(getKey(x, y)))
- {
- return CollisionObject.NULL_BOX;
- }
- return super.getCollisionBox(x, y);
- }
- @Override
- public boolean shouldAiUseCollisionBox(int x, int y)
- {
- return false;
- }
-
- @Override
- public boolean shouldRender(int x, int y)
- {
- return !states.contains(getKey(x, y));
- }
-
- @Override
- public void reset()
- {
- states.clear();
- }
-
- @Override
- public int getBottleScore()
- {
- return score;
- }
- }
|