Expand GUI, add Crosshair AlphaMap, add Crosshair Overlay Image, add Crosshair Overheat Fog

This commit is contained in:
TheCodeBoat 2013-06-14 14:22:56 +02:00
parent e5d435985c
commit 4d7438c7d6
5 changed files with 45 additions and 10 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 57 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 365 B

View File

@ -35,15 +35,18 @@ public class PlayerShootControl extends BaseControl implements ActionListener {
private static final String MAPPING_PLAYER_MOUSE_LEFT_CLICK = "PLAYER_Mouse_Left_Click"; private static final String MAPPING_PLAYER_MOUSE_LEFT_CLICK = "PLAYER_Mouse_Left_Click";
private static final float maxTimeToOverheat = 3f; private static final float maxTimeToOverheat = 3f;
private static final float maxCoolDown = 3f;
/**/ /**/
private InputManager inputManager; private InputManager inputManager;
private GameGUI gui; private GameGUI gui;
private float timeToOverheat = maxTimeToOverheat; private float timeToOverheat = maxTimeToOverheat;
private float coolDown = 0f;
private boolean isShooting = false; private boolean isShooting = false;
public PlayerShootControl(InputManager inputmanager, GameGUI gui) { public PlayerShootControl(InputManager inputmanager, GameGUI gui) {
this.inputManager = inputmanager; this.inputManager = inputmanager;
this.gui = gui; this.gui = gui;
gui.setMaxTimeToOverheat(maxTimeToOverheat);
initMappings(); initMappings();
} }
@ -51,10 +54,17 @@ public class PlayerShootControl extends BaseControl implements ActionListener {
protected void controlUpdate(float tpf) { protected void controlUpdate(float tpf) {
if (spatial.getUserData(UserDataKeys.RUNNING)) { if (spatial.getUserData(UserDataKeys.RUNNING)) {
if (isShooting) { if (isShooting) {
if (coolDown <= 0f) {
timeToOverheat -= tpf; timeToOverheat -= tpf;
gui.updateOverhead(timeToOverheat);
if (timeToOverheat <= 0) { if (timeToOverheat <= 0) {
setShooting(false); setShooting(false);
coolDown = maxCoolDown;
} }
} else {
coolDown -= tpf;
}
} }
} }
} }

View File

@ -19,14 +19,20 @@ package org.wyrez.shootingstars.gui;
import com.jme3.asset.AssetManager; import com.jme3.asset.AssetManager;
import com.jme3.font.BitmapFont; import com.jme3.font.BitmapFont;
import com.jme3.input.event.MouseButtonEvent; import com.jme3.input.event.MouseButtonEvent;
import com.jme3.material.Material;
import com.jme3.math.ColorRGBA;
import com.jme3.math.Vector2f; import com.jme3.math.Vector2f;
import com.jme3.scene.Spatial; import com.jme3.scene.Spatial;
import com.jme3.ui.Picture; import com.jme3.ui.Picture;
import org.wyrez.shootingstars.gui.controls.ButtonBase; import org.wyrez.shootingstars.gui.controls.ButtonBase;
import org.wyrez.shootingstars.gui.controls.IndicatorBase;
import org.wyrez.shootingstars.gui.listener.GameListener; import org.wyrez.shootingstars.gui.listener.GameListener;
import tonegod.gui.controls.buttons.Button; import tonegod.gui.controls.buttons.Button;
import tonegod.gui.controls.extras.Indicator;
import tonegod.gui.controls.text.Label;
import tonegod.gui.controls.windows.Panel; import tonegod.gui.controls.windows.Panel;
import tonegod.gui.core.Screen; import tonegod.gui.core.Screen;
import tonegod.gui.effects.Effect;
/** /**
* *
@ -39,6 +45,7 @@ public class GameGUI extends Panel {
private Button btnResume; private Button btnResume;
private Button btnMenu; private Button btnMenu;
private Picture picCrosshair; private Picture picCrosshair;
private Indicator indOverheat;
private AssetManager assetManager; private AssetManager assetManager;
public GameGUI(Screen screen, GameListener listener, AssetManager assetManager) { public GameGUI(Screen screen, GameListener listener, AssetManager assetManager) {
@ -58,6 +65,9 @@ public class GameGUI extends Panel {
float startPointCrosshairx = 441f; float startPointCrosshairx = 441f;
float startPointCrosshairy = 560f; float startPointCrosshairy = 560f;
float startPointOverheatx = 505f;
float startPointOverheaty = 270f;
float startPointYMenu = 200f; float startPointYMenu = 200f;
btnStart = new ButtonBase(screen, new Vector2f(startPointx, startPointy), btnStart = new ButtonBase(screen, new Vector2f(startPointx, startPointy),
@ -95,21 +105,28 @@ public class GameGUI extends Panel {
picCrosshair.setHeight(400f); picCrosshair.setHeight(400f);
picCrosshair.setImage(assetManager, "Textures/Crosshair.png", true); picCrosshair.setImage(assetManager, "Textures/Crosshair.png", true);
Panel plnCrosshair = new Panel(screen, new Vector2f(startPointCrosshairx, startPointCrosshairy), new Vector2f(0f, 0f)); Panel plnCrosshair = new Panel(screen, new Vector2f(startPointCrosshairx, startPointCrosshairy), new Vector2f(0f, 0f));
plnCrosshair.setIsVisible(false); plnCrosshair.setIsVisible(false);
plnCrosshair.setIgnoreMouse(true); plnCrosshair.setIgnoreMouse(true);
plnCrosshair.attachChild(picCrosshair); plnCrosshair.attachChild(picCrosshair);
indOverheat = new IndicatorBase(screen, new Vector2f(startPointOverheatx, startPointOverheaty),
new Vector2f(275f, 180f), Indicator.Orientation.VERTICAL);
indOverheat.setIndicatorColor(new ColorRGBA(0f, 0f, 1f, 0.5f));
indOverheat.setAlphaMap("Textures/Crosshair_AlphaMap.png");
indOverheat.setOverlayImage("Textures/Crosshair_OverlayImage.png");
//indOverheat.setBaseImage("Textures/Crosshair_Overheat_Fog.png");
this.addChild(btnStart); this.addChild(btnStart);
this.addChild(btnResume); this.addChild(btnResume);
this.addChild(btnMenu); this.addChild(btnMenu);
this.addChild(indOverheat);
this.addChild(plnCrosshair); this.addChild(plnCrosshair);
btnResume.hide(); btnResume.hide();
btnMenu.hide(); btnMenu.hide();
picCrosshair.setCullHint(CullHint.Always); picCrosshair.setCullHint(CullHint.Always);
indOverheat.hide();
} }
public void setStart() { public void setStart() {
@ -117,6 +134,7 @@ public class GameGUI extends Panel {
btnResume.hide(); btnResume.hide();
btnMenu.hide(); btnMenu.hide();
picCrosshair.setCullHint(CullHint.Inherit); picCrosshair.setCullHint(CullHint.Inherit);
indOverheat.show();
} }
public void setWait() { public void setWait() {
@ -124,6 +142,7 @@ public class GameGUI extends Panel {
btnResume.hide(); btnResume.hide();
btnMenu.hide(); btnMenu.hide();
picCrosshair.setCullHint(CullHint.Always); picCrosshair.setCullHint(CullHint.Always);
indOverheat.hide();
} }
public void showMenu() { public void showMenu() {
@ -131,6 +150,7 @@ public class GameGUI extends Panel {
btnResume.show(); btnResume.show();
btnMenu.show(); btnMenu.show();
picCrosshair.setCullHint(CullHint.Always); picCrosshair.setCullHint(CullHint.Always);
indOverheat.hide();
} }
public void resumeGame() { public void resumeGame() {
@ -138,6 +158,7 @@ public class GameGUI extends Panel {
btnResume.hide(); btnResume.hide();
btnMenu.hide(); btnMenu.hide();
picCrosshair.setCullHint(CullHint.Inherit); picCrosshair.setCullHint(CullHint.Inherit);
indOverheat.show();
} }
public void attach() { public void attach() {
@ -149,6 +170,10 @@ public class GameGUI extends Panel {
} }
public void updateOverhead(float percent) { public void updateOverhead(float percent) {
indOverheat.setCurrentValue(percent);
}
public void setMaxTimeToOverheat(float maxTimeToOverheat) {
indOverheat.setMaxValue(maxTimeToOverheat);
} }
} }