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