ADD: Add Stone Mason Building Type
This commit is contained in:
parent
36900334d0
commit
687a4197e9
BIN
assets/prehistoric_house/Faerberhaus.jpg
Normal file
BIN
assets/prehistoric_house/Faerberhaus.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 8.4 MiB |
BIN
assets/prehistoric_house/Faerberhaus1.jpg
Normal file
BIN
assets/prehistoric_house/Faerberhaus1.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 7.0 MiB |
BIN
assets/prehistoric_house/Faerberhaus1.png
Normal file
BIN
assets/prehistoric_house/Faerberhaus1.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 28 MiB |
12
assets/prehistoric_house/stone_mason.mtl
Normal file
12
assets/prehistoric_house/stone_mason.mtl
Normal file
@ -0,0 +1,12 @@
|
||||
# Blender 5.0.1 MTL File: 'None'
|
||||
# www.blender.org
|
||||
|
||||
newmtl _Faerberhaus_FaerberhausFaerberhaus
|
||||
Ns 0.000000
|
||||
Ka 1.000000 1.000000 1.000000
|
||||
Ks 0.000000 0.000000 0.000000
|
||||
Ke 0.000000 0.000000 0.000000
|
||||
Ni 1.500000
|
||||
d 1.000000
|
||||
illum 1
|
||||
map_Kd /home/sebastian/Downloads/prehistoric-house-asparn/source/Asparn_Weberhaus3/Faerberhaus.jpg
|
||||
@ -54,8 +54,15 @@ void GameLayer::onAttach()
|
||||
|
||||
|
||||
auto cabinModel = AssetManager::loadModel("cabin", "assets/cabin/cabin.obj", "assets/cabin/cabin.jpg", loader);
|
||||
|
||||
auto stoneMasonModel = AssetManager::loadModel("stoneMason", "assets/prehistoric_house/stone_mason.obj", "assets/prehistoric_house/Faerberhaus.jpg", loader);
|
||||
//entities.push_back(std::make_shared<Entity>(Entity(cabinModel, glm::vec3(0,0,0), 0,0,0, 1.f)));
|
||||
|
||||
/*auto transformComponent = std::make_shared<TransformComponent>(glm::vec3(0,0,0), glm::vec3(0), 1.f);
|
||||
auto modelComponent = std::make_shared<ModelComponent>(stoneMasonModel);
|
||||
|
||||
EntityID entityID = entityManager->createEntity();
|
||||
entityManager->addComponent(entityID, transformComponent);
|
||||
entityManager->addComponent(entityID, modelComponent);*/
|
||||
}
|
||||
|
||||
void GameLayer::onDetach()
|
||||
@ -74,6 +81,12 @@ void GameLayer::onUpdate()
|
||||
if (InputManager::isKeyPressed(GLFW_KEY_A)) moveDir.x -= 1.0f;
|
||||
if (InputManager::isKeyPressed(GLFW_KEY_D)) moveDir.x += 1.0f;
|
||||
|
||||
if (InputManager::isKeyPressed(GLFW_KEY_1)) {
|
||||
gameMode->setActiveBuilding(BuildingType::FOREST_HUT);
|
||||
} else if (InputManager::isKeyPressed(GLFW_KEY_2)) {
|
||||
gameMode->setActiveBuilding(BuildingType::STONE_MASON);
|
||||
}
|
||||
|
||||
|
||||
camera->move(moveDir, 0.5f);
|
||||
tileHighlightSystem->update(*entityManager, *mousePicker, *camera);
|
||||
|
||||
@ -54,4 +54,16 @@ void GameMode::pay(PlayerID playerID, const std::unordered_map<RessourceType, in
|
||||
}
|
||||
}
|
||||
|
||||
std::optional<BuildingType> GameMode::getActiveBuilding() const {
|
||||
return activeBuilding;
|
||||
}
|
||||
|
||||
void GameMode::clearActiveBuilding() {
|
||||
activeBuilding = std::nullopt;
|
||||
}
|
||||
|
||||
void GameMode::setActiveBuilding(BuildingType buildingType) {
|
||||
activeBuilding = buildingType;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -4,6 +4,8 @@
|
||||
|
||||
#ifndef GAMEMODE_H
|
||||
#define GAMEMODE_H
|
||||
#include <optional>
|
||||
|
||||
#include "../engine/core/ECS/EntityManager.h"
|
||||
#include "hexWorld/ecs/components/BuildingComponent.h"
|
||||
#include "player/Player.h"
|
||||
@ -24,10 +26,12 @@ public:
|
||||
PlayerInventory& getPlayerInventory(PlayerID playerID);
|
||||
|
||||
void pay(PlayerID uint32, const std::unordered_map<RessourceType, int> & pairs);
|
||||
|
||||
std::optional<BuildingType> getActiveBuilding() const;
|
||||
void clearActiveBuilding();
|
||||
void setActiveBuilding(BuildingType buildingType);
|
||||
private:
|
||||
std::unordered_map<PlayerID, Player> players;
|
||||
|
||||
std::optional<BuildingType> activeBuilding;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@ -8,8 +8,11 @@
|
||||
|
||||
const BuildingDefinition & BuildingConfig::get(BuildingType type) {
|
||||
if (type == BuildingType::FOREST_HUT) {
|
||||
static const BuildingDefinition def = TemporaryBuildingDefinitionFactory::createForestHutDefinition();
|
||||
return def;
|
||||
static const BuildingDefinition forest_hut_def = TemporaryBuildingDefinitionFactory::createForestHutDefinition();
|
||||
return forest_hut_def;
|
||||
} else if (type == BuildingType::STONE_MASON) {
|
||||
static const BuildingDefinition stone_mason_def = TemporaryBuildingDefinitionFactory::createStoneMasonDefinition();
|
||||
return stone_mason_def;
|
||||
}
|
||||
std::__throw_runtime_error("Unknown BuildingType");
|
||||
}
|
||||
|
||||
@ -15,9 +15,17 @@ EntityID BuildingFactory::create(EntityManager &em, const BuildingDefinition &de
|
||||
|
||||
em.addComponent(e, std::make_shared<ModelComponent>(AssetManager::getModel(def.model)));
|
||||
|
||||
if (def.type == BuildingType::FOREST_HUT) {
|
||||
em.addComponent(e, std::make_shared<TransformComponent>(
|
||||
tileTransform.position, glm::vec3(0), 1.f
|
||||
));
|
||||
} else {
|
||||
em.addComponent(e, std::make_shared<TransformComponent>(
|
||||
tileTransform.position, glm::vec3(0), 2.f
|
||||
));
|
||||
}
|
||||
|
||||
|
||||
|
||||
em.addComponent(e, std::make_shared<BuildingComponent>(def.type, tileEntity));
|
||||
|
||||
|
||||
@ -18,6 +18,19 @@ namespace TemporaryBuildingDefinitionFactory {
|
||||
"cabin"
|
||||
};
|
||||
}
|
||||
|
||||
static inline BuildingDefinition createStoneMasonDefinition() {
|
||||
auto allowedTileResources = std::vector<RessourceType>{RessourceType::STONE};
|
||||
auto resourceCosts = std::unordered_map<RessourceType, int>{};
|
||||
resourceCosts[RessourceType::WOOD] = 15;
|
||||
resourceCosts[RessourceType::STONE] = 10;
|
||||
return {
|
||||
BuildingType::FOREST_HUT,
|
||||
allowedTileResources,
|
||||
resourceCosts,
|
||||
"stoneMason"
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
#endif //DICEWARS_SIEDLER_TEMPORARYBUILDINGDEFINITIONFACTORY_H
|
||||
@ -7,7 +7,8 @@
|
||||
#include "../../../../engine/core/ECS/EntityManager.h"
|
||||
|
||||
enum class BuildingType {
|
||||
FOREST_HUT
|
||||
FOREST_HUT,
|
||||
STONE_MASON
|
||||
};
|
||||
|
||||
|
||||
|
||||
@ -31,7 +31,14 @@ void BuildingPlacementSystem::update(EntityManager& entityManager, GameMode& gam
|
||||
if (!transform || !gameplay || !render) continue;
|
||||
if (!render->isHighlighted) continue;
|
||||
|
||||
const auto &def = BuildingConfig::get(BuildingType::FOREST_HUT);
|
||||
BuildingDefinition def;
|
||||
if (gameMode.getActiveBuilding() == BuildingType::FOREST_HUT) {
|
||||
def = BuildingConfig::get(BuildingType::FOREST_HUT);
|
||||
} else if (gameMode.getActiveBuilding() == BuildingType::STONE_MASON) {
|
||||
def = BuildingConfig::get(BuildingType::STONE_MASON);
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!BuildingRules::canPlace(def, *gameplay, gameMode, player)) continue;
|
||||
|
||||
|
||||
@ -7,6 +7,7 @@
|
||||
#include <cstdint>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <utility>
|
||||
|
||||
#include "PlayerInventory.h"
|
||||
|
||||
@ -21,8 +22,9 @@ private:
|
||||
|
||||
public:
|
||||
Player() = default;
|
||||
Player(const PlayerID playerID, const std::string& name) : playerID(playerID), name(std::move(name)) {
|
||||
Player(const PlayerID playerID, std::string name) : playerID(playerID), name(std::move(name)) {
|
||||
inventory->add(RessourceType::WOOD, 100);
|
||||
inventory->add(RessourceType::STONE, 178);
|
||||
};
|
||||
|
||||
const std::unique_ptr<PlayerInventory> &getInventory() const;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user