Compare commits

...

3 Commits

20 changed files with 435 additions and 45 deletions

View File

@@ -78,6 +78,8 @@ public class GamePanel extends JPanel implements Runnable {
// GAME STATE
public GameState gameState;
public Map.Area currentArea;
public Map.Area nextArea;
public GamePanel() throws IOException {
this.setPreferredSize(new Dimension(screenWidth, screenHeight));
@@ -252,6 +254,7 @@ public class GamePanel extends JPanel implements Runnable {
assetSetter.setITiles();
eManager.setup();
gameState = GameState.TITLE;
currentArea = Map.Area.OUTSIDE;
tempScreen = new BufferedImage(screenWidth, screenHeight, BufferedImage.TYPE_INT_RGB);
fg2 = (Graphics2D) tempScreen.getGraphics();
@@ -279,4 +282,16 @@ public class GamePanel extends JPanel implements Runnable {
assetSetter.setITiles();
eManager.lighting.resetDay();
}
public void changeArea() {
if(nextArea != currentArea) {
stopMusic();
if(nextArea == Map.Area.OUTSIDE) playMusic(0);
else if(nextArea == Map.Area.DUNGEON) playMusic(19);
else if(nextArea == Map.Area.INDOOR) playMusic(18);
}
currentArea = nextArea;
nextArea = null;
assetSetter.setNPC();
// assetSetter.setMonster();
}
}

View File

@@ -29,7 +29,7 @@ public class UI {
private int transCount;
private int sleepCount;
private int charIndex;
private String combinedText;
private String combinedText = "";
// SUB-STATES
public TradeState tradeState = TradeState.SELECT;
@@ -301,6 +301,7 @@ public class UI {
char[] characters = tradingNPC.dialogue[tradingNPC.dialogueSet][tradingNPC.dialogueIndex].toCharArray();
if(charIndex < characters.length) {
String s = String.valueOf(characters[charIndex]);
panel.playSE(17);
combinedText = combinedText + s;
currentDialogue = combinedText;
charIndex++;
@@ -413,6 +414,7 @@ public class UI {
panel.player.worldY = panel.tileSize * panel.eventH.tempRow;
panel.eventH.prevEventX = panel.player.worldX;
panel.eventH.prevEventY = panel.player.worldY;
panel.changeArea();
}
private void drawTradeScreen() {
switch(tradeState) {

View File

@@ -15,7 +15,8 @@ public enum EntityType {
public enum WeaponType {
SWORD,
AXE
AXE,
PICKAXE
}
}

View File

@@ -2,15 +2,19 @@ package de.miaurizius.jgame2d.core.enums;
public enum Map {
OVERWORLD("worldmap", 0),
HUT("indoor01", 1);
OVERWORLD("worldmap", 0, Area.OUTSIDE),
HUT("indoor01", 1, Area.INDOOR),
DUNGEON_FIRST_FLOOR("dungeon01",2, Area.DUNGEON),
DUNGEON_SECOND_FLOOR("dungeon02", 3, Area.DUNGEON);
private final String name;
private final int index;
private final Area area;
Map(String name, int index) {
Map(String name, int index, Area area) {
this.name = name;
this.index = index;
this.area = area;
}
public String getName() {
@@ -20,4 +24,15 @@ public enum Map {
public int getIndex() {
return index;
}
public Area getArea() {
return area;
}
public enum Area {
INDOOR,
OUTSIDE,
DUNGEON
}
}

View File

@@ -4,12 +4,16 @@ import de.miaurizius.jgame2d.core.GamePanel;
import de.miaurizius.jgame2d.core.enums.Map;
import de.miaurizius.jgame2d.entity.item.*;
import de.miaurizius.jgame2d.entity.monster.OrcMON;
import de.miaurizius.jgame2d.entity.npc.BigRockNPC;
import de.miaurizius.jgame2d.entity.npc.MerchantNPC;
import de.miaurizius.jgame2d.entity.npc.OldManNPC;
import de.miaurizius.jgame2d.entity.monster.GreenSlimeMON;
import de.miaurizius.jgame2d.entity.obstacle.ChestObj;
import de.miaurizius.jgame2d.entity.obstacle.DoorObj;
import de.miaurizius.jgame2d.tile.interactive.DryTreeTI;
import de.miaurizius.jgame2d.entity.obstacle.IronDoorObj;
import de.miaurizius.jgame2d.tile.interactive.DestructibleWallIT;
import de.miaurizius.jgame2d.tile.interactive.DryTreeIT;
import de.miaurizius.jgame2d.tile.interactive.MetalPlateIT;
public class AssetSetter {
@@ -41,6 +45,36 @@ public class AssetSetter {
panel.obj[Map.OVERWORLD.getIndex()][i].worldX = panel.tileSize*30;
panel.obj[Map.OVERWORLD.getIndex()][i].worldY = panel.tileSize*29;
i++;
i = 0;
panel.obj[Map.DUNGEON_FIRST_FLOOR.getIndex()][i] = new ChestObj(panel);
panel.obj[Map.DUNGEON_FIRST_FLOOR.getIndex()][i].setLoot(new PickaxeObj(panel));
panel.obj[Map.DUNGEON_FIRST_FLOOR.getIndex()][i].worldX = panel.tileSize*40;
panel.obj[Map.DUNGEON_FIRST_FLOOR.getIndex()][i].worldY = panel.tileSize*41;
i++;
panel.obj[Map.DUNGEON_FIRST_FLOOR.getIndex()][i] = new ChestObj(panel);
panel.obj[Map.DUNGEON_FIRST_FLOOR.getIndex()][i].setLoot(new PotionObj(panel));
panel.obj[Map.DUNGEON_FIRST_FLOOR.getIndex()][i].worldX = panel.tileSize*13;
panel.obj[Map.DUNGEON_FIRST_FLOOR.getIndex()][i].worldY = panel.tileSize*16;
i++;
panel.obj[Map.DUNGEON_FIRST_FLOOR.getIndex()][i] = new ChestObj(panel);
panel.obj[Map.DUNGEON_FIRST_FLOOR.getIndex()][i].setLoot(new PotionObj(panel));
panel.obj[Map.DUNGEON_FIRST_FLOOR.getIndex()][i].worldX = panel.tileSize*26;
panel.obj[Map.DUNGEON_FIRST_FLOOR.getIndex()][i].worldY = panel.tileSize*34;
i++;
panel.obj[Map.DUNGEON_FIRST_FLOOR.getIndex()][i] = new ChestObj(panel);
panel.obj[Map.DUNGEON_FIRST_FLOOR.getIndex()][i].setLoot(new PotionObj(panel));
panel.obj[Map.DUNGEON_FIRST_FLOOR.getIndex()][i].worldX = panel.tileSize*27;
panel.obj[Map.DUNGEON_FIRST_FLOOR.getIndex()][i].worldY = panel.tileSize*15;
i++;
panel.obj[Map.DUNGEON_FIRST_FLOOR.getIndex()][i] = new IronDoorObj(panel);
panel.obj[Map.DUNGEON_FIRST_FLOOR.getIndex()][i].worldX = panel.tileSize*18;
panel.obj[Map.DUNGEON_FIRST_FLOOR.getIndex()][i].worldY = panel.tileSize*23;
i++;
}
public void setNPC() {
@@ -51,6 +85,23 @@ public class AssetSetter {
panel.npc[Map.HUT.getIndex()][0] = new MerchantNPC(panel);
panel.npc[Map.HUT.getIndex()][0].worldX = panel.tileSize*12;
panel.npc[Map.HUT.getIndex()][0].worldY = panel.tileSize*7;
int i = 0;
panel.npc[Map.DUNGEON_FIRST_FLOOR.getIndex()][i] = new BigRockNPC(panel);
panel.npc[Map.DUNGEON_FIRST_FLOOR.getIndex()][i].worldX = panel.tileSize*20;
panel.npc[Map.DUNGEON_FIRST_FLOOR.getIndex()][i].worldY = panel.tileSize*25;
i++;
panel.npc[Map.DUNGEON_FIRST_FLOOR.getIndex()][i] = new BigRockNPC(panel);
panel.npc[Map.DUNGEON_FIRST_FLOOR.getIndex()][i].worldX = panel.tileSize*11;
panel.npc[Map.DUNGEON_FIRST_FLOOR.getIndex()][i].worldY = panel.tileSize*18;
i++;
panel.npc[Map.DUNGEON_FIRST_FLOOR.getIndex()][i] = new BigRockNPC(panel);
panel.npc[Map.DUNGEON_FIRST_FLOOR.getIndex()][i].worldX = panel.tileSize*23;
panel.npc[Map.DUNGEON_FIRST_FLOOR.getIndex()][i].worldY = panel.tileSize*14;
i++;
}
public void setMonster() {
@@ -87,38 +138,61 @@ public class AssetSetter {
public void setITiles() {
int i = 0;
panel.iTile[Map.OVERWORLD.getIndex()][i] = new DryTreeTI(panel,27,12);i++;
panel.iTile[Map.OVERWORLD.getIndex()][i] = new DryTreeTI(panel,28,12);i++;
panel.iTile[Map.OVERWORLD.getIndex()][i] = new DryTreeTI(panel,29,12);i++;
panel.iTile[Map.OVERWORLD.getIndex()][i] = new DryTreeTI(panel,30,12);i++;
panel.iTile[Map.OVERWORLD.getIndex()][i] = new DryTreeTI(panel,31,12);i++;
panel.iTile[Map.OVERWORLD.getIndex()][i] = new DryTreeTI(panel,32,12);i++;
panel.iTile[Map.OVERWORLD.getIndex()][i] = new DryTreeTI(panel,33,12);i++;
panel.iTile[Map.OVERWORLD.getIndex()][i] = new DryTreeIT(panel,27,12);i++;
panel.iTile[Map.OVERWORLD.getIndex()][i] = new DryTreeIT(panel,28,12);i++;
panel.iTile[Map.OVERWORLD.getIndex()][i] = new DryTreeIT(panel,29,12);i++;
panel.iTile[Map.OVERWORLD.getIndex()][i] = new DryTreeIT(panel,30,12);i++;
panel.iTile[Map.OVERWORLD.getIndex()][i] = new DryTreeIT(panel,31,12);i++;
panel.iTile[Map.OVERWORLD.getIndex()][i] = new DryTreeIT(panel,32,12);i++;
panel.iTile[Map.OVERWORLD.getIndex()][i] = new DryTreeIT(panel,33,12);i++;
panel.iTile[Map.OVERWORLD.getIndex()][i] = new DryTreeTI(panel,30,21);i++;
panel.iTile[Map.OVERWORLD.getIndex()][i] = new DryTreeIT(panel,30,21);i++;
panel.iTile[Map.OVERWORLD.getIndex()][i] = new DryTreeTI(panel,25,27);i++;
panel.iTile[Map.OVERWORLD.getIndex()][i] = new DryTreeTI(panel,26,27);i++;
panel.iTile[Map.OVERWORLD.getIndex()][i] = new DryTreeTI(panel,27,27);i++;
panel.iTile[Map.OVERWORLD.getIndex()][i] = new DryTreeTI(panel,27,28);i++;
panel.iTile[Map.OVERWORLD.getIndex()][i] = new DryTreeTI(panel,27,29);i++;
panel.iTile[Map.OVERWORLD.getIndex()][i] = new DryTreeTI(panel,27,30);i++;
panel.iTile[Map.OVERWORLD.getIndex()][i] = new DryTreeTI(panel,27,31);i++;
panel.iTile[Map.OVERWORLD.getIndex()][i] = new DryTreeTI(panel,28,31);i++;
panel.iTile[Map.OVERWORLD.getIndex()][i] = new DryTreeTI(panel,29,31);i++;
panel.iTile[Map.OVERWORLD.getIndex()][i] = new DryTreeTI(panel,30,31);i++;
panel.iTile[Map.OVERWORLD.getIndex()][i] = new DryTreeIT(panel,25,27);i++;
panel.iTile[Map.OVERWORLD.getIndex()][i] = new DryTreeIT(panel,26,27);i++;
panel.iTile[Map.OVERWORLD.getIndex()][i] = new DryTreeIT(panel,27,27);i++;
panel.iTile[Map.OVERWORLD.getIndex()][i] = new DryTreeIT(panel,27,28);i++;
panel.iTile[Map.OVERWORLD.getIndex()][i] = new DryTreeIT(panel,27,29);i++;
panel.iTile[Map.OVERWORLD.getIndex()][i] = new DryTreeIT(panel,27,30);i++;
panel.iTile[Map.OVERWORLD.getIndex()][i] = new DryTreeIT(panel,27,31);i++;
panel.iTile[Map.OVERWORLD.getIndex()][i] = new DryTreeIT(panel,28,31);i++;
panel.iTile[Map.OVERWORLD.getIndex()][i] = new DryTreeIT(panel,29,31);i++;
panel.iTile[Map.OVERWORLD.getIndex()][i] = new DryTreeIT(panel,30,31);i++;
panel.iTile[Map.OVERWORLD.getIndex()][i] = new DryTreeTI(panel,18,40);i++;
panel.iTile[Map.OVERWORLD.getIndex()][i] = new DryTreeTI(panel,17,40);i++;
panel.iTile[Map.OVERWORLD.getIndex()][i] = new DryTreeTI(panel,16,40);i++;
panel.iTile[Map.OVERWORLD.getIndex()][i] = new DryTreeTI(panel,15,40);i++;
panel.iTile[Map.OVERWORLD.getIndex()][i] = new DryTreeTI(panel,14,40);i++;
panel.iTile[Map.OVERWORLD.getIndex()][i] = new DryTreeTI(panel,13,40);i++;
panel.iTile[Map.OVERWORLD.getIndex()][i] = new DryTreeTI(panel,13,41);i++;
panel.iTile[Map.OVERWORLD.getIndex()][i] = new DryTreeTI(panel,12,41);i++;
panel.iTile[Map.OVERWORLD.getIndex()][i] = new DryTreeTI(panel,11,41);i++;
panel.iTile[Map.OVERWORLD.getIndex()][i] = new DryTreeTI(panel,10,41);i++;
panel.iTile[Map.OVERWORLD.getIndex()][i] = new DryTreeTI(panel,10,40);i++;
panel.iTile[Map.OVERWORLD.getIndex()][i] = new DryTreeIT(panel,18,40);i++;
panel.iTile[Map.OVERWORLD.getIndex()][i] = new DryTreeIT(panel,17,40);i++;
panel.iTile[Map.OVERWORLD.getIndex()][i] = new DryTreeIT(panel,16,40);i++;
panel.iTile[Map.OVERWORLD.getIndex()][i] = new DryTreeIT(panel,15,40);i++;
panel.iTile[Map.OVERWORLD.getIndex()][i] = new DryTreeIT(panel,14,40);i++;
panel.iTile[Map.OVERWORLD.getIndex()][i] = new DryTreeIT(panel,13,40);i++;
panel.iTile[Map.OVERWORLD.getIndex()][i] = new DryTreeIT(panel,13,41);i++;
panel.iTile[Map.OVERWORLD.getIndex()][i] = new DryTreeIT(panel,12,41);i++;
panel.iTile[Map.OVERWORLD.getIndex()][i] = new DryTreeIT(panel,11,41);i++;
panel.iTile[Map.OVERWORLD.getIndex()][i] = new DryTreeIT(panel,10,41);i++;
panel.iTile[Map.OVERWORLD.getIndex()][i] = new DryTreeIT(panel,10,40);i++;
i = 0;
panel.iTile[Map.DUNGEON_FIRST_FLOOR.getIndex()][i] = new DestructibleWallIT(panel,18,30);i++;
panel.iTile[Map.DUNGEON_FIRST_FLOOR.getIndex()][i] = new DestructibleWallIT(panel,17,31);i++;
panel.iTile[Map.DUNGEON_FIRST_FLOOR.getIndex()][i] = new DestructibleWallIT(panel,17,32);i++;
panel.iTile[Map.DUNGEON_FIRST_FLOOR.getIndex()][i] = new DestructibleWallIT(panel,17,34);i++;
panel.iTile[Map.DUNGEON_FIRST_FLOOR.getIndex()][i] = new DestructibleWallIT(panel,18,34);i++;
panel.iTile[Map.DUNGEON_FIRST_FLOOR.getIndex()][i] = new DestructibleWallIT(panel,18,33);i++;
panel.iTile[Map.DUNGEON_FIRST_FLOOR.getIndex()][i] = new DestructibleWallIT(panel,10,22);i++;
panel.iTile[Map.DUNGEON_FIRST_FLOOR.getIndex()][i] = new DestructibleWallIT(panel,10,24);i++;
panel.iTile[Map.DUNGEON_FIRST_FLOOR.getIndex()][i] = new DestructibleWallIT(panel,38,18);i++;
panel.iTile[Map.DUNGEON_FIRST_FLOOR.getIndex()][i] = new DestructibleWallIT(panel,38,19);i++;
panel.iTile[Map.DUNGEON_FIRST_FLOOR.getIndex()][i] = new DestructibleWallIT(panel,38,20);i++;
panel.iTile[Map.DUNGEON_FIRST_FLOOR.getIndex()][i] = new DestructibleWallIT(panel,38,21);i++;
panel.iTile[Map.DUNGEON_FIRST_FLOOR.getIndex()][i] = new DestructibleWallIT(panel,18,13);i++;
panel.iTile[Map.DUNGEON_FIRST_FLOOR.getIndex()][i] = new DestructibleWallIT(panel,18,14);i++;
panel.iTile[Map.DUNGEON_FIRST_FLOOR.getIndex()][i] = new DestructibleWallIT(panel,22,28);i++;
panel.iTile[Map.DUNGEON_FIRST_FLOOR.getIndex()][i] = new DestructibleWallIT(panel,30,28);i++;
panel.iTile[Map.DUNGEON_FIRST_FLOOR.getIndex()][i] = new DestructibleWallIT(panel,32,28);i++;
panel.iTile[Map.DUNGEON_FIRST_FLOOR.getIndex()][i] = new MetalPlateIT(panel,20,22);i++;
panel.iTile[Map.DUNGEON_FIRST_FLOOR.getIndex()][i] = new MetalPlateIT(panel,8,17);i++;
panel.iTile[Map.DUNGEON_FIRST_FLOOR.getIndex()][i] = new MetalPlateIT(panel,39,31);i++;
}
}

View File

@@ -66,12 +66,19 @@ public class EventHandler {
// PIT/POOL TESTS
if(hit(Map.OVERWORLD, 27,16, Direction.RIGHT)) damagePit();
//if(hit(Map.OVERWORLD, 26,16, Direction.RIGHT)) changeMap(Map.DUNGEON_FIRST_FLOOR, 9, 41); //test
else if(hit(Map.OVERWORLD, 23,12, null)) healingPool();
// HUT
else if(hit(Map.OVERWORLD, 10, 39, null)) changeMap(Map.HUT, 12, 13);
else if(hit(Map.HUT, 12, 13, null)) changeMap(Map.OVERWORLD, 10, 39);
//DUNGEON
else if(hit(Map.OVERWORLD, 12,9, null)) changeMap(Map.DUNGEON_FIRST_FLOOR, 9, 41); //enter
else if(hit(Map.DUNGEON_FIRST_FLOOR, 9,41, null)) changeMap(Map.OVERWORLD, 12,9); //leave
else if(hit(Map.DUNGEON_FIRST_FLOOR, 8,7, null)) changeMap(Map.DUNGEON_SECOND_FLOOR, 26, 41); //enter b2
else if(hit(Map.DUNGEON_SECOND_FLOOR, 26, 41, null)) changeMap(Map.DUNGEON_FIRST_FLOOR, 8, 7); //enter b1
// ADVANCED SPEAKING
else if(hit(Map.HUT, 12, 9, Direction.UP)) speak(panel.npc[Map.HUT.getIndex()][0]);
}
@@ -129,6 +136,7 @@ public class EventHandler {
tempCol = col;
tempRow = row;
canTouchEvent = false;
panel.nextArea = map.getArea();
panel.playSE(13);
}
private void speak(Entity entity) {

View File

@@ -37,6 +37,11 @@ public class Sound {
load(14, "assets/sounds/sleep.wav");
load(15, "assets/sounds/blocked.wav");
load(16, "assets/sounds/parry.wav");
load(17, "assets/sounds/speak.wav");
load(18, "assets/sounds/Merchant.wav");
load(19, "assets/sounds/Dungeon.wav");
load(20, "assets/sounds/chipwall.wav");
load(21, "assets/sounds/dooropen.wav");
}
@Deprecated

View File

@@ -120,6 +120,7 @@ public class SaveLoad {
panel.obj[mapNum][i].worldY = ds.mapObjectWorldY[mapNum][i];
if (ds.mapObjectLootNames[mapNum][i] != null) panel.obj[mapNum][i].loot = getObject(ds.mapObjectLootNames[mapNum][i]);
panel.obj[mapNum][i].opened = ds.mapObjectOpened[mapNum][i];
panel.obj[mapNum][i].setDialogue();
if(panel.obj[mapNum][i].opened) panel.obj[mapNum][i].down1 = panel.obj[mapNum][i].image2;
} else panel.obj[mapNum][i] = null;
}

View File

@@ -32,6 +32,7 @@ public class Entity {
public int solidAreaDefaultX, solidAreaDefaultY;
public boolean collision;
public String[][] dialogue = new String[20][20];
public Entity linkedEntity;
// STATE
public int worldX, worldY;
@@ -206,6 +207,7 @@ public class Entity {
// INTERACTION
public void setAction() {}
public void move(Direction direction) {}
public void damageReaction() {}
public void attacking() {
if(panel.player.attackCancel && type == EntityType.PLAYER) return;
@@ -470,6 +472,7 @@ public class Entity {
}
return null;
}
public void setDialogue() {}
public void changeOpacity(Graphics2D graphics2d, float opacity) {
graphics2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, opacity));
}

View File

@@ -6,6 +6,7 @@ import de.miaurizius.jgame2d.core.enums.EntityType;
import de.miaurizius.jgame2d.core.enums.GameState;
import de.miaurizius.jgame2d.core.handlers.KeyHandler;
import de.miaurizius.jgame2d.entity.item.KeyObj;
import de.miaurizius.jgame2d.entity.item.LanternObj;
import de.miaurizius.jgame2d.entity.item.ShieldWoodObj;
import de.miaurizius.jgame2d.entity.item.SwordNormalObj;
import de.miaurizius.jgame2d.entity.projectile.FireballObj;
@@ -257,14 +258,18 @@ public class Player extends Entity {
panel.iTile[panel.currentMap.getIndex()][index].life--;
panel.iTile[panel.currentMap.getIndex()][index].invincible = true;
generateParticle(panel.iTile[panel.currentMap.getIndex()][index], panel.iTile[panel.currentMap.getIndex()][index]);
panel.iTile[panel.currentMap.getIndex()][index].checkDrop();
if(panel.iTile[panel.currentMap.getIndex()][index].life == 0) panel.iTile[panel.currentMap.getIndex()][index] = panel.iTile[panel.currentMap.getIndex()][index].getDestroyedForm();
}
public void interactNPC(int index) {
if(index == 999) return;
//if(!panel.keyH.spacePressed) return; //Only uncomment if text should only appear if player hits space
attackCancel = true;
panel.npc[panel.currentMap.getIndex()][index].speak();
if(panel.keyH.spacePressed) {
attackCancel = true;
panel.npc[panel.currentMap.getIndex()][index].speak();
return;
}
panel.npc[panel.currentMap.getIndex()][index].move(direction);
}
public void speak() {
//This method only exists for character specific things later...
@@ -362,6 +367,7 @@ public class Player extends Entity {
inventory.add(currentWeapon);
inventory.add(currentShield);
inventory.add(new KeyObj(panel));
inventory.add(new LanternObj(panel));
}
public void setDialogue() {
dialogue[0][0] = "You are level " + level + " now!\nYou feel stronger!";
@@ -417,6 +423,16 @@ public class Player extends Entity {
attackRight1 = initEntitySprites("player/attack/boy_axe_right_1", panel.tileSize * 2, panel.tileSize);
attackRight2 = initEntitySprites("player/attack/boy_axe_right_2", panel.tileSize * 2, panel.tileSize);
break;
case PICKAXE:
attackUp1 = initEntitySprites("player/attack/boy_pick_up_1", panel.tileSize, panel.tileSize * 2);
attackUp2 = initEntitySprites("player/attack/boy_pick_up_2", panel.tileSize, panel.tileSize * 2);
attackDown1 = initEntitySprites("player/attack/boy_pick_down_1", panel.tileSize, panel.tileSize * 2);
attackDown2 = initEntitySprites("player/attack/boy_pick_down_2", panel.tileSize, panel.tileSize * 2);
attackLeft1 = initEntitySprites("player/attack/boy_pick_left_1", panel.tileSize * 2, panel.tileSize);
attackLeft2 = initEntitySprites("player/attack/boy_pick_left_2", panel.tileSize * 2, panel.tileSize);
attackRight1 = initEntitySprites("player/attack/boy_pick_right_1", panel.tileSize * 2, panel.tileSize);
attackRight2 = initEntitySprites("player/attack/boy_pick_right_2", panel.tileSize * 2, panel.tileSize);
break;
}
}
public void getGuardImages() {

View File

@@ -0,0 +1,23 @@
package de.miaurizius.jgame2d.entity.item;
import de.miaurizius.jgame2d.core.GamePanel;
import de.miaurizius.jgame2d.core.enums.EntityType;
import de.miaurizius.jgame2d.entity.Entity;
public class PickaxeObj extends Entity {
public PickaxeObj(GamePanel panel) {
super(panel);
name = "Pickaxe";
description = "[" + name + "]\nYou will dig it!";
type = EntityType.WEAPON;
weaponType = EntityType.WeaponType.PICKAXE;
down1 = initEntitySprites("/objects/pickaxe");
price = 75;
knockbackVal = 10;
attackValue = 2;
attackArea.width = 30;
attackArea.height = 30;
}
}

View File

@@ -0,0 +1,119 @@
package de.miaurizius.jgame2d.entity.npc;
import de.miaurizius.jgame2d.core.GamePanel;
import de.miaurizius.jgame2d.core.enums.Direction;
import de.miaurizius.jgame2d.core.enums.EntityType;
import de.miaurizius.jgame2d.core.enums.Map;
import de.miaurizius.jgame2d.entity.Entity;
import de.miaurizius.jgame2d.entity.obstacle.IronDoorObj;
import de.miaurizius.jgame2d.tile.interactive.InteractiveTile;
import de.miaurizius.jgame2d.tile.interactive.MetalPlateIT;
import java.util.ArrayList;
import java.util.Random;
public class BigRockNPC extends Entity {
public BigRockNPC(GamePanel panel) {
super(panel);
type = EntityType.NPC;
name = "bigrock";
direction = Direction.DOWN;
speed = 4;
getImage();
setDialogue();
dialogueSet = -1;
solidArea.x = 2;
solidArea.y = 6;
solidAreaDefaultX = solidArea.x;
solidAreaDefaultY = solidArea.y;
solidArea.width = 44;
solidArea.height = 40;
}
@Override
public void update() {
}
@Override
public void move(Direction direction) {
this.direction = direction;
checkCollision();
if(collisionOn) return;
switch (direction) {
case UP -> worldY -= speed;
case DOWN -> worldY += speed;
case LEFT -> worldX -= speed;
case RIGHT -> worldX += speed;
}
detectPlate();
}
@Override
public void speak() {
super.facePlayer();
super.startDialogue(this,super.dialogueSet);
dialogueSet++;
if(dialogue[dialogueSet][0] == null) dialogueSet = 0;
}
public void detectPlate() {
ArrayList<InteractiveTile> plateList = new ArrayList<>();
ArrayList<Entity> rockList = new ArrayList<>();
for(int i = 0; i < panel.iTile[Map.DUNGEON_FIRST_FLOOR.getIndex()].length; i++) {
if(panel.iTile[panel.currentMap.getIndex()][i] != null && panel.iTile[panel.currentMap.getIndex()][i] instanceof MetalPlateIT) {
plateList.add(panel.iTile[panel.currentMap.getIndex()][i]);
}
}
for(int i = 0; i < panel.npc[Map.DUNGEON_FIRST_FLOOR.getIndex()].length; i++) {
if(panel.npc[panel.currentMap.getIndex()][i] != null && panel.npc[panel.currentMap.getIndex()][i] instanceof BigRockNPC) {
rockList.add(panel.npc[panel.currentMap.getIndex()][i]);
}
}
int count = 0;
for (int i = 0; i < plateList.size(); i++) {
int dx = Math.abs(worldX - plateList.get(i).worldX);
int dy = Math.abs(worldY - plateList.get(i).worldY);
if (Math.max(dx, dy) < 8 ) {
if(linkedEntity == null) {
linkedEntity = plateList.get(i);
panel.playSE(3);
}
} else if(linkedEntity == plateList.get(i)) linkedEntity = null;
}
for(Entity rock : rockList) if(rock.linkedEntity != null) count++;
if(count == rockList.size()) {
for(int i = 0; i < panel.obj[Map.DUNGEON_FIRST_FLOOR.getIndex()].length; i++) {
if(panel.obj[panel.currentMap.getIndex()][i] != null && panel.obj[panel.currentMap.getIndex()][i] instanceof IronDoorObj) {
panel.obj[panel.currentMap.getIndex()][i] = null;
panel.playSE(21);
}
}
}
}
// SETTING THINGS UP
private void getImage() {
up1 = initEntitySprites("npc/bigrock");
up2 = initEntitySprites("npc/bigrock");
down1 = initEntitySprites("npc/bigrock");
down2 = initEntitySprites("npc/bigrock");
left1 = initEntitySprites("npc/bigrock");
left2 = initEntitySprites("npc/bigrock");
right1 = initEntitySprites("npc/bigrock");
right2 = initEntitySprites("npc/bigrock");
}
public void setDialogue() {
dialogue[0][0] = "It's a giant rock.";
}
}

View File

@@ -39,7 +39,7 @@ public class MerchantNPC extends Entity {
right1 = initEntitySprites("npc/merchant_down_1");
right2 = initEntitySprites("npc/merchant_down_2");
}
private void setDialogue() {
public void setDialogue() {
dialogue[0][0] = "He he, so you found me. \nI have some good stuff. \nDo you want to trade?";
dialogue[1][0] = "Come again, hehe!";
dialogue[2][0] = "You need more coins to buy that!";

View File

@@ -68,7 +68,7 @@ public class OldManNPC extends Entity {
right1 = initEntitySprites("npc/oldman_right_1");
right2 = initEntitySprites("npc/oldman_right_2");
}
private void setDialogue() {
public void setDialogue() {
dialogue[0][0] = "Hello, lad.";
dialogue[0][1] = "So you've come to this island to \nfind the treasure?";
dialogue[0][2] = "I used to be a great wizard but now... \nI'm a bit too old for taking an \nadventure.";

View File

@@ -28,6 +28,7 @@ public class ChestObj extends Entity {
solidAreaDefaultY = solidArea.y;
}
@Override
public void setDialogue() {
dialogue[0][0] = "You open the chest and find a " + loot.name + "!\nBut your inventory is full...";
dialogue[1][0] = "You open the chest and find a " + loot.name + "!\nYou obtain the " + loot.name + "!";

View File

@@ -0,0 +1,36 @@
package de.miaurizius.jgame2d.entity.obstacle;
import de.miaurizius.jgame2d.core.GamePanel;
import de.miaurizius.jgame2d.core.enums.EntityType;
import de.miaurizius.jgame2d.entity.Entity;
public class IronDoorObj extends Entity {
GamePanel panel;
public IronDoorObj(GamePanel panel) {
super(panel);
this.panel = panel;
name = "door";
type = EntityType.OBSTACLE;
down1 = initEntitySprites("objects/door_iron");
collision = true;
solidArea.x = 0;
solidArea.y = 16;
solidArea.width = 48;
solidArea.height = 32;
solidAreaDefaultX = solidArea.x;
solidAreaDefaultY = solidArea.y;
setDialogue();
}
public void setDialogue() {
dialogue[0][0] = "It won't budge.";
}
@Override
public void interact() {
startDialogue(this,0);
}
}

View File

@@ -1,6 +1,7 @@
package de.miaurizius.jgame2d.environment;
import de.miaurizius.jgame2d.core.GamePanel;
import de.miaurizius.jgame2d.core.enums.Map;
import java.awt.*;
import java.awt.image.BufferedImage;
@@ -19,8 +20,8 @@ public class Lighting {
}
public void draw(Graphics2D g2) {
g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, filterAlpha));
g2.drawImage(darknessFilter, 0, 0, null);
if(panel.currentArea == Map.Area.OUTSIDE) g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, filterAlpha));
if(panel.currentArea == Map.Area.OUTSIDE || panel.currentArea == Map.Area.DUNGEON) g2.drawImage(darknessFilter, 0, 0, null);
g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 1F));
// DEBUG

View File

@@ -0,0 +1,44 @@
package de.miaurizius.jgame2d.tile.interactive;
import de.miaurizius.jgame2d.core.GamePanel;
import de.miaurizius.jgame2d.core.enums.EntityType;
import de.miaurizius.jgame2d.entity.Entity;
import java.awt.*;
public class DestructibleWallIT extends InteractiveTile {
GamePanel panel;
public DestructibleWallIT(GamePanel panel, int col, int row) {
super(panel, col, row);
this.panel = panel;
this.worldX = panel.tileSize * col;
this.worldY = panel.tileSize * row;
down1 = initEntitySprites("/interactive_tiles/destructiblewall");
destructible = true;
life = 3;
}
// PRE_CONFIGURED
public void playSE() {
panel.playSE(20);
}
// GETTERS
public boolean meetItemReq(Entity entity) {
return entity.currentWeapon.weaponType == EntityType.WeaponType.PICKAXE;
}
public Color getParticleColor() {
return new Color(65, 65,65);
}
public int getParticleSize() {
return 6; //in pixels
}
public int getParticleSpeed() {
return 1;
}
public int getParticleMaxLife() {
return 20;
}
}

View File

@@ -6,11 +6,11 @@ import de.miaurizius.jgame2d.entity.Entity;
import java.awt.*;
public class DryTreeTI extends InteractiveTile{
public class DryTreeIT extends InteractiveTile{
GamePanel panel;
public DryTreeTI(GamePanel panel, int col, int row) {
public DryTreeIT(GamePanel panel, int col, int row) {
super(panel, col, row);
this.panel = panel;
this.worldX = panel.tileSize * col;
@@ -18,7 +18,7 @@ public class DryTreeTI extends InteractiveTile{
down1 = initEntitySprites("/interactive_tiles/drytree");
destructible = true;
life = 3;
life = 2;
}
// PRE_CONFIGURED

View File

@@ -0,0 +1,26 @@
package de.miaurizius.jgame2d.tile.interactive;
import de.miaurizius.jgame2d.core.GamePanel;
public class MetalPlateIT extends InteractiveTile {
GamePanel panel;
public MetalPlateIT(GamePanel panel, int col, int row) {
super(panel, col, row);
this.panel = panel;
this.name = "metal_plate";
this.worldX = panel.tileSize * col;
this.worldY = panel.tileSize * row;
down1 = initEntitySprites("/interactive_tiles/metalplate");
solidArea.x = 0;
solidArea.y = 0;
solidArea.width = 0;
solidArea.height = 0;
solidAreaDefaultX = 0;
solidAreaDefaultY = 0;
}
}