X-Git-Url: https://deadsoftware.ru/gitweb?a=blobdiff_plain;f=core%2Fsrc%2Fru%2Fdeadsoftware%2Fcavedroid%2Fgame%2Fmobs%2FMob.java;h=716c3df07f44dc8e45b06c048716fc721fedeb52;hb=84377178320105196ad70bfa798ba8f299f961b2;hp=bcab5867bc4e8ee9186543eebd206e4733437b86;hpb=2948fcd9c40ebf588ef7d0e7cd8dd34ecaa1f9b2;p=cavedroid.git diff --git a/core/src/ru/deadsoftware/cavedroid/game/mobs/Mob.java b/core/src/ru/deadsoftware/cavedroid/game/mobs/Mob.java index bcab586..716c3df 100644 --- a/core/src/ru/deadsoftware/cavedroid/game/mobs/Mob.java +++ b/core/src/ru/deadsoftware/cavedroid/game/mobs/Mob.java @@ -1,6 +1,7 @@ package ru.deadsoftware.cavedroid.game.mobs; import com.badlogic.gdx.graphics.g2d.SpriteBatch; +import com.badlogic.gdx.math.MathUtils; import com.badlogic.gdx.math.Rectangle; import com.badlogic.gdx.math.Vector2; @@ -14,18 +15,22 @@ public abstract class Mob implements Serializable { public static final int LEFT = 0; public static final int RIGHT = 1; - private float width, height; + private final float width; + private final float height; private int dir; - public boolean flyMode; - public Vector2 pos; - public Vector2 mov; + protected final Vector2 pos; + protected Vector2 mov; private boolean dead; + private boolean canJump, flyMode; protected int animDelta = 6; - public boolean canJump; - int anim; + protected int anim; + + protected static int randomDir() { + return MathUtils.random(1); + } /** * @@ -36,13 +41,12 @@ public abstract class Mob implements Serializable { * @param dir integer representing a direction where 0 is left and 1 is right. * You should use {@link #LEFT} and {@link #RIGHT} constants */ - public Mob(float x, float y, float width, float height, int dir) { + protected Mob(float x, float y, float width, float height, int dir) { pos = new Vector2(x, y); mov = new Vector2(0, 0); this.width = width; this.height = height; canJump = false; - flyMode = false; dead = false; this.dir = dir; } @@ -114,6 +118,10 @@ public abstract class Mob implements Serializable { return dead; } + public int getAnim() { + return anim; + } + /** * Set's mob's dead variable to true and nothing else. It doesn't delete the mob. */ @@ -129,12 +137,44 @@ public abstract class Mob implements Serializable { return new Rectangle(pos.x, pos.y, getWidth(), getHeight()); } - public abstract void ai(); + public Vector2 getPos() { + return pos; + } - public abstract void changeDir(); + public Vector2 getMov() { + return mov; + } + + public float getX() { + return pos.x; + } + + public float getY() { + return pos.y; + } + + public boolean canJump() { + return canJump; + } + + public void setCanJump(boolean canJump) { + this.canJump = canJump; + } + + public boolean isFlyMode() { + return flyMode; + } + + public void setFlyMode(boolean flyMode) { + this.flyMode = flyMode; + } public abstract void draw(SpriteBatch spriteBatch, float x, float y); + public abstract void ai(); + + public abstract void changeDir(); + /** * * @return 0 - if regular mob.