diff options
-rw-r--r-- | kurator/src/Campaign.cpp | 41 | ||||
-rw-r--r-- | kurator/src/Campaign.h | 6 |
2 files changed, 46 insertions, 1 deletions
diff --git a/kurator/src/Campaign.cpp b/kurator/src/Campaign.cpp index c109f63..a3f788e 100644 --- a/kurator/src/Campaign.cpp +++ b/kurator/src/Campaign.cpp @@ -4,22 +4,61 @@ #include <utility> #include <raylib.h> +#include <imgui.h> +#include <kurator/campaign/Scenario.h> +#include <kurator/campaign/scenarios.h> + +#include "Battle.h" #include "Session.h" + namespace kurator { Campaign::Campaign(std::shared_ptr<Session> _session) : - session {std::move(_session)} + session {std::move(_session)}, + ships {}, + team {0}, + level {0}, + id {0} { + auto scenario = campaign::scenarios::example(); + for (auto& ship : scenario.ships) { + if (ship.team == team) { + ship.identifier.id = id++; + ships.push_back(std::move(ship)); + } + } } void Campaign::update(const float) { + if (ImGui::Begin("Campaign")) { + ImGui::Text("Level %d, ships left:", level); + for (const auto& ship : ships) { + if (ship.team == team) + ImGui::Text("%s", ship.type.c_str()); + } + if (ImGui::Button("Start")) { + campaign::Scenario scenario {"encounter", 12000, {}}; + scenario.ships.insert(scenario.ships.cend(), ships.begin(), ships.end()); + auto generator = campaign::scenarios::example(); + for (auto& ship : generator.ships) { + if (ship.team != team) { + ship.identifier.id = id++; + scenario.ships.push_back(std::move(ship)); + } + } + session->push(std::make_shared<Battle>(session, std::move(scenario))); + } + if (ImGui::Button("Back")) + session->pop(); + } + ImGui::End(); } diff --git a/kurator/src/Campaign.h b/kurator/src/Campaign.h index 80d1506..f7beed5 100644 --- a/kurator/src/Campaign.h +++ b/kurator/src/Campaign.h @@ -2,6 +2,8 @@ #include <memory> +#include <kurator/campaign/ShipConfig.h> + #include "Scene.h" #include "Session.h" @@ -18,6 +20,10 @@ public: void draw() const override; private: std::shared_ptr<Session> session; + std::vector<campaign::ShipConfig> ships; + int team; + int level; + int id; }; |