Expand GUI, add Crosshair AlphaMap, add Crosshair Overlay Image, add Crosshair Overheat Fog
This commit is contained in:
parent
e5d435985c
commit
4d7438c7d6
BIN
ShootingStars/assets/Textures/Crosshair_AlphaMap.png
Normal file
BIN
ShootingStars/assets/Textures/Crosshair_AlphaMap.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 3.3 KiB |
BIN
ShootingStars/assets/Textures/Crosshair_Overheat_Fog.png
Normal file
BIN
ShootingStars/assets/Textures/Crosshair_Overheat_Fog.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 57 KiB |
BIN
ShootingStars/assets/Textures/Crosshair_OverlayImage.png
Normal file
BIN
ShootingStars/assets/Textures/Crosshair_OverlayImage.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 365 B |
@ -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 float maxTimeToOverheat = 3f;
|
||||
private static final float maxCoolDown = 3f;
|
||||
/**/
|
||||
private InputManager inputManager;
|
||||
private GameGUI gui;
|
||||
private float timeToOverheat = maxTimeToOverheat;
|
||||
private float coolDown = 0f;
|
||||
private boolean isShooting = false;
|
||||
|
||||
public PlayerShootControl(InputManager inputmanager, GameGUI gui) {
|
||||
this.inputManager = inputmanager;
|
||||
this.gui = gui;
|
||||
gui.setMaxTimeToOverheat(maxTimeToOverheat);
|
||||
initMappings();
|
||||
}
|
||||
|
||||
@ -51,10 +54,17 @@ public class PlayerShootControl extends BaseControl implements ActionListener {
|
||||
protected void controlUpdate(float tpf) {
|
||||
if (spatial.getUserData(UserDataKeys.RUNNING)) {
|
||||
if (isShooting) {
|
||||
timeToOverheat -= tpf;
|
||||
if (timeToOverheat <= 0) {
|
||||
setShooting(false);
|
||||
if (coolDown <= 0f) {
|
||||
timeToOverheat -= tpf;
|
||||
gui.updateOverhead(timeToOverheat);
|
||||
if (timeToOverheat <= 0) {
|
||||
setShooting(false);
|
||||
coolDown = maxCoolDown;
|
||||
}
|
||||
} else {
|
||||
coolDown -= tpf;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -19,14 +19,20 @@ package org.wyrez.shootingstars.gui;
|
||||
import com.jme3.asset.AssetManager;
|
||||
import com.jme3.font.BitmapFont;
|
||||
import com.jme3.input.event.MouseButtonEvent;
|
||||
import com.jme3.material.Material;
|
||||
import com.jme3.math.ColorRGBA;
|
||||
import com.jme3.math.Vector2f;
|
||||
import com.jme3.scene.Spatial;
|
||||
import com.jme3.ui.Picture;
|
||||
import org.wyrez.shootingstars.gui.controls.ButtonBase;
|
||||
import org.wyrez.shootingstars.gui.controls.IndicatorBase;
|
||||
import org.wyrez.shootingstars.gui.listener.GameListener;
|
||||
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.core.Screen;
|
||||
import tonegod.gui.effects.Effect;
|
||||
|
||||
/**
|
||||
*
|
||||
@ -39,6 +45,7 @@ public class GameGUI extends Panel {
|
||||
private Button btnResume;
|
||||
private Button btnMenu;
|
||||
private Picture picCrosshair;
|
||||
private Indicator indOverheat;
|
||||
private AssetManager assetManager;
|
||||
|
||||
public GameGUI(Screen screen, GameListener listener, AssetManager assetManager) {
|
||||
@ -58,6 +65,9 @@ public class GameGUI extends Panel {
|
||||
float startPointCrosshairx = 441f;
|
||||
float startPointCrosshairy = 560f;
|
||||
|
||||
float startPointOverheatx = 505f;
|
||||
float startPointOverheaty = 270f;
|
||||
|
||||
float startPointYMenu = 200f;
|
||||
|
||||
btnStart = new ButtonBase(screen, new Vector2f(startPointx, startPointy),
|
||||
@ -94,22 +104,29 @@ public class GameGUI extends Panel {
|
||||
picCrosshair.setWidth(400f);
|
||||
picCrosshair.setHeight(400f);
|
||||
picCrosshair.setImage(assetManager, "Textures/Crosshair.png", true);
|
||||
|
||||
|
||||
|
||||
|
||||
Panel plnCrosshair = new Panel(screen, new Vector2f(startPointCrosshairx, startPointCrosshairy), new Vector2f(0f, 0f));
|
||||
plnCrosshair.setIsVisible(false);
|
||||
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(btnResume);
|
||||
this.addChild(btnMenu);
|
||||
this.addChild(btnMenu);
|
||||
this.addChild(indOverheat);
|
||||
this.addChild(plnCrosshair);
|
||||
|
||||
btnResume.hide();
|
||||
btnMenu.hide();
|
||||
picCrosshair.setCullHint(CullHint.Always);
|
||||
indOverheat.hide();
|
||||
}
|
||||
|
||||
public void setStart() {
|
||||
@ -117,6 +134,7 @@ public class GameGUI extends Panel {
|
||||
btnResume.hide();
|
||||
btnMenu.hide();
|
||||
picCrosshair.setCullHint(CullHint.Inherit);
|
||||
indOverheat.show();
|
||||
}
|
||||
|
||||
public void setWait() {
|
||||
@ -124,6 +142,7 @@ public class GameGUI extends Panel {
|
||||
btnResume.hide();
|
||||
btnMenu.hide();
|
||||
picCrosshair.setCullHint(CullHint.Always);
|
||||
indOverheat.hide();
|
||||
}
|
||||
|
||||
public void showMenu() {
|
||||
@ -131,6 +150,7 @@ public class GameGUI extends Panel {
|
||||
btnResume.show();
|
||||
btnMenu.show();
|
||||
picCrosshair.setCullHint(CullHint.Always);
|
||||
indOverheat.hide();
|
||||
}
|
||||
|
||||
public void resumeGame() {
|
||||
@ -138,6 +158,7 @@ public class GameGUI extends Panel {
|
||||
btnResume.hide();
|
||||
btnMenu.hide();
|
||||
picCrosshair.setCullHint(CullHint.Inherit);
|
||||
indOverheat.show();
|
||||
}
|
||||
|
||||
public void attach() {
|
||||
@ -149,6 +170,10 @@ public class GameGUI extends Panel {
|
||||
}
|
||||
|
||||
public void updateOverhead(float percent) {
|
||||
|
||||
indOverheat.setCurrentValue(percent);
|
||||
}
|
||||
|
||||
public void setMaxTimeToOverheat(float maxTimeToOverheat) {
|
||||
indOverheat.setMaxValue(maxTimeToOverheat);
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user