Added post mission code.

This commit is contained in:
Steve 2018-02-18 09:29:26 +00:00
parent 1ac2960932
commit 2cd629cf86
6 changed files with 143 additions and 9 deletions

View File

@ -44,7 +44,7 @@ _OBJS += key.o keycard.o
_OBJS += laser.o laserBlob.o laserDroid.o laserTrap.o lift.o lookup.o _OBJS += laser.o laserBlob.o laserDroid.o laserTrap.o lift.o lookup.o
_OBJS += machineGunBlob.o machineGunDroid.o main.o map.o maths.o mia.o missile.o _OBJS += machineGunBlob.o machineGunDroid.o main.o map.o maths.o mia.o missile.o
_OBJS += objectives.o _OBJS += objectives.o
_OBJS += particles.o player.o plasmaBlob.o plasmaDroid.o pistolBlob.o pistolDroid.o powerPoint.o powerPool.o pressurePlate.o pushBlock.o _OBJS += particles.o player.o plasmaBlob.o plasmaDroid.o pistolBlob.o pistolDroid.o postMission.o powerPoint.o powerPool.o pressurePlate.o pushBlock.o
_OBJS += quadtree.o _OBJS += quadtree.o
_OBJS += radar.o _OBJS += radar.o
_OBJS += shotgunBlob.o shotgunDroid.o sound.o spreadGunBlob.o spreadGunDroid.o sprites.o structures.o _OBJS += shotgunBlob.o shotgunDroid.o sound.o spreadGunBlob.o spreadGunDroid.o sprites.o structures.o

View File

@ -232,6 +232,7 @@ enum
WS_PAUSED, WS_PAUSED,
WS_GAME_COMPLETE, WS_GAME_COMPLETE,
WS_OBSERVING, WS_OBSERVING,
WS_QUIT,
WS_COMPLETE, WS_COMPLETE,
WS_MISSION_COMPLETE, WS_MISSION_COMPLETE,
WS_GAME_OVER WS_GAME_OVER

90
src/hub/postMission.c Normal file
View File

@ -0,0 +1,90 @@
/*
Copyright (C) 2018 Parallel Realities
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "postMission.h"
static void logic(void);
static void draw(void);
static void doPostMission(void);
static void updateMissionStatus(void);
void initPostMission(void)
{
startSectionTransition();
if (world.state != WS_QUIT)
{
updateMissionStatus();
}
app.delegate.logic = logic;
app.delegate.draw = draw;
endSectionTransition();
}
static void updateMissionStatus(void)
{
Tuple *t;
for (t = game.missionStatusHead.next ; t != NULL ; t = t->next)
{
if (strcmp(t->key, world.id) == 0)
{
t->value.i = getMissionStatus();
return;
}
}
t = malloc(sizeof(Tuple));
memset(t, 0, sizeof(Tuple));
game.missionStatusTail->next = t;
game.missionStatusTail = t;
STRNCPY(t->key, world.id, MAX_NAME_LENGTH);
t->value.i = getMissionStatus();
}
static void logic(void)
{
if (world.state != WS_QUIT)
{
doPostMission();
}
else
{
doPostMission();
}
}
static void draw(void)
{
}
static void doPostMission(void)
{
saveGame();
saveWorld();
destroyWorld();
initHub();
}

33
src/hub/postMission.h Normal file
View File

@ -0,0 +1,33 @@
/*
Copyright (C) 2018 Parallel Realities
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "../common.h"
extern void startSectionTransition(void);
extern void endSectionTransition(void);
extern void initHub(void);
extern void saveGame(void);
extern void saveWorld(void);
extern void destroyWorld(void);
extern int getMissionStatus(void);
extern App app;
extern Game game;
extern World world;

View File

@ -42,7 +42,6 @@ static void options(void);
static void stats(void); static void stats(void);
static void trophies(void); static void trophies(void);
static void quit(void); static void quit(void);
static void destroyWorld(void);
static Texture *background; static Texture *background;
static int observationIndex; static int observationIndex;
@ -50,6 +49,8 @@ static int showingWidgets;
void initWorld(void) void initWorld(void)
{ {
startSectionTransition();
loadWorld(game.worldId); loadWorld(game.worldId);
background = getTexture(world.background); background = getTexture(world.background);
@ -73,6 +74,8 @@ void initWorld(void)
initMap(); initMap();
initEntities(); initEntities();
addKeysFromStash();
world.enemySpawnTimer = (FPS * rrnd(world.minEnemySpawnTime, world.maxEnemySpawnTime)); world.enemySpawnTimer = (FPS * rrnd(world.minEnemySpawnTime, world.maxEnemySpawnTime));
@ -106,6 +109,8 @@ void initWorld(void)
app.delegate.logic = logic; app.delegate.logic = logic;
app.delegate.draw = draw; app.delegate.draw = draw;
endSectionTransition();
} }
static void logic(void) static void logic(void)
@ -390,9 +395,9 @@ static void doWorldComplete(void)
{ {
world.missionCompleteTimer--; world.missionCompleteTimer--;
if (world.missionCompleteTimer <= 0) if (world.missionCompleteTimer == 0)
{ {
initPostMission();
} }
else if (world.missionCompleteTimer == FPS * 1.5) else if (world.missionCompleteTimer == FPS * 1.5)
{ {
@ -401,10 +406,6 @@ static void doWorldComplete(void)
addTeleportStars((Entity*)world.bob); addTeleportStars((Entity*)world.bob);
playSound(SND_TELEPORT, CH_BOB); playSound(SND_TELEPORT, CH_BOB);
} }
else if (world.missionCompleteTimer == 0)
{
destroyWorld();
}
else else
{ {
doBob(); doBob();
@ -593,6 +594,11 @@ int getMissionStatus(void)
Objective *o; Objective *o;
Entity *e; Entity *e;
int status; int status;
if (world.missionType == MT_TRAINING)
{
return MS_COMPLETE;
}
status = MS_COMPLETE; status = MS_COMPLETE;
@ -677,7 +683,7 @@ static void quit(void)
{ {
} }
static void destroyWorld(void) void destroyWorld(void)
{ {
int i; int i;

View File

@ -86,6 +86,10 @@ extern void destroyQuadtree(void);
extern void loadWorld(char *id); extern void loadWorld(char *id);
extern void initMap(void); extern void initMap(void);
extern void initEntities(void); extern void initEntities(void);
extern void saveGame(void);
extern void saveWorld(void);
extern void initPostMission(void);
extern void addKeysFromStash(void);
extern App app; extern App app;
extern Colors colors; extern Colors colors;