home
This commit is contained in:
parent
238d8a4697
commit
c0874fed60
@ -251,8 +251,8 @@ public class AssetManager {
|
|||||||
for(int i = 0; i < 10; i ++){
|
for(int i = 0; i < 10; i ++){
|
||||||
|
|
||||||
for(int j = 0; j < 6; j++){
|
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);
|
lightTank l = new lightTank(new vector(i*0.25f+ 1.125f,-0.3f, 17.375f - 0.25f*j), 90, 0);
|
||||||
//addLightTank(l);
|
addLightTank(l);
|
||||||
//l.hasMultiShotUpgrade = true;
|
//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);
|
//lightTank l = new lightTank(new vector(i*0.25f + 1.125f,-0.3f, 0.5f + 18.625f + j*0.25f), 90, 0);
|
||||||
|
|
||||||
|
@ -493,7 +493,7 @@ public class mainThread extends JFrame implements KeyListener, ActionListener, M
|
|||||||
lastTime = thisTime;
|
lastTime = thisTime;
|
||||||
}
|
}
|
||||||
sleepTime = 0;
|
sleepTime = 0;
|
||||||
/*while(System.currentTimeMillis()-lastDraw<frameInterval){
|
while(System.currentTimeMillis()-lastDraw<frameInterval){
|
||||||
try {
|
try {
|
||||||
Thread.sleep(1);
|
Thread.sleep(1);
|
||||||
sleepTime++;
|
sleepTime++;
|
||||||
@ -501,7 +501,7 @@ public class mainThread extends JFrame implements KeyListener, ActionListener, M
|
|||||||
// TODO Auto-generated catch block
|
// TODO Auto-generated catch block
|
||||||
e1.printStackTrace();
|
e1.printStackTrace();
|
||||||
}
|
}
|
||||||
}*/
|
}
|
||||||
lastDraw=System.currentTimeMillis();
|
lastDraw=System.currentTimeMillis();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -362,7 +362,7 @@ public class combatManagerAI {
|
|||||||
staticDefenseAhead = false;
|
staticDefenseAhead = false;
|
||||||
for(int i = 0; i < mainThread.ec.theMapAwarenessAI.playerStaticDefenseLocations.length; i++) {
|
for(int i = 0; i < mainThread.ec.theMapAwarenessAI.playerStaticDefenseLocations.length; i++) {
|
||||||
if(mainThread.ec.theMapAwarenessAI.playerStaticDefenseSize[i] > 0) {
|
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 xPos = mainThread.ec.theMapAwarenessAI.playerStaticDefenseLocations[i].x;
|
||||||
float zPos = mainThread.ec.theMapAwarenessAI.playerStaticDefenseLocations[i].z;
|
float zPos = mainThread.ec.theMapAwarenessAI.playerStaticDefenseLocations[i].z;
|
||||||
float d = (xPos - combatCenterX)*(xPos - combatCenterX) + (zPos - combatCenterZ)*(zPos - combatCenterZ);
|
float d = (xPos - combatCenterX)*(xPos - combatCenterX) + (zPos - combatCenterZ)*(zPos - combatCenterZ);
|
||||||
|
@ -6,6 +6,7 @@ import core.vector;
|
|||||||
import entity.lightTank;
|
import entity.lightTank;
|
||||||
import entity.solidObject;
|
import entity.solidObject;
|
||||||
import entity.stealthTank;
|
import entity.stealthTank;
|
||||||
|
import entity.constructionYard;
|
||||||
|
|
||||||
public class defenseManagerAI {
|
public class defenseManagerAI {
|
||||||
public baseInfo theBaseInfo;
|
public baseInfo theBaseInfo;
|
||||||
@ -32,6 +33,9 @@ public class defenseManagerAI {
|
|||||||
public vector majorThreatLocation;
|
public vector majorThreatLocation;
|
||||||
public int majorThreatCooldown;
|
public int majorThreatCooldown;
|
||||||
|
|
||||||
|
public vector gunTurretDeployLocation;
|
||||||
|
public vector missileTurretDeployLocation;
|
||||||
|
|
||||||
|
|
||||||
public defenseManagerAI(baseInfo theBaseInfo){
|
public defenseManagerAI(baseInfo theBaseInfo){
|
||||||
this.theBaseInfo = theBaseInfo;
|
this.theBaseInfo = theBaseInfo;
|
||||||
@ -46,6 +50,9 @@ public class defenseManagerAI {
|
|||||||
minorThreatLocation = new vector(0,0,0);
|
minorThreatLocation = new vector(0,0,0);
|
||||||
majorThreatLocation = new vector(0,0,0);
|
majorThreatLocation = new vector(0,0,0);
|
||||||
majorThreatCooldown = 20;
|
majorThreatCooldown = 20;
|
||||||
|
|
||||||
|
gunTurretDeployLocation = new vector(0,0,0);
|
||||||
|
missileTurretDeployLocation = new vector(0,0,0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -266,13 +273,50 @@ public class defenseManagerAI {
|
|||||||
2. there are threat detected and there is no other missile turret being constructed at the same time
|
2. there are threat detected and there is no other missile turret being constructed at the same time
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//check if AI needs to deploy static defense
|
//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
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -73,8 +73,6 @@ public class unitProductionAI {
|
|||||||
public void processAI(){
|
public void processAI(){
|
||||||
frameAI++;
|
frameAI++;
|
||||||
|
|
||||||
System.out.println(frameAI);
|
|
||||||
|
|
||||||
//set the rally point to near the construction yard which is closest to the AI player's starting position
|
//set the rally point to near the construction yard which is closest to the AI player's starting position
|
||||||
float x = 0;
|
float x = 0;
|
||||||
float z = 999999;
|
float z = 999999;
|
||||||
|
@ -109,6 +109,7 @@ public class bullet {
|
|||||||
movement.unit();
|
movement.unit();
|
||||||
movement.scale(speed + distanceToTarget);
|
movement.scale(speed + distanceToTarget);
|
||||||
target.currentHP -=damage;
|
target.currentHP -=damage;
|
||||||
|
int previousUnderAttackCountDown = target.underAttackCountDown;
|
||||||
target.underAttackCountDown = 120;
|
target.underAttackCountDown = 120;
|
||||||
target.attacker = attacker;
|
target.attacker = attacker;
|
||||||
|
|
||||||
@ -126,10 +127,10 @@ public class bullet {
|
|||||||
for(int j = 0; j < 4; j++){
|
for(int j = 0; j < 4; j++){
|
||||||
if(tile[j] != null){
|
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
|
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){
|
if(tile[j].type < 100){
|
||||||
tile[j].attack(attacker);
|
tile[j].attack(attacker);
|
||||||
tile[j].currentCommand = solidObject.attackInNumbers;
|
tile[j].currentCommand = solidObject.attackCautiously;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user