void GameManager::miracle(SDL_Event & event, WidgetReference widget) { std::cout << "GameManager::miracle(" << widget->id << ")" << std::endl; if(self) { // NOTE: widget->id is the MiracleType (needs to be cast). Faction faction = F_PLAYER_1; EntityType type = (EntityType) widget->id; VillageReference village = villageManager.getVillage(faction); EntityReference townCenter = village->getTownCenter(); if(!townCenter) std::cout << "No town center." << std::endl; else if(!type) std::cout << "No type." << std::endl; else if(0) { Position origin = townCenter->getPosition(); Position position = origin; EntityReference entity = new MiracleEntity(type, 1, position, faction); #pragma unused (entity) //self->createRecord(entity); } else std::cout << "Type: " << type << ", but not implemented." << std::endl; } else std::cerr << "GameManager not initialized." << std::endl; }
void GameManager::build(SDL_Event & event, WidgetReference widget) { std::cout << "GameManager::build(" << widget->id << ")" << std::endl; if(self) { Faction faction = F_PLAYER_1; EntityType type = (EntityType) widget->id; VillageReference village = villageManager.getVillage(faction); EntityReference townCenter = village->getTownCenter(); if(!townCenter) std::cerr << "No town center." << std::endl; else { Position origin = townCenter->getPosition(); Position position = self->obstructionMap->findOpenPosition(origin); EntityReference entity = new Entity(type, 1, position, faction); entityManager.createRecord(entity); self->obstructionMap->set(position, OT_OBSTRUCTED); //std::cout << (*(self->obstructionMap)) << std::endl; } //self->villageManager.buildHouse(); } else std::cerr << "GameManager not initialized." << std::endl; }
void GameManager::setup() { WorldGeneration world; worldSize = world.getWorldSize(); initializeCallbackMap(); buttonContainer = new SdlWidgetContainer(callbackMap, "res/sidebar-files.cfg"); mapView = new SdlMapView(); mapView->hide(); SdlEntity::mapView = mapView; SdlEntity::worldSize = worldSize; // Village Manager villageManager.show(); villageManager.addVillage(F_PLAYER_1); villageManager.addVillage(F_PLAYER_2); hide(); obstructionMap = new ObstructionMap(worldSize); EntityReference tempEntity = world.getNextEntity(); EntityReference storedEntity; int count = 0; while (tempEntity && tempEntity->getType() != ET_NONE) { storedEntity = entityManager.createRecord(tempEntity); villageManager.import(storedEntity); creatureManager.import(storedEntity); if (tempEntity->getGroup() >= EG_MOBILE) obstructionMap->set(tempEntity->getPosition(), OT_CONSIDERED); else obstructionMap->set(tempEntity->getPosition(), OT_OBSTRUCTED); // Get next entity for next loop iteration. delete tempEntity; tempEntity = world.getNextEntity(); count++; } std::cout << count << std::endl; }