Skip to content

Commit

Permalink
Festival!
Browse files Browse the repository at this point in the history
  • Loading branch information
42yeah committed Feb 28, 2020
1 parent 0435031 commit e0aa870
Show file tree
Hide file tree
Showing 4 changed files with 142 additions and 17 deletions.
22 changes: 20 additions & 2 deletions Shear3D/Game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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());
}
}

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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) {
Expand All @@ -1114,6 +1128,10 @@ void Game::refresh() {
}
}

bool Game::isFestival() {
return day % 7 == 0;
}


int distrib = 0;

Expand Down
1 change: 1 addition & 0 deletions Shear3D/Game.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ class Game {
void addItemToChest(int id, Item item);
int getQuantityOf(ItemType type);
void refresh();
bool isFestival();

// === PASSES === //
Program renderProgram;
Expand Down
133 changes: 119 additions & 14 deletions Shear3D/Monster.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<Object> &objects) {
if (ramps.size() <= 0 || begging) {
void Monster::update(float dt, float time, int day, std::vector<Object> &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);
Expand Down Expand Up @@ -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();
}
3 changes: 2 additions & 1 deletion Shear3D/Monster.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,15 @@ class Monster {
Monster() {}
Monster(Texture *tex, int id, glm::vec3 position, GLuint VAO);

void update(float dt, float time, int day, std::vector<Object> &objects);
void update(float dt, float time, int day, std::vector<Object> &objects, bool festive);
void pathfind(glm::vec3 destination, std::vector<Object> &objects);

Object *lookup(glm::vec3 pos, std::vector<Object> &objects);

void render(Program &program);

void interact(Game *game);
void festiveInteract(Game *game);

std::vector<Ramp> ramps;
std::vector<Ramp> festiveRamps;
Expand Down

0 comments on commit e0aa870

Please sign in to comment.