add BigRockNPC and IronDoorObj; update AssetSetter to include new NPC and interactive tiles
This commit is contained in:
@@ -291,6 +291,7 @@ public class GamePanel extends JPanel implements Runnable {
|
||||
}
|
||||
currentArea = nextArea;
|
||||
nextArea = null;
|
||||
assetSetter.setNPC();
|
||||
// assetSetter.setMonster();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -15,7 +15,8 @@ public enum EntityType {
|
||||
|
||||
public enum WeaponType {
|
||||
SWORD,
|
||||
AXE
|
||||
AXE,
|
||||
PICKAXE
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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++;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -66,6 +66,7 @@ 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
|
||||
|
||||
@@ -40,6 +40,8 @@ public class Sound {
|
||||
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
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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));
|
||||
}
|
||||
|
||||
@@ -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
|
||||
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() {
|
||||
|
||||
23
src/de/miaurizius/jgame2d/entity/item/PickaxeObj.java
Normal file
23
src/de/miaurizius/jgame2d/entity/item/PickaxeObj.java
Normal 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;
|
||||
}
|
||||
}
|
||||
119
src/de/miaurizius/jgame2d/entity/npc/BigRockNPC.java
Normal file
119
src/de/miaurizius/jgame2d/entity/npc/BigRockNPC.java
Normal 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.";
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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!";
|
||||
|
||||
@@ -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.";
|
||||
|
||||
@@ -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 + "!";
|
||||
|
||||
36
src/de/miaurizius/jgame2d/entity/obstacle/IronDoorObj.java
Normal file
36
src/de/miaurizius/jgame2d/entity/obstacle/IronDoorObj.java
Normal 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);
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
26
src/de/miaurizius/jgame2d/tile/interactive/MetalPlateIT.java
Normal file
26
src/de/miaurizius/jgame2d/tile/interactive/MetalPlateIT.java
Normal 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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user