Exemplo n.º 1
0
bool CServerMissionMgr::NextMission( )
{
	TRACE( "CServerMissionMgr::NextMission\n" );

	// Check if we're already exiting a level.
	if( m_bExitingLevel )
		return true;

	// If this was a custom level, then the game is over.
	if( m_bCustomLevel )
	{
		// Let the endgame code figure out what we should do.
		if( !EndGame( ))
			return false;

		return true;
	}

	// Get the mission.
	MISSION* pMission = g_pMissionButeMgr->GetMission(m_nCurrentMission);
	if( !pMission )
	{
        ASSERT( !"CServerMissionMgr::NextMission:  Invalid mission." );
		return false;
	}

	// Start level index over and advance the mission index.
	m_nCurrentLevel = 0;
	m_nCurrentRound = 0;
	m_nCurCampaignIndex++;

	// See if we reached the end of our campaign.
	if( m_nCurCampaignIndex >= ( int )m_Campaign.size( ))
	{
		// Let the endgame code figure out what we should do.
		if( !EndGame( ))
			return false;

		return true;
	}

	// Get the missionid from the campaign.
	m_nCurrentMission = m_Campaign[m_nCurCampaignIndex];

	// Flag that this is a new mission so we can tell everyone else.
	m_bNewMission = true;

	// Get the worldname from the mission/level indices.
	char const* pszFilename = GetLevelFromMission( m_nCurrentMission, m_nCurrentLevel );
	if( !pszFilename )
		return false;

	// Do the exit level.
	if( !ExitLevel( pszFilename, false ))
		return false;

	return true;
}
Exemplo n.º 2
0
void hhBlackJack::Stay()
{
	FollowDealerRules();
	AssessScores();
	EndGame();
	UpdateView();
}
Exemplo n.º 3
0
void hhBlackJack::Deal()
{
	// Empty hands
	PlayerHand.Clear();
	DealerHand.Clear();

	Bet = PlayerBet;
	creditsWon = 0;

	// Deal initial hands
	PlayerHand.Append(GetCard(1));
	DealerHand.Append(GetCard(0));
	PlayerHand.Append(GetCard(1));
	DealerHand.Append(GetCard(1));

	RetallyScores();

	bCanIncBet = false;
	bCanDecBet = false;
	bCanDeal = false;
	DeterminePlayCommands();
	resultIndex = -1;

	if (PlayerScore == 21) {
		AssessScores();
		EndGame();
	}

	UpdateView();
}
Exemplo n.º 4
0
int GameSession( int players_number )
{
  GAME *game;

  LogInit();

  if ((game = AcceptPlayers(players_number)) == NULL)
  {
/*    MessageBox(NULL, strerror(GetLastError()), "Vse ochen ploho((", 0);*/
    return 0x239;
  }

  SendPropInfo(*game);

  while (1)
  {
    COMMAND command;
    RESULT result;

    command = ReadCommand(*game);
    result = CheckResult(game, command);
    SendResult(*game, result);
    game->Current_player = (game->Current_player + 1) % game->Players_number;

    if (result.Result == RESULT_WINNER)
    {
      EndGame(*game);
      free(game->Players);
      free(game);
      return 0x30;
    }
  }
}
Exemplo n.º 5
0
	void CTetris::SetGameOver(void)
	{
		EndGame();
		SetGameState(GameOver);
		if (m_gameMusicInstance.isPlaying())
			m_gameMusicInstance.stop();
	}
Exemplo n.º 6
0
//update the game
void GameWindow::Update()
{
	//if in game
	if(m_bInGame){
		//Spawn Enemies
		Spawn();
		//check for damage
		Damage();
		//run enemy ai
		for(int i = 0; i < 7; i++){
			if(m_eAllEnemies[i].m_bOnScreen){
				m_eAllEnemies[i].AI(m_pPlatformList, m_PlatformCount, m_wPlayer);
			}
		}
		//move all entities
		Movement();
		//check players displayed image
		m_wPlayer.SwapImage();
		m_wPlayer.Tick();
		//apply gravity to all entities
		Gravity();
		//reset player velocity
		m_wPlayer.m_xVelocity = 0;
	}
	//handle key input
	HandleInput();
	//draw all images and sprites
	Draw();
	//check if game over
	EndGame();
}
Exemplo n.º 7
0
void AGameState::OnRep_bMatchIsOver()
{
	if ( bMatchIsOver )
	{
		EndGame();
	}
}
Exemplo n.º 8
0
	void CTetris::StartNewGame(void)
	{
		if (GetGameState() == GameRunning || GetGameState() == GamePaused)
			EndGame(false);
		m_curBrick = CreateRandomBrick();
		if (!m_gameMusicInstance.isPlaying())
				m_gameMusicInstance.play();
		SetGameState(GameRunning);
	}
Exemplo n.º 9
0
// Immediately ends the current game (if any).
// params:
// returns:
JSBool EndGame(JSContext* cx, uintN argc, jsval* vp)
{
	JSU_REQUIRE_NO_PARAMS();

	EndGame();

	JS_SET_RVAL(cx, vp, JSVAL_VOID);
	return JS_TRUE;
}
Exemplo n.º 10
0
Engine::~Engine() {
    //End the game
    EndGame();
    //Clean up now Since we can only deconstruct an object once we won't double delete pointers.
    for (int i = 0; i < Width; i++) {
        delete[] Map[i];
    }
    delete[] Map;
}
Exemplo n.º 11
0
void ProcessWon(void)
{
	if(iLastAction)
	{
		iGameStatus = GameMainMenu;
	}

	EndGame();
}
Exemplo n.º 12
0
/** Private **/
void Game::EventHandling()
{
	sf::Event event;
	while(gameWindow.pollEvent(event))
	{
		if(event.type == sf::Event::Closed)
			EndGame();
	}
}
Exemplo n.º 13
0
void base_tetrix_scene::CheckGameStatus()
{
	int i;
	int j;
	int flag = 0;

	int x;
	int y;
	//firstly,check that is need to clear blocks
	for(i = 0; i < m_pcontext_activity->b_y_size; i++)
	{
		for(j = 0; j < m_pcontext_activity->b_x_size; j++)
		{
			if(m_pcontext_activity->pSceneData[j + i*m_pcontext_activity->b_x_size] == 0)
			{                   
				flag=0;
				break;
			}
			else
			{
				flag=1;
			}
		}

		if(flag == 1)//when the ith floor can be clear
		{
			for(j=0; j<m_pcontext_activity->b_x_size; j++)
			{
				m_pcontext_activity->pSceneData[j + i*m_pcontext_activity->b_x_size] = 0;
			}

			for(x=i-1; x>=0; x--)
				for(y=0; y<m_pcontext_activity->b_x_size; y++)
				{
					if(m_pcontext_activity->pSceneData[y + x*m_pcontext_activity->b_x_size] != 0)
					{
						m_pcontext_activity->pSceneData[y + (x+1)*m_pcontext_activity->b_x_size] = m_pcontext_activity->pSceneData[y + x*m_pcontext_activity->b_x_size];
						m_pcontext_activity->pSceneData[y + x*m_pcontext_activity->b_x_size] = 0;
					}
				}
		}
	}

	for(i=0; i<m_pcontext_activity->b_x_size; i++)
	{
		if ( m_pcontext_activity->pSceneData[i] != 0 )
		{
			EndGame();
			return;
		}
	}
	
	Sync_Scene_Data(m_pcontext_freeze, m_pcontext_activity);

	BlockFactory();
}
void TetrixController::OnDataCommand(UINT nCode, WPARAM wParam, LPARAM lParam)
{
	if (IsInGameScope())
	{
		switch (nCode)
		{
		case DATA_CHANGED:
			m_spTetrixViewer->DrawBlocks((const Point *)wParam, (UINT)lParam);
			m_spTetrixViewer->Draw();
			break;
		case DATA_TOP_OVERFLOW:
			m_spSound->PlayEnd();
			EndGame();
			break;
		case DATA_ARRANGE_TO_DELETE:
			m_spSound->PlayDelete((UINT)lParam);
			m_spTetrixViewer->DrawSpecialDestroy((const UINT*)wParam, (UINT)lParam);
			break;
		case DATA_ARRANGE_DELETED:
			{
				switch((UINT)lParam)
				{
				case 0:
					++m_tetrixInfo.singleLineDelTimes;
					break;
				case 1:
					++m_tetrixInfo.doubleLineDelTimes;
					break;
				case 2:
					++m_tetrixInfo.threeLineDelTimes;
					break;
				case 3:
					++m_tetrixInfo.fourLineDelTimes;
					break;
				default:
					ASSERT(FALSE);
					break;
				}
				int nEscape = 500 - m_tetrixInfo.CalcScore() / 100 * 25;
				m_spTimer->Reset(nEscape < 0 ? 15 : nEscape);
			}
			break;
		case DATA_NEXTBLOCK_GENERATED:
			m_spTetrixViewer->DrawNextBlock((const Point *)wParam, (UINT)lParam);
			++m_tetrixInfo.blockNums;
			m_spTetrixViewer->Draw();
			break;

		case DATA_TO_MERGE:
			m_spSound->PlayMerge();
			break;
		default:
			break;
		}
	}
}
Exemplo n.º 15
0
void ProcessLost(void)
{
	if(iLastAction)
	{
		iGameStatus = GameMainMenu;
	}

	EndGame();
	Show();
}
Exemplo n.º 16
0
// Game::Analyze the game board
void Game::Analyze() {

	int check = 0;
	for(int i=0; i<9; i++) {
		switch(Board[i]){
			case 1:
			case 0:
				check++;
				break;
			default:
				break;
		}
	}

	// Horizontal Player 1
	if( (Board[0] == 0 && Board[1] == 0 && Board[2] == 0) ||
		(Board[3] == 0 && Board[4] == 0 && Board[5] == 0) ||
		(Board[6] == 0 && Board[7] == 0 && Board[8] == 0)) {
			EndGame(1);
	}
	// Vertical Player 1
	if( (Board[0] == 0 && Board[3] == 0 && Board[6] == 0) ||
		(Board[1] == 0 && Board[4] == 0 && Board[7] == 0) ||
		(Board[2] == 0 && Board[5] == 0 && Board[8] == 0)) {
			EndGame(1);
	}
	// Diagonal Player 1
	if( (Board[0] == 0 && Board[4] == 0 && Board[8] == 0) ||
		(Board[2] == 0 && Board[4] == 0 && Board[6] == 0)) {
			EndGame(1);
	}

	// ----------------------------------------------------------

	// Horizontal Player 2
	if( (Board[0] == 1 && Board[1] == 1 && Board[2] == 1) ||
		(Board[3] == 1 && Board[4] == 1 && Board[5] == 1) ||
		(Board[6] == 1 && Board[7] == 1 && Board[8] == 1)) {
			EndGame(2);
	}
	// Vertical Player 2
	if( (Board[0] == 1 && Board[3] == 1 && Board[6] == 1) ||
		(Board[1] == 1 && Board[4] == 1 && Board[7] == 1) ||
		(Board[2] == 1 && Board[5] == 1 && Board[8] == 1)) {
			EndGame(2);
	}
	// Diagonal Player 2
	if( (Board[0] == 1 && Board[4] == 1 && Board[8] == 1) ||
		(Board[2] == 1 && Board[4] == 1 && Board[6] == 1)) {
			EndGame(2);
	}

	// We have a Draw!
	if( check >= 9 ) {
		EndGame(0);
	}
}
Exemplo n.º 17
0
	//[!] 메인 함수
	void Tetris()
	{
		ConsoleInit(); // 시작 화면 

		DrawField(); // 게임 영역 출력

		ShowPoint(); // 점수판 출력

		StartGame(); // 게임 시작

		EndGame(); // 게임 종료화 면
	}
Exemplo n.º 18
0
//Method called when the IncInfectButtonP1 is pressed
void IncInfectP1(GtkWidget *widget, gpointer data)
{
	if(EDHGame::edh == 0 /*not edh*/)
	{
		StandardGame::Player1.ChangeInfect(1);
		if(StandardGame::Player1.Lost()&&!StandardGame::Continue)
		{
			EndGame(widget, data);	
		}
	}
	else if(EDHGame::edh == 1 /*2player edh*/||EDHGame::edh == 2 /*3player edh*/)
	{
		EDHGame::EDHPlayer1.ChangeInfect(1);
		if(EDHGame::EDHPlayer1.Lost()&&!StandardGame::Continue)
		{
			EndGame(widget, data);
		}
	}
	StandardGame::RecentPlays.append("Player 1 gained 1 infect \n");
	UpdateLabels();
} 
Exemplo n.º 19
0
bool AUTDomGameMode::CheckScore_Implementation(AUTPlayerState* Scorer)
{
	AUTTeamInfo* WinningTeam = NULL;
	AUTPlayerState* BestPlayer = Scorer;
	// check if team wins by points
	if (GoalScore > 0)
	{
		for (uint8 i = 0; i < NumTeams; i++)
		{
			if (Teams.IsValidIndex(i) && Teams[i]->Score >= GoalScore)
			{
				if (Scorer->Team != Teams[i])
				{
					BestPlayer = FindBestPlayerOnTeam(i);
				}

				DomGameState->SetWinner(BestPlayer);
				EndGame(BestPlayer, FName(TEXT("scorelimit")));
				return true;
				break;
			}
		}
	}
	// check if team wins by time limit
	if (TimeLimit > 0 && DomGameState->GetRemainingTime() <= 0)
	{
		AUTTeamInfo* LeadingTeam = DomGameState->FindLeadingTeam();
		if (LeadingTeam != NULL)
		{
			if (Scorer->Team != LeadingTeam)
			{
				BestPlayer = FindBestPlayerOnTeam(LeadingTeam->GetTeamNum());
			}
			DomGameState->SetWinner(BestPlayer);
			EndGame(BestPlayer, FName(TEXT("TimeLimit")));
			return true;
		}
	}
	return false;
}
Exemplo n.º 20
0
//Method called when the DecLifeButtonP2 is pressed
void DecLifeP2(GtkWidget *widget, gpointer data)
{
	if(EDHGame::edh == 0 /*not edh*/)
	{
		StandardGame::Player2.ChangeLife(-1);
		if(StandardGame::Player2.Lost()&&!StandardGame::Continue)
		{
			EndGame(widget, data);	
		}
	}
	else if(EDHGame::edh == 1 /*2player edh*/||EDHGame::edh == 2 /*3player edh*/)
	{
		EDHGame::EDHPlayer2.ChangeLife(-1);
		if(EDHGame::EDHPlayer2.Lost()&&!StandardGame::Continue)
		{
			EndGame(widget, data);
		}
	}
	
	StandardGame::RecentPlays.append("Player 1 lost 1 life \n");
	UpdateLabels();
} 
Exemplo n.º 21
0
void hhBlackJack::Double()
{
	Bet *= 2;
	PlayerHand.Append(GetCard(1));
	RetallyScores();
	DeterminePlayCommands();

	// Force player to stay
	FollowDealerRules();
	AssessScores();
	EndGame();

	UpdateView();
}
Exemplo n.º 22
0
void hhBlackJack::Hit()
{
	PlayerHand.Append(GetCard(1));
	RetallyScores();
	DeterminePlayCommands();

	if (PlayerScore >= 21 || PlayerHand.Num() == 5) {
		FollowDealerRules();
		AssessScores();
		EndGame();
	}

	UpdateView();
}
Exemplo n.º 23
0
void Pi::HandleRequests()
{
	for (auto request : internalRequests) {
		switch (request) {
		case END_GAME:
			EndGame();
			break;
		case QUIT_GAME:
			Quit();
			break;
		default:
			Output("Pi::HandleRequests, unhandled request type processed.\n");
			break;
		}
	}
	internalRequests.clear();
}
Exemplo n.º 24
0
bool hhBlackJack::HandleSingleGuiCommand(idEntity *entityGui, idLexer *src) {

	idToken token;

	if (!src->ReadToken(&token)) {
		return false;
	}

	if (token == ";") {
		return false;
	}

	if (token.Icmp("deal") == 0) {
		Deal();
	}
	else if (token.Icmp("hit") == 0) {
		Hit();
	}
	else if (token.Icmp("stay") == 0) {
		Stay();
	}
	else if (token.Icmp("double") == 0) {
		Double();
	}
	else if (token.Icmp("incbet") == 0) {
		IncBet();
	}
	else if (token.Icmp("decbet") == 0) {
		DecBet();
	}
	else if (token.Icmp("reset") == 0) {
		Reset();
	}
	else if (token.Icmp("restart") == 0) {
		PlayerCredits = spawnArgs.GetInt("credits");
		Bet = PlayerBet = 1;
		EndGame();
		UpdateView();
	}
	else {
		src->UnreadToken(&token);
		return false;
	}

	return true;
}
Exemplo n.º 25
0
Presenter::Presenter(IView *view)
{
    this->view = view;
    this->game = new GameController();

    QObject* qview = dynamic_cast<QObject*>(view);
    connect(qview, SIGNAL(onNewGame()), this->game, SLOT(onNewGame()));
    connect(qview, SIGNAL(onPause()), this->game, SLOT(onPause()));
    connect(qview, SIGNAL(onRotate()), this->game, SLOT(onRotate()));
    connect(qview, SIGNAL(onToLeft()), this->game, SLOT(onMoveLeft()));
    connect(qview, SIGNAL(onToRight()), this->game, SLOT(onMoveRight()));
    connect(qview, SIGNAL(onSpeedup()), this->game, SLOT(onSpeedup()));
    connect(qview, SIGNAL(onEndGame()), this->game, SLOT(onEnd()));

    connect(game, SIGNAL(onStateChanged()), this, SLOT(StateChange()));
    connect(game, SIGNAL(onGameEnd()), this, SLOT(EndGame()));
    // instead of speedup
    connect(qview, SIGNAL(onMakeMove()), this->game, SLOT(onMove()));

}
Exemplo n.º 26
0
int Game::checkarray(){
	for(int i=0;i<10;++i)
		for(int j=0;j<6;++j){
			
			if((arrayofpoints[i][j])&&(arrayofpoints[i][j+1])&&(arrayofpoints[i][j+2])&&(arrayofpoints[i][j+3])&&(arrayofpoints[i][j+4])){
				int clearcolor = arrayofpoints[i][j]->color;
				if((arrayofpoints[i][j+1]->color == clearcolor)&&(arrayofpoints[i][j+2]->color == clearcolor)&&(arrayofpoints[i][j+3]->color == clearcolor)&&(arrayofpoints[i][j+4]->color == clearcolor))
					arrayofpoints[i][j]->del = arrayofpoints[i][j+1]->del = arrayofpoints[i][j+2]->del = arrayofpoints[i][j+3]->del = arrayofpoints[i][j+4]->del = 1;
			}

			if((arrayofpoints[j][i])&&(arrayofpoints[j+1][i])&&(arrayofpoints[j+2][i])&&(arrayofpoints[j+3][i])&&(arrayofpoints[j+4][i])){
				int clearcolor = arrayofpoints[j][i]->color;
				if((arrayofpoints[j+1][i]->color == clearcolor)&&(arrayofpoints[j+2][i]->color == clearcolor)&&(arrayofpoints[j+3][i]->color == clearcolor)&&(arrayofpoints[j+4][i]->color == clearcolor))
					arrayofpoints[j][i]->del = arrayofpoints[j+1][i]->del = arrayofpoints[j+2][i]->del = arrayofpoints[j+3][i]->del = arrayofpoints[j+4][i]->del = 1;
			}
		}

	
	if(GamePoint::countofpoint == 100) EndGame();
	return delobjects();
}
Exemplo n.º 27
0
	void CTetris::ProcessGameRunning(double dt)
	{
		m_timeSinceGravity += dt;

		if (m_timeSinceGravity < GRAVITYTIME)
		{
			if (!m_forceGravity)
				return;
			else if (m_timeSinceGravity < (GRAVITYTIME / 20.0f))
				return;
		}


		if (LockCheck())
		{
			LockCurBrick();
			delete m_curBrick;
			m_curBrick = nullptr;
		}
		else
			ApplyGravity();

		if (!GetCurBrick())
		{
			delete m_curBrick;
			m_curBrick = nullptr;
			CheckDeleteFilledRows();
			m_curBrick = CreateRandomBrick();
			if (IsFail())
			{
				EndGame();
				SetGameOver();
			}
		}

		// Even if gravity wasn't applied, we set it to 0,
		// because a new brick would been created if Gravity never
		// got applied, and we want the timer to start over.
		m_timeSinceGravity = 0;
	}
Exemplo n.º 28
0
Terrain::Terrain(void) {
  _width = 1024;
  _height = 1024;

  ifstream textFile("height.dat");
  if(!textFile.is_open()) {
    cerr << "Error whilst reading heightmap" << endl;
    EndGame(1);
  } else {
    for(int z = 0; z < 1024; z++) {
      getline(textFile, _line);
      if(_line.empty()) {
        break;
      }
      for(int x = 0; x < 1024; x++) {
        pos = _line.find(' ');
        if(pos == string::npos) {
          break;
        }
        string _line2(_line, 0, pos);
        stringstream strh(_line2);
        strh >> _heightData[z][x];
        _line.erase(0,pos+1);
      }
    }
    textFile.close();
  }

  glGenTextures(1, &_tex);
  glBindTexture(GL_TEXTURE_2D, _tex);
  // GL_MODULATE for correct lighting and shit, not really needed because of shaders.
  // When the texture area is small, bilinear filter the closest mipmap.
  glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_NEAREST);
  // When texture area is large, bilinear filter the original.
  glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
  if(glfwLoadTexture2D("terrain1.tga", GLFW_BUILD_MIPMAPS_BIT) != GL_TRUE) {
    cerr << "Error while reading the terrain texture!" << endl;
    EndGame(1);
  }

  // Calculate the normals.
  _normals = new Vec3f*[_height];
  Vec3f** normals2 = new Vec3f*[_height];
  for(int i = 0; i < _height; i++) {
    _normals[i] = new Vec3f[_width];
    normals2[i] = new Vec3f[_width];
  }

  // Rough normals.
  for(int z = 0; z < _height; z++) {
    for(int x = 0; x < _width; x++) {
      Vec3f sum(0.0, 0.0, 0.0);

      Vec3f down;
      if(z > 0) {
        down = Vec3f(0.0, GetHeight(x, z-1) - GetHeight(x, z), -1.0);
      }
      Vec3f up;
      if(z < _height-1) {
        up = Vec3f(0.0, GetHeight(x, z+1) - GetHeight(x,z), 1.0);
      }
      Vec3f left;
      if(x > 0) {
        left = Vec3f(-1.0, GetHeight(x-1, z) - GetHeight(x,z), 0.0);
      }
      Vec3f right;
      if(x < _width-1) {
        right = Vec3f(1.0, GetHeight(x+1, z) - GetHeight(x,z), 0.0);
      }

      if(x > 0 && z > 0) { 
        sum += down.Cross(left).Normalize();
      }
      if(x > 0 && z < _height-1) {
        sum += left.Cross(up).Normalize();
      }
      if(x < _width-1 && z < _height-1) {
        sum += up.Cross(right).Normalize();
      }
      if(x < _width-1 && z > 0) {
        sum += right.Cross(down).Normalize();
      }

      normals2[x][z] = sum;
    }
  }

  // Smooth notmals.
  const float FALLOUT_RATIO = 0.5f;
  for(int z = 0; z < _height; z++) {
    for(int x = 0; x < _width; x++) {
      Vec3f sum = normals2[x][z];

      if(x > 0) {
        sum += normals2[x-1][z] * FALLOUT_RATIO;
      }
      if(x < _width-1) {
        sum += normals2[x+1][z] * FALLOUT_RATIO;
      }
      if(z > 0) {
        sum += normals2[x][z-1] * FALLOUT_RATIO;
      }
      if(z < _height-1) {
        sum += normals2[x][z+1] * FALLOUT_RATIO;
      }
      if(sum.Magnitude() == 0) {
        sum = Vec3f(0.0, 1.0, 0.0);
      }
      _normals[x][z] = sum;
    }
  }

  // Delete the first array.
  for(int i = 0; i < _height; i++) {
    delete [] normals2[i];
  }
  delete [] normals2;
}
Exemplo n.º 29
0
void DogfightClass::UpdateDogfight (void)
{
	if (vuxRealTime > lastUpdateTime + VU_TICS_PER_SECOND)
	{
		// Check for new players
		TheCampaign.MissionEvaluator->RebuildEvaluationData();
		
		// Update the game status
		UpdateGameStatus();
		
		// Update local game status
		if (localGameStatus == dog_EndRound)
		{
			// Only Matchplay gets here :-)
			if ((restart_matchplay_round) && (vuxRealTime > static_cast<VU_TIME>(restart_matchplay_round)))
			{
				MonoPrint ("Ending Round Now\n");
				
				RoundOver ();
				
				if (GameOver())
				{
					EndGame();
					OTWDriver.EndFlight();
				}
				else
				{
					EndRound();
				}
				
				restart_matchplay_round = 0;
			}
			else
			{
				MonoPrint ("Still waiting to end round %d\n", restart_matchplay_round - vuxRealTime);
				
				if ((gameType == dog_TeamMatchplay) && (CheckRoundOver() == 0))
				{
					RoundOver ();
					
					if (GameOver())
					{
						EndGame();
						OTWDriver.EndFlight();
					}
					else
					{
						EndRound();
					}
					
					restart_matchplay_round = 0;
				}
			}
		}
		else if (localGameStatus == dog_Flying)
		{
			if ((gameType == dog_TeamMatchplay) && (CheckRoundOver() <= 1))
			{
				MonoPrint ("GameStatus: dog EndRound\n");
				restart_matchplay_round = vuxRealTime + 10 * VU_TICS_PER_SECOND;
				localGameStatus = dog_EndRound;
			}
			else if (GameOver())
			{
				EndGame();
				OTWDriver.EndFlight();
			}
			else if (GameManager.NoMorePlayers(FalconLocalGame))
			{
				EndGame();
			}
			else if (gameType != dog_TeamMatchplay)
			{
				RegenerateAvailableAircraft();
			}
		}
		else if (localGameStatus == dog_Starting)
		{
			if (gameType == dog_TeamMatchplay)
			{
				// Wait until all players are no longer flying before resetting
				if (gameStatus != dog_Flying)
				{
					ResetRound();
				}
				
				// Wait until all players are ready before restarting
				if (GameManager.AllPlayersReady(FalconLocalGame))
				{
					GameManager.ReleasePlayer(FalconLocalSession);
					action_cam_started = FALSE;
					action_cam_time = 0;
					OTWDriver.SetExitMenu(FALSE);
					MonoPrint ("GameStatus: dog Flying\n");
					localGameStatus = dog_Flying;
				}
			}
			else
			{
				RegenerateAvailableAircraft();
				MonoPrint ("GameStatus: dog Flying\n");
				localGameStatus = dog_Flying;
			}
		}
		else
		{
			// Check for game restart
			if ((localFlags & DF_VIEWED_SCORES) && (gameStatus == dog_Waiting))
			{
				RestartGame();
			}
			
			if ((FalconLocalSession->GetFlyState() >= FLYSTATE_LOADING) && (FalconLocalSession->GetFlyState() <= FLYSTATE_FLYING))
			{
				MonoPrint ("GameStatus: dog Starting\n");
				localGameStatus = dog_Starting;
			}
		}
		
		lastUpdateTime = vuxRealTime;
		
		if ((!SimDriver.GetPlayerEntity()) && (!action_cam_started) && (!action_cam_time))
		{
			action_cam_time = vuxRealTime + 10 * VU_TICS_PER_SECOND;
			
			action_cam_started = TRUE;
		}
		
		if ((action_cam_started) && (static_cast<VU_TIME>(action_cam_time) > vuxRealTime))
		{
			OTWDriver.ToggleActionCamera();
			action_cam_started = FALSE;
		}
	}
}
Exemplo n.º 30
0
void CPlayScene::GameResultScene( float dTime )
{
	float width = (float)NNApplication::GetInstance()->GetScreenWidth();
	float height = (float)NNApplication::GetInstance()->GetScreenHeight();

	if (m_MainMap->GetGameResult() != GAME_NOT_END)
	{
		m_TimeForResultAnimation += dTime;

		UImanager::GetInstance()->SetAllVisible(false);

		if(m_TimeForResultAnimation < 1.f)
		{
			m_LeftDoor->SetPosition(width*0.25f - 500.f + m_TimeForResultAnimation*500.f, height*0.5f);
			m_RightDoor->SetPosition(width*0.75f + 500.f - m_TimeForResultAnimation*500.f, height*0.5f);

			m_LeftDoor->SetVisible(true);
			m_RightDoor->SetVisible(true);

			return;
		}
	}

	for (int i = 0; i < RESULT_MENU_NUM; i++)
	{
		m_ResultMenu[i][KEY_STATE_OFF]->SetVisible(true);
		m_ResultMenu[i][KEY_STATE_ON]->SetVisible(false);
	}

	switch (m_MainMap->GetGameResult())
	{
	case GAME_RESULT_DRAW:
		m_SpriteMarisaLose->SetVisible(true);
		m_SpriteRaymuLose->SetVisible(true);
		break;
	case GAME_RESULT_WIN:
		if (m_GameMode == CLIENT_MODE)
		{
			m_SpriteRaymuLose->SetVisible(true);
			m_SpriteMarisaWin->SetVisible(true);
		}
		else
		{
			m_SpriteRaymuWin->SetVisible(true);
			m_SpriteMarisaLose->SetVisible(true);
		}
		break;
	case GAME_RESULT_LOSE:
		if (m_GameMode == CLIENT_MODE)
		{
			m_SpriteRaymuWin->SetVisible(true);
			m_SpriteMarisaLose->SetVisible(true);
		}
		else
		{
			m_SpriteRaymuLose->SetVisible(true);
			m_SpriteMarisaWin->SetVisible(true);
		}
		break;
	default:
		break;
	}

	if (NNInputSystem::GetInstance()->GetMainMenuInput() == UP)
		--m_ResultMenuCursor;
	else if (NNInputSystem::GetInstance()->GetMainMenuInput() == DOWN)
		++m_ResultMenuCursor;

	m_ResultMenuCursor += RESULT_MENU_NUM;
	m_ResultMenuCursor %= RESULT_MENU_NUM;

	m_ResultMenu[m_ResultMenuCursor][KEY_STATE_ON]->SetVisible(true);
	
	if (NNInputSystem::GetInstance()->GetSkillKeyInput() == SKILL_KEY_ONE)
	{
		if (m_ResultMenuCursor == RESULT_MENU_EXIT)
			EndGame();
		else if (m_GameMode != TEST_MODE && m_ResultMenuCursor == RESULT_MENU_REGAME)
			m_RePlay = true;
		else if (m_GameMode == TEST_MODE && m_ResultMenuCursor == RESULT_MENU_REGAME)
			Init();
	}

	if (m_RePlay)
	{
		m_MainMap->GetPlayer1()->GetPacketHandler()->m_PacketKeyStatus.mRePlay = true;
		m_MainMap->GetPlayer1()->GetPacketHandler()->m_PacketKeyStatus.mHitCheck = false;
		m_MainMap->GetPlayer1()->GetPacketHandler()->m_PacketKeyStatus.mDirectionStatus = 0;
		m_MainMap->GetPlayer1()->GetPacketHandler()->m_PacketKeyStatus.mSkillStatus = 0;
		m_MainMap->GetPlayer1()->GetPacketHandler()->m_PacketKeyStatus.mSpeedStatus = 0;
		m_MainMap->GetPlayer1()->SendPacket();
	}

	if (m_GameMode != TEST_MODE && m_MainMap->GetPlayer2()->GetPacketHandler()->m_IsPacketrecv)
	{
		if (m_RePlay && m_MainMap->GetPlayer2()->GetPacketHandler()->m_PacketKeyStatus.mRePlay)
		{
			m_MainMap->GetPlayer2()->GetPacketHandler()->m_IsPacketrecv = false;
			m_MainMap->GetPlayer1()->GetPacketHandler()->m_PacketKeyStatus.mRePlay = false;
			Init();
		}
	}
	
}