FIX: First build, then upgrade
This commit is contained in:
parent
398414a43d
commit
041f423b4f
@ -105,9 +105,11 @@ void GameLayer::onUpdate()
|
|||||||
turnSystem->nextTurn(*turnState, Application::getInstance().getEventBus());
|
turnSystem->nextTurn(*turnState, Application::getInstance().getEventBus());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (InputManager::isKeyPressed(GLFW_KEY_U)) {
|
|
||||||
auto modelStateComponent = entityManager->getComponent<ModelStateComponent>(testEntity);
|
if (gameInputUser->isKeyboardEnabled()) {
|
||||||
modelStateComponent->params["fillRatio"] += 0.1f;
|
if (Application::getInstance().keyboard->keyPressEvent(GLFW_KEY_U)) {
|
||||||
|
gameMode->setUpgradeMode(!gameMode->isUpgradeMode());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
AnimationSystem::update(*entityManager, EngineTime::totalTime);
|
AnimationSystem::update(*entityManager, EngineTime::totalTime);
|
||||||
@ -115,7 +117,9 @@ void GameLayer::onUpdate()
|
|||||||
if (gameInputUser->isMouseEnabled()) {
|
if (gameInputUser->isMouseEnabled()) {
|
||||||
tileHighlightSystem->update(*entityManager, *mousePicker, *camera, *gameMode);
|
tileHighlightSystem->update(*entityManager, *mousePicker, *camera, *gameMode);
|
||||||
SelectionSystem::update(*entityManager, *gameInputUser, *mousePicker);
|
SelectionSystem::update(*entityManager, *gameInputUser, *mousePicker);
|
||||||
|
if (gameMode->isUpgradeMode()) {
|
||||||
UpgradeSystem::tryUpdate(*entityManager, *gameMode, gameMode->getCurrentPlayer(), *turnState);
|
UpgradeSystem::tryUpdate(*entityManager, *gameMode, gameMode->getCurrentPlayer(), *turnState);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
tileHighlightSystem->reset(*entityManager);
|
tileHighlightSystem->reset(*entityManager);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -83,4 +83,12 @@ glm::vec3 GameMode::getColorOfPlayer(PlayerID playerID) {
|
|||||||
return players[playerID].getColor();
|
return players[playerID].getColor();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GameMode::setUpgradeMode(bool upgradeMode) {
|
||||||
|
this->upgradeMode = upgradeMode;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool GameMode::isUpgradeMode() const {
|
||||||
|
return upgradeMode;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -40,9 +40,14 @@ public:
|
|||||||
void addResource(PlayerID uint32, RessourceType ressource, int get_storage);
|
void addResource(PlayerID uint32, RessourceType ressource, int get_storage);
|
||||||
glm::vec3 getColorOfPlayer(PlayerID playerID);
|
glm::vec3 getColorOfPlayer(PlayerID playerID);
|
||||||
|
|
||||||
|
void setUpgradeMode(bool upgradeMode);
|
||||||
|
bool isUpgradeMode() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::unordered_map<PlayerID, Player> players;
|
std::unordered_map<PlayerID, Player> players;
|
||||||
std::optional<BuildingType> activeBuilding;
|
std::optional<BuildingType> activeBuilding;
|
||||||
|
|
||||||
|
bool upgradeMode = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -35,6 +35,7 @@ EntityID BuildingFactory::create(EntityManager &em, const BuildingDefinition &de
|
|||||||
|
|
||||||
auto modelStateComponent = std::make_shared<ModelStateComponent>();
|
auto modelStateComponent = std::make_shared<ModelStateComponent>();
|
||||||
modelStateComponent->params["fillRatio"] = 0.f;
|
modelStateComponent->params["fillRatio"] = 0.f;
|
||||||
|
modelStateComponent->params["level"] = 1.f;
|
||||||
|
|
||||||
auto producingComponent = std::make_shared<ProducingComponent>( ProducingComponent(def.produces, def.baseAmountPerTurn, false));
|
auto producingComponent = std::make_shared<ProducingComponent>( ProducingComponent(def.produces, def.baseAmountPerTurn, false));
|
||||||
producingComponent->setMaxStorage(def.maxStorage);
|
producingComponent->setMaxStorage(def.maxStorage);
|
||||||
|
|||||||
@ -17,6 +17,7 @@ void SelectionSystem::update(EntityManager &em, GameInputUser& input, MousePicke
|
|||||||
if (!input.isMouseEnabled()) return;
|
if (!input.isMouseEnabled()) return;
|
||||||
|
|
||||||
if (!Application::getInstance().mouse->isButtonDown(MouseButton::LEFT)) {
|
if (!Application::getInstance().mouse->isButtonDown(MouseButton::LEFT)) {
|
||||||
|
selectedEntity = 0;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -31,8 +32,4 @@ void SelectionSystem::update(EntityManager &em, GameInputUser& input, MousePicke
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Application::getInstance().mouse->isReleaseEvent(MouseButton::LEFT)) {
|
|
||||||
selectedEntity = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
Loading…
Reference in New Issue
Block a user