From e0aa87001552316564845184c31cda98bd39d296 Mon Sep 17 00:00:00 2001 From: 42yeah Date: Fri, 28 Feb 2020 16:37:00 +0800 Subject: [PATCH] Festival! --- Shear3D/Game.cpp | 22 +++++++- Shear3D/Game.hpp | 1 + Shear3D/Monster.cpp | 133 +++++++++++++++++++++++++++++++++++++++----- Shear3D/Monster.hpp | 3 +- 4 files changed, 142 insertions(+), 17 deletions(-) diff --git a/Shear3D/Game.cpp b/Shear3D/Game.cpp index 5d855b7..9bf5235 100644 --- a/Shear3D/Game.cpp +++ b/Shear3D/Game.cpp @@ -184,6 +184,9 @@ void Game::update() { day++; dayLock = true; notifications.push_back(Notification("A New Day", "A new day has begun. It is now day " + std::to_string(day) + ". ", true, 10.0f)); + if (isFestival()) { + notifications.push_back(Notification("Festival!", "You smell festival in the air.", true, 10.0f)); + } refresh(); } if (standarized > 0.1f) { @@ -306,7 +309,7 @@ void Game::update() { } for (int i = 0; i < monsters.size(); i++) { - monsters[i].update(deltaTime, standarized, day, objects); + monsters[i].update(deltaTime, standarized, day, objects, isFestival()); } } @@ -863,7 +866,11 @@ void Game::renderGUI() { interactingObject = nullptr; } if (interactingMonster && glm::distance(interactingMonster->position, camera.position) <= 4.0f) { - interactingMonster->interact(this); + if (isFestival()) { + interactingMonster->festiveInteract(this); + } else { + interactingMonster->interact(this); + } interacting = true; } else { interactingMonster = nullptr; @@ -917,6 +924,7 @@ void Game::hospital(std::string reason) { monsters[10].destinationRamp = nullptr; stamina = 3.0f; hunger = 3.0f; + hallucinating = 0.0f; // Find coin for (int i = 0; i < items.size(); i++) { if (items[i].type == EGG) { @@ -1101,6 +1109,12 @@ void Game::refresh() { steaks = 0; steakCounter = priceDistrib(dev); + if (isFestival()) { + distrib = std::uniform_int_distribution<>(2, 6); + steaks = distrib(dev); + steakCounter = 10000.0f; // No new steaks during festival + } + rented = false; int numTacos = getQuantityOf(TACO); if (numTacos > 0) { @@ -1114,6 +1128,10 @@ void Game::refresh() { } } +bool Game::isFestival() { + return day % 7 == 0; +} + int distrib = 0; diff --git a/Shear3D/Game.hpp b/Shear3D/Game.hpp index ae379a1..9c72244 100644 --- a/Shear3D/Game.hpp +++ b/Shear3D/Game.hpp @@ -71,6 +71,7 @@ class Game { void addItemToChest(int id, Item item); int getQuantityOf(ItemType type); void refresh(); + bool isFestival(); // === PASSES === // Program renderProgram; diff --git a/Shear3D/Monster.cpp b/Shear3D/Monster.cpp index d5ce4fe..42984de 100644 --- a/Shear3D/Monster.cpp +++ b/Shear3D/Monster.cpp @@ -26,23 +26,39 @@ void Monster::render(Program &program) { glDrawArrays(GL_TRIANGLES, 0, 6); } -void Monster::update(float dt, float time, int day, std::vector &objects) { - if (ramps.size() <= 0 || begging) { +void Monster::update(float dt, float time, int day, std::vector &objects, bool festive) { + if (ramps.size() <= 0 || festiveRamps.size() <= 0 || begging) { return; } Ramp *prevRamp = nullptr, currentRamp; - for (int i = 0; i < ramps.size(); i++) { - if (ramps[i].time >= time) { - currentRamp = ramps[i]; - if (i <= 0) { - rampIndex = -1; + if (!festive) { + for (int i = 0; i < ramps.size(); i++) { + if (ramps[i].time >= time) { + currentRamp = ramps[i]; + if (i <= 0) { + rampIndex = -1; + break; + } + rampIndex = i - 1; + prevRamp = &ramps[i - 1]; + break; + } + } + } else { + for (int i = 0; i < festiveRamps.size(); i++) { + if (festiveRamps[i].time >= time) { + currentRamp = festiveRamps[i]; + if (i <= 0) { + rampIndex = -1; + break; + } + rampIndex = i - 1; + prevRamp = &festiveRamps[i - 1]; break; } - rampIndex = i - 1; - prevRamp = &ramps[i - 1]; - break; } } + // interpolate // float t = (time - prevRamp.time) / (currentRamp.time - prevRamp.time); // destination = glm::mix(prevRamp.destination, currentRamp.destination, t); @@ -1077,7 +1093,96 @@ void Monster::interact(Game *game) { ImGui::End(); } - - - - +void Monster::festiveInteract(Game *game) { + game->escape(game->escaping = true); + ImGui::SetNextWindowSize(ImVec2{ 400.0f, 300.0f }, ImGuiCond_FirstUseEver); + ImGui::Begin("Dialogue"); + switch (id) { + case 1: + switch (rampIndex) { + case 0: + ImGui::Text("Zzz..."); + break; + + case 5: + case 6: + switch (conversationId) { + case 0: + if (game->eggCount > 0) { + ImGui::Text("Hey you. Today's eggs are on the house.\nEnjoy!"); + if (ImGui::Button("Take the eggs")) { + game->addItem(Item(EGG, game->eggCount)); + game->eggCount = 0; + conversationId = 1; + } + } else { + ImGui::Text("Alright. I gave you the egg, now get out."); + } + break; + + case 1: + ImGui::Text("Yeah. Now get out."); + break; + } + break; + + default: + ImGui::Text("You were wished having a good time\nduring the festival."); + break; + } + break; + + case 2: + switch (rampIndex) { + case 0: + ImGui::Text("Zzz..."); + break; + + case 9: + case 10: + switch (conversationId) { + case 0: + if (game->steaks > 0) { + ImGui::Text("Here. Even though we don't always see eye to eye (ha!)\nTake these free steaks. It's a festival tribute.\nI bought a lot from the chef for today!"); + if (ImGui::Button("Take the steaks")) { + game->addItem(Item(STEAK, game->steaks)); + game->steaks = 0; + conversationId = 1; + } + } else { + ImGui::Text("Well, no steaks left!\nHave a good festival, whatever this is."); + } + break; + + case 1: + ImGui::Text("Yeah yeah. Bye!"); + break; + } + + break; + + default: + ImGui::Text("You were wished having a good time\nduring the festival."); + break; + } + break; + + default: + switch (rampIndex) { + case 0: + ImGui::Text("Zzz..."); + break; + + default: + ImGui::Text("You were wished having a good time\nduring the festival."); + break; + } + break; + } + + if (ImGui::Button("Try to leave") || destinationRamp != game->interactingMonsterRamp) { + texId = id; + game->interactingMonster = nullptr; + } + ImGui::End(); +} diff --git a/Shear3D/Monster.hpp b/Shear3D/Monster.hpp index 1a1a267..d40f02b 100644 --- a/Shear3D/Monster.hpp +++ b/Shear3D/Monster.hpp @@ -29,7 +29,7 @@ class Monster { Monster() {} Monster(Texture *tex, int id, glm::vec3 position, GLuint VAO); - void update(float dt, float time, int day, std::vector &objects); + void update(float dt, float time, int day, std::vector &objects, bool festive); void pathfind(glm::vec3 destination, std::vector &objects); Object *lookup(glm::vec3 pos, std::vector &objects); @@ -37,6 +37,7 @@ class Monster { void render(Program &program); void interact(Game *game); + void festiveInteract(Game *game); std::vector ramps; std::vector festiveRamps;