add dungeon area transitions and update sound effects for new locations
This commit is contained in:
@@ -78,6 +78,8 @@ public class GamePanel extends JPanel implements Runnable {
|
|||||||
|
|
||||||
// GAME STATE
|
// GAME STATE
|
||||||
public GameState gameState;
|
public GameState gameState;
|
||||||
|
public Map.Area currentArea;
|
||||||
|
public Map.Area nextArea;
|
||||||
|
|
||||||
public GamePanel() throws IOException {
|
public GamePanel() throws IOException {
|
||||||
this.setPreferredSize(new Dimension(screenWidth, screenHeight));
|
this.setPreferredSize(new Dimension(screenWidth, screenHeight));
|
||||||
@@ -252,6 +254,7 @@ public class GamePanel extends JPanel implements Runnable {
|
|||||||
assetSetter.setITiles();
|
assetSetter.setITiles();
|
||||||
eManager.setup();
|
eManager.setup();
|
||||||
gameState = GameState.TITLE;
|
gameState = GameState.TITLE;
|
||||||
|
currentArea = Map.Area.OUTSIDE;
|
||||||
|
|
||||||
tempScreen = new BufferedImage(screenWidth, screenHeight, BufferedImage.TYPE_INT_RGB);
|
tempScreen = new BufferedImage(screenWidth, screenHeight, BufferedImage.TYPE_INT_RGB);
|
||||||
fg2 = (Graphics2D) tempScreen.getGraphics();
|
fg2 = (Graphics2D) tempScreen.getGraphics();
|
||||||
@@ -279,4 +282,15 @@ public class GamePanel extends JPanel implements Runnable {
|
|||||||
assetSetter.setITiles();
|
assetSetter.setITiles();
|
||||||
eManager.lighting.resetDay();
|
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.setMonster();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -414,6 +414,7 @@ public class UI {
|
|||||||
panel.player.worldY = panel.tileSize * panel.eventH.tempRow;
|
panel.player.worldY = panel.tileSize * panel.eventH.tempRow;
|
||||||
panel.eventH.prevEventX = panel.player.worldX;
|
panel.eventH.prevEventX = panel.player.worldX;
|
||||||
panel.eventH.prevEventY = panel.player.worldY;
|
panel.eventH.prevEventY = panel.player.worldY;
|
||||||
|
panel.changeArea();
|
||||||
}
|
}
|
||||||
private void drawTradeScreen() {
|
private void drawTradeScreen() {
|
||||||
switch(tradeState) {
|
switch(tradeState) {
|
||||||
|
|||||||
@@ -2,15 +2,19 @@ package de.miaurizius.jgame2d.core.enums;
|
|||||||
|
|
||||||
public enum Map {
|
public enum Map {
|
||||||
|
|
||||||
OVERWORLD("worldmap", 0),
|
OVERWORLD("worldmap", 0, Area.OUTSIDE),
|
||||||
HUT("indoor01", 1);
|
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 String name;
|
||||||
private final int index;
|
private final int index;
|
||||||
|
private final Area area;
|
||||||
|
|
||||||
Map(String name, int index) {
|
Map(String name, int index, Area area) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.index = index;
|
this.index = index;
|
||||||
|
this.area = area;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getName() {
|
public String getName() {
|
||||||
@@ -20,4 +24,15 @@ public enum Map {
|
|||||||
public int getIndex() {
|
public int getIndex() {
|
||||||
return index;
|
return index;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Area getArea() {
|
||||||
|
return area;
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum Area {
|
||||||
|
INDOOR,
|
||||||
|
OUTSIDE,
|
||||||
|
DUNGEON
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -72,6 +72,12 @@ public class EventHandler {
|
|||||||
else if(hit(Map.OVERWORLD, 10, 39, null)) changeMap(Map.HUT, 12, 13);
|
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);
|
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
|
// ADVANCED SPEAKING
|
||||||
else if(hit(Map.HUT, 12, 9, Direction.UP)) speak(panel.npc[Map.HUT.getIndex()][0]);
|
else if(hit(Map.HUT, 12, 9, Direction.UP)) speak(panel.npc[Map.HUT.getIndex()][0]);
|
||||||
}
|
}
|
||||||
@@ -129,6 +135,7 @@ public class EventHandler {
|
|||||||
tempCol = col;
|
tempCol = col;
|
||||||
tempRow = row;
|
tempRow = row;
|
||||||
canTouchEvent = false;
|
canTouchEvent = false;
|
||||||
|
panel.nextArea = map.getArea();
|
||||||
panel.playSE(13);
|
panel.playSE(13);
|
||||||
}
|
}
|
||||||
private void speak(Entity entity) {
|
private void speak(Entity entity) {
|
||||||
|
|||||||
@@ -38,6 +38,8 @@ public class Sound {
|
|||||||
load(15, "assets/sounds/blocked.wav");
|
load(15, "assets/sounds/blocked.wav");
|
||||||
load(16, "assets/sounds/parry.wav");
|
load(16, "assets/sounds/parry.wav");
|
||||||
load(17, "assets/sounds/speak.wav");
|
load(17, "assets/sounds/speak.wav");
|
||||||
|
load(18, "assets/sounds/Merchant.wav");
|
||||||
|
load(19, "assets/sounds/Dungeon.wav");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package de.miaurizius.jgame2d.environment;
|
package de.miaurizius.jgame2d.environment;
|
||||||
|
|
||||||
import de.miaurizius.jgame2d.core.GamePanel;
|
import de.miaurizius.jgame2d.core.GamePanel;
|
||||||
|
import de.miaurizius.jgame2d.core.enums.Map;
|
||||||
|
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
import java.awt.image.BufferedImage;
|
import java.awt.image.BufferedImage;
|
||||||
@@ -19,8 +20,8 @@ public class Lighting {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void draw(Graphics2D g2) {
|
public void draw(Graphics2D g2) {
|
||||||
g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, filterAlpha));
|
if(panel.currentArea == Map.Area.OUTSIDE) g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, filterAlpha));
|
||||||
g2.drawImage(darknessFilter, 0, 0, null);
|
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));
|
g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 1F));
|
||||||
|
|
||||||
// DEBUG
|
// DEBUG
|
||||||
|
|||||||
Reference in New Issue
Block a user