Added time up status for finishing a challenge already partly passed.

This commit is contained in:
Steve 2016-03-05 15:34:37 +00:00
parent f55a4e57c8
commit 09a89e692b
6 changed files with 48 additions and 27 deletions

BIN
gfx/battle/timeUp.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.5 KiB

View File

@ -96,7 +96,7 @@ void initBattle(void)
static void logic(void)
{
if (battle.status == MS_IN_PROGRESS || battle.status == MS_COMPLETE || battle.status == MS_FAILED)
if (battle.status == MS_IN_PROGRESS || battle.status == MS_COMPLETE || battle.status == MS_FAILED || battle.status == MS_TIME_UP)
{
handleKeyboard();
@ -276,12 +276,12 @@ static void handleKeyboard(void)
break;
}
memset(app.keyboard, 0, sizeof(int) * MAX_KEYBOARD_KEYS);
clearInput();
playSound(SND_GUI_CLOSE);
}
if (app.keyboard[SDL_SCANCODE_TAB])
if (battle.status == MS_IN_PROGRESS && app.keyboard[SDL_SCANCODE_TAB])
{
battle.status = MS_PAUSED;
}
@ -296,7 +296,7 @@ static void resume(void)
{
show = SHOW_BATTLE;
memset(app.keyboard, 0, sizeof(int) * MAX_KEYBOARD_KEYS);
clearInput();
}
static void continueGame(void)

View File

@ -83,6 +83,7 @@ extern void destroyBullets(void);
extern void destroyEffects(void);
extern void initChallengeHome(void);
extern void updateAccuracyStats(unsigned int *stats);
extern void clearInput(void);
extern App app;
extern Battle battle;

View File

@ -28,6 +28,7 @@ static SDL_Texture *missionStartTexture;
static SDL_Texture *missionInProgressTexture;
static SDL_Texture *missionCompleteTexture;
static SDL_Texture *missionFailedTexture;
static SDL_Texture *timeUpTexture;
static const char *objectiveStatus[OS_MAX];
void initMissionInfo(void)
@ -43,6 +44,7 @@ void initMissionInfo(void)
missionInProgressTexture = !isChallenge ? getTexture("gfx/battle/missionInProgress.png") : getTexture("gfx/battle/challengeInProgress.png");
missionCompleteTexture = !isChallenge ? getTexture("gfx/battle/missionComplete.png") : getTexture("gfx/battle/challengeComplete.png");
missionFailedTexture = !isChallenge ? getTexture("gfx/battle/missionFailed.png") : getTexture("gfx/battle/challengeFailed.png");
timeUpTexture = getTexture("gfx/battle/timeUp.png");
}
void drawMissionInfo(void)
@ -74,6 +76,18 @@ void drawMissionInfo(void)
}
}
break;
case MS_TIME_UP:
if (battle.missionFinishedTimer <= -FPS)
{
drawMissionSummary(timeUpTexture);
if (battle.missionFinishedTimer <= -(FPS * 2))
{
drawWidgets("battleWon");
}
}
break;
}
}

View File

@ -31,8 +31,8 @@ static void failChallenge(void);
static void updateChallenges(void);
static char *getFormattedChallengeDescription(const char *format, ...);
char *getChallengeDescription(Challenge *c);
static int hasFailedAllChallenges(void);
static int challengeFinished(void);
static int alreadyPassed(void);
static void printStats(void);
static char descriptionBuffer[MAX_DESCRIPTION_LENGTH];
@ -80,14 +80,14 @@ void doChallenges(void)
{
if (challengeFinished())
{
updateChallenges();
if (hasFailedAllChallenges())
if (battle.stats[STAT_TIME] >= game.currentMission->challengeData.timeLimit)
{
failChallenge();
}
else
{
updateChallenges();
completeChallenge();
}
}
@ -120,24 +120,6 @@ static int challengeFinished(void)
return 0;
}
static int hasFailedAllChallenges(void)
{
int i;
Challenge *c;
for (i = 0 ; i < MAX_CHALLENGES ; i++)
{
c = game.currentMission->challengeData.challenges[i];
if (c && c->passed)
{
return 0;
}
}
return 1;
}
static void updateChallenges(void)
{
int i;
@ -379,5 +361,28 @@ static void failChallenge(void)
retreatEnemies();
player->flags |= EF_IMMORTAL;
if (alreadyPassed())
{
battle.status = MS_TIME_UP;
}
}
}
static int alreadyPassed(void)
{
int i;
Challenge *c;
for (i = 0 ; i < MAX_CHALLENGES ; i++)
{
c = game.currentMission->challengeData.challenges[i];
if (c && c->passed)
{
return 1;
}
}
return 0;
}

View File

@ -262,7 +262,8 @@ enum
MS_IN_PROGRESS,
MS_PAUSED,
MS_COMPLETE,
MS_FAILED
MS_FAILED,
MS_TIME_UP
};
enum