This commit is contained in:
Pan 2019-02-25 14:05:58 +13:00
parent 238d8a4697
commit c0874fed60
6 changed files with 54 additions and 11 deletions

View File

@ -251,8 +251,8 @@ public class AssetManager {
for(int i = 0; i < 10; i ++){
for(int j = 0; j < 6; j++){
//lightTank l = new lightTank(new vector(i*0.25f+ 1.125f,-0.3f, 17.375f - 0.25f*j), 90, 0);
//addLightTank(l);
lightTank l = new lightTank(new vector(i*0.25f+ 1.125f,-0.3f, 17.375f - 0.25f*j), 90, 0);
addLightTank(l);
//l.hasMultiShotUpgrade = true;
//lightTank l = new lightTank(new vector(i*0.25f + 1.125f,-0.3f, 0.5f + 18.625f + j*0.25f), 90, 0);

View File

@ -493,7 +493,7 @@ public class mainThread extends JFrame implements KeyListener, ActionListener, M
lastTime = thisTime;
}
sleepTime = 0;
/*while(System.currentTimeMillis()-lastDraw<frameInterval){
while(System.currentTimeMillis()-lastDraw<frameInterval){
try {
Thread.sleep(1);
sleepTime++;
@ -501,7 +501,7 @@ public class mainThread extends JFrame implements KeyListener, ActionListener, M
// TODO Auto-generated catch block
e1.printStackTrace();
}
}*/
}
lastDraw=System.currentTimeMillis();
}

View File

@ -362,7 +362,7 @@ public class combatManagerAI {
staticDefenseAhead = false;
for(int i = 0; i < mainThread.ec.theMapAwarenessAI.playerStaticDefenseLocations.length; i++) {
if(mainThread.ec.theMapAwarenessAI.playerStaticDefenseSize[i] > 0) {
if(mainThread.ec.theMapAwarenessAI.playerStaticDefenseStrength[i] > 5) {
if(mainThread.ec.theMapAwarenessAI.playerStaticDefenseStrength[i] > 6) {
float xPos = mainThread.ec.theMapAwarenessAI.playerStaticDefenseLocations[i].x;
float zPos = mainThread.ec.theMapAwarenessAI.playerStaticDefenseLocations[i].z;
float d = (xPos - combatCenterX)*(xPos - combatCenterX) + (zPos - combatCenterZ)*(zPos - combatCenterZ);

View File

@ -6,6 +6,7 @@ import core.vector;
import entity.lightTank;
import entity.solidObject;
import entity.stealthTank;
import entity.constructionYard;
public class defenseManagerAI {
public baseInfo theBaseInfo;
@ -32,6 +33,9 @@ public class defenseManagerAI {
public vector majorThreatLocation;
public int majorThreatCooldown;
public vector gunTurretDeployLocation;
public vector missileTurretDeployLocation;
public defenseManagerAI(baseInfo theBaseInfo){
this.theBaseInfo = theBaseInfo;
@ -46,6 +50,9 @@ public class defenseManagerAI {
minorThreatLocation = new vector(0,0,0);
majorThreatLocation = new vector(0,0,0);
majorThreatCooldown = 20;
gunTurretDeployLocation = new vector(0,0,0);
missileTurretDeployLocation = new vector(0,0,0);
}
@ -268,11 +275,48 @@ public class defenseManagerAI {
//check if AI needs to deploy static defense
/*
Deploy gun turret if the threat location if
Deploy gun turret if the minor/major threat is close enough to the construction yard
*/
solidObject[] AIStructures = mainThread.ec.theMapAwarenessAI.AIStructures;
gunTurretDeployLocation.reset();
missileTurretDeployLocation.reset();
constructionYard[] constructionYards = mainThread.theAssetManager.constructionYards;
for(int i = 0; i < constructionYards.length; i++){
if(constructionYards[i] != null && constructionYards[i].teamNo != 0 && constructionYards[i].currentHP >0) {
float distanceToThreat = 999f;
float threatX = 0;
float threatZ = 0;
if(minorThreatLocation.x !=0) {
distanceToThreat = (float)Math.sqrt((minorThreatLocation.x-constructionYards[i].centre.x)*(minorThreatLocation.x-constructionYards[i].centre.x) +
(minorThreatLocation.z-constructionYards[i].centre.z)*(minorThreatLocation.z-constructionYards[i].centre.z));
threatX = minorThreatLocation.x;
threatZ = minorThreatLocation.z;
}
if(majorThreatLocation.x !=0) {
distanceToThreat = (float)Math.sqrt((majorThreatLocation.x-constructionYards[i].centre.x)*(majorThreatLocation.x-constructionYards[i].centre.x) +
(majorThreatLocation.z-constructionYards[i].centre.z)*(majorThreatLocation.z-constructionYards[i].centre.z));
threatX = majorThreatLocation.x;
threatZ = majorThreatLocation.z;
}
//find deploy location of gun turret
if(threatX != 0 && distanceToThreat < 4.25) {
//check the number of gun turrets that are already deployed near the threat location
}
}
}
}

View File

@ -73,8 +73,6 @@ public class unitProductionAI {
public void processAI(){
frameAI++;
System.out.println(frameAI);
//set the rally point to near the construction yard which is closest to the AI player's starting position
float x = 0;
float z = 999999;

View File

@ -109,6 +109,7 @@ public class bullet {
movement.unit();
movement.scale(speed + distanceToTarget);
target.currentHP -=damage;
int previousUnderAttackCountDown = target.underAttackCountDown;
target.underAttackCountDown = 120;
target.attacker = attacker;
@ -126,10 +127,10 @@ public class bullet {
for(int j = 0; j < 4; j++){
if(tile[j] != null){
if(tile[j].teamNo == targetTeamNo && tile[j].teamNo!= attacker.teamNo && tile[j].attackStatus != solidObject.isAttacking && tile[j].currentCommand != solidObject.move && tile[j].isCloaked == false
&& tile[j].currentCommand != solidObject.attackCautiously && tile[j].currentCommand != solidObject.attackInNumbers){
&& previousUnderAttackCountDown <=30 && (tile[j].currentCommand == solidObject.StandBy || tile[j].secondaryCommand == solidObject.attackMove)){
if(tile[j].type < 100){
tile[j].attack(attacker);
tile[j].currentCommand = solidObject.attackInNumbers;
tile[j].currentCommand = solidObject.attackCautiously;
}
}