/* * Decompiled with CFR 0.152. * * Could not load the following classes: * com.jme3.animation.AnimControl * com.jme3.animation.LoopMode * com.jme3.app.Application * com.jme3.asset.AssetManager * com.jme3.audio.AudioNode * com.jme3.bullet.collision.shapes.CapsuleCollisionShape * com.jme3.bullet.collision.shapes.CollisionShape * com.jme3.bullet.control.BetterCharacterControl * com.jme3.bullet.control.GhostControl * com.jme3.effect.ParticleEmitter * com.jme3.effect.ParticleMesh$Type * com.jme3.material.Material * com.jme3.math.ColorRGBA * com.jme3.math.Vector3f * com.jme3.scene.Spatial * com.jme3.scene.control.Control * tonegod.gui.core.Screen */ package mygame; import com.jme3.animation.AnimControl; import com.jme3.animation.LoopMode; import com.jme3.app.Application; import com.jme3.asset.AssetManager; import com.jme3.audio.AudioNode; import com.jme3.bullet.collision.shapes.CapsuleCollisionShape; import com.jme3.bullet.collision.shapes.CollisionShape; import com.jme3.bullet.control.BetterCharacterControl; import com.jme3.bullet.control.GhostControl; import com.jme3.effect.ParticleEmitter; import com.jme3.effect.ParticleMesh; import com.jme3.material.Material; import com.jme3.math.ColorRGBA; import com.jme3.math.Vector3f; import com.jme3.scene.Spatial; import com.jme3.scene.control.Control; import mygame.Character; import mygame.Exchange; import mygame.WalkingEnemyControl; import tonegod.gui.core.Screen; public class WalkingEnemy extends Character { public BetterCharacterControl walkingEnemyControl; public GhostControl ghost; private WalkingEnemyControl control = new WalkingEnemyControl(); private float health; private AssetManager assetManager; public float reverseWalk; public ParticleEmitter blood; public boolean dead = false; public float deadtimer = 0.0f; public WalkingEnemy(String name) { super(name); this.addControl((Control)this.control); } public WalkingEnemy(String name, AssetManager am) { super(name); this.addControl((Control)this.control); this.assetManager = am; } public void setupModelControl() { this.modelAnimControl = (AnimControl)this.model.getControl(AnimControl.class); this.modelAnimChannel = this.modelAnimControl.createChannel(); this.modelAnimChannel.setAnim("stand"); } public void setupGUI() { Screen screen = new Screen((Application)Exchange.app, "tonegod/gui/style/def/style_map.xml"); } public void setModel(Spatial model) { this.model = model; this.setupModel(); this.setupControl(); this.setupModelControl(); this.wholeBody.attachChild(this.model); this.blood = new ParticleEmitter("Emitter", ParticleMesh.Type.Triangle, 10); Material mat_red = this.assetManager.loadMaterial("Materials/blood.j3m"); this.blood.setMaterial(mat_red); this.blood.setImagesX(2); this.blood.setImagesY(2); this.blood.setEndColor(new ColorRGBA(1.0f, 0.0f, 0.0f, 0.75f)); this.blood.setStartColor(new ColorRGBA(1.0f, 0.0f, 0.0f, 0.25f)); this.blood.getParticleInfluencer().setInitialVelocity(new Vector3f(1.0f, 2.0f, 1.0f)); this.blood.setParticlesPerSec(0.0f); this.blood.setStartSize(1.0f); this.blood.setEndSize(1.0f); this.blood.setGravity(0.0f, 2.0f, 0.0f); this.blood.setLowLife(1.0f); this.blood.setHighLife(0.5f); this.blood.getParticleInfluencer().setVelocityVariation(0.3f); this.blood.setRandomAngle(true); this.blood.setSelectRandomImage(true); this.attachChild((Spatial)this.blood); } void setupModel() { this.model.setLocalScale(0.5f); this.wholeBody.attachChild(this.model); } private void setupControl() { this.walkingEnemyControl = new BetterCharacterControl(1.0f, 2.0f, 8.0f); this.addControl((Control)this.walkingEnemyControl); this.ghost = new GhostControl((CollisionShape)new CapsuleCollisionShape(1.0f, 0.5f)); this.ghost.addCollideWithGroup(1); this.addControl((Control)this.ghost); } public float getHealth() { return this.health; } public void setHealth(float health) { this.health = health; } public void doDamage(float damage) { this.health -= damage; this.reverseWalk = 0.5f; if (this.health <= 0.0f) { this.die(); } AudioNode hit = new AudioNode(this.assetManager, "Sounds/Effects/damage.ogg", false); hit.setLooping(false); hit.setVolume(100.0f); this.getParent().attachChild((Spatial)hit); hit.play(); this.blood.emitAllParticles(); } public void die() { this.modelAnimChannel.setAnim("die"); this.modelAnimChannel.setLoopMode(LoopMode.DontLoop); this.ghost.setEnabled(false); this.walkingEnemyControl.setEnabled(false); AudioNode an = (AudioNode)this.getChild("walkingSound"); an.stop(); Exchange.removeEnemy(this); Exchange.setKilled(Exchange.killed + 1); Exchange.spawnItem(this.getLocalTranslation()); this.dead = true; } }