From 8b6ad1af8680bb5939c6e780f36d6f106c4a1e8b Mon Sep 17 00:00:00 2001 From: Pan Date: Mon, 1 Apr 2019 21:27:00 +1300 Subject: [PATCH] home commit --- core/mainThread.java | 51 +++++++++---------- core/postProcessingThread.java | 4 +- enemyAI/baseExpensionAI.java | 25 +++++++--- enemyAI/scoutingManagerAI.java | 9 ++-- gui/gameMenu.java | 86 ++++++++++++++++++++++++++++----- images/time.png | Bin 0 -> 492 bytes 6 files changed, 126 insertions(+), 49 deletions(-) create mode 100644 images/time.png diff --git a/core/mainThread.java b/core/mainThread.java index 490175a..66be6cb 100644 --- a/core/mainThread.java +++ b/core/mainThread.java @@ -104,33 +104,6 @@ public class mainThread extends JFrame implements KeyListener, ActionListener, M } - //create camera - Camera = new camera(new vector(3,2f,-1.25f), 0, 300); - - //Create look up tables - gameData.makeData(); - - //init grid - gridMap = new grid(128); - - //init light source - sunLight.init(); - - //init rasterizer - rasterizer.init(); - - //init 2d to 3d factory - my2Dto3DFactory = new Turn2DTo3DFactory(); - my2Dto3DFactory.init(); - - loadTexture(); - - //init post processing thread - postProcessingThread.init(); - - theAssetManager = new AssetManager(); - theAssetManager.init(); - frameIndex = 0; frameInterval = 33; lastDraw = 0; @@ -172,7 +145,31 @@ public class mainThread extends JFrame implements KeyListener, ActionListener, M //thread is always lag the main thread by 1 frame. However it is barely noticeable. public void actionPerformed(ActionEvent e){ + if(frameIndex == 0) { + //create camera + Camera = new camera(new vector(3,2f,-1.25f), 0, 300); + //Create look up tables + gameData.makeData(); + + //init grid + gridMap = new grid(128); + + //init light source + sunLight.init(); + + //init rasterizer + rasterizer.init(); + + //init 2d to 3d factory + my2Dto3DFactory = new Turn2DTo3DFactory(); + my2Dto3DFactory.init(); + + loadTexture(); + + theAssetManager = new AssetManager(); + theAssetManager.init(); + } frameIndex++; diff --git a/core/postProcessingThread.java b/core/postProcessingThread.java index 8eed649..d722fff 100644 --- a/core/postProcessingThread.java +++ b/core/postProcessingThread.java @@ -188,7 +188,9 @@ public class postProcessingThread implements Runnable{ } public void run(){ - + if(frameIndex == 0) + init(); + while(true){ synchronized (this) { try { diff --git a/enemyAI/baseExpensionAI.java b/enemyAI/baseExpensionAI.java index 37ce303..7f1757b 100644 --- a/enemyAI/baseExpensionAI.java +++ b/enemyAI/baseExpensionAI.java @@ -20,8 +20,8 @@ public class baseExpensionAI { public int numberOfStealthTankScout; public int frameAI; public vector temp; - - + public boolean allExpansionOccupied; + public int lastExpansionLocation; public baseExpensionAI(baseInfo theBaseInfo){ this.theBaseInfo = theBaseInfo; @@ -48,7 +48,7 @@ public class baseExpensionAI { scouts = new stealthTank[3]; - + lastExpansionLocation = 7; } @@ -56,6 +56,10 @@ public class baseExpensionAI { frameAI++; + //when all the expansion position has been utilized then do nothing + if(allExpansionOccupied) + return; + if(frameAI > 750 && frameAI < 1000 && !expensionListRerolled) { //if the AI has smaller force than player when it's time to grab a third base, use the less aggressive base expansion route if(mainThread.ec.theCombatManagerAI.checkIfAIHasBiggerForce(1) == false) { @@ -80,11 +84,9 @@ public class baseExpensionAI { } } + expensionGoldMine = goldMines[expensionPiorityList[targetExpension]]; - - - //produce a total of 3 scout units, check if there are any stealth tank in the production numberOfActiveScout = 0; numberOfStealthTankScout = 0; @@ -205,6 +207,17 @@ public class baseExpensionAI { //change the preferred gold mine to the one near the new expension once MCV is deployed if(myMCV.getDistance(expensionGoldMine) < 2 && myMCV.getDistance(expensionGoldMine) > 0.75 && myMCV.canBeDeployed()){ + if(expensionPiorityList[targetExpension] == lastExpansionLocation) { + allExpansionOccupied = true; + for(int i = 0; i < scouts.length; i++){ + if(scouts[i] != null && scouts[i].currentHP >0){ + mainThread.ec.theUnitProductionAI.addStealthTank((stealthTank)scouts[i]); + scouts[i].moveTo(mainThread.ec.theUnitProductionAI.rallyPoint.x, mainThread.ec.theUnitProductionAI.rallyPoint.z); + scouts[i].currentCommand = solidObject.attackMove; + scouts[i].secondaryCommand = solidObject.attackMove; + } + } + } myMCV.expand(); mainThread.ec.theEconomyManagerAI.preferedGoldMine = expensionGoldMine; } diff --git a/enemyAI/scoutingManagerAI.java b/enemyAI/scoutingManagerAI.java index 2f904fa..e501832 100644 --- a/enemyAI/scoutingManagerAI.java +++ b/enemyAI/scoutingManagerAI.java @@ -40,7 +40,7 @@ public class scoutingManagerAI { }; exploringNodes = new float[][]{ - {9, 3.5f}, {2,2}, {14, 14} + {8f, 3f}, {2,2}, {14, 14} }; destinationNode = 0; @@ -58,7 +58,8 @@ public class scoutingManagerAI { if(avoidingIncomingPlayerUnitCooldown > 0) avoidingIncomingPlayerUnitCooldown--; - if(gameTime%275 > 235 && gameTime%275 < 275 && gameTime < 600 && scoutingMode == patrolling){ + boolean scoutIsLightTank = scout != null && scout.type == 0; + if((gameTime%275 > 235 && gameTime%275 < 275 && !scoutIsLightTank) && gameTime < 600 && scoutingMode == patrolling || (scoutIsLightTank && gameTime < 240)){ scoutingMode = exploring; destinationNode = 0; movementOrderIssued = false; @@ -319,7 +320,7 @@ public class scoutingManagerAI { public boolean needStealthTank(){ if(theBaseInfo.canBuildStealthTank){ - if(scout == null || scout.currentHP <= 0 || scout.type != 6){ + if((scout == null || scout.currentHP <= 0 || scout.type != 6) && gameTime > 280){ return true; } } @@ -337,7 +338,7 @@ public class scoutingManagerAI { scout.currentCommand = solidObject.attackMove; scout.secondaryCommand = solidObject.attackMove; } - + destinationNode = 0; scout = o; movementOrderIssued = false; } diff --git a/gui/gameMenu.java b/gui/gameMenu.java index 3d3eb05..1e6625c 100644 --- a/gui/gameMenu.java +++ b/gui/gameMenu.java @@ -21,24 +21,36 @@ public class gameMenu { public String imageFolder = ""; - public int[] titleImage; + public int[] titleImage, lightTankImage, rocketTankImage, stealthTankImage, heavyTankImage; public button newGame, unpauseGame, showHelp, quitGame, abortGame, easyGame, normalGame, hardGame, quitDifficulty, quitHelpMenu, nextPage, previousPage; - public char[] easyDescription, normalDescription, hardDescription, helpPage1; + public char[] easyDescription, normalDescription, hardDescription, helpPage1, helpPage2, helpPage3; public int currentHelpPage; public ArrayList