added init & taktical view by ownColor
This commit is contained in:
@@ -277,6 +277,10 @@ public float getRotation() {
|
||||
return (rotationAngle / 2) % 360;
|
||||
}
|
||||
|
||||
public void setRotation(float rotationAngle){
|
||||
this.rotationAngle = rotationAngle;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the current scroll value.
|
||||
*
|
||||
|
||||
@@ -75,8 +75,8 @@ public static void main(String[] args) {
|
||||
AppSettings settings = new AppSettings(true);
|
||||
settings.setSamples(128);
|
||||
settings.setCenterWindow(true);
|
||||
settings.setWidth(1080);
|
||||
settings.setHeight(720);
|
||||
settings.setWidth((int) (1920*0.9f));
|
||||
settings.setHeight((int) (1080*0.9f));
|
||||
settings.setVSync(false);
|
||||
|
||||
MdgaApp app = new MdgaApp();
|
||||
@@ -107,7 +107,7 @@ public void simpleInitApp() {
|
||||
gameView = new GameView(this);
|
||||
ceremonyView = new CeremonyView(this);
|
||||
|
||||
enter(MdgaState.MAIN);
|
||||
enter(MdgaState.GAME);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
import com.jme3.util.SkyFactory;
|
||||
import com.jme3.util.SkyFactory.EnvMapType;
|
||||
import pp.mdga.client.MdgaApp;
|
||||
import pp.mdga.game.Color;
|
||||
|
||||
public class CameraHandler {
|
||||
MdgaApp app;
|
||||
@@ -29,11 +30,15 @@ public class CameraHandler {
|
||||
DirectionalLightShadowFilter dlsf;
|
||||
|
||||
Spatial sky;
|
||||
private Color ownColor;
|
||||
private boolean init;
|
||||
private boolean initRot;
|
||||
|
||||
public CameraHandler(MdgaApp app, FilterPostProcessor fpp) {
|
||||
init = false;
|
||||
initRot = false;
|
||||
this.app = app;
|
||||
this.fpp = fpp;
|
||||
|
||||
// Save the default camera state
|
||||
this.defaultCameraPosition = app.getCamera().getLocation().clone();
|
||||
this.defaultCameraRotation = app.getCamera().getRotation().clone();
|
||||
@@ -56,11 +61,15 @@ public CameraHandler(MdgaApp app, FilterPostProcessor fpp) {
|
||||
|
||||
}
|
||||
|
||||
public void init() {
|
||||
public void init(Color ownColor) {
|
||||
app.getRootNode().addLight(sun);
|
||||
app.getRootNode().addLight(ambient);
|
||||
app.getRootNode().attachChild(sky);
|
||||
fpp.addFilter(dlsf);
|
||||
init = true;
|
||||
initRot = true;
|
||||
this.ownColor = ownColor;
|
||||
app.getInputSynchronize().setRotation(getInitAngleByColor(ownColor)*2);
|
||||
}
|
||||
|
||||
public void shutdown() {
|
||||
@@ -76,6 +85,7 @@ public void shutdown() {
|
||||
}
|
||||
|
||||
public void update(float scroll, float rotation) {
|
||||
if(!init) return;
|
||||
float scrollValue = Math.max(0, Math.min(scroll, 100));
|
||||
|
||||
float rotationValue = rotation % 360;
|
||||
@@ -83,6 +93,7 @@ public void update(float scroll, float rotation) {
|
||||
rotationValue += 360;
|
||||
}
|
||||
|
||||
|
||||
float radius;
|
||||
|
||||
float verticalAngle;
|
||||
@@ -91,10 +102,10 @@ public void update(float scroll, float rotation) {
|
||||
radius = 30f;
|
||||
} else {
|
||||
verticalAngle = 90f;
|
||||
rotationValue = 270f;
|
||||
rotationValue = getAngleByColor(ownColor);
|
||||
radius = 50f;
|
||||
}
|
||||
|
||||
System.out.println(rotationValue);
|
||||
float verticalAngleRadians = FastMath.DEG_TO_RAD * verticalAngle;
|
||||
|
||||
float z = radius * FastMath.sin(verticalAngleRadians);
|
||||
@@ -107,4 +118,18 @@ public void update(float scroll, float rotation) {
|
||||
app.getCamera().lookAt(Vector3f.ZERO, Vector3f.UNIT_Z);
|
||||
}
|
||||
|
||||
private float getAngleByColor(Color color){
|
||||
return switch (color){
|
||||
case ARMY -> 0;
|
||||
case AIRFORCE -> 90;
|
||||
case NAVY -> 270;
|
||||
case CYBER -> 180;
|
||||
default -> throw new RuntimeException("None is not allowed");
|
||||
};
|
||||
}
|
||||
|
||||
private float getInitAngleByColor(Color color){
|
||||
return (getAngleByColor(color) + 180) % 360;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -58,9 +58,9 @@ public GameView(MdgaApp app) {
|
||||
|
||||
@Override
|
||||
public void onEnter() {
|
||||
camera.init();
|
||||
boardHandler.init();
|
||||
setOwnColor(Color.AIRFORCE);
|
||||
camera.init(ownColor);
|
||||
boardHandler.init();
|
||||
guiHandler.init(ownColor);
|
||||
|
||||
app.getViewPort().addProcessor(fpp);
|
||||
|
||||
Reference in New Issue
Block a user