Merge
This commit is contained in:
commit
f7a86cd4ca
BIN
ShootingStars/assets/Textures/Hex.jpg
Normal file
BIN
ShootingStars/assets/Textures/Hex.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 22 KiB |
Binary file not shown.
@ -21,9 +21,11 @@ import com.jme3.app.DebugKeysAppState;
|
||||
import com.jme3.app.SimpleApplication;
|
||||
import com.jme3.app.StatsAppState;
|
||||
import com.jme3.app.state.AppStateManager;
|
||||
import com.jme3.math.Vector3f;
|
||||
import com.jme3.renderer.Camera;
|
||||
import com.jme3.scene.Node;
|
||||
import org.wyrez.persij.PersiJContainer;
|
||||
import org.wyrez.shootingstars.factories.Materials;
|
||||
import org.wyrez.shootingstars.states.State;
|
||||
import org.wyrez.shootingstars.states.StateManager;
|
||||
import tonegod.gui.core.Screen;
|
||||
@ -44,17 +46,19 @@ public class ShootingStars extends SimpleApplication {
|
||||
|
||||
@Override
|
||||
public void simpleInitApp() {
|
||||
System.setProperty("jna.library.path", "lib/vlc");
|
||||
registerTypes();
|
||||
initGUI();
|
||||
|
||||
Materials.initialize(assetManager);
|
||||
cam.setFrustumFar(2500f);
|
||||
//TODO debug
|
||||
cam.setLocation(new Vector3f(0f, 2500f, 0f));
|
||||
|
||||
sManager = container.resolve(StateManager.class);
|
||||
sManager.setState(State.START);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void simpleUpdate(float tpf) {
|
||||
}
|
||||
|
||||
private void initGUI() {
|
||||
guiNode.addControl(container.resolve(Screen.class));
|
||||
}
|
||||
|
||||
@ -0,0 +1,50 @@
|
||||
/*
|
||||
* Copyright (C) 2013 Darth Affe <http://wyrez.org> and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.wyrez.shootingstars.factories;
|
||||
|
||||
import com.jme3.asset.AssetManager;
|
||||
import com.jme3.material.Material;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Darth Affe
|
||||
*/
|
||||
public enum Materials {
|
||||
|
||||
UNSHADED("Common/MatDefs/Misc/Unshaded.j3md", null),
|
||||
HEX("Common/MatDefs/Light/Lighting.j3md", "Textures/Hex.jpg");
|
||||
private static AssetManager assetManager;
|
||||
private String material;
|
||||
private String texture;
|
||||
|
||||
Materials(String material, String texture) {
|
||||
this.material = material;
|
||||
this.texture = texture;
|
||||
}
|
||||
|
||||
public Material create() {
|
||||
Material mat = new Material(assetManager, material);
|
||||
if (texture != null) {
|
||||
mat.setTexture("DiffuseMap", assetManager.loadTexture(texture));
|
||||
}
|
||||
return mat;
|
||||
}
|
||||
|
||||
public static void initialize(AssetManager assetManager) {
|
||||
Materials.assetManager = assetManager;
|
||||
}
|
||||
}
|
||||
107
ShootingStars/src/org/wyrez/shootingstars/game/Cinema.java
Normal file
107
ShootingStars/src/org/wyrez/shootingstars/game/Cinema.java
Normal file
@ -0,0 +1,107 @@
|
||||
/*
|
||||
* Copyright (C) 2013 Darth Affe <http://wyrez.org> and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.wyrez.shootingstars.game;
|
||||
|
||||
import com.jme3.material.Material;
|
||||
import com.jme3.math.FastMath;
|
||||
import com.jme3.math.Vector3f;
|
||||
import com.jme3.renderer.RenderManager;
|
||||
import com.jme3.scene.Geometry;
|
||||
import com.jme3.texture.Image;
|
||||
import com.jme3.texture.Texture2D;
|
||||
import com.sun.jna.Memory;
|
||||
import java.nio.ByteBuffer;
|
||||
import org.wyrez.shootingstars.factories.Materials;
|
||||
import org.wyrez.shootingstars.mesh.CinemaHex;
|
||||
import uk.co.caprica.vlcj.player.MediaPlayerFactory;
|
||||
import uk.co.caprica.vlcj.player.direct.BufferFormat;
|
||||
import uk.co.caprica.vlcj.player.direct.DirectMediaPlayer;
|
||||
import uk.co.caprica.vlcj.player.direct.RenderCallback;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Darth Affe
|
||||
*/
|
||||
public class Cinema extends Geometry implements RenderCallback {
|
||||
|
||||
private static final int WIDTH = 1280;
|
||||
private static final int HEIGHT = 720;
|
||||
private static final int DEPTH = 4;
|
||||
private static final String VIDEO_FORMAT = "RGBA";
|
||||
private static final Image.Format TEXTURE_FORMAT = Image.Format.RGBA8;
|
||||
private final MediaPlayerFactory mediaPlayerFactory;
|
||||
private final DirectMediaPlayer mediaPlayer;
|
||||
private final Image videoImage;
|
||||
private final Texture2D videoTexture;
|
||||
private final Object bufferLock = new Object();
|
||||
private ByteBuffer buffer;
|
||||
|
||||
public Cinema(String file) {
|
||||
this(file, 1000f);
|
||||
}
|
||||
|
||||
public Cinema(String file, float radius) {
|
||||
this(file, radius, Vector3f.ZERO);
|
||||
}
|
||||
|
||||
public Cinema(String file, float radius, Vector3f pos) {
|
||||
super("Cinema: " + file, new CinemaHex(pos, radius,
|
||||
radius * ((float) HEIGHT / (float) WIDTH)));
|
||||
mediaPlayerFactory = new MediaPlayerFactory("--no-video-title-show", "--quiet");
|
||||
mediaPlayer = mediaPlayerFactory.newDirectMediaPlayer(VIDEO_FORMAT, WIDTH, HEIGHT, WIDTH * DEPTH, this);
|
||||
videoImage = new Image(TEXTURE_FORMAT, WIDTH, HEIGHT, null);
|
||||
videoTexture = new Texture2D(videoImage);
|
||||
|
||||
Material mat = Materials.UNSHADED.create();
|
||||
mat.setTexture("ColorMap", videoTexture);
|
||||
this.setMaterial(mat);
|
||||
this.rotate(0f, FastMath.PI / 6f, 0f);
|
||||
|
||||
mediaPlayer.prepareMedia(file);
|
||||
}
|
||||
|
||||
public void play() {
|
||||
mediaPlayer.play();
|
||||
}
|
||||
|
||||
public void pause() {
|
||||
mediaPlayer.pause();
|
||||
}
|
||||
|
||||
public void stop() {
|
||||
mediaPlayer.stop();
|
||||
}
|
||||
|
||||
public void cleanup() {
|
||||
stop();
|
||||
mediaPlayer.release();
|
||||
mediaPlayerFactory.release();
|
||||
}
|
||||
|
||||
public void render() {
|
||||
synchronized (bufferLock) {
|
||||
videoImage.setData(buffer);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void display(DirectMediaPlayer mediaPlayer, Memory[] nativeBuffers, BufferFormat bufferFormat) {
|
||||
synchronized (bufferLock) {
|
||||
buffer = nativeBuffers[0].getByteBuffer(0, WIDTH * HEIGHT * DEPTH);
|
||||
}
|
||||
}
|
||||
}
|
||||
92
ShootingStars/src/org/wyrez/shootingstars/game/Ground.java
Normal file
92
ShootingStars/src/org/wyrez/shootingstars/game/Ground.java
Normal file
@ -0,0 +1,92 @@
|
||||
/*
|
||||
* Copyright (C) 2013 Darth Affe <http://wyrez.org> and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.wyrez.shootingstars.game;
|
||||
|
||||
import com.jme3.light.AmbientLight;
|
||||
import com.jme3.material.Material;
|
||||
import com.jme3.math.ColorRGBA;
|
||||
import com.jme3.math.FastMath;
|
||||
import com.jme3.math.Vector3f;
|
||||
import com.jme3.scene.Geometry;
|
||||
import com.jme3.scene.Node;
|
||||
import org.wyrez.shootingstars.factories.Materials;
|
||||
import org.wyrez.shootingstars.mesh.HexPrism;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Darth Affe
|
||||
*/
|
||||
public class Ground extends Node {
|
||||
|
||||
public Ground() {
|
||||
this(1000f);
|
||||
}
|
||||
|
||||
public Ground(float radius) {
|
||||
this(radius, 0.1f);
|
||||
}
|
||||
|
||||
public Ground(float radius, float factor) {
|
||||
super("Ground");
|
||||
generateHexGrid(radius, factor);
|
||||
addLight();
|
||||
}
|
||||
|
||||
//TODO cleanup
|
||||
private void generateHexGrid(float borderWidth, float factor) {
|
||||
float size = borderWidth * factor;
|
||||
int maxIterations = (int) (borderWidth / size) - 2;
|
||||
|
||||
Material mat = Materials.HEX.create();
|
||||
Geometry geom = new Geometry("HexPrism" + 0 + " - " + 0,
|
||||
new HexPrism(new Vector3f(0f, 0f, 0f), size, 10f));
|
||||
geom.setMaterial(mat);
|
||||
this.attachChild(geom);
|
||||
|
||||
float xcc = 0f;
|
||||
float ycc = 0f;
|
||||
float centerDistance = size * FastMath.sqrt(3f);
|
||||
for (int iteration = 0; iteration < maxIterations; iteration++) {
|
||||
float xc = xcc;
|
||||
float yc = ycc - (float) iteration * centerDistance;
|
||||
float dx = (FastMath.sqrt(3f) * centerDistance / 2f);
|
||||
float dy = centerDistance / 2f;
|
||||
|
||||
for (int directions = 0; directions < 6; directions++) {
|
||||
for (int steps = 0; steps < iteration; steps++) {
|
||||
geom = new Geometry("HexPrism" + xc + " - " + yc,
|
||||
new HexPrism(new Vector3f(xc, 0f, yc), size,
|
||||
(iteration == maxIterations - 1) ? 160f : 10f));
|
||||
geom.setMaterial(mat);
|
||||
this.attachChild(geom);
|
||||
xc = xc + dx;
|
||||
yc = yc + dy;
|
||||
}
|
||||
float dxn = (FastMath.cos(FastMath.PI / 3f) * dx - FastMath.sin(FastMath.PI / 3f) * dy);
|
||||
float dyn = (FastMath.sin(FastMath.PI / 3f) * dx + FastMath.cos(FastMath.PI / 3f) * dy);
|
||||
dx = dxn;
|
||||
dy = dyn;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void addLight() {
|
||||
AmbientLight ambient = new AmbientLight();
|
||||
ambient.setColor(ColorRGBA.White);
|
||||
this.addLight(ambient);
|
||||
}
|
||||
}
|
||||
@ -16,9 +16,13 @@
|
||||
*/
|
||||
package org.wyrez.shootingstars.gui;
|
||||
|
||||
import com.jme3.font.BitmapFont;
|
||||
import com.jme3.input.event.MouseButtonEvent;
|
||||
import com.jme3.math.Vector2f;
|
||||
import org.wyrez.shootingstars.gui.controls.ButtonBase;
|
||||
import org.wyrez.shootingstars.gui.controls.PanelBase;
|
||||
import org.wyrez.shootingstars.gui.listener.GameListener;
|
||||
import tonegod.gui.controls.buttons.Button;
|
||||
import tonegod.gui.controls.windows.Panel;
|
||||
import tonegod.gui.core.Screen;
|
||||
|
||||
@ -27,9 +31,10 @@ import tonegod.gui.core.Screen;
|
||||
* @author Darth Affe
|
||||
*/
|
||||
public class GameGUI extends Panel {
|
||||
|
||||
|
||||
private GameListener listener;
|
||||
|
||||
private Panel pnlStart;
|
||||
|
||||
public GameGUI(Screen screen, GameListener listener) {
|
||||
super(screen, new Vector2f(0f, 0f), new Vector2f(1280f, 720f)); //create for full hd
|
||||
this.listener = listener;
|
||||
@ -38,18 +43,38 @@ public class GameGUI extends Panel {
|
||||
create();
|
||||
this.resize(screen.getWidth(), screen.getHeight(), Borders.SE);
|
||||
}
|
||||
|
||||
|
||||
private void create() {
|
||||
//Panel panel = new PanelBase(screen, new Vector2f(15, 15), new Vector2f(800, 500));
|
||||
//panel.setIgnoreMouse(true);
|
||||
|
||||
//this.addChild(panel);
|
||||
pnlStart = new PanelBase(screen, new Vector2f(15, 15), new Vector2f(800, 500));
|
||||
pnlStart.setIgnoreMouse(true);
|
||||
|
||||
Button btnStart = new ButtonBase(screen, new Vector2f(360f, 360f),
|
||||
new Vector2f(200f, 30f)) {
|
||||
@Override
|
||||
public void onButtonMouseLeftUp(MouseButtonEvent evt, boolean toggled) {
|
||||
listener.start();
|
||||
}
|
||||
};
|
||||
btnStart.setText("Start Game");
|
||||
btnStart.setTextAlign(BitmapFont.Align.Center);
|
||||
|
||||
pnlStart.addChild(btnStart);
|
||||
|
||||
this.addChild(pnlStart);
|
||||
}
|
||||
|
||||
|
||||
public void setStart() {
|
||||
pnlStart.hide();
|
||||
}
|
||||
|
||||
public void setWait() {
|
||||
pnlStart.show();
|
||||
}
|
||||
|
||||
public void attach() {
|
||||
screen.addElement(this);
|
||||
}
|
||||
|
||||
|
||||
public void detach() {
|
||||
screen.removeElement(this);
|
||||
}
|
||||
|
||||
@ -17,15 +17,11 @@
|
||||
package org.wyrez.shootingstars.gui;
|
||||
|
||||
import com.jme3.font.BitmapFont;
|
||||
import com.jme3.input.event.MouseButtonEvent;
|
||||
import com.jme3.math.ColorRGBA;
|
||||
import com.jme3.math.Vector2f;
|
||||
import org.wyrez.shootingstars.gui.controls.ButtonBase;
|
||||
import org.wyrez.shootingstars.gui.controls.IndicatorBase;
|
||||
import org.wyrez.shootingstars.gui.controls.PanelBase;
|
||||
import org.wyrez.shootingstars.gui.listener.LoadingListener;
|
||||
import org.wyrez.shootingstars.states.util.LoadingProgress;
|
||||
import tonegod.gui.controls.buttons.Button;
|
||||
import tonegod.gui.controls.extras.Indicator;
|
||||
import tonegod.gui.controls.text.Label;
|
||||
import tonegod.gui.controls.windows.Panel;
|
||||
@ -37,14 +33,11 @@ import tonegod.gui.core.Screen;
|
||||
*/
|
||||
public class LoadingGui extends Panel {
|
||||
|
||||
private LoadingListener listener;
|
||||
private Label lblStatus;
|
||||
private Indicator indProgress;
|
||||
private Button btnStart;
|
||||
|
||||
public LoadingGui(Screen screen, LoadingListener listener) {
|
||||
public LoadingGui(Screen screen) {
|
||||
super(screen, new Vector2f(0f, 0f), new Vector2f(1280f, 720f)); //create for full hd
|
||||
this.listener = listener;
|
||||
this.setIgnoreMouse(true);
|
||||
this.setIsVisible(false);
|
||||
create();
|
||||
@ -64,19 +57,8 @@ public class LoadingGui extends Panel {
|
||||
lblStatus = new Label(screen, new Vector2f(360f, 400f), new Vector2f(200f, 30f));
|
||||
lblStatus.setTextAlign(BitmapFont.Align.Center);
|
||||
|
||||
btnStart = new ButtonBase(screen, new Vector2f(360f, 360f),
|
||||
new Vector2f(200f, 30f)) {
|
||||
@Override
|
||||
public void onButtonMouseLeftUp(MouseButtonEvent evt, boolean toggled) {
|
||||
listener.startGame();
|
||||
}
|
||||
};
|
||||
btnStart.setText("Start Game");
|
||||
btnStart.setTextAlign(BitmapFont.Align.Center);
|
||||
|
||||
panel.addChild(indProgress);
|
||||
panel.addChild(lblStatus);
|
||||
panel.addChild(btnStart);
|
||||
|
||||
this.addChild(panel);
|
||||
}
|
||||
@ -93,16 +75,4 @@ public class LoadingGui extends Panel {
|
||||
lblStatus.setText(progress.getText());
|
||||
indProgress.setCurrentValue(progress.getValue());
|
||||
}
|
||||
|
||||
public void setLoadingStart() {
|
||||
btnStart.hide();
|
||||
indProgress.show();
|
||||
lblStatus.show();
|
||||
}
|
||||
|
||||
public void setLoadingDone() {
|
||||
btnStart.show();
|
||||
indProgress.hide();
|
||||
lblStatus.hide();
|
||||
}
|
||||
}
|
||||
|
||||
@ -22,4 +22,5 @@ package org.wyrez.shootingstars.gui.listener;
|
||||
*/
|
||||
public interface GameListener {
|
||||
|
||||
public void start();
|
||||
}
|
||||
|
||||
@ -1,26 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2013 Darth Affe <http://wyrez.org> and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.wyrez.shootingstars.gui.listener;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Darth Affe
|
||||
*/
|
||||
public interface LoadingListener {
|
||||
|
||||
public void startGame();
|
||||
}
|
||||
@ -16,9 +16,13 @@
|
||||
*/
|
||||
package org.wyrez.shootingstars.states;
|
||||
|
||||
import com.jme3.app.FlyCamAppState;
|
||||
import com.jme3.app.state.AbstractAppState;
|
||||
import com.jme3.app.state.AppStateManager;
|
||||
import com.jme3.renderer.RenderManager;
|
||||
import com.jme3.scene.Node;
|
||||
import org.wyrez.shootingstars.game.Cinema;
|
||||
import org.wyrez.shootingstars.game.Ground;
|
||||
import org.wyrez.shootingstars.gui.GameGUI;
|
||||
import org.wyrez.shootingstars.gui.listener.GameListener;
|
||||
import tonegod.gui.core.Screen;
|
||||
@ -32,6 +36,8 @@ public class GameState extends AbstractAppState implements GameListener {
|
||||
private StateManager stateManager;
|
||||
private Node rootNode;
|
||||
private GameGUI gui;
|
||||
private Cinema cinema;
|
||||
private Ground ground;
|
||||
|
||||
public GameState(Node rootNode, Screen screen, StateManager stateManager) {
|
||||
this.rootNode = rootNode;
|
||||
@ -39,17 +45,50 @@ public class GameState extends AbstractAppState implements GameListener {
|
||||
this.stateManager = stateManager;
|
||||
}
|
||||
|
||||
public void loadGround() {
|
||||
this.ground = new Ground();
|
||||
}
|
||||
|
||||
public void loadCinema() {
|
||||
this.cinema = new Cinema("Broken.mp4"); //TODO settings?
|
||||
cinema.move(0f, 160f, 0f);
|
||||
}
|
||||
|
||||
public void start() {
|
||||
gui.setStart();
|
||||
cinema.play();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stateAttached(AppStateManager stateManager) {
|
||||
stateManager.attach(new FlyCamAppState()); //TODO debug
|
||||
rootNode.attachChild(cinema);
|
||||
rootNode.attachChild(ground);
|
||||
gui.setWait();
|
||||
gui.attach();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stateDetached(AppStateManager stateManager) {
|
||||
stateManager.detach(new FlyCamAppState()); //TODO debug
|
||||
gui.detach();
|
||||
rootNode.detachChild(ground);
|
||||
rootNode.detachChild(cinema);
|
||||
cinema.cleanup();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(RenderManager rm) {
|
||||
cinema.render();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(float tpf) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void cleanup() {
|
||||
super.cleanup();
|
||||
cinema.cleanup();
|
||||
}
|
||||
}
|
||||
|
||||
@ -19,7 +19,6 @@ package org.wyrez.shootingstars.states;
|
||||
import com.jme3.app.state.AbstractAppState;
|
||||
import com.jme3.app.state.AppStateManager;
|
||||
import org.wyrez.shootingstars.gui.LoadingGui;
|
||||
import org.wyrez.shootingstars.gui.listener.LoadingListener;
|
||||
import org.wyrez.shootingstars.states.util.LoadingProgress;
|
||||
import tonegod.gui.core.Screen;
|
||||
|
||||
@ -27,7 +26,7 @@ import tonegod.gui.core.Screen;
|
||||
*
|
||||
* @author Darth Affe
|
||||
*/
|
||||
public class LoadingState extends AbstractAppState implements LoadingListener {
|
||||
public class LoadingState extends AbstractAppState {
|
||||
|
||||
private StateManager stateManager;
|
||||
private LoadingGui gui;
|
||||
@ -35,7 +34,7 @@ public class LoadingState extends AbstractAppState implements LoadingListener {
|
||||
|
||||
public LoadingState(Screen screen, StateManager stateManager) {
|
||||
this.stateManager = stateManager;
|
||||
this.gui = new LoadingGui(screen, this);
|
||||
this.gui = new LoadingGui(screen);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -53,7 +52,6 @@ public class LoadingState extends AbstractAppState implements LoadingListener {
|
||||
public void update(float tpf) {
|
||||
switch (currentProgress) {
|
||||
case START:
|
||||
gui.setLoadingStart();
|
||||
currentProgress = LoadingProgress.ANALYSE_LOW_BAND;
|
||||
break;
|
||||
case ANALYSE_LOW_BAND:
|
||||
@ -62,6 +60,10 @@ public class LoadingState extends AbstractAppState implements LoadingListener {
|
||||
break;
|
||||
case ANALYSE_HIGH_BAND:
|
||||
analyseHighBand();
|
||||
currentProgress = LoadingProgress.LOADING_CINEMA;
|
||||
break;
|
||||
case LOADING_CINEMA:
|
||||
loadingCinema();
|
||||
currentProgress = LoadingProgress.GENERATING_SCENE;
|
||||
break;
|
||||
case GENERATING_SCENE:
|
||||
@ -69,7 +71,7 @@ public class LoadingState extends AbstractAppState implements LoadingListener {
|
||||
currentProgress = LoadingProgress.DONE;
|
||||
break;
|
||||
case DONE:
|
||||
gui.setLoadingDone();
|
||||
done();
|
||||
break;
|
||||
}
|
||||
gui.updateProgress(currentProgress);
|
||||
@ -77,29 +79,23 @@ public class LoadingState extends AbstractAppState implements LoadingListener {
|
||||
|
||||
private void analyseLowBand() {
|
||||
//TODO fill
|
||||
try {
|
||||
Thread.sleep(1000);
|
||||
} catch (Exception ex) {
|
||||
}
|
||||
}
|
||||
|
||||
private void analyseHighBand() {
|
||||
//TODO fill
|
||||
try {
|
||||
Thread.sleep(1000);
|
||||
} catch (Exception ex) {
|
||||
}
|
||||
}
|
||||
|
||||
private void loadingCinema() {
|
||||
GameState gs = stateManager.getState(State.GAME);
|
||||
gs.loadCinema();
|
||||
}
|
||||
|
||||
private void generateScene() {
|
||||
//TODO fill
|
||||
try {
|
||||
Thread.sleep(1000);
|
||||
} catch (Exception ex) {
|
||||
}
|
||||
GameState gs = stateManager.getState(State.GAME);
|
||||
gs.loadGround();
|
||||
}
|
||||
|
||||
public void startGame() {
|
||||
public void done() {
|
||||
stateManager.setState(State.GAME);
|
||||
}
|
||||
}
|
||||
|
||||
@ -40,11 +40,7 @@ public class StateManager {
|
||||
appStateManager.attach(getState(State.getState()));
|
||||
}
|
||||
|
||||
public <T extends AppState> T getTypedState(State state) {
|
||||
return (T) getState(state);
|
||||
}
|
||||
|
||||
public AppState getState(State state) {
|
||||
public <T extends AppState> T getState(State state) {
|
||||
Class clazz = state.getClazz();
|
||||
if (clazz == null) {
|
||||
return null;
|
||||
@ -52,6 +48,6 @@ public class StateManager {
|
||||
if (!container.isTypeRegistered(clazz)) {
|
||||
container.registerType(clazz, true);
|
||||
}
|
||||
return (AppState) container.resolve(clazz);
|
||||
return (T) container.resolve(clazz);
|
||||
}
|
||||
}
|
||||
|
||||
@ -23,8 +23,8 @@ package org.wyrez.shootingstars.states.util;
|
||||
public enum LoadingProgress {
|
||||
|
||||
START("Loading...", 0), ANALYSE_LOW_BAND("Analyse Low-Band...", 0),
|
||||
ANALYSE_HIGH_BAND("Analyse High-Band...", 1), GENERATING_SCENE("Generating Scene...", 2),
|
||||
DONE("Done!", 3);
|
||||
ANALYSE_HIGH_BAND("Analyse High-Band...", 1), LOADING_CINEMA("Loading Cinema", 2),
|
||||
GENERATING_SCENE("Generating Scene...", 3), DONE("Done!", 3);
|
||||
private String text;
|
||||
private float value;
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user