Commit 1b3936ec authored by Elias Broschin's avatar Elias Broschin
Browse files

fixed

parent 5bd299f0
......@@ -19,8 +19,7 @@ public:
return gdw::type_id<gdw::item_container_component>();
}
void update(float dt);
bool isActive() { return timer > 0; }
item_type type() {return item_type_;}
private:
item_type item_type_;
int timer;
......
#ifndef __ITEM_TYPE__
#define __ITEM_TYPE__
enum class item_type {
enum item_type {
NONE = -1,
magnet_field,
emp,
accelerator,
portal,
NONE
type_count
};
#endif
......@@ -32,7 +32,7 @@ public:
float player_speed() {return player_speed_;}
void create_asteroid(glm::vec3 pos, std::string mesh_name, float scale, glm::vec3 rotation);
void create_item(glm::vec3 pos);
void create_item(glm::vec3 pos, int type);
void destroy_all_victims();
void destroy_all_asteroids();
......
......@@ -10,28 +10,4 @@ namespace gdw {
item_container_component::~item_container_component() {}
void item_container_component::update(float dt)
{
timer -= dt;
if(timer > 0){
// ####### MAGNET FIELD ########
if(item_type_ == item_type::magnet_field){
}
// ####### EMP ########
else if(item_type_ == item_type::emp){
}
// ####### ACCELERATOR ########
else if(item_type_ == item_type::accelerator){
}
// ####### PORTAL ########
else if(item_type_ == item_type::portal){
}
}
}
} //Namespace gdw
......@@ -15,13 +15,30 @@ namespace gdw {
if(equipped_item_ == item_type::NONE)
return;
auto& placed_item = engine_.entity_manager().emplace_back(world_pos, glm::angleAxis(glm::radians(90.f), glm::vec3(1,0,0)));
placed_item.emplace_back<staticmesh_component>("mesh/cube.msh");
placed_item.emplace_back<item_container_component>(equipped_item_);
switch(equipped_item_) {
case item_type::magnet_field: {
auto& placed_item = engine_.entity_manager().emplace_back(world_pos, glm::angleAxis(glm::radians(90.f), glm::vec3(1,0,0)));
placed_item.emplace_back<staticmesh_component>("mesh/cube.msh");
break;
}
case item_type::emp: {
auto& placed_item = engine_.entity_manager().emplace_back(world_pos, glm::angleAxis(glm::radians(90.f), glm::vec3(1,0,0)));
placed_item.emplace_back<staticmesh_component>("mesh/cube.msh");
break;
}
case item_type::portal: {
auto& placed_item = engine_.entity_manager().emplace_back(world_pos, glm::angleAxis(glm::radians(90.f), glm::vec3(1,0,0)));
placed_item.emplace_back<staticmesh_component>("mesh/cube.msh");
break;
}
case item_type::accelerator: {
auto& placed_item = engine_.entity_manager().emplace_back(world_pos, glm::angleAxis(glm::radians(90.f), glm::vec3(1,0,0)));
placed_item.emplace_back<staticmesh_component>("mesh/cube.msh");
break;
}
}
equipped_item_ = item_type::NONE;
}
}
} //Namespace gdw
......@@ -26,6 +26,7 @@
#include <gameplay/item/item_type.h>
#include <util/config.hpp>
#include <util/config_manager.hpp>
#include <gameplay/item/item_container_component.h>
namespace gdw {
......@@ -163,7 +164,11 @@ namespace gdw {
for(auto &item : items_to_create) {
srand (time(0)*time(0));
if(rand()%100 <= item_drop_chance) {
create_item(item);
srand (time(0)*time(0));
constexpr int max = item_type::type_count;
constexpr int min = 0;
int r = (rand() % max + min);
create_item(item, r);
}
}
items_to_create.clear();
......@@ -246,7 +251,7 @@ namespace gdw {
maploader_.add_agent(pos, victim.id());
}
void level_manager::create_item(glm::vec3 pos) {
void level_manager::create_item(glm::vec3 pos, int type) {
auto& entity_manager = engine_.entity_manager();
auto &item = entity_manager.emplace_back(glm::vec3(pos.x-1.f, 3.f, pos.z), glm::angleAxis(glm::radians(90.f), glm::vec3(0.f, 1.f, 0.f)));
......@@ -261,6 +266,7 @@ namespace gdw {
auto &item_coll = item.emplace_back<collision_component>(new sphere(glm::vec3(0.f), 1.f));
item.emplace_back<object_type_component>("ITEM");
item.emplace_back<item_container_component>(item_type(type));
items_.emplace_back(item.id());
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment