📄 base.java
字号:
zol = new ZOrderedList(netwar.gui.HexViewer.getHexViewer().getTransform());
zol.add(new SpoofZ(new GraphicTriangle(vr[0].getSum(basePoints[0]), vr[0].getSum(basePoints[1]), vr[0].getSum(basePoints[2]), Color.darkGray),Float.MAX_VALUE));
zol.add(new SpoofZ(new GraphicTriangle(vr[0].getSum(basePoints[0]), vr[0].getSum(basePoints[2]), vr[0].getSum(basePoints[3]), Color.darkGray),Float.MAX_VALUE));
zol.add(new SpoofZ(new GraphicTriangle(vr[0].getSum(basePoints[0]), vr[0].getSum(basePoints[3]), vr[0].getSum(basePoints[4]), Color.darkGray),Float.MAX_VALUE));
zol.add(new SpoofZ(new GraphicTriangle(vr[0].getSum(basePoints[0]), vr[0].getSum(basePoints[4]), vr[0].getSum(basePoints[5]), Color.darkGray),Float.MAX_VALUE));
zol.add(new SpoofZ(new GraphicTriangle(vr[0].getSum(basePoints[0]), vr[0].getSum(basePoints[5]), vr[0].getSum(basePoints[6]), Color.darkGray),Float.MAX_VALUE));
zol.add(new SpoofZ(new GraphicTriangle(vr[0].getSum(basePoints[0]), vr[0].getSum(basePoints[6]), vr[0].getSum(basePoints[1]), Color.darkGray),Float.MAX_VALUE));
zol.add(new GraphicTriangle(vr[0].getSum(basePoints[19]), vr[0].getSum(basePoints[7]), vr[0].getSum(basePoints[13]), myPlayer.getColor().darker().darker()));
zol.add(new GraphicTriangle(vr[0].getSum(basePoints[20]), vr[0].getSum(basePoints[8]), vr[0].getSum(basePoints[14]), myPlayer.getColor().darker().darker()));
zol.add(new GraphicTriangle(vr[0].getSum(basePoints[21]), vr[0].getSum(basePoints[9]), vr[0].getSum(basePoints[15]), myPlayer.getColor().darker().darker()));
zol.add(new GraphicTriangle(vr[0].getSum(basePoints[22]), vr[0].getSum(basePoints[10]), vr[0].getSum(basePoints[16]), myPlayer.getColor().darker().darker()));
zol.add(new GraphicTriangle(vr[0].getSum(basePoints[23]), vr[0].getSum(basePoints[11]), vr[0].getSum(basePoints[17]), myPlayer.getColor().darker().darker()));
zol.add(new GraphicTriangle(vr[0].getSum(basePoints[24]), vr[0].getSum(basePoints[12]), vr[0].getSum(basePoints[18]), myPlayer.getColor().darker().darker()));
for(int i = 0; i < 6; i++) {
halls[i] = new CoherentPointSet(21);
halls[i].add(new SelfConvertingPoint(HexType.m_middleLeft));
halls[i].add(new SelfConvertingPoint(HexType.m_topRight));
halls[i].add(new SelfConvertingPoint(HexType.m_topRight));
halls[i].getPoint(2).doSum(HexType.m_middleRight);
halls[i].getPoint(2).doSum(HexType.m_topRight);
halls[i].add((SelfConvertingPoint)(new SelfConvertingPoint(0,0,10)).doSum(halls[i].getPoint(0)));
halls[i].add((SelfConvertingPoint)(new SelfConvertingPoint(0,0,10)).doSum(halls[i].getPoint(1)));
halls[i].add((SelfConvertingPoint)(new SelfConvertingPoint(0,0,10)).doSum(halls[i].getPoint(2)));
halls[i].add((SelfConvertingPoint)(new SelfConvertingPoint(0,0,10)).doSum(halls[i].getPoint(3)));
halls[i].add((SelfConvertingPoint)(new SelfConvertingPoint(0,0,10)).doSum(halls[i].getPoint(4)));
halls[i].add((SelfConvertingPoint)(new SelfConvertingPoint(0,0,10)).doSum(halls[i].getPoint(5)));
halls[i].add(new SelfConvertingPoint(HexType.m_lowerLeft.x, HexType.m_lowerLeft.y, 20));
halls[i].add(new SelfConvertingPoint(HexType.m_middleRight.x, HexType.m_middleRight.y, 20));
halls[i].add(new SelfConvertingPoint(HexType.m_middleRight.x, HexType.m_middleRight.y, 20));
halls[i].getPoint(11).doSum(HexType.m_middleRight);
halls[i].getPoint(11).doSum(HexType.m_topRight);
halls[i].add((SelfConvertingPoint)(new SelfConvertingPoint(0,0,-10)).doSum(halls[i].getPoint(9)));
halls[i].add((SelfConvertingPoint)(new SelfConvertingPoint(0,0,-10)).doSum(halls[i].getPoint(10)));
halls[i].add((SelfConvertingPoint)(new SelfConvertingPoint(0,0,-10)).doSum(halls[i].getPoint(11)));
halls[i].add((SelfConvertingPoint)(new SelfConvertingPoint(0,0,-10)).doSum(halls[i].getPoint(12)));
halls[i].add((SelfConvertingPoint)(new SelfConvertingPoint(0,0,-10)).doSum(halls[i].getPoint(13)));
halls[i].add((SelfConvertingPoint)(new SelfConvertingPoint(0,0,-10)).doSum(halls[i].getPoint(14)));
halls[i].rotate(Point3D.origin, Point3D.unitUp, 60 * i);
halls[i].translate(vr[0]);
zol.add(new GraphicParallelogram(halls[i].getPoint(0), halls[i].getPoint(1), halls[i].getPoint(4), halls[i].getPoint(3), Color.darkGray.brighter()));
zol.add(new GraphicParallelogram(halls[i].getPoint(1), halls[i].getPoint(2), halls[i].getPoint(5), halls[i].getPoint(4), Color.darkGray.brighter()));
zol.add(new GraphicParallelogram(halls[i].getPoint(3), halls[i].getPoint(4), halls[i].getPoint(7), halls[i].getPoint(6), Color.darkGray.brighter()));
zol.add(new GraphicParallelogram(halls[i].getPoint(4), halls[i].getPoint(5), halls[i].getPoint(8), halls[i].getPoint(7), Color.darkGray.brighter()));
zol.add(new GraphicParallelogram(halls[i].getPoint(9), halls[i].getPoint(10), halls[i].getPoint(13), halls[i].getPoint(12), Color.darkGray.brighter()));
zol.add(new GraphicParallelogram(halls[i].getPoint(10), halls[i].getPoint(11), halls[i].getPoint(14), halls[i].getPoint(13), Color.darkGray.brighter()));
zol.add(new GraphicParallelogram(halls[i].getPoint(12), halls[i].getPoint(13), halls[i].getPoint(16), halls[i].getPoint(15), Color.darkGray.brighter()));
zol.add(new GraphicParallelogram(halls[i].getPoint(13), halls[i].getPoint(14), halls[i].getPoint(17), halls[i].getPoint(16), Color.darkGray.brighter()));
zol.add(new SpoofZ(new GraphicParallelogram(halls[i].getPoint(6), halls[i].getPoint(8), halls[i].getPoint(11), halls[i].getPoint(9), Color.darkGray),Float.MAX_VALUE));
doors[i] = new CoherentPointSet(9);
doors[i].add(new SelfConvertingPoint(HexType.m_topRight));
doors[i].add(new SelfConvertingPoint(HexType.m_topRight.x, HexType.m_topRight.y, 10));
doors[i].add(new SelfConvertingPoint(HexType.m_topRight.x, HexType.m_topRight.y, 20));
doors[i].add(new SelfConvertingPoint(HexType.m_middleRight));
doors[i].add(new SelfConvertingPoint(HexType.m_middleRight.x, HexType.m_middleRight.y, 10));
doors[i].add(new SelfConvertingPoint(HexType.m_middleRight.x, HexType.m_middleRight.y, 20));
doors[i].add((SelfConvertingPoint)(new SelfConvertingPoint(HexType.m_middleRight)).doSum(HexType.m_topRight).doProduct(0.5f));
doors[i].add((SelfConvertingPoint)(new SelfConvertingPoint(0,0,10)).doSum(doors[i].getPoint(6)));
doors[i].add((SelfConvertingPoint)(new SelfConvertingPoint(0,0,10)).doSum(doors[i].getPoint(7)));
doors[i].translate(HexType.m_middleRight);
doors[i].translate(HexType.m_topRight);
doors[i].rotate(Point3D.origin, Point3D.unitUp, 60 * i);
doors[i].translate(vr[0]);
zol.add(new GraphicParallelogram(doors[i].getPoint(0), doors[i].getPoint(1), doors[i].getPoint(7), doors[i].getPoint(6), myPlayer.getColor().darker()));
zol.add(new GraphicParallelogram(doors[i].getPoint(1), doors[i].getPoint(2), doors[i].getPoint(8), doors[i].getPoint(7), myPlayer.getColor().darker()));
zol.add(new GraphicParallelogram(doors[i].getPoint(6), doors[i].getPoint(7), doors[i].getPoint(4), doors[i].getPoint(3), myPlayer.getColor().darker()));
zol.add(new GraphicParallelogram(doors[i].getPoint(7), doors[i].getPoint(8), doors[i].getPoint(5), doors[i].getPoint(4), myPlayer.getColor().darker()));
}
}
/** Draw this Base onto GameViewer v, by using v's drawing methods.*/
public void draw(GameViewer v) {
vcgt.draw(v);
if(health > 0)
zol.draw(v);
}
public void addTo(GameViewer v) {
v.add(vcgt);
if(health > 0) {
for(ZListNode zln = zol.zNode; zln != null; zln = zln.getNext())
v.add(zln.getThing());
}
}
public void killGraphics() {
vcgt.kill();
for(ZListNode zln = zol.zNode; zln != null; zln = zol.zNode)
zln.getThing().kill();
}
/** Return the height of this Base for selection box and explosion hit calculations.
* @return The height of the Base in game-space units.
*/
public float getHeight() {
return 10.0f;
}
/** Return the width of this Base for selection box and explosion hit calculations.
* @return The width of the Base in game-space units.
*/
public float getWidth() {
return 25.0f;
}
/** Return the number of frames of animation for creation animation.
* The Base is pre-built before the game, so no creation animation.
* @return The number of frames of game-time needed to animate creation.
*/
protected int framesToMake() {
return 0;
}
/** Perform the data changes for one frame of animation while being made.
* The Base is pre-built before the game, so this method does nothing.
*/
protected void animateMake() {
}
/** Return the square of the maximum weapon range of this GameObject.
* Since the base has no weapons, it returns 0.
* @return The square of the weapons range in game-space units.
*/
public float weaponRangeSquared() {
return 0f;
}
/** Return the number of frames to wait between firing shots.
* Since the base has no weapons, it returns 0.
*/
public int weaponDelay() {
return 0;
}
/** Clear the current long-term goal. Since the base is immobile,
* it doesn't use the goal system.
*/
public void setGoal() {
}
/** Set the current long-term goal to a location, at hex coordinate
* (gx, gy). Since the base is immobile, it doesn't 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) {
}
/** Set the current long-term goal to a GameObject.
* Since the base is immobile, it doesn't use the goal system.
* @param u The GameObject which is the goal.
*/
public void setGoal(GameObject u) {
}
/** Makes adjustments if possible (for independent turrets) and returns
* true if the current target is within the firing arc (though it may
* be out of range to fire). For the Base, it returns false, because
* there is no weapon.
* @return True iff the target is within the firing arc.
*/
protected boolean aim() {
return false;
}
/** Performs the calculations for one frame of animation during the
* death sequence.
*/
protected void animateDie() {
if(frame == framesToDie()) {
ZListNode zln;
GraphicThing thing;
int i=0;
for(zln = zol.zNode; zln != null; zln = zln.getNext()) {
i++;
}
ZListNode zlna[] = new ZListNode[i];
i=0;
for(zln = zol.zNode; zln != null; zln = zln.getNext()) {
zlna[i++] = zln;
}
for(i=0;i<zlna.length;i++) {
thing = zlna[i].getThing();
thing.kill();
thing.explode(vr[0]);
}
}
frame--;
if(frame == 0) {
remove();
Hex.getHex(x,y).unreserve();
Hex.getHex(x-1,y).unreserve();
Hex.getHex(x-1,y+1).unreserve();
Hex.getHex(x,y+1).unreserve();
Hex.getHex(x,y+2).unreserve();
Hex.getHex(x+1,y+1).unreserve();
Hex.getHex(x+1,y+2).unreserve();
Hex.getHex(x,y).leave(this);
Hex.getHex(x-1,y+1).leave(this);
Hex.getHex(x-1,y+2).leave(this);
Hex.getHex(x,y+1).leave(this);
Hex.getHex(x,y+2).leave(this);
Hex.getHex(x+1,y+1).leave(this);
Hex.getHex(x+1,y+2).leave(this);
if(Player.EndGame()) {
if(!Player.getLocal().baseDead())
netwar.Netwar.netwar.victory();
else
netwar.Netwar.netwar.failure();
}
}
}
/** Returns the number of frames of animation for the death sequence.
* @return The number of frames needed to animate death.
*/
protected int framesToDie() {
return 50;
}
/** Return true if the object is not a valid target for attacks nor following.
* This is always true for indestructable obstacles.
* Otherwise, it is true only when the Unit/obstacle is destroyed.
* This is necessary to allow a GameObject to become completely dereferenced.
* @return True iff the unit is destroyed or it is both immobile and indestructable.
*/
public boolean isDead() {
return (health <= 0);
}
/** Return true if an explosion can possibly damage this object.
* @return True iff the object is damageable.
*/
public boolean damageable() {
return (health > 0);
}
/** Apply damage to this object. A GameObject can apply its own rules for
* taking damage. The 'standard' is to track a health integer, which is
* reduced by (dam - armor) for each hit, with a minimum loss of 1 per hit.
* @param dam The number of damage points to be inflicted.
*/
public void recieveDamage(int dam) {
if(dam < 1) return;
health -= (dam < ARMOR + 1) ? (1) : (dam - ARMOR);
if(health <= 0) {
action = 5;
frame = framesToDie();
}
}
public int getHealth() {
return health;
}
static final String[] PROPERTIES = {"Health", "Max Health", "Name", "Armor"};
protected String[] PROPERTIES() {
return PROPERTIES;
}
protected String getProperty(int p) {
switch(p) {
case 0:
return Integer.toString(health);
case 1:
return Integer.toString(MAXHEALTH);
case 2:
return NAME;
case 3:
return Integer.toString(ARMOR);
default:
Assert.notFalse(false, "getProperty(int) error.");
}
return null;
}
public float getStatusFraction() {
return (float) health / MAXHEALTH;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -