Friday, 12 June 2009

Team members

Designers;
Leah Betts
Todd Crawford
Alix Hatherall
Joshua Hodge

Programmers
James Jones
Yucel Karamanli
Will Warren
Stewart Rice
Aaron Hamlin

Introduction

During the second year of our university course we asked to worked on a group project of 8 indivudals, half of us beeing programmers and other half of us beeing the designers. The project which assigned to us to work on was, creating a prototype game based on a fixed story lines.

Through out the development of the game, we specificly asked to keep a diary to provide an eloctronical proofe of what we beeing doing during the scheduled time of the project. Hence the development diary of my blog has born :P .

Monday, 4 May 2009

Week 1

I was absent;

Through out the week one I havent done much exept getting used to Torque Engine. I had a go with he tutorials in TDN site as well as one in GarageGames. Additionaly studied the game concept which has been posted on the google groups.

Sunday, 3 May 2009

Week 2

Assigned tasks
  • Look in to camera collision: bug with the engine
  • Look in to Gui
Task 1:
The first task was a finding a solution to a bug inside the engine. When the player model was near a wall and facing towards to front, camera would go inside the player model ;
the only way that I could think of was increasing the size of the boundary box of the player but that was a very bad idea since it also means increasing the size of the collision mesh.

Task2
Understanding the GUI was quite easy, since I looked in to last week. However, since the Gui was not the important part, i didn't do much work on it exept creating couple of splash screens and a main menu.

Week 3

Assigned Tasks:
  • Lighting
  • Texture Animation

Task 1:
I played around with default lights which comes with the engine. Unlike lighting pack, the default lights from engine were dynamic. I also tried to create a player lighting by attaching the light to the center of a simple shape which I created in Maya .


Task 2:
Looked in to the texture animation in torque, Found out we could use an animation technique called IFL(image file List ). I think this term only applies to TGE. It is basicly a list of images animated on the DTS object but there are only tutorials for 3Ds max and LightWave.
Here is the link for the tutorial
http://tdn.garagegames.com/wiki/DTS/Advanced_Lessons

Week 4


Assigned Task
  • Create a Terrain based on Todd's map (working with Todd)

Task 1
In order to create the terrain, i had to make a heaight map. By using this heigh map, I could easly create a terrain and adjust it to look like Todd's map. I used a third party program called Terragen to create the height map.

After I created a couple of draft versions of the terrain I asked feed back from Todd and made sure it is acceptable. we additionally add some texture to terrain . I introduced the image files which has been created by Todd and he done the painting of the terrain.

Week 5


Assigned Task
  1. populate the map with Place holders
  2. Add snow particles in to the game map (particles from Aaron)
  3. Find out if specular mapping working in TGE
  4. make a player light following player all time
Task 1:
Mike suggested us to populate the map by using the models inside the engine. Additionaly , we had a hud model from artists to put in to the game.

Task2 :
Also added the snow particles which done by Aaron in to the game.

Task3:
In order to make the tattoos of the player character get effected by light source, I was asked to search if the specular map was supported in TGE. Soon we found it was only available in TGEA unless if we could code it.

Task4:
successfully done. I created a light holder model with three joints. Root, mount0 and mount Point. mount0 node used for attaching the Light holder to player model. mountPoint used as attaching a spot light to the lightHolder model.

Week 6

Assigned Tasks
  1. Adding lights in to the game world
  2. Moving the game map from Tutorial.Base to starter.fps
  3. placing additional placeholders and models from artists

Task 1 :
I was expecting the task finish soon since I was already working on lighting. but that didint go as I planned. too much lighting in terrain give me performance problems. Tried to improve the performance by changing all the light to static type. however, static lights failed on me too when I saw the weird lighting effects. snapshot below displays this problem.


Reducing the rendering distance wasn't an option since Designers wanted to view all the level at the beginning. Mike suggested to divide the terrain to two parts. A city in distance; showing everything in the level and a city level which shows only the city.

I took some of his idea and add third separate level. The reason for the third level was making sure that when we placed the objects and light the fortress area, we would minimize the performance issue. I talked about the approach with designers and everyone was happy.

Dividing the level also bring the issue of teleporting from one level to another. Thankfully I found a good tutorial for that. By the end of the week, I had static lights as well as dynamic lights and teleportation triggers in the game world.

Task 2 :
This was assigned on thursday's meeting with programmers. Since all of the team members using starter.fps as demo, I had to move the works that I have done to starter.fps

Task 3:
Thanks to the lighting issues, I couldnt work on this much. It wasn't a big deal since there weren't many models to put in to the engine.

Week 7

Assigned Tasks
  1. black out the screen when teleporting to next mission
  2. start working on Gui
  3. simplify the game map
  4. include flare animation to dynamic lights

Task 1:

It was a simple process than what we all thought. All I had to do was call a function which was already implemented inside the engine (setBlackOut) . I also scheduled the blackout in order to stop showing the Loading window before the black out complete.

Task 2:
Started working on Gui. First think I have done modify the main menu and LoadingGui which come with the starter.fps. Additionaly created a function to display different background images in loading gui for different levels. More simply, if the player teleports to fortress leve, a fortress image would show and if teleports to hill top , a hill top image would show.

Task 3
I reduced the crazy amount of image shape replicaters I previosly used for ogranic materials.

Task4
enabled the flare animation for dynamic lights. This made the torch lights more realistic.

Additionally I had some new models from Designers. I added them in to the game.

Week 8

Assigned Tasks:
  1. integrate a single built(as a team)
  2. Add new models from artists
  3. playing animation and adding the character light from week 3(last minute task)

Task 1:
Beeing aware of the presentation, we integrated the works of all programmers as one unit. We couldn't understand why advanced camera would use too much resources. We had to go with out the advanced camera due to the lag caused in game.

Task 2:

This part was done through out the week. Designers textured almost all of the models.I replaced the existing ones with these new fixed models. Also we add the stable and horses in to the game

Task 3:

Me and Todd worked on this together. We firstly add the player character in to the game. He created run, back, sidewalk, jump animations for the player character. Additionaly he created wave, node and cry animations which then I binded each animation to specific keys.

He also add a mount node in to the back of the player character which gave me the option of mounting the light from my previos week.

Through out the easter

Through out the easter I worked on:
  1. creating count down timer
  2. playing cutscenes in engine

Task 1:
I used one of the sources on the internet to create a count down hud. There was already a timer hud in engine but it wasn't counting reverse and didnt had the pause/unpause functionality.

After I get it working I had to change the desing of the counter. I used Mike's suggesten. Created roman numbers and used it as the timer. Currently it only displays the remaining minutes. Additionaly , I made sure that the game ends if th timer reaches 0.

Task2:
I looked in to how to play avi formats in engine. Found a tutorial for that but it diddn't work with the current version of the engine. I am sure it was fixible, but thanks to the luck on knowledge in coding, I had to look in to alternative ways. Soon after I found out we could play OGM or OGG movie formats as long as if they were composed of Theora and Vorbis codec. luckly I found a converter suggested from garage games which converted the avi format to OGM in previosly specifed codecs(Vorbis and Theora)

I randomly loaded a OGG file from internet and test it . Outcome was a success.

week 9

Assigned tasks
  1. add new models and design works from designer in to the game
  2. work on shadows
During this week I mainly concantrated on adding materials from designers in to the game.
However through out the end of the week , Added some shadows in the terrain as well.

Week 10

assigned tasks.
  1. add remaining materials from designers
  2. create a endGame Gui with Restart and Quit buttons
  3. make the light holder model invisible.
  4. Make sure game ends if the guard caches the player

Task 1 :
Since there were no new materials, I couldn't do anything on this task. Probabily we have to do remaining bits on next week.

Task2:
Created an endGAme gui displayed for ending the game. When the time runs out or when the player cought by a guard, game would be over. I also made sure that player could restart the game after clicking a retry button.

Task3:
I worked on maya to make the light holder shape for player character invisible. I added the transparant texture on top of the model.

Task4:
Created a oncollision function and checked if the collided object is A.I guard. If it is true, I called the endGame Gui for ending the game .

Saturday, 2 May 2009

How to: Add models in to the engine as static shapes

There are two ways we can add models in to the game
As tsStatic shapes which inherits from sceneobject class or/and
As stacicShape which inherits from ShapeBase class

putting the models as tsStatic shape is an easy job. All we need to do is put the models in to the data folder and engine will recognise these models for us.

For static shapes its a bit more work. We need to make sure that each model has a static shape data block. Hence every object created from this datablock becomes a staticshape and inherites everything from its parent classes.

I put the all static shape data folders in to the staticShapes.cs folder, located at server/scritps.

// celtic building (not an interior)
datablock StaticShapeData(celticBuilding)
{
category = "Celticbuildings";
shapeFile = "~/data/shapes/buildings/hut.dts";
};

datablock StaticShapeData(romanBuilding1)
{
category = "romanBuildings";
shapeFile = "~/data/shapes/buildings/Building1.dts";
};
datablock StaticShapeData(romanBuilding2)
{
category = "romanBuilding";
shapeFile = "~/data/shapes/buildings/Building2.dts";
};
datablock StaticShapeData(romanBuildingData)
{
category = "romanBuilding";
shapeFile = "~/data/shapes/buildings/Building1.dts";
};

datablock StaticShapeData(romanBuildingData2)
{
category = "romanBuilding";
shapeFile = "~/data/shapes/buildings/romanbuild1.dts";
};

//torch for building shapes
datablock StaticShapeData(torchStaticShape)
{
category = "torch";
shapeFile = "~/data/shapes/lightHolder/torch.dts";
scale = "5 5 5";
};
// light holder shape used for mounting to player
datablock StaticShapeData(playerLightHolder)
{
category = "lightHolder";
shapeFile = "~/data/shapes/lightHolder/lightHolder.dts";
};

datablock StaticShapeData(fortressWall)
{
category = "fortress";
shapeFile = "~/data/shapes/buildings/fort.dts";
};
datablock StaticShapeData(marketTent)
{
category = "market";
shapeFile = "~/data/shapes/buildings/markettent.dts";
};

datablock StaticShapeData(seat)
{
category = "seat";
shapeFile = "~/data/shapes/otherModels/seat1.dts";
};
datablock StaticShapeData(table)
{
category = "table";
shapeFile = "~/data/shapes/otherModels/table1.dts";
};
datablock StaticShapeData(cart)
{
category = "cart";
shapeFile = "~/data/shapes/otherModels/cart.dts";
};
datablock StaticShapeData(stable)
{
category = "stable";
shapeFile = "~/data/shapes/buildings/stable.dts";
};
datablock StaticShapeData(fence)
{
category = "cart";
shapeFile = "~/data/shapes/otherModels/fence.dts";
};
datablock StaticShapeData(temple)
{
category = "stable";
shapeFile = "~/data/shapes/buildings/temple2.dts";
};
datablock StaticShapeData(amphi)
{
category = "stable";
shapeFile = "~/data/shapes/buildings/colis.dts";
};


our work with the staticShapes.cs is done. Now we need to execute this script to compile.
In order to do that all we need is add a single line of code in game.cs file located at server/scripts
exec("./staticShapes.cs");
Now we can see these data blocks in world editor creator and create static shapes.

How to: Add intro and cutscene as OGM/OGG format

Creating a IntroGui to display the intro scene
Firstly , I need to create a gui to display the intro scene. In order to be able to play OGM or OGG movie i need to use the gui controller named GuiTheoraCtrl.

theoraFile attribute used for locating the media file which I am going to use in our intro. Next thing I need to do create some functions to load the introGui and end the playback once the media finishes.I will be adding all these codes in to the intro.Gui

First function which i will be creating is loadIntroGui. As anyone can guess it will be used to load the introGui.


This function will be called from chechStartUpDone function scripted in StartUpGui. Which located at gameDirectory/client/ui





I also need to create a method which stops the playback and load the main menu Gui.






Now there is a problem which we have to look in to. How can we know when to stop the playback? So far , I couldn't find any information regarding to this. Then I thought i could schedule(delay) to this function call based on the time frame of the video. in simple terms, if the video is 6 second long then I could be able to schedule the function call to 6 second. Luckly schedule function already comes with the engine.








Our Intro is done. Now we can move on to cut scene.


Creating CutSceneGui to display cutscene movie

same as above, first thing I need to do is create a GuiTheoraCtrl and functions to load the gui.
Following pic showing the code is a bit long. For clear view just click on the pic.


Now our Gui is done we need to concentrate on how to activate this GUI in game. The simplest way is using the trigger. When the player gets in to the trigger we can call the loadCutSceneGui function. in order to create a trigger, first think I need to do is create a trigger data block and onEnterTrigger function to load the gui.


there are some additional things I have done in onEnterTrigger().
firstly, I stoped the game sound then paused the countdown.
and I eventuallyfreeze the game play by using $timeScale variable. This call absolutely necessary otherwise, while the movie playing the game will still continue under the canvas(game window)
The rest of the code used for loading the gui after we enter in to the trigger.

Placing the movieTrigger in to the game world
We now need to place the movie trigger in to the game. We can modify the mission file or alternatively we can use the world editor in game.

I am going to use world editor so that I can see what I am doing.
- start the game as usual
- once the game starts press on f11 to bring world editor
- choose world editor creator from the window toolbar
- find the trigger sim object from mission object\ mission sim group and click on it.
- Building Object Trigger pop up window will display on screen. choose the movie trigger datablock which we defined. Now we have a movie trigger in game world.
- scale/place it as you prefer.

Converting Avi to OGG/OGV (Additional)

There is a convertor which we can use to convert avi format to ogv format. the program is called ffmep2Theora and its downloadeble from;
http://v2v.cc/~j/ffmpeg2theora/

This program, works only in command prompt.
In order to conver the avi video;
- put the avi in to the directory ffmpeg2theora folder.(in my pc i use "C:\documents and Settings\school
- now in command prompt type the name of the program followed by space, followed by the name of the avi (with its extension). as an example lets say the avi format I am going to convert is named cutscene. So i need to type: ffmeg2theora cutscene.avi

How to: end game when caught by Guards

Ending the game if a guard catches the player

Torque engine comes with a console method called onCollision. This is the function which I will be working on.

In the game we will be colliding with many objects.Hence, if I am going to use this function i need to know what I am colliding with. One way i can do this is the check the collided object and see what kind of datablock it is based on. collided object has to be defined with a datablock other wise wont work.

after studying of the code, I found that the datablock used for A.I guards is AIPlayer. The data block scripted in player.cs (located at gameDirectory/server/scripts). I will also define the oncollision function inside the player.cs file



next thing i need to do is create a way to end the game. I will be checking the $isBeenCought variable. if it is true it will end the game.

The repeatTillQuit function has been discussed in how to add count down timer. I need to modify this function further to end the game if the player get caught. I prefer this function just because it is recursive. The function scheduled to call it self every one second. Basicly I can check the status of the game in every one second.


Note that i also add if else statement to see if the game ends as a result of running out of time or being caught by a guard. By using if else statements, i can change the background images and screen writing based on the way the game ended.

How to: add teleportation triggers

The teleportation scripts are not the result of a hard work of my side.Most of the code has been provided from garage games community. All I had to do was modify it as I needed. Here is the link forthe tutorial.I just found a tutorial regarding to that and modified it four our game. Resource can be found from the following link;
http://www.garagegames.com/community/forums/viewthread/34506


Here is my modified version of teleportation trigger data blocks and functions (all scripted inside
http://www.garagegames.com/community/resources/view/7532

$scene0="starter.fps/data/missions/caerleonRomanCity.mis";// loading second mission area romanCity
$scene1="starter.fps/data/missions/caerleonFortress.mis";// loading third mission area fortress
$scene2="starter.fps/data/missions/caerleonHillTop.mis";// loading first mission area hillTop
$scene3="starter.fps/data/missions/caerleonCelticCity.mis";// loading forth mission area celticCity
$currentScene = $scene2;

// creating teleport triggers for romanCity mission

//from celticCity to romanCityS point
datablock TriggerData(toRomanCityS)
{
tickPeriodMS = 100;
};
//from romanCity to fortress West point
datablock TriggerData(toFortressW)
{
tickPeriodMS = 100;
};
//from romanCity to celticCity Norht point
datablock TriggerData(toCelticCityN)
{
tickPeriodMS = 100;
};
datablock TriggerData(toRomanCityN)
{
tickPeriodMS = 100;
};

datablock TriggerData(toRomanCityNW)
{
tickPeriodMS = 100;
};

//from hilltop to fortress entrence
datablock TriggerData(toFortressN)
{
tickPeriodMS = 100;
};


//creating teleport triggers for hillTop mission
//from romanCity to hillTop
datablock TriggerData(toHillTopSouth)
{
tickPeriodMS = 100;
};

datablock TriggerData(toHillTopSouthW)
{
tickPeriodMS = 100;
};

//creating teleport triggers for fortress mission
//from fortress to hillTop
datablock TriggerData(toHillTopSouthE)
{
tickPeriodMS = 100;
};

//from fortress to romancity
datablock TriggerData(toRomanCityE)
{
tickPeriodMS = 100;
};

//function for teleporting from celticCity to romanCitySout Point
function toRomanCityS::onEnterTrigger(%this,%trigger,%obj)
{
Parent::onEnterTrigger(%this,%trigger,%obj);
LoadingGui.setBitmap("starter.fps/client/ui/cityImage");
LaunchMission($scene0, "romanCitySPoint");
$currentScene = $scene0;
pauseCountdown();


}
//function for teleporting from fortress to romanCityWest Point
function toRomanCityE::onEnterTrigger(%this,%trigger,%obj)
{
Parent::onEnterTrigger(%this,%trigger,%obj);
LoadingGui.setBitmap("starter.fps/client/ui/cityImage");
LaunchMission($scene0, "romanCityEastPoint");
$currentScene = $scene0;
pauseCountdown();
}

//function for teleporting from romanCity to fortressWest Point
function toFortressW::onEnterTrigger(%this,%trigger,%obj)
{
Parent::onEnterTrigger(%this,%trigger,%obj);
LoadingGui.setBitmap("starter.fps/client/ui/fortressImage");
LaunchMission($scene1, "fortressSPoint");
$currentScene = $scene1;
pauseCountdown();
}
//function for teleporting from romanCity to celticCityNorth point
function toCelticCityN::onEnterTrigger(%this,%trigger,%obj)
{
Parent::onEnterTrigger(%this,%trigger,%obj);
LoadingGui.setBitmap($scene3);
LaunchMission($scene3, "celticCityNorthPoint");
$currentScene = $scene3;
pauseCountdown();
}

//function for teleporting from romanCity to hillTopSouthWPoint
function toHillTopSouthW::onEnterTrigger(%this,%trigger,%obj)
{
Parent::onEnterTrigger(%this,%trigger,%obj);
LoadingGui.setBitmap("starter.fps/client/ui/hillTopImage");
LaunchMission($scene2, "hillTopSouthWPoint");
$currentScene = $scene2;
pauseCountdown();
}
//function for teleporting from romanCity to hillTopSouthPoint
function toHillTopSouth::onEnterTrigger(%this,%trigger,%obj)
{
Parent::onEnterTrigger(%this,%trigger,%obj);
LoadingGui.setBitmap("starter.fps/client/ui/hillTopImage");
LaunchMission($scene2, "hillTopSouthPoint");
$currentScene = $scene2;
pauseCountdown();
}
//function for teleporting from fortress to hillTopSoutEhPoint
function toHillTopSouthE::onEnterTrigger(%this,%trigger,%obj)
{
Parent::onEnterTrigger(%this,%trigger,%obj);
LoadingGui.setBitmap("starter.fps/client/ui/hillTopImage");
LaunchMission($scene2, "hillTopSouthEPoint");
$currentScene = $scene2;
pauseCountdown();
}

//function for teleporting from hillTop to romanCityNorthW point
function toRomanCityNW::onEnterTrigger(%this,%trigger,%obj)
{
Parent::onEnterTrigger(%this,%trigger,%obj);
LoadingGui.setBitmap("starter.fps/client/ui/cityImage");
LaunchMission($scene0, "romanCityNWPoint");
$currentScene = $scene0;
pauseCountdown();
}

//function for teleporting from hillTop to romanCity North point
function toRomanCityN::onEnterTrigger(%this,%trigger,%obj)
{
Parent::onEnterTrigger(%this,%trigger,%obj);
LoadingGui.setBitmap("starter.fps/client/ui/cityImage");
LaunchMission($scene0, "romanCityNPoint");
$currentScene = $scene0;
pauseCountdown();
}

//function for teleporting from hillTop to Fortress North Point
function toFortressN::onEnterTrigger(%this,%trigger,%obj)
{
Parent::onEnterTrigger(%this,%trigger,%obj);
LoadingGui.setBitmap("starter.fps/client/ui/fortressImage");
LaunchMission($scene1, "fortressNPoint");
$currentScene = $scene1;
pauseCountdown();
}

function LaunchMission(%mission, %spawn, %timeout)
{
fadeScreenOutandIn(0,5000,5000,0);
if (!$Game::LaunchingMission)
{

$Game::NextMission = %mission;
$Game::NextSpawn = %spawn;
$Game::LaunchingMission = true;
schedule(5000, 0, "onLaunchMission");
}
}




function onLaunchMission()
{
$Game::LaunchingMission = false;
loadMission($Game::NextMission);
}


also changed the pickSpawnPoint function scripted in Game.cs folder to following code:

function pickSpawnPoint()
{
%groupName = "MissionGroup/PlayerDropPoints";

if ( $Game::NextSpawn !$= "" ) {

%spawn = nameToID( %groupName @ "/" @ $Game::NextSpawn );
$Game::NextSpawn = "";
if ( %spawn != -1 )
return %spawn.getTransform();
}

%group = nameToID(%groupName);
if (%group != -1) {
%count = %group.getCount();
if (%count != 0) {
%index = 0; //getRandom(%count-1);
%spawn = %group.getObject(%index);
return %spawn.getTransform();
}
else
error("No spawn points found in " @ %groupName);
}
else
error("Missing spawn points group " @ %groupName);

// Could be no spawn points, in which case we'll stick the
// player at the center of the world.
return "0 0 300 1 0 0 0";
}

How to: add count down timer



Modifying the GuiClockHud in engine

Torque engine comes with a timer function. In order to use this function, we need to create a Gui Hud in our play screen. The component which we going to use named as GuiClockHud. However there are some problems we need to consider.
GuiClockHud only used for counting upwards. It doesn’t have the functionality of count down timer. Also it doesn’t have a function for pausing the time while loading the mission areas. In order to fix this tiny problems we need to modify the actual C++ file used for GuiClockHud.

In garage games there is a tutorial already covering how to do this. http://www.garagegames.com/community/resources/view/4978
Basicly all of the code which we need for modification of the engine provided in above link.

So our first job is compiling the torque engine with a new GuiClockHud which provides a countdown , pause and unpause functionality.


Adding GuiClockHud in to Play screen

After we compiled our code we can display our countdown timer by adding a new Hud object in to our play screen gui. Our play screen named as CloakGui.All we need to do add the following lines for creating GuiClockHud.





Displaying the countdown timer

First think we need to do is to set the countdown time by calling the setReverseTime function. In this case our CountDown gui named as Timer. We
can set the Time by adding “Timer.setReverseTime(600)” .

Now, we should be able to see the count down starting from 10 minutes.
However there is a design issue which we should consider. The Count down timer is more suited for games which takes place in modern times. More precisely, the count down timer doesn’t suite for ancient games like ours.

Modifying Countdown timer further with Torque Scripting
.

The way I approach this problem is not the best way . however with the limited knowledge I could only think of this for time being.

In order to make more ancient looking timer, I created 10 roman numerals which was suggested by Mike. All these numerals stored as jpg files in client/ui/romanNum.

Now all I need to do;
- create a GuiBitmap control which used for displaying the jpg files which been created .
- create function which reads the current time from the actual GuiClockHud which we previously created and change the bitmap of the GuiBitmap control with a correct jpg file.


Creating GuiBitmap Control

Again, we need to display the jpg files in Play screen therefore we need to add a
guibitmap control in Clock.gui.
















Creating a TimerImageList.cs file for our functions

The first function which I will be creating used for selecting correct jpg file and assigning to the GuiBitmapCtrl. The following snapshot displays the code for this function.



All those if statements are used for checking the current time and changing the bitmap image of the GuiBitmapCtrl which we created previously.


Keeping track of the countdown timer for ending the game and changing the bitmap Image
There are two thinks we need consider. The first thing we have to consider is keeping the track of the time so that when the countdown timer gets in to the next minute, it changes the current image of the Guibitmap control to the correct image.

The second thing we have to consider is ending the game if the timer reaches zero.



repeatTillQuit function keep repeats by calling itself. This function calls the setTimerImage function in it’s body.

I also add additional functionality which is used for ending the game. if the countdown reaches under one second, endgame function will be called to end the game.

Ending the game was a bit tricky task. Since the repeatTillQuit function will execute before the actual game starts, the count time will be equal to zero. Therefore, the game would end before even starts. In order to fix this problem, I created a global Boolean variable which used for tracking whether if the game is running or not running. If the game is not running, the endgame function will be skipped until the game starts.


Pausing and Unpausing the Timer.

Additionaly I created two funtions to pause and unpause timer. This is an important function which we could use when we loading the mission.












Setting up the executions and function calls

- add timerImageList.cs in to the execution list of the init.cs file located at client/scripts folder. We have to make sure that timerImageList.cs executes before the CloakGui. Other wise cloakGui won’t be able to find the function since it is not compiled yet.

- need to set the value of isCountStarted global variable to “True” after player enters the game. We can set the value in GameConnection::onClientEnterGame method.

- need to set the time limit and pause it at the same time when the mainMenuGui loads. We can use this gui for required function calls.

- need to unpause the timer right after missiondownload. Therefore, we need to call unpauseCountDown function in missionDonwloadComplete function which is defined in missionDownload.cs. Located at client/scripts folder.

- need to pause the timer when we enter in to teleportation triggers. Therefore we need to call pauseCountDown function in every function used for teleportation. All the teleportation functions placed in teleportTriggers.cs file located at server/scripts folder.

- need to reset the time and pause it if the game ends. This is important because if the game reloads after a while it will continue from old time.