?? lmghunter.java
字號:
lowerHalf.rotate(vr[0], Point3D.unitUp, 10);
vr[1].doRotate(Point3D.origin, Point3D.unitUp, 10);
vr[2].doRotate(Point3D.origin, Point3D.unitUp, 10);
ZListNode zln;
int n=0;
for(zln = zol.zNode; zln != null; zln = zln.getNext()) {
n++;
}
ZListNode zlna[] = new ZListNode[n];
n=0;
for(zln = zol.zNode; zln != null; zln = zln.getNext()) {
zlna[n++] = zln;
}
for(n=0;n<zlna.length;n++) {
zlna[n].getThing().update();
}
zol.update();
}
/** Do the processing for a frame of animation while rotating right. */
protected void animateRotateRight() {
lowerHalf.rotate(vr[0], Point3D.unitUp, 350);
vr[1].doRotate(Point3D.origin, Point3D.unitUp, 350);
vr[2].doRotate(Point3D.origin, Point3D.unitUp, 350);
ZListNode zln;
int n=0;
for(zln = zol.zNode; zln != null; zln = zln.getNext()) {
n++;
}
ZListNode zlna[] = new ZListNode[n];
n=0;
for(zln = zol.zNode; zln != null; zln = zln.getNext()) {
zlna[n++] = zln;
}
for(n=0;n<zlna.length;n++) {
zlna[n].getThing().update();
}
zol.update();
}
/** Returns the number of damage points to be ignored from each hit.
* Under standard health/armor rules, a unit cannot take less than 1 damage per hit.
* @return The armor value of the unit.
*/
protected int armor() {
return 2;
}
/** Returns the number of Hexes to get within if in Pursuit Mode.
* As long as the Unit is this close to its target, it will remain stationary and fire.
* This allows long range Units to abuse their range advantage by staying back while firing.
* @return The range to approach to, in hexes.
*/
public int followRange() {
return 3;
}
/** Returns the number of frames needed to move forward one hex.
* @return How many frames it takes to move one hex.
*/
protected int framesToMove() {
return 12;
}
/** Returns the number of frames needed to rotate one hex-side.
* @return How many frames it takes to rotate sixty degrees.
*/
protected int framesToRotate() {
return 6;
}
/** Returns The maximum value of health for this Unit, which is the initial value for health.
* @return The amount of damage that must be taken to destroy the Unit.
*/
protected int maxHealth() {
return 200;
}
/** If a turret is available, rotate it toward the target.
* @return true iff the target is within the firing arc.
*/
protected boolean aim() {
if(target != null && target.isDead()) {
target = null;
targetSSMDS = null;
if(mode == 2)
mode = 0;
return false;
}
Point3D vec;
if(target != null) vec = targetSSMDS.getVector(this);
else vec = vr[1]; //Aim forward (don't fire)
float fore = (vec.x * vr[3].x + vec.y * vr[3].y);
float left = (vec.y * vr[4].y + vec.x * vr[4].x);
float cosine = (float)(fore / (Math.sqrt(fore * fore + left * left)));
boolean aimLeft = (left > 0);
int aimAngle;
if(cosine > Trig.cos(1)) {
aimAngle = 0;
}else if(cosine > Trig.cos(2)) {
aimAngle = 1;
}else if(cosine > Trig.cos(3)) {
aimAngle = 2;
}else if(cosine > Trig.cos(4)) {
aimAngle = 3;
}else if(cosine > Trig.cos(5)) {
aimAngle = 4;
}else if(cosine > Trig.cos(10)){
aimAngle = 5;
}else{
aimAngle = 10;
}
if(aimAngle == 0) aimLeft = true;
upperHalf.rotate(upperHalf.getPoint(1), Point3D.unitUp, (aimLeft)?(aimAngle):(360 - aimAngle));
vr[3].doRotate(Point3D.origin, Point3D.unitUp, (aimLeft)?(aimAngle):(360 - aimAngle));
vr[4].doRotate(Point3D.origin, Point3D.unitUp, (aimLeft)?(aimAngle):(360 - aimAngle));
ZListNode zln;
int n=0;
for(zln = zol.zNode; zln != null; zln = zln.getNext()) {
n++;
}
ZListNode zlna[] = new ZListNode[n];
n=0;
for(zln = zol.zNode; zln != null; zln = zln.getNext()) {
zlna[n++] = zln;
}
for(n=0;n<zlna.length;n++) {
zlna[n].getThing().update();
}
zol.update();
return (aimAngle < 5 && target != null && target.getPlayer() != myPlayer);
}
/** Perform the data changes for one frame of animation while dying. */
protected void animateDie() {
if(frame == framesToDie())
zol.explode((new Point3D(0,0,-5)).doSum(vr[0]));
frame--;
if(frame == 0) {
remove();
Hex.getHex(resX,resY).unreserve();
Hex.getHex(x,y).leave(this);
}
}
protected void animateMake() {
}
/** Draw this GameObject onto GameViewer v, by using v's drawing methods.
* @param v The GameViewer which will display this GameObject.
* @see netwar.gui.HexViewer
*/
public void draw(GameViewer v) {
zol.draw(v);
}
/** Returns the number of frames of animation for the death sequence.
* @return The number of frames needed to animate death.
*/
protected int framesToDie() {
return 5;
}
/** Returns the number of frames of animation for the creation sequence.
* @return The number of frames needed to animate creation.
*/
protected int framesToMake() {
return 20;
}
/** Return the height of this GameObject for selection box and explosion hit calculations.
* @return The height of the GameObject in game-space units.
*/
public float getHeight() {
return upperHalf.getPoint(1).z;
}
/** Return the width of this GameObject for selection box and explosion hit calculations.
* @return The width of the GameObject in game-space units.
*/
public float getWidth() {
return 7.0f;
}
/** Return the number of frames to wait between firing shots.
*/
public int weaponDelay() {
return 1;
}
/** Return the square of the maximum weapon range of this GameObject.
* @return The square of the weapons range in game-space units.
*/
public float weaponRangeSquared() {
return 6400f;
}
public float scanRangeSquared() {
return 25600f;
}
/** LMGHunter fires a Laser.
* Laser is a straight flying shot which can only damage its intended target.
* It explodes when the angle between it velocity and the vector to its target exceeds 90 degrees.
* <BR> Initial location = varies.
* <BR> Initial velocity = five units, level with the ground, in the aimed direction.
* <BR> Base damage = 6
* <BR> Radius of explosion = 5 units.
* <BR> Life of projectile = 18 cycles.
*/
protected boolean fire() {
Projectile.newProjectile(new Laser(Color.green), (leftFire)?(upperHalf.getPoint(5)):(upperHalf.getPoint(6)), vr[3].getProduct(5), 10, 25, 18, this, target);
leftFire = !leftFire;
return true;
}
public int cost() {
return 150;
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -