diff --git a/core/AssetManager.java b/core/AssetManager.java index 08d17d6..1de4a6c 100644 --- a/core/AssetManager.java +++ b/core/AssetManager.java @@ -230,9 +230,9 @@ public class AssetManager { //techCenter.rocketTankResearched_enemy = true; //}else { - //heavyTank l = new heavyTank(new vector(j*0.25f+ 1.125f,-0.3f, 22.125f - i*0.25f), 90, 1); + heavyTank l = new heavyTank(new vector(j*0.25f+ 1.125f,-0.3f, 22.125f - i*0.25f), 90, 1); - //addHeavyTank(l); + addHeavyTank(l); //} @@ -245,13 +245,13 @@ public class AssetManager { //harvester l = new harvester(new vector(i*0.25f+ 1.125f,-0.3f, 17.375f - 0.25f*j), 90, 0); //addHarvester(l); //l.hasMultiShotUpgrade = true; - //stealthTank l = new stealthTank(new vector(i*0.25f + 1.125f,-0.3f, 0.5f + 18.625f + j*0.25f), 90, 0); + lightTank l = new lightTank(new vector(i*0.25f + 1.125f,-0.3f, 0.5f + 18.625f + j*0.25f), 90, 0); //l.attackRange = 1.99f; //lightTank.tileCheckList_player = lightTank.generateTileCheckList(6); - //addStealthTank(l); + addLightTank(l); //if(j == 0 && i == 0) //addMissileTurret(new missileTurret(i*0.25f -0.125f + 1, -0.65f, 0.25f + 17.125f + j*0.25f, 0)); @@ -319,6 +319,10 @@ public class AssetManager { mainThread.gridMap.reset(); solidObject.globalUniqID = 0; + + postProcessingThread.reset(); + + System.gc(); } diff --git a/core/mainThread.java b/core/mainThread.java index 9ca1c4a..c77e4a6 100644 --- a/core/mainThread.java +++ b/core/mainThread.java @@ -59,7 +59,7 @@ public class mainThread extends JFrame implements KeyListener, ActionListener, M public static final int endGameMenu = 3; public static String timeString; - public static boolean fogOfWarDisabled; + public static boolean fogOfWarDisabled = false; public mainThread(){ setTitle("Battle Tank 3"); diff --git a/core/polygon3D.java b/core/polygon3D.java index 930db3f..e60c44a 100644 --- a/core/polygon3D.java +++ b/core/polygon3D.java @@ -16,7 +16,7 @@ public class polygon3D { public vector centre; //The number of vertex - public int L; + public byte L; //whether the polygon is completely bounded by the screen public boolean withinViewScreen; @@ -49,7 +49,7 @@ public class polygon3D { public solidObject parentObject; //A pool of vectors which will be used for vector arithmetic - public vector + public static vector tempVector1 = new vector(0,0,0), tempVector2 = new vector(0,0,0), tempVector3 = new vector(0,0,0), @@ -71,7 +71,7 @@ public class polygon3D { public int visibleCount; //type of the polygon - public int type; + public byte type; //the diffuse/ambient intensity of this polygon public int diffuse_I; @@ -89,10 +89,10 @@ public class polygon3D { public int color; //light map texture for this polygon - public int lightMapTextureIndex; + //public int lightMapTextureIndex; //max texel change rate in x direction; - public int max_dx = 512; + //public int max_dx = 512; //Whether origin, rightEnd and bottomEnd vectors match exactly the corners of the polygon public boolean textureFitPolygon; @@ -104,12 +104,12 @@ public class polygon3D { //Constuctor of the polygon class, it will only accept convex polygons public polygon3D(vector[] vertex3D, vector origin, vector rightEnd, vector bottomEnd, texture myTexture, float scaleX, float scaleY, int type){ - this.type = type; + this.type = (byte)type; this.vertex3D = vertex3D; this.myTexture = myTexture; this.scaleX = scaleX; this.scaleY = scaleY; - L = vertex3D.length; + L = (byte)vertex3D.length; diffuse_I = 31; shadowBias = 30000; diff --git a/core/postProcessingThread.java b/core/postProcessingThread.java index f801e66..a8c1d2b 100644 --- a/core/postProcessingThread.java +++ b/core/postProcessingThread.java @@ -187,6 +187,12 @@ public class postProcessingThread implements Runnable{ eyeDirection = new vector(0,0,0); } + public static void reset() { + theMiniMap.reset(); + } + + + public void run(){ if(frameIndex == 0) init(); @@ -413,6 +419,7 @@ public class postProcessingThread implements Runnable{ //draw health bar/Group info/unit level for every selected unit for(int i = 0; i < 100; i++){ + if(currentSelectedUnitsInfo[i][0] != -1){ ObjectType = (currentSelectedUnitsInfo[i][0] & 0xff); groupNo = ((currentSelectedUnitsInfo[i][0] & 0xff00) >> 8); @@ -425,7 +432,7 @@ public class postProcessingThread implements Runnable{ //draw group info if(groupNo != 255){ - theTextRenderer.drawText_outline(xPos, yPos + 3, ""+(groupNo+1), currentScreen, 0xffffff, 0); + theTextRenderer.drawText_outline(xPos, yPos + 3, String.valueOf(groupNo+1), currentScreen, 0xffffff, 0); } if(level != 0){ theTextRenderer.drawStarCharacter(xPos + healthBarLength - 13, yPos + 5, level, currentScreen, 0xffff33, 0); diff --git a/core/vector.java b/core/vector.java index 1cfa54f..df9a858 100644 --- a/core/vector.java +++ b/core/vector.java @@ -10,9 +10,9 @@ public final class vector{ //2d position on screen (from light point of view) public float screenX_lightspace, screenY_lightspace; - public final static int Z_length = 650; + public static final int Z_length = 650; - public final int orthogonalScale = 220; + public static final int orthogonalScale = 220; public static float old_X, old_Y, old_Z, zInverse, lengthInverse; diff --git a/enemyAI/harassmentAI.java b/enemyAI/harassmentAI.java index b5c38a0..48e610e 100644 --- a/enemyAI/harassmentAI.java +++ b/enemyAI/harassmentAI.java @@ -139,7 +139,7 @@ public class harassmentAI { for(int i = 0; i < squad.length; i++) { if(squad[i] != null && squad[i].currentHP > 0 ) { numberOfSquad++; - if(squad[i].secondaryDestinationX != gatherLocation.x || squad[i].secondaryDestinationY != gatherLocation.z || (squad[i].movement.x == 0 && squad[i].movement.z == 0 && squad[i].currentMovementStatus == solidObject.freeToMove)){ + if(squad[i].secondaryDestinationX != gatherLocation.x || squad[i].secondaryDestinationY != gatherLocation.z){ squad[i].attackMoveTo(gatherLocation.x,gatherLocation.z); squad[i].currentCommand = solidObject.attackMove; squad[i].secondaryCommand = solidObject.attackMove; @@ -214,10 +214,25 @@ public class harassmentAI { harassDirection.unit(); if(scout != null) { + + boolean squadIsUnderAttack = false; + for(int i = 0; i < squad.length; i++) { + if(squad[i] != null && squad[i].underAttackCountDown > 0) { + squadIsUnderAttack = true; + } + } + if(scout.underAttackCountDown > 0) + squadIsUnderAttack = true; - scout.moveTo(squadCenter.x + harassDirection.x*1.75f, squadCenter.z + harassDirection.z*1.75f); - scout.currentCommand = solidObject.move; - scout.secondaryCommand = solidObject.StandBy; + if(!squadIsUnderAttack) { + scout.moveTo(squadCenter.x + harassDirection.x*1.5f, squadCenter.z + harassDirection.z*1.5f); + scout.currentCommand = solidObject.move; + scout.secondaryCommand = solidObject.StandBy; + }else if(miniFrameAI%30 == 29){ + scout.attackMoveTo(squadCenter.x, squadCenter.z); + scout.currentCommand = solidObject.attackMove; + scout.secondaryCommand = solidObject.attackMove; + } } } diff --git a/entity/stealthTank.java b/entity/stealthTank.java index 303881e..8d6ad44 100644 --- a/entity/stealthTank.java +++ b/entity/stealthTank.java @@ -1309,14 +1309,14 @@ public class stealthTank extends solidObject{ myDamageModified = myDamage; if(secondaryTargets[i].type==0 || targetObject.type==1){ - myDamageModified=(int)(myDamage*3); + myDamageModified=(int)(myDamage*2); }else if(targetObject.type==6){ myDamageModified=(int)(myDamage*1.75); }else if(targetObject.type == 2 || targetObject.type == 3){ myDamageModified=(int)(myDamage*0.3); }else if(secondaryTargets[i].type == 7) { - myDamageModified=0; //heavy tank is immue to secondary attack + myDamageModified=(int)(myDamage*0.2); } diff --git a/gui/MiniMap.java b/gui/MiniMap.java index 61df425..515eb3b 100644 --- a/gui/MiniMap.java +++ b/gui/MiniMap.java @@ -1,5 +1,6 @@ package gui; +import core.gameData; import core.mainThread; import core.postProcessingThread; import core.vector; @@ -11,6 +12,8 @@ public class MiniMap { public boolean[][] bitmapVision; public static vector corner1, corner2, corner3, corner4; public static boolean isDrawingWindow; + public int[][] warningSigns; + public int[] warningSignLife; public void init(){ @@ -36,6 +39,14 @@ public class MiniMap { corner2 = new vector(0,0,0); corner3 = new vector(0,0,0); corner4 = new vector(0,0,0); + + warningSigns = new int[5][2]; + warningSignLife = new int[5]; + } + + public void reset() { + warningSigns = new int[5][2]; + warningSignLife = new int[5]; } @@ -57,11 +68,81 @@ public class MiniMap { //draw unit positions on minimap drawUnit(screen, minimapBitmap, unitsForMiniMap, unitsForMiniMapCount); + //draw warning signs + drawWarningSigns(screen); + //draw view window drawViewWindow(screen); } + public void drawWarningSigns(int[] screen) { + for(int i = 0; i < warningSignLife.length; i++) { + if(warningSignLife[i] > 0) { + warningSignLife[i]--; + + + //calculate the radius and angle base on the remining life in the warning sign + + int extenedR = (warningSignLife[i]- 325)*3; + if(extenedR < 0) + extenedR = 0; + float r = 12 + extenedR; + int angle = (warningSignLife[i]*6)%360; + + //calculate the coordinate of the 3 defining points of the warning sign + int centerX = warningSigns[i][0]; + int centerY = warningSigns[i][1]; + + int xPos1 = centerX + (int)(r*gameData.cos[angle]); + int yPos1 = centerY + (int)(r*gameData.sin[angle]); + + angle = (angle + 120)%360; + + int xPos2 = centerX + (int)(r*gameData.cos[angle]); + int yPos2 = centerY + (int)(r*gameData.sin[angle]); + + drawLine(xPos1, yPos1, xPos2,yPos2, screen, 0x660000); + + angle = (angle + 120)%360; + + int xPos3 = centerX + (int)(r*gameData.cos[angle]); + int yPos3 = centerY + (int)(r*gameData.sin[angle]); + + drawLine(xPos3, yPos3, xPos2,yPos2, screen, 0x660000); + + drawLine(xPos3, yPos3, xPos1,yPos1, screen, 0x660000); + } + } + } + + public void spawnWarningSign(int xPos, int yPos) { + boolean closeToExisingWarningSign = false; + for(int j = 0; j < warningSigns.length; j++) { + if(warningSignLife[j] > 0) { + //check if the spawn location is too lose to exisiting + int x = warningSigns[j][0]; + int y = warningSigns[j][1]; + double d = Math.sqrt((x - xPos)*(x - xPos) + (y - yPos)*(y - yPos)); + if(d < 10) { + closeToExisingWarningSign = true; + break; + } + } + } + + if(!closeToExisingWarningSign) { + for(int i = 0; i < warningSigns.length; i++) { + if(warningSignLife[i] == 0) { + warningSigns[i][0] = xPos; + warningSigns[i][1] = yPos; + warningSignLife[i] = 350; + break; + } + } + } + } + public void drawViewWindow(int[] screen){ int xPos1, xPos2, xPos3,xPos4, yPos1, yPos2, yPos3, yPos4; @@ -76,14 +157,10 @@ public class MiniMap { yPos4 = 127 - (int)(corner4.z*64/16); - drawLine(xPos1+1, yPos1, xPos2-1,yPos2, screen); - drawLine(xPos2, yPos2, xPos3,yPos3, screen); - drawLine(xPos3-1, yPos3, xPos4+1,yPos4, screen); - drawLine(xPos4, yPos4, xPos1,yPos1, screen); - - - - + drawLine(xPos1+1, yPos1, xPos2-1,yPos2, screen, 0xbfbfbf); + drawLine(xPos2, yPos2, xPos3,yPos3, screen, 0xbfbfbf); + drawLine(xPos3-1, yPos3, xPos4+1,yPos4, screen, 0xbfbfbf); + drawLine(xPos4, yPos4, xPos1,yPos1, screen, 0xbfbfbf); } public void findCorners(){ @@ -95,7 +172,7 @@ public class MiniMap { } - public void drawLine(int xPos1, int yPos1, int xPos2, int yPos2, int[] screen){ + public void drawLine(int xPos1, int yPos1, int xPos2, int yPos2, int[] screen, int lineColor){ int start = 381 * 768 + 3; int x, y; int xDirection, yDirection; @@ -121,7 +198,7 @@ public class MiniMap { if(x < 0 || x > 127 || y < 0 || y > 127) continue; color = screen[start + x + y*768]; - screen[start + x + y*768] = ((((color&0xFEFEFE)>>1)&0xFEFEFE)>>1) + 0xbfbfbf; + screen[start + x + y*768] = ((((color&0xFEFEFE)>>1)&0xFEFEFE)>>1) + lineColor; } }else{ @@ -133,7 +210,7 @@ public class MiniMap { if(x < 0 || x > 127 || y < 0 || y > 127) continue; color = screen[start + x + y*768]; - screen[start + x + y*768] = ((((color&0xFEFEFE)>>1)&0xFEFEFE)>>1) + 0xbfbfbf; + screen[start + x + y*768] = ((((color&0xFEFEFE)>>1)&0xFEFEFE)>>1) + lineColor; } } @@ -172,6 +249,7 @@ public class MiniMap { color = friendlyUnitColor; if(unitsForMiniMap[i][4] == 10001){ color = underAttackColor; + spawnWarningSign(xPos, yPos); } if((screen[index]>>24) == 0)