//----------------------------------------------------------------------------- // Torque Game Engine // // Copyright (c) 2001 GarageGames.Com //----------------------------------------------------------------------------- //---------------------------------------------------------------------------- // Game start / end events sent from the server //---------------------------------------------------------------------------- function clientCmdGameStart() { } function getBestTimes(%mis) { for(%i = 0; %i < 3; %i++) { $hs[%i] = $pref::highScores[%mis, %i]; if($hs[%i] $= "") { if(MissionInfo.time) $hs[%i] = MissionInfo.time @ "\tKevin"; else $hs[%i] = "5998999\tKevin"; } } } function clientCmdGameEnd() { if($playingDemo) return; getBestTimes($Server::MissionFile); if($Server::MissionFile $= "marble/data/missions/expert/timmysfork.mis") { // if we've beaten The Final Challenge show the epic finale gameIsCompleteSignalForEndGameGui(1); Canvas.pushDialog(congratsGui); } $highScoreIndex = ""; for(%i = 0; %i < 3; %i++) { if($Game::ScoreTime < getField($hs[%i], 0)) { for(%j = 2; %j > %i; %j--) { $hs[%j] = $hs[%j - 1]; } $highScoreIndex = %i; $hs[%i] = $Game::ScoreTime @ "\t" @ $pref::highScoreName; break; } } reformatGameEndText(); Canvas.pushDialog(EndGameGui); if($highScoreIndex !$= "") { if($highScoreIndex == 0) %msgIn = ""; else if($highScoreIndex == 1) %msgIn = " 2nd"; else %msgIn = " 3rd"; EnterNameText.setText("YOU\'RE WINNER!\nYou got the" @ %msgIn @ " best time!"); Canvas.pushDialog(EnterNameDlg); EnterNameEdit.setSelectionRange(0, 100000); } } function highScoreNameAccept() { Canvas.popDialog(EnterNameDlg); for(%i = 0; %i < 3; %i++) $pref::highScores[$Server::MissionFile, %i] = $hs[%i]; } function highScoreNameChanged() { $hs[$highScoreIndex] = $Game::ScoreTime @ "\t" @ $pref::highScoreName; reformatGameEndText(); } function reformatGameEndText() { // Final Score %text = "" @ "Final Time:\t" @ formatTime($Game::ScoreTime) @ "\n"; // Qualification time if($Game::Qualified) { %text = %text @ "" @ ((MissionInfo.goldTime && $Game::ScoreTime < MissionInfo.goldTime) ? "You beat the Superb time!" : "You've qualified!"); } else %text = %text @ "You failed to qualify!"; // Basic time info %text = %text @ "\n\n"; if (MissionInfo.time) %text = %text @ "" @ "Qualify Time:\t" @ ($Game::Qualified? "": "") @ formatTime(MissionInfo.time) @ "\n"; else %text = %text @ "Qualify Time:\t\t99:59.99\n"; if(MissionInfo.goldTime) { %text = %text @ "Superb Time:\t" @ formatTime(MissionInfo.goldTime) @ "\n"; } %text = %text @ "" @ "Elapsed Time:\t" @ formatTime($Game::ElapsedTime) @ "\n" @ "Bonus Time:\t" @ formatTime($Game::BonusTime) @ "\n"; %text = %text @ "\nBest Times:\n"; for(%i = 0; %i < 3; %i++) { %time = getField($hs[%i], 0); %name = getField($hs[%i], 1); %text = %text @ "" @ %i+1 @ ". " @ %name @ "\t" @ (%time < MissionInfo.goldTime ? "" : "") @ formatTime(%time) @ "\n"; } // Display the end-game screen EndGameGuiDescription.setText(%text); } //----------------------------------------------------------------------------- function formatTime(%time) { %isNeg = "\t"; if (%time < 0) { %time = -%time; %isNeg = "-\t"; } //%hundredth = mFloor((%time % 1000) / 10); %thousandth = mFloor(%time % 1000); %totalSeconds = mFloor(%time / 1000); %seconds = mFloor(%totalSeconds % 60); %minutes = mFloor(%totalSeconds / 60); %secondsOne = mFloor(%seconds % 10); %secondsTen = mFloor(%seconds / 10); %minutesOne = mFloor(%minutes % 10); %minutesTen = mFloor(%minutes / 10); //%hundredthOne = mFloor(%hundredth % 10); //%hundredthTen = mFloor(%hundredth / 10); %thousandthOne = mFloor(%thousandth % 10); %thousandthTen = mFloor(mFloor(%thousandth / 10) % 10); %thousandthHundred = mFloor(%thousandth / 100); return %isNeg @ %minutesTen @ %minutesOne @ ":" @ %secondsTen @ %secondsOne @ "." @ //%hundredthTen @ %hundredthOne; %thousandthHundred @ %thousandthTen @ %thousandthOne; //%thousandthHundred @ %thousandthTen; // same as hundredths above but with thousandths }