|
|
@ -93,7 +93,7 @@ void FaceBall::InitializeEnemyData() { |
|
|
|
enemyData[EXIT] = { "EXIT",undefined,GREEN }; |
|
|
|
enemyData[EXIT] = { "EXIT",undefined,GREEN }; |
|
|
|
enemyData[START] = { "SPAWN POSITION",undefined,{128,64,0} }; |
|
|
|
enemyData[START] = { "SPAWN POSITION",undefined,{128,64,0} }; |
|
|
|
enemyData[SHOOTME] = { "SHOOTME",enemy_ShootMe,YELLOW,1,1,PI / 8,2,1 }; |
|
|
|
enemyData[SHOOTME] = { "SHOOTME",enemy_ShootMe,YELLOW,1,1,PI / 8,2,1 }; |
|
|
|
enemyData[ISHOOT] = { "ISHOOT",enemy_IShoot,YELLOW,1,1,PI / 6,2,1,0.4f }; |
|
|
|
enemyData[SHOOTME2] = { "SHOOTME2",enemy_IShoot,YELLOW,1,1,PI / 6,2,1,0.5f }; |
|
|
|
enemyData[SONAR] = { "Sonar",enemy_Sonar,RED,5,1,PI / 8,2,1 }; |
|
|
|
enemyData[SONAR] = { "Sonar",enemy_Sonar,RED,5,1,PI / 8,2,1 }; |
|
|
|
enemyData[COIN] = { "Coin",undefined,BLUE }; |
|
|
|
enemyData[COIN] = { "Coin",undefined,BLUE }; |
|
|
|
enemyData[POWERUP_ARMOR] = { "Armor",undefined,{96,0,96} }; |
|
|
|
enemyData[POWERUP_ARMOR] = { "Armor",undefined,{96,0,96} }; |
|
|
@ -1532,12 +1532,38 @@ void FaceBall::RunEnemyAI(Enemy& e,float fElapsedTime,int myIndex) { |
|
|
|
case SHOOTME: { |
|
|
|
case SHOOTME: { |
|
|
|
e.rot += 0.5 * fElapsedTime; |
|
|
|
e.rot += 0.5 * fElapsedTime; |
|
|
|
}break; |
|
|
|
}break; |
|
|
|
case ISHOOT: { |
|
|
|
case SHOOTME2: { |
|
|
|
switch (e.GetPhase()) { |
|
|
|
switch (e.GetPhase()) { |
|
|
|
case Phase::DEFAULT: { |
|
|
|
case Phase::DEFAULT: { |
|
|
|
vf2d movementVec = {std::cosf(e.rot) * dat.movSpd * fElapsedTime,std::sinf(e.rot) * dat.movSpd * fElapsedTime }; |
|
|
|
vf2d movementVec = { std::cosf(e.rot) * dat.movSpd * fElapsedTime,std::sinf(e.rot) * dat.movSpd * fElapsedTime }; |
|
|
|
if (-1==CheckEnemyCollision({ movementVec.x,0,movementVec.y },{e.pos.x,e.pos.z},e.radius,myIndex)&& |
|
|
|
if (-1 == CheckEnemyCollision({ movementVec.x,0,movementVec.y }, { e.pos.x,e.pos.z }, e.radius, myIndex) && |
|
|
|
!CheckCollision({movementVec.x,0,movementVec.y},{e.pos.x,e.pos.z}, e.radius)) { |
|
|
|
!CheckCollision({ movementVec.x,0,movementVec.y }, { e.pos.x,e.pos.z }, e.radius)) { |
|
|
|
|
|
|
|
e.pos.x += movementVec.x; |
|
|
|
|
|
|
|
e.pos.z += movementVec.y; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else { |
|
|
|
|
|
|
|
e.SetPhase(Phase::TURNING); |
|
|
|
|
|
|
|
e.turnAmt = PI; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}break; |
|
|
|
|
|
|
|
case Phase::TURNING: { |
|
|
|
|
|
|
|
if (e.turnAmt > 0) { |
|
|
|
|
|
|
|
float rotAmt = std::min(e.turnAmt, dat.rotSpd * fElapsedTime); |
|
|
|
|
|
|
|
e.turnAmt -= rotAmt; |
|
|
|
|
|
|
|
e.rot += rotAmt; |
|
|
|
|
|
|
|
if (e.turnAmt <= 0) { |
|
|
|
|
|
|
|
e.SetPhase(Phase::DEFAULT); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}break; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}break; |
|
|
|
|
|
|
|
case ISHOOT2: { |
|
|
|
|
|
|
|
switch (e.GetPhase()) { |
|
|
|
|
|
|
|
case Phase::DEFAULT: { |
|
|
|
|
|
|
|
vf2d movementVec = { std::cosf(e.rot) * dat.movSpd * fElapsedTime,std::sinf(e.rot) * dat.movSpd * fElapsedTime }; |
|
|
|
|
|
|
|
if (-1 == CheckEnemyCollision({ movementVec.x,0,movementVec.y }, { e.pos.x,e.pos.z }, e.radius, myIndex) && |
|
|
|
|
|
|
|
!CheckCollision({ movementVec.x,0,movementVec.y }, { e.pos.x,e.pos.z }, e.radius)) { |
|
|
|
e.pos.x += movementVec.x; |
|
|
|
e.pos.x += movementVec.x; |
|
|
|
e.pos.z += movementVec.y; |
|
|
|
e.pos.z += movementVec.y; |
|
|
|
if (e.CanShoot()) { |
|
|
|
if (e.CanShoot()) { |
|
|
@ -1551,7 +1577,7 @@ void FaceBall::RunEnemyAI(Enemy& e,float fElapsedTime,int myIndex) { |
|
|
|
}break; |
|
|
|
}break; |
|
|
|
case Phase::TURNING: { |
|
|
|
case Phase::TURNING: { |
|
|
|
if (e.turnAmt > 0) { |
|
|
|
if (e.turnAmt > 0) { |
|
|
|
float rotAmt = std::min(e.turnAmt,dat.rotSpd * fElapsedTime); |
|
|
|
float rotAmt = std::min(e.turnAmt, dat.rotSpd * fElapsedTime); |
|
|
|
e.turnAmt -= rotAmt; |
|
|
|
e.turnAmt -= rotAmt; |
|
|
|
e.rot += rotAmt; |
|
|
|
e.rot += rotAmt; |
|
|
|
if (e.turnAmt <= 0) { |
|
|
|
if (e.turnAmt <= 0) { |
|
|
|