play sound and change presence of tile if interacted with
This commit is contained in:
@@ -27,6 +27,7 @@ public class Sound {
|
|||||||
load(8, "assets/sounds/levelup.wav");
|
load(8, "assets/sounds/levelup.wav");
|
||||||
load(9, "assets/sounds/cursor.wav");
|
load(9, "assets/sounds/cursor.wav");
|
||||||
load(10, "assets/sounds/burning.wav");
|
load(10, "assets/sounds/burning.wav");
|
||||||
|
load(11, "assets/sounds/cuttree.wav");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
|
|||||||
@@ -222,7 +222,8 @@ public class Player extends Entity {
|
|||||||
public void interactTile(int index) {
|
public void interactTile(int index) {
|
||||||
if(index == 999 || !panel.iTile[index].destructible) return;
|
if(index == 999 || !panel.iTile[index].destructible) return;
|
||||||
if(!panel.iTile[index].meetItemReq(this)) return;
|
if(!panel.iTile[index].meetItemReq(this)) return;
|
||||||
panel.iTile[index] = null;
|
panel.iTile[index].playSE();
|
||||||
|
panel.iTile[index] = panel.iTile[index].getDestroyedForm();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void interactNPC(int index) {
|
public void interactNPC(int index) {
|
||||||
|
|||||||
@@ -21,4 +21,12 @@ public class DryTreeTI extends InteractiveTile{
|
|||||||
public boolean meetItemReq(Entity entity) {
|
public boolean meetItemReq(Entity entity) {
|
||||||
return entity.currentWeapon.weaponType == EntityType.WeaponType.AXE;
|
return entity.currentWeapon.weaponType == EntityType.WeaponType.AXE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void playSE() {
|
||||||
|
panel.playSE(11);
|
||||||
|
}
|
||||||
|
|
||||||
|
public InteractiveTile getDestroyedForm() {
|
||||||
|
return new TrunkIT(panel, worldX/panel.tileSize, worldY/panel.tileSize);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,6 +16,13 @@ public class InteractiveTile extends Entity {
|
|||||||
public void update() {
|
public void update() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void playSE() {}
|
||||||
|
|
||||||
|
public InteractiveTile getDestroyedForm() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
public boolean meetItemReq(Entity entity) {
|
public boolean meetItemReq(Entity entity) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
26
src/de/miaurizius/jgame2d/tile/interactive/TrunkIT.java
Normal file
26
src/de/miaurizius/jgame2d/tile/interactive/TrunkIT.java
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
package de.miaurizius.jgame2d.tile.interactive;
|
||||||
|
|
||||||
|
import de.miaurizius.jgame2d.core.GamePanel;
|
||||||
|
|
||||||
|
public class TrunkIT extends InteractiveTile {
|
||||||
|
|
||||||
|
GamePanel panel;
|
||||||
|
|
||||||
|
public TrunkIT(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/trunk");
|
||||||
|
|
||||||
|
solidArea.x = 0;
|
||||||
|
solidArea.y = 0;
|
||||||
|
solidArea.width = 0;
|
||||||
|
solidArea.height = 0;
|
||||||
|
solidAreaDefaultX = 0;
|
||||||
|
solidAreaDefaultY = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user