Separate each condition as separate functions
This commit is contained in:
@@ -17,5 +17,9 @@ public:
|
|||||||
std::string winMessage;
|
std::string winMessage;
|
||||||
std::string loseMessage;
|
std::string loseMessage;
|
||||||
virtual void PropUpdate(LPPROPGRIDITEM &pItem);
|
virtual void PropUpdate(LPPROPGRIDITEM &pItem);
|
||||||
|
void winCondition();
|
||||||
|
void loseCondition();
|
||||||
|
void pauseCondition();
|
||||||
|
void drawCondition();
|
||||||
void Step(SimTime sdt);
|
void Step(SimTime sdt);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -177,6 +177,32 @@ void LevelInstance::PropUpdate(LPPROPGRIDITEM &pItem)
|
|||||||
Instance::PropUpdate(pItem);
|
Instance::PropUpdate(pItem);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void LevelInstance::winCondition()
|
||||||
|
{
|
||||||
|
DataModelInstance* DataModel = (DataModelInstance*)getParent(); //If level parent gets changed to something other than Datamodel it could cause nasty data corruption bugs
|
||||||
|
DataModel->setMessage(winMessage);
|
||||||
|
DataModel->toggleRun();
|
||||||
|
}
|
||||||
|
|
||||||
|
void LevelInstance::loseCondition()
|
||||||
|
{
|
||||||
|
DataModelInstance* DataModel = (DataModelInstance*)getParent();
|
||||||
|
DataModel->setMessage(loseMessage);
|
||||||
|
DataModel->toggleRun();
|
||||||
|
}
|
||||||
|
|
||||||
|
void LevelInstance::pauseCondition()
|
||||||
|
{
|
||||||
|
DataModelInstance* DataModel = (DataModelInstance*)getParent();
|
||||||
|
DataModel->toggleRun();
|
||||||
|
}
|
||||||
|
|
||||||
|
void LevelInstance::drawCondition()
|
||||||
|
{
|
||||||
|
DataModelInstance* DataModel = (DataModelInstance*)getParent();
|
||||||
|
DataModel->toggleRun();
|
||||||
|
}
|
||||||
|
|
||||||
void LevelInstance::Step(SimTime sdt)
|
void LevelInstance::Step(SimTime sdt)
|
||||||
{
|
{
|
||||||
switch(TimerAffectsScore)
|
switch(TimerAffectsScore)
|
||||||
@@ -196,24 +222,21 @@ void LevelInstance::Step(SimTime sdt)
|
|||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
timer = 0.0f;
|
timer = 0.0f;
|
||||||
DataModelInstance* DataModel = (DataModelInstance*)getParent(); //If level parent gets changed to something other than Datamodel it could cause nasty data corruption bugs
|
|
||||||
switch(TimerUpAction)
|
switch(TimerUpAction)
|
||||||
{
|
{
|
||||||
case Enum::ActionType::Nothing:
|
case Enum::ActionType::Nothing:
|
||||||
break;
|
break;
|
||||||
case Enum::ActionType::Pause:
|
case Enum::ActionType::Pause:
|
||||||
DataModel->toggleRun();
|
pauseCondition();
|
||||||
break;
|
break;
|
||||||
case Enum::ActionType::Lose:
|
case Enum::ActionType::Lose:
|
||||||
DataModel->setMessage(loseMessage);
|
loseCondition();
|
||||||
DataModel->toggleRun();
|
|
||||||
break;
|
break;
|
||||||
case Enum::ActionType::Draw:
|
case Enum::ActionType::Draw:
|
||||||
DataModel->toggleRun();
|
drawCondition();
|
||||||
break;
|
break;
|
||||||
case Enum::ActionType::Win:
|
case Enum::ActionType::Win:
|
||||||
DataModel->setMessage(winMessage);
|
winCondition();
|
||||||
DataModel->toggleRun();
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user