Wave management added.
This commit is contained in:
parent
d4e37b6179
commit
8978130bd8
@ -1,44 +1,44 @@
|
||||
7
|
||||
6
|
||||
32777
|
||||
32778
|
||||
41369
|
||||
41514
|
||||
8202
|
||||
8728
|
||||
24584
|
||||
8200
|
||||
16792
|
||||
9160
|
||||
8204
|
||||
40965
|
||||
57753
|
||||
24584
|
||||
25104
|
||||
49561
|
||||
8744
|
||||
24576
|
||||
8192
|
||||
16784
|
||||
8196
|
||||
16384
|
||||
24996
|
||||
8197
|
||||
8193
|
||||
8192
|
||||
416
|
||||
8194
|
||||
8192
|
||||
16272
|
||||
16276
|
||||
8193
|
||||
2
|
||||
25492
|
||||
8201
|
||||
16272
|
||||
8192
|
||||
16276
|
||||
8196
|
||||
8737
|
||||
2
|
||||
24580
|
||||
16937
|
||||
8192
|
||||
8192
|
||||
8196
|
||||
8197
|
||||
8351
|
||||
8197
|
||||
8195
|
||||
8595
|
||||
8198
|
||||
273
|
||||
16276
|
||||
8196
|
||||
8195
|
||||
8602
|
||||
8194
|
||||
8202
|
||||
8202
|
||||
8194
|
||||
16278
|
||||
25126
|
||||
|
@ -325,7 +325,15 @@ void FaceBall::LoadLevel(int level)
|
||||
mapFloor.tris.push_back({ {{(float)x + 1,0,(float)y},{(float)x,0,(float)y + 1},{(float)x + 1,0,(float)y + 1}},{{1,0},{0,1},{1,1}},{WHITE,WHITE,WHITE}, floor_tex });
|
||||
EnemyID id = mapData[y][x].enemyId;
|
||||
if (id>=SHOOTME&& id < POWERUP_ARMOR) {
|
||||
enemies.push_back({ id,vec3d{x + 0.5f,0,y + 0.5f},((int)mapData[y][x].facingDir-1)*PI/2,enemyData[id].radius});
|
||||
if (mapData[y][x].wave1) {
|
||||
enemies.push_back({ id,vec3d{x + 0.5f,0,y + 0.5f},((int)mapData[y][x].facingDir - 1) * PI / 2,enemyData[id].radius });
|
||||
} else
|
||||
if (mapData[y][x].wave2) {
|
||||
wave2Enemies.push_back({ id,vec3d{x + 0.5f,0,y + 0.5f},((int)mapData[y][x].facingDir - 1) * PI / 2,enemyData[id].radius });
|
||||
}
|
||||
else {
|
||||
wave3Enemies.push_back({ id,vec3d{x + 0.5f,0,y + 0.5f},((int)mapData[y][x].facingDir - 1) * PI / 2,enemyData[id].radius });
|
||||
}
|
||||
}
|
||||
if (id >= POWERUP_ARMOR) {
|
||||
SpawnPowerup(PowerupType((int)id-55), vec3d{ x + 0.5f,0,y + 0.5f });
|
||||
@ -1422,10 +1430,9 @@ void FaceBall::HandleKeys(float fElapsedTime) {
|
||||
else {
|
||||
pitch = 0;
|
||||
if (GetMouse(0).bPressed) {
|
||||
if (bullets.size() >= shotLimit) {
|
||||
bullets.erase(bullets.begin());
|
||||
if (bullets.size() < shotLimit) {
|
||||
bullets.push_back({ bullet,{player.GetPos().x,player.GetPos().y - 0.15f, player.GetPos().z},fYaw,0.125f,{shotSpd * std::cosf(fYaw),shotSpd * std::sinf(fYaw)},GREEN,true });
|
||||
}
|
||||
bullets.push_back({ bullet,{player.GetPos().x,player.GetPos().y - 0.15f, player.GetPos().z},fYaw,0.125f,{shotSpd * std::cosf(fYaw),shotSpd * std::sinf(fYaw)},GREEN,true });
|
||||
}
|
||||
}
|
||||
if (GetKey(Q).bHeld) {
|
||||
@ -2123,6 +2130,47 @@ bool FaceBall::OnUserUpdate(float fElapsedTime)
|
||||
if (camoDuration >= 0) {
|
||||
camoDuration -= fElapsedTime;
|
||||
}
|
||||
if (EnemiesAlive() < 5) {
|
||||
if (tagsRemaining <= 0) {
|
||||
//Look at all wave 2 enemies first, if we can't spawn one in then look at wave 3 enemies, and try to spawn one in.
|
||||
if (wave2Enemies.size()>0){
|
||||
for (int i=0;i<wave2Enemies.size();i++){
|
||||
Enemy&e=wave2Enemies[i];
|
||||
if (CheckEnemyCollision({0,0,0},{e.pos.x,e.pos.z},e.radius)==-1&&
|
||||
!CheckPlayerCollision({0,0,0},{e.pos.x,e.pos.z},e.radius)){
|
||||
enemies.push_back(e);
|
||||
wave2Enemies.erase(wave2Enemies.begin()+i);
|
||||
goto spawningDone;
|
||||
}
|
||||
}
|
||||
} else
|
||||
if (wave3Enemies.size()>0){
|
||||
for (int i=0;i<wave3Enemies.size();i++){
|
||||
Enemy&e=wave3Enemies[i];
|
||||
if (CheckEnemyCollision({0,0,0},{e.pos.x,e.pos.z},e.radius)==-1&&
|
||||
!CheckPlayerCollision({0,0,0},{e.pos.x,e.pos.z},e.radius)){
|
||||
enemies.push_back(e);
|
||||
wave3Enemies.erase(wave3Enemies.begin()+i);
|
||||
goto spawningDone;
|
||||
}
|
||||
}
|
||||
}
|
||||
spawningDone:
|
||||
int a;
|
||||
}
|
||||
else {
|
||||
//Look at wave 2 enemies, and try to spawn one in.
|
||||
for (int i=0;i<wave2Enemies.size();i++){
|
||||
Enemy&e=wave2Enemies[i];
|
||||
if (CheckEnemyCollision({0,0,0},{e.pos.x,e.pos.z},e.radius)==-1&&
|
||||
!CheckPlayerCollision({0,0,0},{e.pos.x,e.pos.z},e.radius)){
|
||||
enemies.push_back(e);
|
||||
wave2Enemies.erase(wave2Enemies.begin()+i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
for (std::vector<Bullet>::iterator it = bullets.begin(); it != bullets.end();) {
|
||||
Bullet& b = *it;
|
||||
if (!b.Update(fElapsedTime)) {
|
||||
@ -2262,6 +2310,16 @@ void FaceBall::ResetScore() {
|
||||
lastAwardedScore = 0;
|
||||
}
|
||||
|
||||
int FaceBall::EnemiesAlive(){
|
||||
int alive=0;
|
||||
for (Enemy&e:enemies){
|
||||
if (!e.isDead()){
|
||||
alive++;
|
||||
}
|
||||
}
|
||||
return alive;
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
FaceBall demo;
|
||||
|
@ -266,6 +266,8 @@ class FaceBall : public PixelGameEngine
|
||||
std::map<EnemyID, EnemyData>enemyData;
|
||||
std::map<PowerupType, PowerupData>powerupData;
|
||||
std::vector<Enemy>enemies;
|
||||
std::vector<Enemy>wave2Enemies;
|
||||
std::vector<Enemy>wave3Enemies;
|
||||
std::vector<Powerup>powerups;
|
||||
private:
|
||||
Mesh mapWalls,mapFloor,enemy_ShootMe,undefined,
|
||||
@ -397,6 +399,7 @@ class FaceBall : public PixelGameEngine
|
||||
void Display3DKillerModel();
|
||||
int CheckPowerupCollision(vec3d movementVector, vf2d pos, float radius);
|
||||
void ResetScore();
|
||||
int EnemiesAlive();
|
||||
public:
|
||||
vi2d MAP_SIZE;
|
||||
float restingTriangleYDepth = 0.f;
|
||||
|
Loading…
x
Reference in New Issue
Block a user