92 lines
2.8 KiB
Java
92 lines
2.8 KiB
Java
/*
|
|
* Decompiled with CFR 0.152.
|
|
*
|
|
* Could not load the following classes:
|
|
* com.jme3.animation.AnimEventListener
|
|
* com.jme3.animation.LoopMode
|
|
* com.jme3.asset.AssetManager
|
|
* com.jme3.audio.AudioNode
|
|
* com.jme3.bullet.collision.shapes.BoxCollisionShape
|
|
* com.jme3.bullet.collision.shapes.CollisionShape
|
|
* com.jme3.bullet.control.GhostControl
|
|
* com.jme3.math.Vector3f
|
|
* com.jme3.scene.Spatial
|
|
* com.jme3.scene.control.Control
|
|
*/
|
|
package mygame;
|
|
|
|
import com.jme3.animation.AnimEventListener;
|
|
import com.jme3.animation.LoopMode;
|
|
import com.jme3.asset.AssetManager;
|
|
import com.jme3.audio.AudioNode;
|
|
import com.jme3.bullet.collision.shapes.BoxCollisionShape;
|
|
import com.jme3.bullet.collision.shapes.CollisionShape;
|
|
import com.jme3.bullet.control.GhostControl;
|
|
import com.jme3.math.Vector3f;
|
|
import com.jme3.scene.Spatial;
|
|
import com.jme3.scene.control.Control;
|
|
import mygame.Exchange;
|
|
import mygame.Player;
|
|
import mygame.SkillListener;
|
|
import mygame.WalkingEnemy;
|
|
import mygame.Weapon;
|
|
|
|
public class Sword
|
|
extends Weapon
|
|
implements Runnable {
|
|
GhostControl ghost;
|
|
AssetManager assetManager;
|
|
|
|
public Sword(String name) {
|
|
super(name);
|
|
}
|
|
|
|
public Sword(String name, AssetManager am, Exchange ex) {
|
|
super(name);
|
|
this.assetManager = am;
|
|
this.exchange = ex;
|
|
this.COOLDOWN1_TIME = 0.5f;
|
|
}
|
|
|
|
protected void setupControl() {
|
|
this.ghost = new GhostControl((CollisionShape)new BoxCollisionShape(new Vector3f(0.25f, 0.25f, 1.75f)));
|
|
this.ghost.addCollideWithGroup(1);
|
|
this.addControl((Control)this.ghost);
|
|
this.modelAnimControl.addListener((AnimEventListener)new SkillListener(this));
|
|
}
|
|
|
|
public void skill1() {
|
|
if (this.cooldown1 <= 0.0f && !this.skill1) {
|
|
this.skill1 = true;
|
|
this.cooldown1 = this.COOLDOWN1_TIME;
|
|
this.modelAnimChannel.setAnim("skill1");
|
|
this.modelAnimChannel.setSpeed(2.0f);
|
|
this.modelAnimChannel.setLoopMode(LoopMode.DontLoop);
|
|
AudioNode hit = new AudioNode(this.assetManager, "Sounds/Effects/sword_hit1.ogg", false);
|
|
hit.setLooping(false);
|
|
hit.setPositional(true);
|
|
hit.setLocalTranslation(this.getLocalTranslation());
|
|
hit.setVolume(5.0f);
|
|
this.attachChild((Spatial)hit);
|
|
hit.play();
|
|
int i = 0;
|
|
while (true) {
|
|
if (i >= Exchange.enemies.size()) break;
|
|
WalkingEnemy enemy = Exchange.enemies.get(i);
|
|
if (this.ghost.getOverlappingObjects().contains(enemy.ghost)) {
|
|
enemy.doDamage(50.0f);
|
|
Player player = (Player)this.getParent().getParent();
|
|
}
|
|
++i;
|
|
}
|
|
}
|
|
}
|
|
|
|
public void run() {
|
|
this.skill1();
|
|
}
|
|
|
|
public void skill2() {
|
|
}
|
|
}
|