Client work of the Week #4
@@ -167,12 +167,14 @@ private void addGameTracks() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void updateGameTracks() {
|
private void updateGameTracks() {
|
||||||
if (playing != null && playing.nearEnd(3) && trackTimer.getTimeInSeconds() > 20) {
|
if(playing.nearEnd(10)) {
|
||||||
trackTimer.reset();
|
|
||||||
|
|
||||||
if (gameTracks.isEmpty()) {
|
if (gameTracks.isEmpty()) {
|
||||||
addGameTracks();
|
addGameTracks();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (playing != null && playing.nearEnd(3) && trackTimer.getTimeInSeconds() > 20) {
|
||||||
|
trackTimer.reset();
|
||||||
|
|
||||||
MusicAsset nextTrack = gameTracks.remove(0);
|
MusicAsset nextTrack = gameTracks.remove(0);
|
||||||
|
|
||||||
@@ -181,12 +183,10 @@ private void updateGameTracks() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public float getMainVolume() {
|
public float getMainVolume() {
|
||||||
|
|
||||||
return mainVolume;
|
return mainVolume;
|
||||||
}
|
}
|
||||||
|
|
||||||
public float getMusicVolume() {
|
public float getMusicVolume() {
|
||||||
|
|
||||||
return musicVolume;
|
return musicVolume;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -194,12 +194,24 @@ public float getSoundVolume() {
|
|||||||
return soundVolume;
|
return soundVolume;
|
||||||
}
|
}
|
||||||
|
|
||||||
public float getMusicVolumeTotal() {
|
public void setMainVolume(float mainVolume) {
|
||||||
|
this.mainVolume = mainVolume;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMusicVolume(float musicVolume) {
|
||||||
|
this.musicVolume = musicVolume;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSoundVolume(float soundVolume) {
|
||||||
|
this.soundVolume = soundVolume;
|
||||||
|
}
|
||||||
|
|
||||||
|
float getMusicVolumeTotal() {
|
||||||
|
|
||||||
return getMusicVolume() * getMainVolume();
|
return getMusicVolume() * getMainVolume();
|
||||||
}
|
}
|
||||||
|
|
||||||
public float getSoundVolumeTotal() {
|
float getSoundVolumeTotal() {
|
||||||
return getSoundVolume() * getMainVolume();
|
return getSoundVolume() * getMainVolume();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ public AnimationHandler(MdgaApp app) {
|
|||||||
this.app = app;
|
this.app = app;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void playAnimation(AnimationType type) {
|
public void playAnimation(MdgaAnimation type) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
package pp.mdga.client.Animation;
|
package pp.mdga.client.Animation;
|
||||||
|
|
||||||
public enum AnimationType {
|
public enum MdgaAnimation {
|
||||||
}
|
}
|
||||||
@@ -1,3 +1,3 @@
|
|||||||
package pp.mdga.client.Board;
|
package pp.mdga.client.Board;
|
||||||
|
|
||||||
public record AssetOnMap(Asset asset, int x, int y){}
|
record AssetOnMap(BoardAsset boardAsset, int x, int y){}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
package pp.mdga.client.Board;
|
package pp.mdga.client.Board;
|
||||||
|
|
||||||
public enum Asset {
|
enum BoardAsset {
|
||||||
bigTent,
|
bigTent,
|
||||||
cardStack,
|
cardStack,
|
||||||
cir,
|
cir,
|
||||||
@@ -28,20 +28,20 @@ public enum Asset {
|
|||||||
private final String diffPath;
|
private final String diffPath;
|
||||||
private final float size;
|
private final float size;
|
||||||
|
|
||||||
Asset(){
|
BoardAsset(){
|
||||||
String folderFileName = "./" + name() + "/" + name();
|
String folderFileName = "./" + name() + "/" + name();
|
||||||
this.modelPath = folderFileName + ".j3o";
|
this.modelPath = folderFileName + ".j3o";
|
||||||
this.diffPath = folderFileName + "_diff.png";
|
this.diffPath = folderFileName + "_diff.png";
|
||||||
this.size = 1f;
|
this.size = 1f;
|
||||||
}
|
}
|
||||||
|
|
||||||
Asset(String modelPath, String diffPath){
|
BoardAsset(String modelPath, String diffPath){
|
||||||
this.modelPath = modelPath;
|
this.modelPath = modelPath;
|
||||||
this.diffPath = diffPath;
|
this.diffPath = diffPath;
|
||||||
this.size = 1f;
|
this.size = 1f;
|
||||||
}
|
}
|
||||||
|
|
||||||
Asset(float size){
|
BoardAsset(float size){
|
||||||
String folderFileName = "./" + name() + "/" + name();
|
String folderFileName = "./" + name() + "/" + name();
|
||||||
this.modelPath = folderFileName + ".j3o";
|
this.modelPath = folderFileName + ".j3o";
|
||||||
this.diffPath = folderFileName + "_diff.png";
|
this.diffPath = folderFileName + "_diff.png";
|
||||||
@@ -64,16 +64,22 @@ private void initMap() {
|
|||||||
for (AssetOnMap aom : assetsOnMap){
|
for (AssetOnMap aom : assetsOnMap){
|
||||||
int x = aom.x();
|
int x = aom.x();
|
||||||
int y = aom.y();
|
int y = aom.y();
|
||||||
Spatial model = createModel(aom.asset());
|
Vector3f pos = gridToWorld(x,y);
|
||||||
model.setLocalTranslation(gridToWorld(x,y));
|
|
||||||
|
if(aom.boardAsset().name().contains("node")) {
|
||||||
|
infield.add(new NodeControl(app, pos, aom.boardAsset()));
|
||||||
|
} else {
|
||||||
|
Spatial model = createModel(aom.boardAsset());
|
||||||
|
model.setLocalTranslation(pos);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private Spatial createModel(Asset asset){
|
private Spatial createModel(BoardAsset boardAsset){
|
||||||
String modelName = asset.getModelPath();
|
String modelName = boardAsset.getModelPath();
|
||||||
String texName = asset.getDiffPath();
|
String texName = boardAsset.getDiffPath();
|
||||||
Spatial model = app.getAssetManager().loadModel(modelName);
|
Spatial model = app.getAssetManager().loadModel(modelName);
|
||||||
model.scale(asset.getSize());
|
model.scale(boardAsset.getSize());
|
||||||
model.rotate((float) Math.toRadians(0), 0, (float) Math.toRadians(90));
|
model.rotate((float) Math.toRadians(0), 0, (float) Math.toRadians(90));
|
||||||
model.setShadowMode(RenderQueue.ShadowMode.CastAndReceive);
|
model.setShadowMode(RenderQueue.ShadowMode.CastAndReceive);
|
||||||
Material mat = new Material(app.getAssetManager(), "Common/MatDefs/Light/Lighting.j3md");
|
Material mat = new Material(app.getAssetManager(), "Common/MatDefs/Light/Lighting.j3md");
|
||||||
|
|||||||
@@ -1,13 +1,12 @@
|
|||||||
package pp.mdga.client.Board;
|
package pp.mdga.client.Board;
|
||||||
|
|
||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.io.InputStreamReader;
|
import java.io.InputStreamReader;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class MapLoader {
|
class MapLoader {
|
||||||
static public List<AssetOnMap> loadMap(String mapName) {
|
static public List<AssetOnMap> loadMap(String mapName) {
|
||||||
List<AssetOnMap> assetsOnMap = new ArrayList<>();
|
List<AssetOnMap> assetsOnMap = new ArrayList<>();
|
||||||
|
|
||||||
@@ -34,8 +33,8 @@ static public List<AssetOnMap> loadMap(String mapName) {
|
|||||||
int x = Integer.parseInt(coordinates[0]);
|
int x = Integer.parseInt(coordinates[0]);
|
||||||
int y = Integer.parseInt(coordinates[1]);
|
int y = Integer.parseInt(coordinates[1]);
|
||||||
|
|
||||||
Asset asset = getLoadedAsset(assetName);
|
BoardAsset boardAsset = getLoadedAsset(assetName);
|
||||||
assetsOnMap.add(new AssetOnMap(asset, x, y));
|
assetsOnMap.add(new AssetOnMap(boardAsset, x, y));
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
@@ -44,23 +43,23 @@ static public List<AssetOnMap> loadMap(String mapName) {
|
|||||||
return assetsOnMap;
|
return assetsOnMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
static private Asset getLoadedAsset(String assetName) {
|
static private BoardAsset getLoadedAsset(String assetName) {
|
||||||
return switch(assetName){
|
return switch(assetName){
|
||||||
case "node" -> Asset.node_normal;
|
case "node" -> BoardAsset.node_normal;
|
||||||
case "node_start" -> Asset.node_start;
|
case "node_start" -> BoardAsset.node_start;
|
||||||
case "node_bonus" -> Asset.node_bonus;
|
case "node_bonus" -> BoardAsset.node_bonus;
|
||||||
case "node_home_blue" -> Asset.node_home_blue;
|
case "node_home_blue" -> BoardAsset.node_home_blue;
|
||||||
case "node_home_yellow" -> Asset.node_home_yellow;
|
case "node_home_yellow" -> BoardAsset.node_home_yellow;
|
||||||
case "node_home_black" -> Asset.node_home_black;
|
case "node_home_black" -> BoardAsset.node_home_black;
|
||||||
case "node_home_green" -> Asset.node_home_green;
|
case "node_home_green" -> BoardAsset.node_home_green;
|
||||||
case "world" -> Asset.world;
|
case "world" -> BoardAsset.world;
|
||||||
case "tent_big" -> Asset.bigTent;
|
case "tent_big" -> BoardAsset.bigTent;
|
||||||
case "tent_small" -> Asset.smallTent;
|
case "tent_small" -> BoardAsset.smallTent;
|
||||||
case "stack" -> Asset.cardStack;
|
case "stack" -> BoardAsset.cardStack;
|
||||||
case "jet" -> Asset.jet;
|
case "jet" -> BoardAsset.jet;
|
||||||
case "radar" -> Asset.radar;
|
case "radar" -> BoardAsset.radar;
|
||||||
case "ship" -> Asset.ship;
|
case "ship" -> BoardAsset.ship;
|
||||||
case "tank" -> Asset.tank;
|
case "tank" -> BoardAsset.tank;
|
||||||
default -> throw new IllegalStateException("Unexpected asset in .mdga file: " + assetName);
|
default -> throw new IllegalStateException("Unexpected asset in .mdga file: " + assetName);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,30 @@
|
|||||||
package pp.mdga.client.Board;
|
package pp.mdga.client.Board;
|
||||||
|
|
||||||
public class NodeControl {
|
import com.jme3.material.Material;
|
||||||
|
import com.jme3.math.Vector3f;
|
||||||
|
import com.jme3.renderer.queue.RenderQueue;
|
||||||
|
import com.jme3.scene.Spatial;
|
||||||
|
import pp.mdga.client.MdgaApp;
|
||||||
|
|
||||||
|
class NodeControl {
|
||||||
|
private final MdgaApp app;
|
||||||
|
|
||||||
|
private Spatial model;
|
||||||
|
|
||||||
|
NodeControl(MdgaApp app, Vector3f pos, BoardAsset boardAsset) {
|
||||||
|
this.app = app;
|
||||||
|
|
||||||
|
String modelName = boardAsset.getModelPath();
|
||||||
|
String texName = boardAsset.getDiffPath();
|
||||||
|
Spatial model = app.getAssetManager().loadModel(modelName);
|
||||||
|
model.scale(boardAsset.getSize());
|
||||||
|
model.rotate((float) Math.toRadians(0), 0, (float) Math.toRadians(90));
|
||||||
|
model.setShadowMode(RenderQueue.ShadowMode.CastAndReceive);
|
||||||
|
Material mat = new Material(app.getAssetManager(), "Common/MatDefs/Light/Lighting.j3md");
|
||||||
|
mat.setTexture("DiffuseMap", app.getAssetManager().loadTexture(texName));
|
||||||
|
model.setMaterial(mat);
|
||||||
|
app.getRootNode().attachChild(model);
|
||||||
|
|
||||||
|
model.setLocalTranslation(pos);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
package pp.mdga.client.Board;
|
package pp.mdga.client.Board;
|
||||||
|
|
||||||
public class PieceControl {
|
class PieceControl {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
package pp.mdga.client.Board;
|
package pp.mdga.client.Board;
|
||||||
|
|
||||||
public class PileControl {
|
class PileControl {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user