Add game source, converter pipeline, and web port
This commit is contained in:
@@ -0,0 +1,522 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*
|
||||
* Could not load the following classes:
|
||||
* com.jme3.animation.AnimChannel
|
||||
* com.jme3.animation.AnimControl
|
||||
* com.jme3.animation.AnimEventListener
|
||||
* com.jme3.animation.LoopMode
|
||||
* com.jme3.app.Application
|
||||
* com.jme3.app.SimpleApplication
|
||||
* com.jme3.app.state.AppState
|
||||
* com.jme3.audio.AudioNode
|
||||
* com.jme3.bullet.BulletAppState
|
||||
* com.jme3.bullet.collision.PhysicsCollisionEvent
|
||||
* com.jme3.bullet.collision.PhysicsCollisionListener
|
||||
* com.jme3.bullet.control.RigidBodyControl
|
||||
* com.jme3.collision.Collidable
|
||||
* com.jme3.collision.CollisionResults
|
||||
* com.jme3.input.controls.ActionListener
|
||||
* com.jme3.input.controls.AnalogListener
|
||||
* com.jme3.input.controls.InputListener
|
||||
* com.jme3.input.controls.KeyTrigger
|
||||
* com.jme3.input.controls.MouseButtonTrigger
|
||||
* com.jme3.input.controls.Trigger
|
||||
* com.jme3.light.AmbientLight
|
||||
* com.jme3.light.Light
|
||||
* com.jme3.math.ColorRGBA
|
||||
* com.jme3.math.Ray
|
||||
* com.jme3.math.Vector2f
|
||||
* com.jme3.math.Vector3f
|
||||
* com.jme3.post.Filter
|
||||
* com.jme3.post.FilterPostProcessor
|
||||
* com.jme3.post.SceneProcessor
|
||||
* com.jme3.post.filters.CartoonEdgeFilter
|
||||
* com.jme3.renderer.Caps
|
||||
* com.jme3.renderer.queue.RenderQueue$ShadowMode
|
||||
* com.jme3.scene.Spatial
|
||||
* com.jme3.scene.control.Control
|
||||
* com.jme3.shadow.DirectionalLightShadowFilter
|
||||
* com.jme3.shadow.DirectionalLightShadowRenderer
|
||||
* tonegod.gui.controls.extras.Indicator
|
||||
* tonegod.gui.controls.extras.Indicator$Orientation
|
||||
* tonegod.gui.controls.text.Label
|
||||
* tonegod.gui.core.Element
|
||||
* tonegod.gui.core.Screen
|
||||
* tonegod.gui.effects.Effect
|
||||
* tonegod.gui.effects.Effect$EffectEvent
|
||||
* tonegod.gui.effects.Effect$EffectType
|
||||
*/
|
||||
package jme3.hello;
|
||||
|
||||
import com.jme3.animation.AnimChannel;
|
||||
import com.jme3.animation.AnimControl;
|
||||
import com.jme3.animation.AnimEventListener;
|
||||
import com.jme3.animation.LoopMode;
|
||||
import com.jme3.app.Application;
|
||||
import com.jme3.app.SimpleApplication;
|
||||
import com.jme3.app.state.AppState;
|
||||
import com.jme3.audio.AudioNode;
|
||||
import com.jme3.bullet.BulletAppState;
|
||||
import com.jme3.bullet.collision.PhysicsCollisionEvent;
|
||||
import com.jme3.bullet.collision.PhysicsCollisionListener;
|
||||
import com.jme3.bullet.control.RigidBodyControl;
|
||||
import com.jme3.collision.Collidable;
|
||||
import com.jme3.collision.CollisionResults;
|
||||
import com.jme3.input.controls.ActionListener;
|
||||
import com.jme3.input.controls.AnalogListener;
|
||||
import com.jme3.input.controls.InputListener;
|
||||
import com.jme3.input.controls.KeyTrigger;
|
||||
import com.jme3.input.controls.MouseButtonTrigger;
|
||||
import com.jme3.input.controls.Trigger;
|
||||
import com.jme3.light.AmbientLight;
|
||||
import com.jme3.light.Light;
|
||||
import com.jme3.math.ColorRGBA;
|
||||
import com.jme3.math.Ray;
|
||||
import com.jme3.math.Vector2f;
|
||||
import com.jme3.math.Vector3f;
|
||||
import com.jme3.post.Filter;
|
||||
import com.jme3.post.FilterPostProcessor;
|
||||
import com.jme3.post.SceneProcessor;
|
||||
import com.jme3.post.filters.CartoonEdgeFilter;
|
||||
import com.jme3.renderer.Caps;
|
||||
import com.jme3.renderer.queue.RenderQueue;
|
||||
import com.jme3.scene.Spatial;
|
||||
import com.jme3.scene.control.Control;
|
||||
import com.jme3.shadow.DirectionalLightShadowFilter;
|
||||
import com.jme3.shadow.DirectionalLightShadowRenderer;
|
||||
import java.util.Random;
|
||||
import mygame.Exchange;
|
||||
import mygame.Player;
|
||||
import mygame.Staff;
|
||||
import mygame.Sword;
|
||||
import mygame.WalkingEnemy;
|
||||
import tonegod.gui.controls.extras.Indicator;
|
||||
import tonegod.gui.controls.text.Label;
|
||||
import tonegod.gui.core.Element;
|
||||
import tonegod.gui.core.Screen;
|
||||
import tonegod.gui.effects.Effect;
|
||||
import wpq.tests.PlayerCam;
|
||||
|
||||
public class TestCameraNode
|
||||
extends SimpleApplication
|
||||
implements AnalogListener,
|
||||
ActionListener,
|
||||
AnimEventListener,
|
||||
PhysicsCollisionListener {
|
||||
private Player player;
|
||||
Vector3f direction = new Vector3f();
|
||||
private FilterPostProcessor fpp;
|
||||
private BulletAppState bulletAppState;
|
||||
Screen screen;
|
||||
Indicator ind1;
|
||||
Label spiderCounter;
|
||||
Label label;
|
||||
Indicator waveCounter;
|
||||
Indicator cooldownLeft;
|
||||
Indicator cooldownRight;
|
||||
Indicator skill2;
|
||||
Label gameover;
|
||||
int change = 0;
|
||||
private int winCount = 0;
|
||||
PlayerCam playerCam;
|
||||
private float spawnTimer;
|
||||
private float timer;
|
||||
boolean left = false;
|
||||
boolean right = false;
|
||||
boolean down = false;
|
||||
boolean up = false;
|
||||
Vector3f walkDirection = new Vector3f(Vector3f.ZERO);
|
||||
private DirectionalLightShadowRenderer dlsr;
|
||||
private DirectionalLightShadowFilter dlsf;
|
||||
private static int SPAWN_TIME = 10;
|
||||
private int spawns = 1;
|
||||
private boolean gameover_flag = false;
|
||||
public Exchange exchange;
|
||||
|
||||
public static void main(String[] args) {
|
||||
TestCameraNode app = new TestCameraNode();
|
||||
app.setDisplayFps(false);
|
||||
app.setDisplayStatView(false);
|
||||
app.start();
|
||||
}
|
||||
|
||||
public void simpleInitApp() {
|
||||
this.bulletAppState = new BulletAppState();
|
||||
this.stateManager.attach((AppState)this.bulletAppState);
|
||||
this.exchange = new Exchange();
|
||||
Exchange.setRootNode(this.rootNode);
|
||||
Exchange.setBulletAppState(this.bulletAppState);
|
||||
Exchange.setAssetManager(this.assetManager);
|
||||
Exchange.setViewPort(this.viewPort);
|
||||
Exchange.setApp(this);
|
||||
this.spawnTimer = 0.0f;
|
||||
this.timer = 0.0f;
|
||||
this.setupPlayer();
|
||||
this.setupGround();
|
||||
this.setupWalls();
|
||||
this.setupCam();
|
||||
this.setupLight();
|
||||
this.registerInput();
|
||||
this.setupFilters();
|
||||
this.setupGUI();
|
||||
}
|
||||
|
||||
private void setupPlayer() {
|
||||
this.player = new Player("Player");
|
||||
this.player.setHat(this.assetManager.loadModel("Models/helmet/helmet.j3o"));
|
||||
Staff staff = new Staff("Staff", this.assetManager, this.exchange);
|
||||
staff.setModel(this.assetManager.loadModel("Models/staff/staff.mesh.j3o"));
|
||||
this.player.setLeftHand(staff);
|
||||
Sword sword = new Sword("Sword", this.assetManager, this.exchange);
|
||||
sword.setModel(this.assetManager.loadModel("Models/sword/sword.mesh.j3o"));
|
||||
this.bulletAppState.getPhysicsSpace().add((Object)sword);
|
||||
this.player.setRightHand(sword);
|
||||
this.player.setModel(this.assetManager.loadModel("Models/blob/Blob.mesh.j3o"));
|
||||
this.bulletAppState.getPhysicsSpace().add((Object)this.player.playerControl);
|
||||
this.rootNode.attachChild((Spatial)this.player);
|
||||
this.bulletAppState.getPhysicsSpace().addCollisionListener((PhysicsCollisionListener)this);
|
||||
}
|
||||
|
||||
private void setupSpider(Vector3f spawn) {
|
||||
WalkingEnemy walkingSpider = new WalkingEnemy("Spider", this.assetManager);
|
||||
walkingSpider.setLocalTranslation(spawn);
|
||||
walkingSpider.setModel(this.assetManager.loadModel("Models/spider/spider.mesh.j3o"));
|
||||
walkingSpider.modelAnimChannel.setAnim("walk");
|
||||
walkingSpider.setHealth(100.0f);
|
||||
walkingSpider.modelAnimChannel.setLoopMode(LoopMode.Loop);
|
||||
Exchange.enemies.add(walkingSpider);
|
||||
AudioNode walksound = new AudioNode(this.assetManager, "Sounds/Effects/spiderwalking.ogg", false);
|
||||
walksound.setName("walkingSound");
|
||||
walksound.setLooping(true);
|
||||
walksound.setVolume(2.0f);
|
||||
walkingSpider.attachChild((Spatial)walksound);
|
||||
walksound.play();
|
||||
this.bulletAppState.getPhysicsSpace().add((Object)walkingSpider.ghost);
|
||||
this.bulletAppState.getPhysicsSpace().add((Object)walkingSpider.walkingEnemyControl);
|
||||
this.rootNode.attachChild((Spatial)walkingSpider);
|
||||
}
|
||||
|
||||
private void spawnSpider() {
|
||||
Random r = new Random();
|
||||
int spawnx = r.nextInt(81) - 40;
|
||||
int spawnz = r.nextInt(81) - 40;
|
||||
Vector3f spawnpoint = new Vector3f((float)spawnx, 0.0f, (float)spawnz);
|
||||
AudioNode spawnsound = new AudioNode(this.assetManager, "Sounds/Effects/spawn.ogg", false);
|
||||
spawnsound.setLooping(false);
|
||||
spawnsound.setPositional(true);
|
||||
spawnsound.setLocalTranslation(spawnpoint);
|
||||
spawnsound.setVolume(5.0f);
|
||||
this.rootNode.attachChild((Spatial)spawnsound);
|
||||
spawnsound.play();
|
||||
this.setupSpider(spawnpoint);
|
||||
}
|
||||
|
||||
private void setupGround() {
|
||||
int rotation_flag = 0;
|
||||
for (int x = -50; x < 50; x += 10) {
|
||||
for (int z = -50; z < 50; z += 10) {
|
||||
Spatial ground;
|
||||
if (rotation_flag == 5) {
|
||||
rotation_flag = 0;
|
||||
ground = this.assetManager.loadModel("Models/tile2/tile.mesh.j3o");
|
||||
} else {
|
||||
ground = this.assetManager.loadModel("Models/tile1/tile.mesh.j3o");
|
||||
++rotation_flag;
|
||||
}
|
||||
ground.scale(5.0f);
|
||||
ground.setLocalTranslation((float)x, -1.0f, (float)z);
|
||||
RigidBodyControl ground_solid = new RigidBodyControl(0.0f);
|
||||
ground.addControl((Control)ground_solid);
|
||||
this.bulletAppState.getPhysicsSpace().add((Object)ground_solid);
|
||||
ground.setShadowMode(RenderQueue.ShadowMode.Receive);
|
||||
this.rootNode.attachChild(ground);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void setupWalls() {
|
||||
float x;
|
||||
for (x = -60.0f; x < 60.0f; x += 10.0f) {
|
||||
this.createWall(x, 50.0f);
|
||||
this.createWall(x, -50.0f);
|
||||
}
|
||||
for (x = -60.0f; x < 60.0f; x += 10.0f) {
|
||||
this.createWall(50.0f, x);
|
||||
this.createWall(-50.0f, x);
|
||||
}
|
||||
}
|
||||
|
||||
private void createWall(float x, float z) {
|
||||
Spatial wall = this.assetManager.loadModel("Models/wall1/wall1.mesh.j3o");
|
||||
wall.scale(5.0f);
|
||||
wall.setLocalTranslation(x, 0.0f, z);
|
||||
RigidBodyControl wall_solid = new RigidBodyControl(0.0f);
|
||||
wall.addControl((Control)wall_solid);
|
||||
this.bulletAppState.getPhysicsSpace().add((Object)wall);
|
||||
wall.setShadowMode(RenderQueue.ShadowMode.CastAndReceive);
|
||||
this.rootNode.attachChild(wall);
|
||||
}
|
||||
|
||||
private void setupCam() {
|
||||
this.playerCam = new PlayerCam(this.player, "CamNode", this.cam);
|
||||
this.playerCam.setupCamera();
|
||||
this.flyCam.setEnabled(false);
|
||||
}
|
||||
|
||||
private void setupLight() {
|
||||
AmbientLight al = new AmbientLight();
|
||||
al.setColor(new ColorRGBA(0.6f, 0.6f, 0.9f, 1.0f));
|
||||
this.rootNode.addLight((Light)al);
|
||||
}
|
||||
|
||||
public void registerInput() {
|
||||
Trigger[] triggerArray = new Trigger[2];
|
||||
triggerArray[0] = new KeyTrigger(200);
|
||||
triggerArray[1] = new KeyTrigger(17);
|
||||
this.inputManager.addMapping("moveForward", triggerArray);
|
||||
Trigger[] triggerArray2 = new Trigger[2];
|
||||
triggerArray2[0] = new KeyTrigger(208);
|
||||
triggerArray2[1] = new KeyTrigger(31);
|
||||
this.inputManager.addMapping("moveBackward", triggerArray2);
|
||||
Trigger[] triggerArray3 = new Trigger[2];
|
||||
triggerArray3[0] = new KeyTrigger(205);
|
||||
triggerArray3[1] = new KeyTrigger(32);
|
||||
this.inputManager.addMapping("moveRight", triggerArray3);
|
||||
Trigger[] triggerArray4 = new Trigger[2];
|
||||
triggerArray4[0] = new KeyTrigger(203);
|
||||
triggerArray4[1] = new KeyTrigger(30);
|
||||
this.inputManager.addMapping("moveLeft", triggerArray4);
|
||||
this.inputManager.addMapping("rightHand", new Trigger[]{new MouseButtonTrigger(1)});
|
||||
Trigger[] triggerArray5 = new Trigger[1];
|
||||
triggerArray5[0] = new KeyTrigger(18);
|
||||
this.inputManager.addMapping("skill2", triggerArray5);
|
||||
this.inputManager.addMapping("leftHand", new Trigger[]{new MouseButtonTrigger(0)});
|
||||
this.inputManager.addMapping("die", new Trigger[]{new MouseButtonTrigger(2)});
|
||||
this.inputManager.addMapping("jump", new Trigger[]{new KeyTrigger(57)});
|
||||
this.inputManager.addListener((InputListener)this, new String[]{"moveForward", "moveBackward", "moveRight", "moveLeft", "rightHand", "leftHand", "die", "jump", "skill2"});
|
||||
}
|
||||
|
||||
public void setupFilters() {
|
||||
if (this.renderer.getCaps().contains(Caps.GLSL100)) {
|
||||
this.fpp = new FilterPostProcessor(this.assetManager);
|
||||
CartoonEdgeFilter toon = new CartoonEdgeFilter();
|
||||
toon.setEdgeColor(ColorRGBA.Black);
|
||||
this.fpp.addFilter((Filter)toon);
|
||||
this.viewPort.addProcessor((SceneProcessor)this.fpp);
|
||||
}
|
||||
}
|
||||
|
||||
public void onAnalog(String name, float value, float tpf) {
|
||||
}
|
||||
|
||||
public void onAction(String name, boolean keyPressed, float tpf) {
|
||||
try {
|
||||
if (name.equals("rightHand") && !keyPressed) {
|
||||
this.player.rightHand.skill1();
|
||||
}
|
||||
if (name.equals("leftHand") && !keyPressed) {
|
||||
this.player.leftHand.skill1();
|
||||
}
|
||||
}
|
||||
catch (NullPointerException e) {
|
||||
// empty catch block
|
||||
}
|
||||
if (name.equals("skill2") && !keyPressed) {
|
||||
this.player.leftHand.skill2();
|
||||
}
|
||||
if (name.equals("die") && !keyPressed) {
|
||||
this.player.switchHands();
|
||||
}
|
||||
if (name.equals("jump")) {
|
||||
this.player.playerControl.jump();
|
||||
}
|
||||
if (name.equals("moveLeft")) {
|
||||
this.left = keyPressed;
|
||||
} else if (name.equals("moveRight")) {
|
||||
this.right = keyPressed;
|
||||
} else if (name.equals("moveForward")) {
|
||||
this.up = keyPressed;
|
||||
} else if (name.equals("moveBackward")) {
|
||||
this.down = keyPressed;
|
||||
}
|
||||
}
|
||||
|
||||
public void setupGUI() {
|
||||
this.screen = new Screen((Application)this, "tonegod/gui/style/def/style_map.xml");
|
||||
this.screen.initialize();
|
||||
this.guiNode.addControl((Control)this.screen);
|
||||
this.ind1 = new Indicator(this.screen, "Healthbar", new Vector2f(10.0f, 10.0f), Indicator.Orientation.HORIZONTAL){
|
||||
|
||||
public void onChange(float arg0, float arg1) {
|
||||
}
|
||||
};
|
||||
this.ind1.setMaxValue(100.0f);
|
||||
this.ind1.setCurrentValue(this.player.health);
|
||||
this.ind1.setIndicatorColor(ColorRGBA.Red);
|
||||
this.ind1.setDisplayPercentage();
|
||||
this.screen.addElement((Element)this.ind1);
|
||||
this.cooldownLeft = new Indicator(this.screen, "cooldownLeft", new Vector2f(10.0f, (float)(this.settings.getHeight() - 30)), Indicator.Orientation.HORIZONTAL){
|
||||
|
||||
public void onChange(float arg0, float arg1) {
|
||||
}
|
||||
};
|
||||
this.cooldownLeft.setMaxValue(100.0f);
|
||||
this.cooldownLeft.setCurrentValue(100.0f);
|
||||
this.cooldownLeft.setIndicatorColor(ColorRGBA.Blue);
|
||||
this.cooldownLeft.setText("Fireball");
|
||||
this.screen.addElement((Element)this.cooldownLeft);
|
||||
this.cooldownRight = new Indicator(this.screen, "cooldownRight", new Vector2f(10.0f, (float)(this.settings.getHeight() - 70)), Indicator.Orientation.HORIZONTAL){
|
||||
|
||||
public void onChange(float arg0, float arg1) {
|
||||
}
|
||||
};
|
||||
this.cooldownRight.setMaxValue(100.0f);
|
||||
this.cooldownRight.setCurrentValue(100.0f);
|
||||
this.cooldownRight.setIndicatorColor(ColorRGBA.Blue);
|
||||
this.cooldownRight.setText("Sword");
|
||||
this.screen.addElement((Element)this.cooldownRight);
|
||||
this.skill2 = new Indicator(this.screen, "skill2", new Vector2f(10.0f, (float)(this.settings.getHeight() - 50)), Indicator.Orientation.HORIZONTAL){
|
||||
|
||||
public void onChange(float arg0, float arg1) {
|
||||
}
|
||||
};
|
||||
this.skill2.setMaxValue(100.0f);
|
||||
this.skill2.setCurrentValue(100.0f);
|
||||
this.skill2.setIndicatorColor(ColorRGBA.Blue);
|
||||
this.skill2.setText("Teleport");
|
||||
this.screen.addElement((Element)this.skill2);
|
||||
this.label = new Label(this.screen, "Timer", new Vector2f(10.0f, 50.0f), new Vector2f(200.0f, 100.0f));
|
||||
this.label.setFontColor(ColorRGBA.Yellow);
|
||||
this.label.setFontSize(30.0f);
|
||||
this.screen.addElement((Element)this.label);
|
||||
this.waveCounter = new Indicator(this.screen, "waveCounter", new Vector2f(10.0f, 30.0f), Indicator.Orientation.HORIZONTAL){
|
||||
|
||||
public void onChange(float arg0, float arg1) {
|
||||
}
|
||||
};
|
||||
this.waveCounter.setMaxValue((float)SPAWN_TIME);
|
||||
this.waveCounter.setCurrentValue((float)SPAWN_TIME - this.spawnTimer);
|
||||
this.waveCounter.setIndicatorColor(ColorRGBA.Yellow);
|
||||
this.waveCounter.setFontColor(ColorRGBA.Black);
|
||||
this.waveCounter.setText("next Wave in...");
|
||||
this.screen.addElement((Element)this.waveCounter);
|
||||
this.spiderCounter = new Label(this.screen, "SpiderCounter", new Vector2f(10.0f, 30.0f), new Vector2f(200.0f, 100.0f));
|
||||
this.spiderCounter.setFontColor(ColorRGBA.Yellow);
|
||||
this.spiderCounter.setFontSize(30.0f);
|
||||
this.screen.addElement((Element)this.spiderCounter);
|
||||
this.gameover = new Label(this.screen, "GameOver", new Vector2f(0.0f, 0.0f), new Vector2f((float)this.settings.getWidth(), 400.0f));
|
||||
this.gameover.setFont("/Interface/Fonts/FleshWound.fnt");
|
||||
this.gameover.setFontSize(100.0f);
|
||||
this.gameover.setFontColor(ColorRGBA.White);
|
||||
this.gameover.setText("Verloren!");
|
||||
Effect ef = new Effect(Effect.EffectType.FadeIn, Effect.EffectEvent.Show, 2.0f);
|
||||
this.gameover.hide();
|
||||
this.gameover.addEffect(Effect.EffectEvent.Show, ef);
|
||||
this.screen.addElement((Element)this.gameover);
|
||||
}
|
||||
|
||||
public void reduceCooldowns(float tpf) {
|
||||
this.player.leftHand.reduceCooldowns(tpf);
|
||||
this.player.rightHand.reduceCooldowns(tpf);
|
||||
}
|
||||
|
||||
public void simpleUpdate(float tpf) {
|
||||
this.reduceCooldowns(tpf);
|
||||
this.cooldownLeft.setCurrentValue(this.player.leftHand.cooldown1 * (this.cooldownLeft.getMaxValue() / this.player.leftHand.COOLDOWN1_TIME));
|
||||
this.skill2.setCurrentValue(this.player.leftHand.cooldown2 * (this.skill2.getMaxValue() / this.player.leftHand.COOLDOWN2_TIME));
|
||||
this.cooldownRight.setCurrentValue(this.player.rightHand.cooldown1 * (this.cooldownRight.getMaxValue() / this.player.rightHand.COOLDOWN1_TIME));
|
||||
this.spiderCounter.setText("Kills: " + Exchange.killed);
|
||||
if (!this.gameover_flag) {
|
||||
CollisionResults results = new CollisionResults();
|
||||
Vector2f click2d = this.inputManager.getCursorPosition();
|
||||
Vector3f click3d = this.cam.getWorldCoordinates(new Vector2f(click2d.x, click2d.y), 0.0f).clone();
|
||||
Vector3f dir = this.cam.getWorldCoordinates(new Vector2f(click2d.x, click2d.y), 1.0f).subtractLocal(click3d).normalizeLocal();
|
||||
Ray ray = new Ray(click3d, dir);
|
||||
this.rootNode.collideWith((Collidable)ray, results);
|
||||
for (int i = 0; i < results.size(); ++i) {
|
||||
float dist = results.getCollision(i).getDistance();
|
||||
Vector3f pt = results.getCollision(i).getContactPoint();
|
||||
this.player.wholeBody.lookAt(pt, Vector3f.UNIT_Y);
|
||||
this.player.pt = pt;
|
||||
}
|
||||
Vector3f camDir = this.cam.getDirection().clone().multLocal(8.0f);
|
||||
Vector3f camLeft = this.cam.getLeft().clone().multLocal(8.0f);
|
||||
camDir.y = 0.0f;
|
||||
camLeft.y = 0.0f;
|
||||
this.walkDirection.set(0.0f, 0.0f, 0.0f);
|
||||
if (this.left) {
|
||||
this.walkDirection.addLocal(camLeft);
|
||||
}
|
||||
if (this.right) {
|
||||
this.walkDirection.addLocal(camLeft.negate());
|
||||
}
|
||||
if (this.up) {
|
||||
this.walkDirection.addLocal(camDir);
|
||||
}
|
||||
if (this.down) {
|
||||
this.walkDirection.addLocal(camDir.negate());
|
||||
}
|
||||
if (this.walkDirection.length() == 0.0f) {
|
||||
if ("walk".equals(this.player.modelAnimChannel.getAnimationName())) {
|
||||
this.player.modelAnimChannel.setAnim("stand", 1.0f);
|
||||
}
|
||||
} else if ("stand".equals(this.player.modelAnimChannel.getAnimationName())) {
|
||||
this.player.modelAnimChannel.setAnim("walk", 0.7f);
|
||||
}
|
||||
this.walkDirection.normalizeLocal().multLocal(7.5f);
|
||||
this.player.playerControl.setWalkDirection(this.walkDirection);
|
||||
this.ind1.setCurrentValue(this.player.health);
|
||||
if (this.player.health <= 0.0f) {
|
||||
this.player.die();
|
||||
this.gameover.showWithEffect();
|
||||
AudioNode gameover = new AudioNode(this.assetManager, "Sounds/Effects/gameover.ogg", false);
|
||||
gameover.setLooping(false);
|
||||
gameover.setVolume(5.0f);
|
||||
this.rootNode.attachChild((Spatial)gameover);
|
||||
gameover.play();
|
||||
this.gameover_flag = true;
|
||||
}
|
||||
this.waveCounter.setCurrentValue((float)SPAWN_TIME - this.spawnTimer);
|
||||
this.spawnTimer += tpf;
|
||||
if (this.spawnTimer >= (float)SPAWN_TIME) {
|
||||
for (int spawn_counts = 0; spawn_counts < this.spawns; ++spawn_counts) {
|
||||
this.spawnSpider();
|
||||
}
|
||||
++this.spawns;
|
||||
this.spawnTimer = 0.0f;
|
||||
}
|
||||
this.label.setText("Wave No.:" + (this.spawns - 1));
|
||||
}
|
||||
}
|
||||
|
||||
public void onAnimCycleDone(AnimControl control, AnimChannel channel, String animName) {
|
||||
if (animName.equals("walk")) {
|
||||
channel.setAnim("stand", 0.1f);
|
||||
channel.setLoopMode(LoopMode.DontLoop);
|
||||
channel.setSpeed(1.0f);
|
||||
}
|
||||
if (animName.equals("skill1")) {
|
||||
channel.setAnim("normal", 0.1f);
|
||||
channel.setLoopMode(LoopMode.DontLoop);
|
||||
channel.setSpeed(1.0f);
|
||||
}
|
||||
}
|
||||
|
||||
public void onAnimChange(AnimControl control, AnimChannel channel, String animName) {
|
||||
if (animName.equals("skill1")) {
|
||||
// empty if block
|
||||
}
|
||||
}
|
||||
|
||||
public void collision(PhysicsCollisionEvent event) {
|
||||
try {
|
||||
if (event.getNodeA().getName().equals("Spider") && event.getNodeB().getName().equals("Player") || event.getNodeB().getName().equals("Spider") && event.getNodeA().getName().equals("Player")) {
|
||||
this.player.health -= 0.25f;
|
||||
}
|
||||
}
|
||||
catch (Exception exception) {
|
||||
// empty catch block
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user