|
@@ -6,6 +6,7 @@
|
|
|
#include "CrystalPoint.h"
|
|
#include "CrystalPoint.h"
|
|
|
#include <fstream>
|
|
#include <fstream>
|
|
|
#include <iostream>
|
|
#include <iostream>
|
|
|
|
|
+#include <algorithm>
|
|
|
#include "WorldHandler.h"
|
|
#include "WorldHandler.h"
|
|
|
|
|
|
|
|
World::World(const std::string &fileName):
|
|
World::World(const std::string &fileName):
|
|
@@ -99,6 +100,7 @@ World::World(const std::string &fileName):
|
|
|
entities.push_back(new LevelObject(object["file"].asString(), position, rotation, scale, hasCollision));
|
|
entities.push_back(new LevelObject(object["file"].asString(), position, rotation, scale, hasCollision));
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ maxEnemies = 0;
|
|
|
//Load and place enemies into world
|
|
//Load and place enemies into world
|
|
|
for (auto e : v["enemies"])
|
|
for (auto e : v["enemies"])
|
|
|
{
|
|
{
|
|
@@ -124,6 +126,7 @@ World::World(const std::string &fileName):
|
|
|
Vec3f position(e["pos"][0].asFloat(), e["pos"][1].asFloat(), e["pos"][2].asFloat());
|
|
Vec3f position(e["pos"][0].asFloat(), e["pos"][1].asFloat(), e["pos"][2].asFloat());
|
|
|
position.y = getHeight(position.x, position.z) + 2.0f;
|
|
position.y = getHeight(position.x, position.z) + 2.0f;
|
|
|
|
|
|
|
|
|
|
+ maxEnemies++;
|
|
|
enemies.push_back(new Enemy(e["file"].asString(), position, rotation, scale));
|
|
enemies.push_back(new Enemy(e["file"].asString(), position, rotation, scale));
|
|
|
}
|
|
}
|
|
|
maxCrystals = 0;
|
|
maxCrystals = 0;
|
|
@@ -239,8 +242,6 @@ void World::draw()
|
|
|
float lightAmbient[4] = { 0.2, 0.2, 0.2, 1 };
|
|
float lightAmbient[4] = { 0.2, 0.2, 0.2, 1 };
|
|
|
glLightfv(GL_LIGHT0, GL_AMBIENT, lightAmbient);
|
|
glLightfv(GL_LIGHT0, GL_AMBIENT, lightAmbient);
|
|
|
|
|
|
|
|
- glColor4f(1, 1, 1, 1);
|
|
|
|
|
-
|
|
|
|
|
skybox->draw();
|
|
skybox->draw();
|
|
|
|
|
|
|
|
heightmap->Draw();
|
|
heightmap->Draw();
|
|
@@ -259,6 +260,9 @@ void World::update(float elapsedTime)
|
|
|
for (auto &entity : entities)
|
|
for (auto &entity : entities)
|
|
|
entity->update(elapsedTime);
|
|
entity->update(elapsedTime);
|
|
|
|
|
|
|
|
|
|
+ int count = 0;
|
|
|
|
|
+ int remove = false;
|
|
|
|
|
+
|
|
|
for (auto &enemy : enemies)
|
|
for (auto &enemy : enemies)
|
|
|
{
|
|
{
|
|
|
|
|
|
|
@@ -277,10 +281,24 @@ void World::update(float elapsedTime)
|
|
|
break;
|
|
break;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ if (enemy->attack)
|
|
|
|
|
+ {
|
|
|
|
|
+ remove = true;
|
|
|
|
|
+ continue;
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
enemy->position.y = getHeight(enemy->position.x, enemy->position.z) + 2.0f;
|
|
enemy->position.y = getHeight(enemy->position.x, enemy->position.z) + 2.0f;
|
|
|
|
|
+
|
|
|
|
|
+ if(!remove)
|
|
|
|
|
+ count++;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ if(remove)
|
|
|
|
|
+ enemies.erase(enemies.begin() + count);
|
|
|
|
|
+
|
|
|
|
|
+ skybox->update(elapsedTime, maxEnemies - enemies.size(), maxEnemies);
|
|
|
|
|
+
|
|
|
if (portal->mayEnter)
|
|
if (portal->mayEnter)
|
|
|
WorldHandler::getInstance()->NextWorld();
|
|
WorldHandler::getInstance()->NextWorld();
|
|
|
}
|
|
}
|