commit from work

This commit is contained in:
Pan Hu 2019-01-15 18:03:26 +13:00
parent 44511cf577
commit 0198d3c2a6
5 changed files with 61 additions and 16 deletions

View File

@ -251,8 +251,8 @@ public class AssetManager {
for(int i = 0; i < 10; i ++){
for(int j = 0; j < 6; j++){
//heavyTank l = new heavyTank(new vector(i*0.25f+ 1.125f,-0.3f, 17.375f - 0.25f*j), 90, 0);
//addHeavyTank(l);
heavyTank l = new heavyTank(new vector(i*0.25f+ 1.125f,-0.3f, 17.375f - 0.25f*j), 90, 0);
addHeavyTank(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

@ -21,6 +21,7 @@ public class defenseManagerAI {
public solidObject[] stealthTanksControlledByCombatAI;
public solidObject[] defenders;
public int numOfDefenders;
public vector direction;
@ -125,12 +126,53 @@ public class defenseManagerAI {
minorThreatLocation.reset();
majorThreatLocation.reset();
// if the size of the player unit cluster is less than 5, and no heavy tanks in the cluster, then borrow some unites from combatAI to deal with the threat
//if(mainPlayerForceSize < 5 && playerForceContainsNoHeavyTank(mainPlayerForceLocation) && playerForceIsNearBase(mainPlayerForceLocation)) {
//}
System.out.println(playerForceContainsNoHeavyTank(mainPlayerForceLocation));
}
public boolean playerForceIsNearBase(vector location) {
return false;
}
public boolean playerForceContainsNoHeavyTank(vector location) {
solidObject o = null;
for(int i = 0; i < mainThread.ec.theMapAwarenessAI.playerUnitInMinimap.length; i++) {
o = mainThread.ec.theMapAwarenessAI.playerUnitInMinimap[i];
if(o !=null && o.currentHP > 0 && o.type == 7 && (o.centre.x - location.x)*(o.centre.x - location.x) + (o.centre.z - location.z)*(o.centre.z - location.z) < 4)
return false;
}
return true;
}
public void addUnitToDefenders(solidObject o) {
numOfDefenders = 0;
for(int i = 0; i < defenders.length; i++) {
if(defenders[i] != null && defenders[i].currentHP > 0)
numOfDefenders++;
}
if(numOfDefenders == defenders.length && minorThreatLocation.x == 0) {
for(int i = defenders.length - 1; i > 0; i--)
defenders[i] = defenders[i - 1];
defenders[0] = o;
}else {
for(int i = 0; i < defenders.length; i++) {
if(defenders[i] == null || defenders[i].currentHP <= 0) {
defenders[i] = o;
break;
}
}
}
}

View File

@ -545,12 +545,7 @@ public class mapAwarenessAI {
playerForceDirections[i].set(0,0,0);
playerForceSize[i] = 0;
}
if(numberOfPlayerUnitsOnMinimap < 5)
return;
for(int i = 0; i < playerUnitInMinimap.length; i++) {
if(playerUnitInMinimap[i] == null)
continue;

View File

@ -164,8 +164,17 @@ public class scoutingManagerAI {
}
if(scout.type == 0)
if(scout.type == 0) {
if(mainThread.ec.theDefenseManagerAI.minorThreatLocation.x != 0 || mainThread.ec.theDefenseManagerAI.majorThreatLocation.x != 0) {
if(scout.currentHP > 0) {
mainThread.ec.theUnitProductionAI.addLightTank((lightTank)scout);
scout.moveTo(mainThread.ec.theUnitProductionAI.rallyPoint.x, mainThread.ec.theUnitProductionAI.rallyPoint.z);
scout.currentCommand = solidObject.attackMove;
scout.secondaryCommand = solidObject.attackMove;
}
}
return;
}
//try to avoid collision with player units
int xPos_old = scout.boundary2D.x1;
@ -221,9 +230,6 @@ public class scoutingManagerAI {
scout.boundary2D.setOrigin(xPos_old, yPos_old);
}
}
@ -304,9 +310,9 @@ public class scoutingManagerAI {
//build light tank as scout when stealth tank tech is locked
public boolean needLightTank(){
//if((scout == null ) && !theBaseInfo.canBuildStealthTank){
// return true;
//}
if((scout == null ) && !theBaseInfo.canBuildStealthTank && mainThread.ec.theDefenseManagerAI.minorThreatLocation.x == 0 && mainThread.ec.theDefenseManagerAI.majorThreatLocation.x == 0){
return true;
}
return false;
}

View File

@ -253,6 +253,7 @@ public class unitProductionAI {
if(lightTanksControlledByCombatAI[i] == null || (lightTanksControlledByCombatAI[i] != null && lightTanksControlledByCombatAI[i].currentHP <=0)){
lightTanksControlledByCombatAI[i] = o;
unitProduced++;
mainThread.ec.theDefenseManagerAI.addUnitToDefenders(o);
break;
}
}
@ -293,6 +294,7 @@ public class unitProductionAI {
if(stealthTanksControlledByCombatAI[i] == null || (stealthTanksControlledByCombatAI[i] != null && stealthTanksControlledByCombatAI[i].currentHP <=0)){
stealthTanksControlledByCombatAI[i] = o;
unitProduced++;
mainThread.ec.theDefenseManagerAI.addUnitToDefenders(o);
break;
}
}