Skip to content

Commit

Permalink
refactor stuff, add dialog to scavenger character
Browse files Browse the repository at this point in the history
  • Loading branch information
evanbowman committed Oct 13, 2020
1 parent 715ee7a commit 5814c62
Show file tree
Hide file tree
Showing 27 changed files with 963 additions and 675 deletions.
645 changes: 355 additions & 290 deletions source/data/file_english.cpp

Large diffs are not rendered by default.

659 changes: 363 additions & 296 deletions source/data/file_spanish.cpp

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion source/data/overlay_dialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
// + 93 tiles not compressed
// Total size: 512 + 2976 = 3488
//
// Time-stamp: 2020-10-11, 17:59:30
// Time-stamp: 2020-10-12, 19:26:14
// Exported by Cearn's GBA Image Transmogrifier, v0.8.16
// ( http://www.coranac.com/projects/#grit )
//
Expand Down
2 changes: 1 addition & 1 deletion source/data/overlay_dialog.s
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
@ + 93 tiles not compressed
@ Total size: 512 + 2976 = 3488
@
@ Time-stamp: 2020-10-11, 17:59:30
@ Time-stamp: 2020-10-12, 19:26:14
@ Exported by Cearn's GBA Image Transmogrifier, v0.8.16
@ ( http://www.coranac.com/projects/#grit )
@
Expand Down
2 changes: 1 addition & 1 deletion source/entity/bosses/gatekeeper.hpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#pragma once

#include "entity/enemies/enemy.hpp"
#include "localization.hpp"
#include "localeString.hpp"


class LaserExplosion;
Expand Down
2 changes: 1 addition & 1 deletion source/entity/bosses/theTwins.hpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#pragma once

#include "entity/enemies/enemy.hpp"
#include "localization.hpp"
#include "localeString.hpp"


class LaserExplosion;
Expand Down
1 change: 1 addition & 0 deletions source/entity/details/signpost.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ void Signpost::update(Platform&, Game&, Microseconds dt)

static LocaleString memorial_dialog[] = {
LocaleString::memorial_str,
LocaleString::memorial_str_commentary,
LocaleString::empty
};

Expand Down
90 changes: 45 additions & 45 deletions source/game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2205,7 +2205,7 @@ int base_price(Item::Type item)
return 100;

default:
return 1;
return 0;
}
}

Expand Down Expand Up @@ -2342,6 +2342,50 @@ COLD bool Game::respawn_entities(Platform& pfrm)
details_.transform(clear_entities);
effects_.transform(clear_entities);

if (scavenger_) {
if (is_boss_level(level() - 1)) {
switch (level() - 1) {
case boss_0_level:
scavenger_->inventory_.push_back(Item::Type::long_jump_z2);
break;

case boss_1_level:
scavenger_->inventory_.push_back(Item::Type::long_jump_z3);
break;

case boss_2_level:
scavenger_->inventory_.push_back(Item::Type::long_jump_z4);
break;
}
}

auto& sc_inventory = scavenger_->inventory_;
const u32 item_count = rng::choice<7>(rng::critical_state);
while (sc_inventory.size() < item_count) {
auto item = static_cast<Item::Type>(
rng::choice<static_cast<int>(Item::Type::count)>(
rng::critical_state));

if ((int)item < (int)Item::Type::inventory_item_start or
item_is_persistent(item) or item == Item::Type::long_jump_z2 or
item == Item::Type::long_jump_z3 or
item == Item::Type::long_jump_z4) {

continue;
}

sc_inventory.push_back(item);
}

sc_inventory.push_back(Item::Type::orange);

if (rng::choice<2>(rng::critical_state)) {
sc_inventory.push_back(Item::Type::orange);
}

rng::shuffle(sc_inventory, rng::critical_state);
}

if (level() == 0) {
details().spawn<Lander>(Vec2<Float>{409.f, 112.f});
details().spawn<ItemChest>(Vec2<Float>{348, 154},
Expand Down Expand Up @@ -2667,50 +2711,6 @@ COLD bool Game::respawn_entities(Platform& pfrm)
}
}

if (scavenger_) {
if (is_boss_level(level() - 1)) {
switch (level() - 1) {
case boss_0_level:
scavenger_->inventory_.push_back(Item::Type::long_jump_z2);
break;

case boss_1_level:
scavenger_->inventory_.push_back(Item::Type::long_jump_z3);
break;

case boss_2_level:
scavenger_->inventory_.push_back(Item::Type::long_jump_z4);
break;
}
}

auto& sc_inventory = scavenger_->inventory_;
const u32 item_count = rng::choice<7>(rng::critical_state);
while (sc_inventory.size() < item_count) {
auto item = static_cast<Item::Type>(
rng::choice<static_cast<int>(Item::Type::count)>(
rng::critical_state));

if ((int)item < (int)Item::Type::inventory_item_start or
item_is_persistent(item) or item == Item::Type::long_jump_z2 or
item == Item::Type::long_jump_z3 or
item == Item::Type::long_jump_z4) {

continue;
}

sc_inventory.push_back(item);
}

sc_inventory.push_back(Item::Type::orange);

if (rng::choice<2>(rng::critical_state)) {
sc_inventory.push_back(Item::Type::orange);
}

rng::shuffle(sc_inventory, rng::critical_state);
}

return true;
}

Expand Down
2 changes: 1 addition & 1 deletion source/game.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
#include "entity/peerPlayer.hpp"
#include "entity/player.hpp"
#include "function.hpp"
#include "localization.hpp"
#include "localeString.hpp"
#include "persistentData.hpp"
#include "platform/platform.hpp"
#include "powerup.hpp"
Expand Down
10 changes: 10 additions & 0 deletions source/localeString.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,14 @@ enum class LocaleString {
long_jump_z2_title,
long_jump_z3_title,
long_jump_z4_title,
sc_dialog_skip,
sc_dialog_accelerator,
sc_dialog_lethargy,
sc_dialog_map_system,
sc_dialog_explosive_rounds,
sc_dialog_signal_jammer,
sc_dialog_orange,
sc_dialog_jumpdrive,
single_use_warning,
locked,
peer_too_close_to_item,
Expand Down Expand Up @@ -127,7 +135,9 @@ enum class LocaleString {
chat_chat,
chat_hello,
chat_q_got_oranges,
scavenger_shop,
memorial_str,
memorial_str_commentary,
worker_notebook_1_str,
worker_notebook_2_str,
engineer_notebook_1_str,
Expand Down
12 changes: 10 additions & 2 deletions source/state/activeState.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,9 @@ StatePtr ActiveState::update(Platform& pfrm, Game& game, Microseconds delta)
}
if (pfrm.keyboard().down_transition(game.action2_key())) {
game.effects().get<DialogBubble>().clear();
return state_pool().create<DialogState>(sp->get_dialog());
auto future_state = make_deferred_state<ActiveState>();
return state_pool().create<DialogState>(future_state,
sp->get_dialog());
}
} else {
if (length(game.effects().get<DialogBubble>())) {
Expand Down Expand Up @@ -219,7 +221,13 @@ StatePtr ActiveState::update(Platform& pfrm, Game& game, Microseconds delta)

game.effects().get<DialogBubble>().pop();

return state_pool().create<ItemShopState>();
auto future_state = make_deferred_state<ItemShopState>();
static const LocaleString scavenger_dialog[] = {
LocaleString::scavenger_shop,
LocaleString::empty
};
return state_pool().create<DialogState>(future_state,
scavenger_dialog);
}
} else {
if (length(game.effects().get<DialogBubble>())) {
Expand Down
2 changes: 1 addition & 1 deletion source/state/bossDeathSequenceState.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ BossDeathSequenceState::update(Platform& pfrm, Game& game, Microseconds delta)
}
if (counter_ > fade_duration) {
pfrm.screen().fade(0.f);
return state_pool().create<ActiveState>(game);
return state_pool().create<ActiveState>();

} else {
const auto amount = 1.f - smoothstep(0.f, fade_duration, counter_);
Expand Down
10 changes: 8 additions & 2 deletions source/state/dialogState.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,13 @@ StatePtr DialogState::update(Platform& pfrm, Game& game, Microseconds delta)
if (pfrm.keyboard().down_transition(game.action2_key()) or
pfrm.keyboard().down_transition(game.action1_key())) {

display_mode_ = DisplayMode::animate_out;
if (text_[1] not_eq LocaleString::empty) {
++text_;
init_text(pfrm, *text_);
display_mode_ = DisplayMode::animate_in;
} else {
display_mode_ = DisplayMode::animate_out;
}
}
break;

Expand All @@ -239,7 +245,7 @@ StatePtr DialogState::update(Platform& pfrm, Game& game, Microseconds delta)
break;

case DisplayMode::clear:
return state_pool().create<ActiveState>(game);
return exit_state_();
}

return null_state();
Expand Down
2 changes: 1 addition & 1 deletion source/state/fadeInState.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ StatePtr FadeInState::update(Platform& pfrm, Game& game, Microseconds delta)
constexpr auto fade_duration = milliseconds(800);
if (counter_ > fade_duration) {
if (game.level() == 0) {
return state_pool().create<ActiveState>(game);
return state_pool().create<ActiveState>();
} else {
pfrm.screen().fade(1.f, current_zone(game).energy_glow_color_);
pfrm.sleep(2);
Expand Down
2 changes: 1 addition & 1 deletion source/state/inventoryState.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ StatePtr InventoryState::update(Platform& pfrm, Game& game, Microseconds delta)
MenuState::update(pfrm, game, delta);

if (pfrm.keyboard().down_transition<inventory_key>()) {
return state_pool().create<ActiveState>(game);
return state_pool().create<ActiveState>();
}

if (pfrm.keyboard().down_transition<Key::start>()) {
Expand Down
56 changes: 50 additions & 6 deletions source/state/itemShopState.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,12 @@ void ItemShopState::enter(Platform& pfrm, Game& game, State& prev_state)
pfrm.set_tile(Layer::overlay, st.x - 1, st.y - 1, 420);

game.camera().set_speed(2.8f);

if (display_mode_ == DisplayMode::animate_in_buy or
display_mode_ == DisplayMode::animate_in_sell) {
heading_text_.reset();
buy_sell_text_.reset();
}
}


Expand All @@ -74,7 +80,14 @@ void ItemShopState::exit(Platform& pfrm, Game& game, State& next_state)
OverworldState::exit(pfrm, game, next_state);

buy_item_bar_.reset();
buy_options_bar_.reset();
sell_item_bar_.reset();
sell_options_bar_.reset();
buy_sell_text_.reset();
heading_text_.reset();
buy_sell_icon_.reset();
info_icon_.reset();
coin_icon_.reset();
selector_.reset();
score_.reset();

Expand Down Expand Up @@ -558,7 +571,8 @@ StatePtr ItemShopState::update(Platform& pfrm, Game& game, Microseconds delta)

auto offset = buy_page_num_ * 3 + selector_pos_;
if (offset < (int)game.scavenger()->inventory_.size()) {
if (game.score() >= (u64)price) {
if (price not_eq 0 and
game.score() >= (u64)price) {
game.score() -= price;

auto it = game.scavenger()->inventory_.begin() + offset;
Expand All @@ -567,6 +581,20 @@ StatePtr ItemShopState::update(Platform& pfrm, Game& game, Microseconds delta)
game.inventory().push_item(pfrm, game, item, false);
}
}
} else if (selector_x_ == 2) {
auto resume_state =
make_deferred_state<ItemShopState>(DisplayMode::animate_in_buy,
selector_pos_,
buy_page_num_);

const auto item =
get_buy_item(game, buy_page_num_, selector_pos_);

if (auto handler = inventory_item_handler(item)) {
const LocaleString* dialog = handler->scavenger_dialog_;
return state_pool().create<DialogState>(resume_state,
dialog);
}
}
display_mode_ = DisplayMode::deflate_buy_options;
timer_ = 0;
Expand Down Expand Up @@ -765,10 +793,13 @@ StatePtr ItemShopState::update(Platform& pfrm, Game& game, Microseconds delta)
const auto sale_item =
get_sale_item(game, sell_page_num_, selector_pos_);

const auto price = base_price(sale_item);

int skip = sell_page_num_ * 3 + selector_pos_;

const auto price = base_price(sale_item);
if (price == 0) {
goto DONE;
}

for (int page = 0; page < Inventory::pages; ++page) {
for (int row = 0; row < Inventory::rows; ++row) {
for (int col = 0; col < Inventory::cols; ++col) {
Expand All @@ -790,7 +821,20 @@ StatePtr ItemShopState::update(Platform& pfrm, Game& game, Microseconds delta)
DONE:;

} else if (selector_x_ == 2) {
// item info
const auto mode_resume = DisplayMode::animate_in_sell;
auto resume_state =
make_deferred_state<ItemShopState>(mode_resume,
selector_pos_,
sell_page_num_);

const auto sale_item =
get_sale_item(game, sell_page_num_, selector_pos_);

if (auto handler = inventory_item_handler(sale_item)) {
const LocaleString* dialog = handler->scavenger_dialog_;
return state_pool().create<DialogState>(resume_state,
dialog);
}
}
display_mode_ = DisplayMode::deflate_sell_options;
timer_ = 0;
Expand Down Expand Up @@ -937,7 +981,7 @@ StatePtr ItemShopState::update(Platform& pfrm, Game& game, Microseconds delta)

buy_item_bar_->set_display_percentage(0.f);

return state_pool().create<ActiveState>(game);
return state_pool().create<ActiveState>();
}
} break;

Expand All @@ -954,7 +998,7 @@ StatePtr ItemShopState::update(Platform& pfrm, Game& game, Microseconds delta)

sell_item_bar_->set_display_percentage(0.f);

return state_pool().create<ActiveState>(game);
return state_pool().create<ActiveState>();
}
} break;

Expand Down
2 changes: 1 addition & 1 deletion source/state/logfileViewerState.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ LogfileViewerState::update(Platform& pfrm, Game& game, Microseconds delta)
auto screen_tiles = calc_screen_tiles(pfrm);

if (pfrm.keyboard().down_transition<Key::alt_1>()) {
return state_pool().create<ActiveState>(game);
return state_pool().create<ActiveState>();
} else if (pfrm.keyboard().down_transition<Key::down>()) {
offset_ += screen_tiles.x;
repaint(pfrm, offset_);
Expand Down
2 changes: 1 addition & 1 deletion source/state/networkConnectWaitState.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ NetworkConnectWaitState::update(Platform& pfrm, Game& game, Microseconds delta)

t.assign(str);
pfrm.network_peer().listen();
return state_pool().create<ActiveState>(game);
return state_pool().create<ActiveState>();
}

case Platform::NetworkPeer::internet: {
Expand Down
Loading

0 comments on commit 5814c62

Please sign in to comment.