?? palm.java
字號:
/*
Netwar
Copyright (C) 2002 Daniel Grund, Kyle Kakligian, Jason Komutrattananon, & Brian Hibler.
This file is part of Netwar.
Netwar is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
Netwar is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Netwar; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
package netwar.game.object;
import netwar.game.*;
import netwar.utils.*;
import netwar.utils.vectorgraphics.*;
/** Palm tree object. Destroyable obstacle.
* @author Group N2 - Project Netwar
* @author Kyle Kakligian
*/
public class Palm extends netwar.game.GameObject {
// colors
private static java.awt.Color brown = new java.awt.Color(128,64,0);
private static java.awt.Color green = new java.awt.Color(64, 160, 0);
private static java.awt.Color drgreen = new java.awt.Color(64, 128, 0);
// point list
private static SelfConvertingPoint _pts[] = {
new SelfConvertingPoint(0, 0, 0),
new SelfConvertingPoint(-0.00000,-0.91000, 0.00000),
new SelfConvertingPoint( 1.02412, 1.45172, 0.00000),
new SelfConvertingPoint(-0.76412, 1.45172, -0.00000),
new SelfConvertingPoint(-0.00000,-0.68375, 4.75243),
new SelfConvertingPoint( 0.82412, 0.66268, 4.74470),
new SelfConvertingPoint(-0.69412, 0.66268, 4.74470),
new SelfConvertingPoint(-0.00000, 0.12585, 9.68890),
new SelfConvertingPoint( 0.56545, 1.82279, 9.30297),
new SelfConvertingPoint(-0.56545, 1.82279, 9.30297),
new SelfConvertingPoint( 0.01141, 1.49262, 11.30000),
new SelfConvertingPoint(-2.60630, 4.48881, 9.67522),
new SelfConvertingPoint(-7.08400, 4.13934, 7.36984),
new SelfConvertingPoint(-4.16649, 1.87175, 10.34874),
new SelfConvertingPoint( 0.01141, 1.49262, 11.30000),
new SelfConvertingPoint(-4.16649, 0.48728, 9.84309),
new SelfConvertingPoint(-6.56393,-3.58629, 8.98570),
new SelfConvertingPoint(-2.60630,-2.13973, 10.47672),
new SelfConvertingPoint( 0.01141, 1.49262, 11.30000),
new SelfConvertingPoint(-1.54879,-2.51917, 11.47878),
new SelfConvertingPoint( 0.53147,-6.06527, 8.08414),
new SelfConvertingPoint( 1.57160,-2.51917, 11.47878),
new SelfConvertingPoint( 0.01141, 1.49262, 11.30000),
new SelfConvertingPoint( 3.45461,-2.72733, 11.53235),
new SelfConvertingPoint( 6.28131,-3.91661, 9.05479),
new SelfConvertingPoint( 4.18931, 0.48728, 9.84309),
new SelfConvertingPoint( 0.01141, 1.49262, 11.30000),
new SelfConvertingPoint( 4.18931, 1.77154, 9.95313),
new SelfConvertingPoint( 6.99950, 5.04401, 9.13377),
new SelfConvertingPoint( 2.62911, 4.48881, 9.67522),
new SelfConvertingPoint( 0.01141, 1.49262, 11.30000),
new SelfConvertingPoint( 1.57160, 5.08010, 9.52305),
new SelfConvertingPoint(-0.50866, 8.44301, 6.46970),
new SelfConvertingPoint(-2.37429, 6.67900, 9.11156)};
private static CoherentPointSet points = new CoherentPointSet(_pts.length);
private static GraphicThing appearance= null;
private VirtualCoherentGraphicThing myAppearance;;
/** Creates a new instance of PineTree */
public Palm() {
}
/** Initialize the Point3Ds used for this Base.
* These are the location of the ground-center of the Base in game-space, and
* the relative locations of the triangle/line vertices relative to that point.
*/
protected void createVectors() {
vr = new Point3D[1];
vr[0] = Hex.getMapPoint(x,y);
if(appearance == null) {
appearance = new OrderedGraphicSet( new GraphicTriangle( _pts[8], _pts[9], _pts[7], drgreen), _pts.length);
((OrderedGraphicSet)appearance).add(new GraphicTriangle( _pts[2], _pts[4], _pts[1], brown), false);
((OrderedGraphicSet)appearance).add(new GraphicTriangle( _pts[5], _pts[4], _pts[2], brown), false);
((OrderedGraphicSet)appearance).add(new GraphicTriangle( _pts[5], _pts[2], _pts[3], brown), false);
((OrderedGraphicSet)appearance).add(new GraphicTriangle( _pts[6], _pts[5], _pts[3], brown), false);
((OrderedGraphicSet)appearance).add(new GraphicTriangle( _pts[4], _pts[6], _pts[3], brown), false);
((OrderedGraphicSet)appearance).add(new GraphicTriangle( _pts[1], _pts[4], _pts[3], brown), false);
((OrderedGraphicSet)appearance).add(new GraphicTriangle( _pts[7], _pts[4], _pts[5], brown), false);
((OrderedGraphicSet)appearance).add(new GraphicTriangle( _pts[8], _pts[7], _pts[5], brown), false);
((OrderedGraphicSet)appearance).add(new GraphicTriangle( _pts[8], _pts[5], _pts[6], brown), false);
((OrderedGraphicSet)appearance).add(new GraphicTriangle( _pts[9], _pts[8], _pts[6], brown), false);
((OrderedGraphicSet)appearance).add(new GraphicTriangle( _pts[7], _pts[9], _pts[6], brown), false);
((OrderedGraphicSet)appearance).add(new GraphicTriangle( _pts[4], _pts[7], _pts[6], brown), false);
((OrderedGraphicSet)appearance).add(new GraphicTriangle( _pts[12], _pts[13], _pts[11], green), false);
((OrderedGraphicSet)appearance).add(new GraphicTriangle( _pts[13], _pts[10], _pts[11], green), false);
((OrderedGraphicSet)appearance).add(new GraphicTriangle( _pts[16], _pts[17], _pts[15], green), false);
((OrderedGraphicSet)appearance).add(new GraphicTriangle( _pts[17], _pts[14], _pts[15], green), false);
((OrderedGraphicSet)appearance).add(new GraphicTriangle( _pts[20], _pts[21], _pts[19], green), false);
((OrderedGraphicSet)appearance).add(new GraphicTriangle( _pts[21], _pts[18], _pts[19], green), false);
((OrderedGraphicSet)appearance).add(new GraphicTriangle( _pts[24], _pts[25], _pts[23], green), false);
((OrderedGraphicSet)appearance).add(new GraphicTriangle( _pts[25], _pts[22], _pts[23], green), false);
((OrderedGraphicSet)appearance).add(new GraphicTriangle( _pts[28], _pts[29], _pts[27], green), false);
((OrderedGraphicSet)appearance).add(new GraphicTriangle( _pts[29], _pts[26], _pts[27], green), false);
((OrderedGraphicSet)appearance).add(new GraphicTriangle( _pts[32], _pts[33], _pts[31], green), false);
((OrderedGraphicSet)appearance).add(new GraphicTriangle( _pts[33], _pts[30], _pts[31], green), false);
for(int t = 0; t < _pts.length; t++)
points.add(_pts[t]);
}
if(netwar.Mapper.theApp != null) myAppearance = new VirtualCoherentGraphicThing(appearance, points, vr[0], (new java.util.Random()).nextInt(360));
else myAppearance = new VirtualCoherentGraphicThing(appearance, points, vr[0], netwar.Netwar.netwar.random.nextInt(360));
}
/** Returns false, because the tree has no weapon.
* @return false
*/
protected boolean aim() {
return false;
}
/** Perform the data changes for one frame of animation while dying. */
protected void animateDie() {
if(frame == framesToDie()) {
Hex.getHex(x,y).unreserve();
Hex.getHex(x,y).leave(this);
myAppearance.explode(vr[0]);
}
frame--;
if(frame == 0)
remove();
}
/** Perform the data changes for one frame of animation while being made.
* Pine trees pre-exist: there is no formation animation.
*/
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) {
myAppearance.draw(v);
}
/** Requests that the GraphicThing(s) used by this object be added to GameViewer v.
* @param v The GameViewer which will be displaying the object.
*/
public void addTo(GameViewer v) {
v.add(myAppearance);
}
public void killGraphics() {
myAppearance.kill();
}
/** Returns the number of frames of animation for the death sequence.
* @return 5
*/
protected int framesToDie() {
return 10;
}
/** Returns the number of frames of animation for the creation sequence.
* @return 0
*/
protected int framesToMake() {
return 0;
}
/** Return the height of this GameObject for selection box and explosion hit calculations.
* @return 20
*/
public float getHeight() {
return 20f;
}
/** Return the width of this GameObject for selection box and explosion hit calculations.
* @return 5
*/
public float getWidth() {
return 6.2f;
}
/** Clear the current long-term goal. */
public void setGoal() {
}
/** Set the current long-term goal to a GameObject.
* This is a tree. It does not use the goal system.
* @param u The GameObject which is the goal.
*/
public void setGoal(GameObject u) {
}
/** Set the current long-term goal to a location, at hex coordinate (gx, gy).
* This is a tree. It does not use the goal system.
* @param gx The x coordinate of the goal, in hex coords.
* @param gy The y coordinate of the goal, in hex coords.
*/
public void setGoal(int gx, int gy) {
}
/** Perform operations for this time step.
* Specifically, perform the Point3D transforms for any/all animations,
* fire at an enemy if possible, and do any required decision making.
* This is a tree. It is only animated if it is dying.
*/
protected void update() {
if(action == 5)
animateDie();
}
/** Return the number of frames to wait between firing shots.
* @return 0
*/
public int weaponDelay() {
return 0;
}
/** Return the square of the maximum weapon range of this GameObject.
* @return 0
*/
public float weaponRangeSquared() {
return 0f;
}
public boolean isDead() {
return (action == 5);
}
public boolean damageable() {
return (action != 5);
}
/** The tree uses the 'threshold damage system'.
* If sufficient damage (15 or more) is dealt in one blow,
* the tree is destroyed.
*/
public void recieveDamage(int dam) {
if(dam >= 15) {
action = 5;
frame = framesToDie();
}
}
static final String[] PROPERTIES = {};
protected String[] PROPERTIES() {
return PROPERTIES;
}
protected String getProperty(int p) {
switch(p) {
default:
Assert.notFalse(false, "getProperty(int) error.");
}
return null;
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -