diff --git a/C++ProjectTemplate b/C++ProjectTemplate index c46d2e0..37f2cfb 100755 Binary files a/C++ProjectTemplate and b/C++ProjectTemplate differ diff --git a/main.cpp b/main.cpp index 396cf5d..db873a0 100644 --- a/main.cpp +++ b/main.cpp @@ -175,6 +175,7 @@ std::vector> SHOP_ITEMS={}; int MONEY=0; int ENEMY_MONEY_SUM=0; int SHOP_MENU_CURSOR=0; +Object*SHOPKEEPER_INTERACTING_WITH=nullptr; /* [Choice1,Choice2,Choice3] @@ -196,9 +197,11 @@ void DisplayMessageBox(std::string targetT) { messageBoxStopMarker=0; } -void SetupShop(std::vector> shopItems){ +void SetupShop(Object*shopkeeper,std::vector> shopItems){ + SHOP_MENU_CURSOR=0; SHOP_ITEMS.clear(); SHOP_ITEMS=shopItems; + SHOPKEEPER_INTERACTING_WITH=shopkeeper; } 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:{ CursorControl(SHOP_MENU_CURSOR,SHOP_ITEMS.size()+1); if (ACTIONKEYPRESSED) { - + if (SHOP_MENU_CURSOR==SHOP_ITEMS.size()) { + if (SHOPKEEPER_INTERACTING_WITH!=nullptr) { + GAME_STATE=GameState::GAME_WORLD; + SHOPKEEPER_INTERACTING_WITH->ShoppingCompleted(); + } + } } }break; } diff --git a/object.h b/object.h index 2fbc039..040db4a 100644 --- a/object.h +++ b/object.h @@ -61,6 +61,7 @@ class Object{ virtual Interaction Interact()=0; virtual void ChoiceMade(int choice)=0; virtual void DialogClosed()=0; + virtual void ShoppingCompleted()=0; void SetScale(vd2d scale) { this->scale=scale; if (spr!=nullptr) { @@ -176,6 +177,7 @@ class Standard_Obj : public Object{ Interaction Interact()override{return {};} void DialogClosed()override{}; void ChoiceMade(int choice)override{}; + void ShoppingCompleted()override{}; }; 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."}};} void DialogClosed()override{}; void ChoiceMade(int choice)override{}; + void ShoppingCompleted()override{}; }; extern int MESSAGE_BOX_DIALOG_ANSWER; extern bool GAME_FLAGS[128]; extern int GAME_STATE; -extern void SetupShop(std::vector> shopItems); +extern void SetupShop(Object*shopkeeper,std::vector> shopItems); extern std::mapITEMLIST; +extern void DisplayMessageBox(std::string targetT); class Shopkeeper_Obj : public Object{ DynamicObject(Shopkeeper_Obj) @@ -224,6 +228,7 @@ class Shopkeeper_Obj : public Object{ void DialogClosed()override{ GAME_STATE = GameState::SHOPKEEPER_MENU; SetupShop( + this, { {ITEMLIST[ItemName::EGG],8}, {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 \ No newline at end of file