Created
March 26, 2012 11:50
-
-
Save jaz303/2204603 to your computer and use it in GitHub Desktop.
classy enums
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public enum ShotType { | |
PISTOL (2, new Vec3f(0, 0, -35), new Vec3f(0, -1, 0), 0.99f), | |
ARTILLERY (200, new Vec3f(0, 30, -40), new Vec3f(0, -20, 0), 0.99f), | |
FIREBALL (1, new Vec3f(0, 0, -10), new Vec3f(0, 6, 0), 0.9f), | |
LASER (0.1f, new Vec3f(0, 0, -100), new Vec3f(0, 0, 0), 0.99f); | |
private final float mass; | |
private final Vec3f velocity; | |
private final Vec3f acceleration; | |
private final float damping; | |
ShotType(float m, Vec3f v, Vec3f a, float d) { | |
this.mass = m; | |
this.velocity = v; | |
this.acceleration = a; | |
this.damping = d; | |
} | |
public void primeParticle(Particle p) { | |
p.setMass(mass); | |
p.setVelocity(this.velocity.x, this.velocity.y, this.velocity.z); | |
p.setAcceleration(this.acceleration.x, this.acceleration.y, this.acceleration.z); | |
p.setDamping(damping); | |
} | |
public ShotType next() { | |
int next = this.ordinal() + 1; | |
if (next >= ShotType.values().length) { | |
next = 0; | |
} | |
return ShotType.values()[next]; | |
} | |
public ShotType prev() { | |
int prev = this.ordinal() - 1; | |
if (prev < 0) { | |
prev = ShotType.values().length - 1; | |
} | |
return ShotType.values()[prev]; | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment