generated from sigonasr2/CPlusPlusProjectTemplate
Advanced flag setting and branching. Choice made function
Co-authored-by: sigonasr2 <sigonasr2@gmail.com>
This commit is contained in:
parent
f77b7f3cf2
commit
320e9bdf30
Binary file not shown.
9
main.cpp
9
main.cpp
@ -171,6 +171,7 @@ int MESSAGE_BOX_DIALOG_CHOICES_MADE=0;
|
|||||||
std::vector<std::string> MESSAGE_BOX_CHOICE_LIST={};
|
std::vector<std::string> MESSAGE_BOX_CHOICE_LIST={};
|
||||||
bool waitingForChoice=false;
|
bool waitingForChoice=false;
|
||||||
int MESSAGE_BOX_DIALOG_CHOICE_CURSOR=0;
|
int MESSAGE_BOX_DIALOG_CHOICE_CURSOR=0;
|
||||||
|
Object*INTERACTING_WITH=nullptr;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
[Choice1,Choice2,Choice3]
|
[Choice1,Choice2,Choice3]
|
||||||
@ -800,16 +801,19 @@ This is a test message that lets us trigger straight from a cutscene! Cool!)"),
|
|||||||
messageBoxMarker++;
|
messageBoxMarker++;
|
||||||
int counter=0;
|
int counter=0;
|
||||||
while (messageBoxFinalText[messageBoxMarker]-'0'!=MESSAGE_BOX_DIALOG_CHOICE_CURSOR) {
|
while (messageBoxFinalText[messageBoxMarker]-'0'!=MESSAGE_BOX_DIALOG_CHOICE_CURSOR) {
|
||||||
while(messageBoxFinalText[messageBoxMarker]!='>'&&messageBoxFinalText[messageBoxMarker]!='<') {
|
while(messageBoxFinalText[messageBoxMarker]!='>'&&messageBoxFinalText[messageBoxMarker]!='<'&&messageBoxFinalText[messageBoxMarker]!='\t') {
|
||||||
messageBoxMarker++;
|
messageBoxMarker++;
|
||||||
}
|
}
|
||||||
messageBoxMarker++;
|
messageBoxMarker++;
|
||||||
}
|
}
|
||||||
messageBoxMarker+=2;
|
messageBoxMarker+=2;
|
||||||
}
|
}
|
||||||
while (messageBoxFinalText[messageBoxMarker]!='<'&&messageBoxFinalText[messageBoxMarker]!='>') {
|
while (messageBoxFinalText[messageBoxMarker]!='<'&&messageBoxFinalText[messageBoxMarker]!='>'&&messageBoxFinalText[messageBoxMarker]!='\t') {
|
||||||
responseText+=messageBoxFinalText[messageBoxMarker++];
|
responseText+=messageBoxFinalText[messageBoxMarker++];
|
||||||
}
|
}
|
||||||
|
if (INTERACTING_WITH!=nullptr) {
|
||||||
|
INTERACTING_WITH->ChoiceMade(MESSAGE_BOX_DIALOG_CHOICE_CURSOR);
|
||||||
|
}
|
||||||
DisplayMessageBox("");
|
DisplayMessageBox("");
|
||||||
targetText=responseText;
|
targetText=responseText;
|
||||||
}
|
}
|
||||||
@ -1267,6 +1271,7 @@ This is a test message that lets us trigger straight from a cutscene! Cool!)"),
|
|||||||
}
|
}
|
||||||
if (closest!=nullptr) {
|
if (closest!=nullptr) {
|
||||||
//Run the Interaction for this object.
|
//Run the Interaction for this object.
|
||||||
|
INTERACTING_WITH=closest;
|
||||||
Interaction interaction = closest->Interact();
|
Interaction interaction = closest->Interact();
|
||||||
if (interaction.messages.size()>0) {
|
if (interaction.messages.size()>0) {
|
||||||
INTERACTION_MESSAGES=interaction.messages;
|
INTERACTION_MESSAGES=interaction.messages;
|
||||||
|
17
object.h
17
object.h
@ -58,6 +58,7 @@ class Object{
|
|||||||
virtual Object* CreateType(int id,std::string name,vd2d pos,Animation*spr,vd2d scale={1,1},Pixel color=WHITE,int animationSpd=1,bool temp=false)=0;
|
virtual Object* CreateType(int id,std::string name,vd2d pos,Animation*spr,vd2d scale={1,1},Pixel color=WHITE,int animationSpd=1,bool temp=false)=0;
|
||||||
//When the player tries to interact with this object.
|
//When the player tries to interact with this object.
|
||||||
virtual Interaction Interact()=0;
|
virtual Interaction Interact()=0;
|
||||||
|
virtual void ChoiceMade(int choice)=0;
|
||||||
void SetScale(vd2d scale) {
|
void SetScale(vd2d scale) {
|
||||||
this->scale=scale;
|
this->scale=scale;
|
||||||
if (spr!=nullptr) {
|
if (spr!=nullptr) {
|
||||||
@ -171,6 +172,7 @@ class Object{
|
|||||||
class Standard_Obj : public Object{
|
class Standard_Obj : public Object{
|
||||||
DynamicObject(Standard_Obj)
|
DynamicObject(Standard_Obj)
|
||||||
Interaction Interact()override{return {};}
|
Interaction Interact()override{return {};}
|
||||||
|
void ChoiceMade(int choice)override{}
|
||||||
};
|
};
|
||||||
|
|
||||||
class TrashCan_Obj : public Object{
|
class TrashCan_Obj : public Object{
|
||||||
@ -178,6 +180,7 @@ class TrashCan_Obj : public Object{
|
|||||||
Interaction Interact()override{
|
Interaction Interact()override{
|
||||||
frameIndex=1;
|
frameIndex=1;
|
||||||
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 ChoiceMade(int choice)override{}
|
||||||
};
|
};
|
||||||
|
|
||||||
extern int MESSAGE_BOX_DIALOG_ANSWER;
|
extern int MESSAGE_BOX_DIALOG_ANSWER;
|
||||||
@ -191,15 +194,25 @@ class Shopkeeper_Obj : public Object{
|
|||||||
>1:What would you like to sell?\
|
>1:What would you like to sell?\
|
||||||
>2:Are you okay?<";
|
>2:Are you okay?<";
|
||||||
Interaction Interact()override{
|
Interaction Interact()override{
|
||||||
if (GAME_FLAGS[(int)Flag::SHOPKEER_BRANCH1]&&MESSAGE_BOX_DIALOG_ANSWER==2) {
|
if (GAME_FLAGS[(int)Flag::SHOPKEER_BRANCH1]) {
|
||||||
MESSAGE_BOX_DIALOG_ANSWER=0;
|
|
||||||
GAME_FLAGS[(int)Flag::SHOPKEER_BRANCH1]=false;
|
GAME_FLAGS[(int)Flag::SHOPKEER_BRANCH1]=false;
|
||||||
|
switch (MESSAGE_BOX_DIALOG_ANSWER) {
|
||||||
|
case 2:{
|
||||||
return {{"No! Stay away! [Okay,Ignore]\
|
return {{"No! Stay away! [Okay,Ignore]\
|
||||||
>0:Yeah I thought so.\
|
>0:Yeah I thought so.\
|
||||||
>1:...<"}};
|
>1:...<"}};
|
||||||
|
}break;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
return {{welcomeMessage},flag:Flag::SHOPKEER_BRANCH1};
|
return {{welcomeMessage},flag:Flag::SHOPKEER_BRANCH1};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
void ChoiceMade(int choice)override{
|
||||||
|
if (GAME_FLAGS[(int)Flag::SHOPKEER_BRANCH1]) {
|
||||||
|
if (choice!=2) {
|
||||||
|
GAME_FLAGS[(int)Flag::SHOPKEER_BRANCH1]=false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
Loading…
x
Reference in New Issue
Block a user