12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879 |
- package me.hammerle.supersnuvi.tiles;
- import me.hammerle.snuviengine.api.Texture.Animation;
- import me.hammerle.supersnuvi.entity.Entity;
- import me.hammerle.supersnuvi.gamelogic.Level;
- import me.hammerle.supersnuvi.util.CollisionBox;
- import me.hammerle.supersnuvi.util.CollisionObject;
- import me.hammerle.supersnuvi.util.Face;
- public class WaterTile extends BaseTile
- {
- private final static Animation WATER = Level.TILES.addAnimation(160, 0,
- "resources/water/water_frame1.png", "resources/water/water_frame2.png",
- "resources/water/water_frame3.png", "resources/water/water_frame4.png",
- "resources/water/water_frame5.png", "resources/water/water_frame6.png",
- "resources/water/water_frame7.png", "resources/water/water_frame8.png");
-
- private int counter = 0;
- private final int level;
-
- public WaterTile(int level)
- {
- super(0.3125f, 0.0f, 0.375f, 0.00390625f * (level + 1));
- this.level = level;
- super.setCollisionBox(CollisionBox.createScaledTileBox(0.1f, (getOffsetY() / Tile.SIZE) + 0.1f, 0.9f, 1.0f));
- super.setMovementBox(CollisionObject.NULL_BOX);
- }
- @Override
- public void onEntityCollide(Entity ent, int x, int y, Face face)
- {
- super.onEntityCollide(ent, x, y, face);
-
- ent.getMovement().setInWater(true);
-
- float motionY = ent.getMotionY();
- if(motionY < 0)
- {
- motionY *= 0.92d;
- if(Math.abs(motionY) < 0.1)
- {
- motionY = 0;
- }
- ent.setMotionY(motionY);
- }
- }
- @Override
- public boolean shouldAiUseCollisionBox(int x, int y)
- {
- return false;
- }
- @Override
- public void tick()
- {
- if(level == 15)
- {
- counter++;
- if(counter > 3)
- {
- counter = 0;
- WATER.nextFrame();
- }
- }
- }
-
- @Override
- public final float getOffsetY()
- {
- return Tile.SIZE - (Tile.SIZE / 16) * (level + 1);
- }
- @Override
- public final float getHeight()
- {
- return (Tile.SIZE / 16) * (level + 1);
- }
- }
|