?? bushred.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 BushRed extends Bush {
// colors
private static java.awt.Color red = new java.awt.Color(224, 0,0);
// point list
private static SelfConvertingPoint _pts2[] = {
new SelfConvertingPoint(0, 0, 0),
new SelfConvertingPoint(-2.54509, -0.04361, 2.53887),
new SelfConvertingPoint(-2.03904, -0.15954, 2.87754),
new SelfConvertingPoint(-2.24014, -0.55345, 2.58594),
new SelfConvertingPoint( 0.82447, 2.36969, 2.09345),
new SelfConvertingPoint( 0.22073, 2.36969, 2.09345),
new SelfConvertingPoint( 0.54166, 2.54627, 1.72663),
new SelfConvertingPoint(-2.94813, 0.70831, 1.82138),
new SelfConvertingPoint(-3.21554, 0.33529, 1.89638),
new SelfConvertingPoint(-3.14054, 0.34025, 1.45216),
new SelfConvertingPoint( 0.56498, -1.79133, 0.99609),
new SelfConvertingPoint( 0.29005, -1.57347, 1.59937),
new SelfConvertingPoint( 0.85407, -1.49344, 1.49857)};
protected static CoherentPointSet points2 = new CoherentPointSet(_pts.length + _pts2.length);
protected static GraphicThing appearance2= null;
protected VirtualCoherentGraphicThing myAppearance2;;
/** Creates a new instance of PineTree */
public BushRed() {
}
/** 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() {
super.createVectors();
if(appearance2 == null) {
appearance2 = new OrderedGraphicSet( appearance, _pts2.length + 1);
((OrderedGraphicSet)appearance2).add(new GraphicTriangle( _pts2[2], _pts2[1], _pts2[3], red), false);
((OrderedGraphicSet)appearance2).add(new GraphicTriangle( _pts2[5], _pts2[4], _pts2[6], red), false);
((OrderedGraphicSet)appearance2).add(new GraphicTriangle( _pts2[8], _pts2[7], _pts2[9], red), false);
((OrderedGraphicSet)appearance2).add(new GraphicTriangle( _pts2[12], _pts2[11], _pts2[10], red), false);
for(int t = 0; t < _pts2.length; t++)
points2.add(_pts2[t]);
for(int t = 0; t < _pts.length; t++)
points2.add(_pts[t]);
}
if(netwar.Mapper.theApp != null) myAppearance2 = new VirtualCoherentGraphicThing(appearance2, points2, vr[0], (new java.util.Random()).nextInt(360));
else myAppearance2 = new VirtualCoherentGraphicThing(appearance2, points2, 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);
myAppearance2.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) {
myAppearance2.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(myAppearance2);
}
public void killGraphics() {
myAppearance2.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 > 5)
netwar.gui.HexViewer.getHexViewer().displayString(mess[(new java.util.Random()).nextInt(mess.length)]);
}
private static final String mess[] = {"A feeble attempt to destroy one little tree has failed.", "The fruited tree is too strong.", "Don't eat at Freebird's."};
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 + -