⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 goal.cpp

📁 很好游戏代码
💻 CPP
字号:

#include "Goal.h"

GoalQueue::GoalQueue()
{
}

GoalQueue::~GoalQueue()
{
	ResetSubgoals();
}

typeGoalStatus GoalQueue::UpdateSubgoals( float secs_elapsed )
{
	if (mGoals.empty()) return statusSucceeded; //return success when no goals left
	
	mGoals.front()->Update( secs_elapsed );
	
	//if the goal is in progress, simply return this status
	//if the goal has failed, clear the entire subgoal list
	//if the goal has succeeded, remove it, return 
	typeGoalStatus status = mGoals.front()->GoalStatus();
	
	switch (status){
	case statusInProgress:
		break;
	case statusFailed:
		ResetSubgoals();
		return statusFailed; //return failure
		break;
	case statusSucceeded:
		delete mGoals.front();
		mGoals.pop_front();
		break;
	}
	
	//returns statusInProgress if we didn't fail and there are still goals on the list
	return statusInProgress; 
}

void GoalQueue::NewSubgoal( Goal* pGoal )
{
	mGoals.push_back( pGoal );
}

void GoalQueue::InsertSubgoal( Goal* pGoal )
{
	mGoals.push_back( pGoal );
}

void GoalQueue::ResetSubgoals() 
{ 
	while (!mGoals.empty()){
		Goal *pGoal = mGoals.back();
		delete pGoal;
		mGoals.pop_back();
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -