Shopping completed trigger added.

Co-authored-by: sigonasr2 <sigonasr2@gmail.com>
master
sigonasr2 2 years ago
parent 9535d6fa54
commit 7e26720c08
  1. BIN
      C++ProjectTemplate
  2. 12
      main.cpp
  3. 10
      object.h

Binary file not shown.

@ -175,6 +175,7 @@ std::vector<std::pair<Item*,int>> SHOP_ITEMS={};
int MONEY=0; int MONEY=0;
int ENEMY_MONEY_SUM=0; int ENEMY_MONEY_SUM=0;
int SHOP_MENU_CURSOR=0; int SHOP_MENU_CURSOR=0;
Object*SHOPKEEPER_INTERACTING_WITH=nullptr;
/* /*
[Choice1,Choice2,Choice3] [Choice1,Choice2,Choice3]
@ -196,9 +197,11 @@ void DisplayMessageBox(std::string targetT) {
messageBoxStopMarker=0; messageBoxStopMarker=0;
} }
void SetupShop(std::vector<std::pair<Item*,int>> shopItems){ void SetupShop(Object*shopkeeper,std::vector<std::pair<Item*,int>> shopItems){
SHOP_MENU_CURSOR=0;
SHOP_ITEMS.clear(); SHOP_ITEMS.clear();
SHOP_ITEMS=shopItems; SHOP_ITEMS=shopItems;
SHOPKEEPER_INTERACTING_WITH=shopkeeper;
} }
bool MOUSE_PRESSED_DOWN=false,MOUSE_DOWN=false,MOUSE_RELEASED=false; //TODO Implement Mouse things. bool MOUSE_PRESSED_DOWN=false,MOUSE_DOWN=false,MOUSE_RELEASED=false; //TODO Implement Mouse things.
@ -1801,7 +1804,12 @@ This is a test message that lets us trigger straight from a cutscene! Cool!)"),
case GameState::SHOPKEEPER_MENU:{ case GameState::SHOPKEEPER_MENU:{
CursorControl(SHOP_MENU_CURSOR,SHOP_ITEMS.size()+1); CursorControl(SHOP_MENU_CURSOR,SHOP_ITEMS.size()+1);
if (ACTIONKEYPRESSED) { if (ACTIONKEYPRESSED) {
if (SHOP_MENU_CURSOR==SHOP_ITEMS.size()) {
if (SHOPKEEPER_INTERACTING_WITH!=nullptr) {
GAME_STATE=GameState::GAME_WORLD;
SHOPKEEPER_INTERACTING_WITH->ShoppingCompleted();
}
}
} }
}break; }break;
} }

@ -61,6 +61,7 @@ class Object{
virtual Interaction Interact()=0; virtual Interaction Interact()=0;
virtual void ChoiceMade(int choice)=0; virtual void ChoiceMade(int choice)=0;
virtual void DialogClosed()=0; virtual void DialogClosed()=0;
virtual void ShoppingCompleted()=0;
void SetScale(vd2d scale) { void SetScale(vd2d scale) {
this->scale=scale; this->scale=scale;
if (spr!=nullptr) { if (spr!=nullptr) {
@ -176,6 +177,7 @@ class Standard_Obj : public Object{
Interaction Interact()override{return {};} Interaction Interact()override{return {};}
void DialogClosed()override{}; void DialogClosed()override{};
void ChoiceMade(int choice)override{}; void ChoiceMade(int choice)override{};
void ShoppingCompleted()override{};
}; };
class TrashCan_Obj : public Object{ class TrashCan_Obj : public Object{
@ -185,13 +187,15 @@ class TrashCan_Obj : public Object{
return {{"You dig around the trash can.","Nope! Just looks like plain ol' trash."}};} return {{"You dig around the trash can.","Nope! Just looks like plain ol' trash."}};}
void DialogClosed()override{}; void DialogClosed()override{};
void ChoiceMade(int choice)override{}; void ChoiceMade(int choice)override{};
void ShoppingCompleted()override{};
}; };
extern int MESSAGE_BOX_DIALOG_ANSWER; extern int MESSAGE_BOX_DIALOG_ANSWER;
extern bool GAME_FLAGS[128]; extern bool GAME_FLAGS[128];
extern int GAME_STATE; extern int GAME_STATE;
extern void SetupShop(std::vector<std::pair<Item*,int>> shopItems); extern void SetupShop(Object*shopkeeper,std::vector<std::pair<Item*,int>> shopItems);
extern std::map<ItemName,Item*>ITEMLIST; extern std::map<ItemName,Item*>ITEMLIST;
extern void DisplayMessageBox(std::string targetT);
class Shopkeeper_Obj : public Object{ class Shopkeeper_Obj : public Object{
DynamicObject(Shopkeeper_Obj) DynamicObject(Shopkeeper_Obj)
@ -224,6 +228,7 @@ class Shopkeeper_Obj : public Object{
void DialogClosed()override{ void DialogClosed()override{
GAME_STATE = GameState::SHOPKEEPER_MENU; GAME_STATE = GameState::SHOPKEEPER_MENU;
SetupShop( SetupShop(
this,
{ {
{ITEMLIST[ItemName::EGG],8}, {ITEMLIST[ItemName::EGG],8},
{ITEMLIST[ItemName::COOKIE],4}, {ITEMLIST[ItemName::COOKIE],4},
@ -232,5 +237,8 @@ class Shopkeeper_Obj : public Object{
} }
); );
} }
void ShoppingCompleted()override{
DisplayMessageBox("Thanks for shopping with us! Have a great day.");
};
}; };
#endif #endif
Loading…
Cancel
Save