add BatMON and SkeletonLordMON; update AssetSetter to include new monsters and adjust player interaction
This commit is contained in:
@@ -51,6 +51,7 @@ public class Entity {
|
||||
public boolean onPath;
|
||||
public boolean knockback;
|
||||
public boolean guarding;
|
||||
public boolean rage;
|
||||
public Direction knockbackDirection;
|
||||
|
||||
// COUNTER
|
||||
@@ -161,9 +162,9 @@ public class Entity {
|
||||
int screenX = worldX - panel.player.worldX + panel.player.screenX;
|
||||
int screenY = worldY - panel.player.worldY + panel.player.screenY;
|
||||
|
||||
if(worldX + panel.tileSize > panel.player.worldX - panel.player.screenX &&
|
||||
if(worldX + panel.tileSize*5 > panel.player.worldX - panel.player.screenX &&
|
||||
worldX - panel.tileSize < panel.player.worldX + panel.player.screenX &&
|
||||
worldY + panel.tileSize > panel.player.worldY - panel.player.screenY &&
|
||||
worldY + panel.tileSize*5 > panel.player.worldY - panel.player.screenY &&
|
||||
worldY - panel.tileSize < panel.player.worldY + panel.player.screenY
|
||||
) {
|
||||
|
||||
@@ -191,8 +192,8 @@ public class Entity {
|
||||
if(dying) dyingAnimation(graphics2d);
|
||||
if(type == EntityType.PLAYER || name.equals("orc")) { // only modify sprite render position for player because I dont know yet how monster attack sprite are gonna look
|
||||
if(attacking) graphics2d.drawImage(parseSpriteATK(),
|
||||
(direction == Direction.LEFT) ? screenX - panel.tileSize : screenX,
|
||||
(direction == Direction.UP) ? screenY - panel.tileSize : screenY, null);
|
||||
(direction == Direction.LEFT) ? screenX - left1.getWidth() : screenX,
|
||||
(direction == Direction.UP) ? screenY - up1.getHeight() : screenY, null);
|
||||
else if(guarding) graphics2d.drawImage(parseSpriteGRD(), screenX, screenY, null);
|
||||
else graphics2d.drawImage(parseSprite(), screenX, screenY, null);
|
||||
} else graphics2d.drawImage(parseSprite(), screenX, screenY, null);
|
||||
@@ -207,6 +208,19 @@ public class Entity {
|
||||
|
||||
// INTERACTION
|
||||
public void setAction() {}
|
||||
public void moveTowardPlayer(int interval) {
|
||||
actionLock++;
|
||||
if(actionLock > interval) {
|
||||
if(dX(panel.player) > dY(panel.player)) {
|
||||
if(panel.player.getCenterX() < getCenterX()) direction = Direction.LEFT;
|
||||
else direction = Direction.RIGHT;
|
||||
} else if(dX(panel.player) < dY(panel.player)) {
|
||||
if(panel.player.getCenterY() < getCenterY()) direction = Direction.UP;
|
||||
else direction = Direction.DOWN;
|
||||
}
|
||||
actionLock = 0;
|
||||
}
|
||||
}
|
||||
public void move(Direction direction) {}
|
||||
public void damageReaction() {}
|
||||
public void attacking() {
|
||||
@@ -415,10 +429,16 @@ public class Entity {
|
||||
return (worldY + solidArea.y) / panel.tileSize;
|
||||
}
|
||||
public int dX(Entity target) {
|
||||
return Math.abs(worldX - target.worldX);
|
||||
return Math.abs(getCenterX() - target.getCenterX());
|
||||
}
|
||||
public int dY(Entity target) {
|
||||
return Math.abs(worldY - target.worldY);
|
||||
return Math.abs(getCenterY() - target.getCenterY());
|
||||
}
|
||||
public int getCenterX() {
|
||||
return worldX + left1.getWidth()/2;
|
||||
}
|
||||
public int getCenterY() {
|
||||
return worldY + up1.getHeight()/2;
|
||||
}
|
||||
public int dTile(Entity target) {
|
||||
//if(Objects.equals(name, "orc")) System.out.println("dX: " + dX(target) + " dY: " + dY(target));
|
||||
@@ -589,16 +609,16 @@ public class Entity {
|
||||
|
||||
switch(direction) {
|
||||
case UP -> {
|
||||
if(panel.player.worldY < worldY && yDist < straight && xDist < horizontal) targetInRange = true;
|
||||
if(panel.player.getCenterY() < getCenterY() && yDist < straight && xDist < horizontal) targetInRange = true;
|
||||
}
|
||||
case DOWN -> {
|
||||
if(panel.player.worldY > worldY && yDist < straight && xDist < horizontal) targetInRange = true;
|
||||
if(panel.player.getCenterY() > getCenterY() && yDist < straight && xDist < horizontal) targetInRange = true;
|
||||
}
|
||||
case LEFT -> {
|
||||
if(panel.player.worldX < worldX && xDist < straight && yDist < horizontal) targetInRange = true;
|
||||
if(panel.player.getCenterX() < getCenterX() && xDist < straight && yDist < horizontal) targetInRange = true;
|
||||
}
|
||||
case RIGHT -> {
|
||||
if(panel.player.worldX > worldX && xDist < straight && yDist < horizontal) targetInRange = true;
|
||||
if(panel.player.getCenterX() > getCenterX() && xDist < straight && yDist < horizontal) targetInRange = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -610,9 +630,9 @@ public class Entity {
|
||||
shotAvailableCount = 0;
|
||||
}
|
||||
}
|
||||
public void setRandomDirection() {
|
||||
public void setRandomDirection(int interval) {
|
||||
actionLock++;
|
||||
if(actionLock == 120) { //lock action for x frames
|
||||
if(actionLock > interval) { //lock action for x frames
|
||||
Random rand = new Random();
|
||||
int i = rand.nextInt(100)+1; //Generate number between 1 and 100
|
||||
if(i <= 25) direction = Direction.UP;
|
||||
|
||||
Reference in New Issue
Block a user