//-----------------------------------------------------------------------------------
void TheGame::UpdateMapSelection(float deltaSeconds)
{
    UNUSED(deltaSeconds);
    if (InputSystem::instance->WasKeyJustPressed(InputSystem::ExtraKeys::ESC))
    {
        SetGameState(GameState::MAIN_MENU);
    }
    if (InputSystem::instance->WasKeyJustPressed(InputSystem::ExtraKeys::TAB))
    {
        m_autoGenerate = !m_autoGenerate;
    }
    char indexCharacter = 'A';
    for (auto iterator = EnvironmentBlueprint::s_envirnomentBlueprints.begin(); iterator != EnvironmentBlueprint::s_envirnomentBlueprints.end(); ++iterator)
    {
        if (InputSystem::instance->IsKeyDown(indexCharacter++))
        {
            EnvironmentBlueprint* environmentBlueprint = iterator->second;
            GenerationProcessData* genProcessData = environmentBlueprint->m_generationProcesses.at(0);
            m_currentGenerator = GeneratorRegistration::CreateGeneratorByName(genProcessData->m_generatorName);
            m_currentMap = new Map(environmentBlueprint->m_size);
            m_currentGenerator->InitializeMap(m_currentMap);
            m_currentEnvironment = iterator->second;
            SetGameState(GameState::GENERATION);
            return;
        }
    }

}
Exemplo n.º 2
0
IGameController::IGameController(CGameContext *pGameServer)
{
	m_pGameServer = pGameServer;
	m_pServer = m_pGameServer->Server();

	// balancing
	m_aTeamSize[TEAM_RED] = 0;
	m_aTeamSize[TEAM_BLUE] = 0;
	m_UnbalancedTick = TBALANCE_OK;

	// game
	m_GameState = IGS_GAME_RUNNING;
	m_GameStateTimer = TIMER_INFINITE;
	m_GameStartTick = Server()->Tick();
	m_MatchCount = 0;
	m_RoundCount = 0;
	m_SuddenDeath = 0;
	m_aTeamscore[TEAM_RED] = 0;
	m_aTeamscore[TEAM_BLUE] = 0;
	if(g_Config.m_SvWarmup)
		SetGameState(IGS_WARMUP_USER, g_Config.m_SvWarmup);
	else
		SetGameState(IGS_WARMUP_GAME, TIMER_INFINITE);

	// info
	m_GameFlags = 0;
	m_pGameType = "unknown";
	m_GameInfo.m_MatchCurrent = m_MatchCount+1;
	m_GameInfo.m_MatchNum = (str_length(g_Config.m_SvMaprotation) && g_Config.m_SvMatchesPerMap) ? g_Config.m_SvMatchesPerMap : 0;
	m_GameInfo.m_ScoreLimit = g_Config.m_SvScorelimit;
	m_GameInfo.m_TimeLimit = g_Config.m_SvTimelimit;

	// map
	m_aMapWish[0] = 0;
}
Exemplo n.º 3
0
void IGameController::OnPlayerReadyChange(CPlayer *pPlayer)
{
	if(g_Config.m_SvPlayerReadyMode && pPlayer->GetTeam() != TEAM_SPECTATORS && !pPlayer->m_DeadSpecMode)
	{
		// change players ready state
		pPlayer->m_IsReadyToPlay ^= 1;

		// check if it effects current game state
		switch(m_GameState)
		{
		case IGS_GAME_RUNNING:
			// one player isn't ready -> pause the game
			if(!pPlayer->m_IsReadyToPlay)
				SetGameState(IGS_GAME_PAUSED, TIMER_INFINITE);
			break;
		case IGS_WARMUP_USER:
			// all players are ready -> end warmup
			if(GetPlayersReadyState())
				SetGameState(IGS_WARMUP_USER, 0);
			break;
		case IGS_GAME_PAUSED:
			// all players are ready -> unpause the game
			if(GetPlayersReadyState())
				SetGameState(IGS_GAME_PAUSED, 0);
			break;
		case IGS_WARMUP_GAME:
		case IGS_START_COUNTDOWN:
		case IGS_END_MATCH:
		case IGS_END_ROUND:
			// not effected
			break;
		}
	}
}
//-----------------------------------------------------------------------------------
void TheGame::Update(float deltaSeconds)
{
    if (InputSystem::instance->WasKeyJustPressed('D'))
    {
        g_renderDebug = !g_renderDebug;
    }
    if(InputSystem::instance->WasKeyJustPressed('1'))
    {
        SetGameState(GameState::MAIN_MENU);
    }
    else if (InputSystem::instance->WasKeyJustPressed('2'))
    {
        SetGameState(GameState::MAP_SELECTION);
    }
    else if (InputSystem::instance->WasKeyJustPressed('3'))
    {
        SetGameState(GameState::GENERATION);
    }
    else if (InputSystem::instance->WasKeyJustPressed('4'))
    {
        SetGameState(GameState::PLAYING);
    }
    else if (InputSystem::instance->WasKeyJustPressed('5'))
    {
        SetGameState(GameState::PAUSED);
    }

    switch(GetGameState())
    {
    case GameState::MAIN_MENU:
        UpdateMainMenu(deltaSeconds);
        break;
    case GameState::MAP_SELECTION:
        EnvironmentBlueprint::LoadEnvironmentBlueprints();
        UpdateMapSelection(deltaSeconds);
        break;
    case GameState::GENERATION:
        UpdateGeneration(deltaSeconds);
        break;
    case GameState::PLAYING:
        if (m_player == nullptr)
        {
            m_player = new Player();
            SpawnInGame(m_player);
            m_currentMap->UpdateFOVFrom(m_player->m_position, m_player->m_viewDistance);

            for (int i = 0; i < NPCFactory::s_NPCFactories.size(); ++i)
            {
                NPC* enemyPointer = NPCFactory::GetNPCAt(i); 
                SpawnInGame(enemyPointer);
            }
        }
        UpdatePlaying(deltaSeconds);
        break;
    case GameState::PAUSED:
        UpdatePaused(deltaSeconds);
        break;
    }
    MessageLog::instance->Update(deltaSeconds);
}
Exemplo n.º 5
0
void IGameController::StartRound()
{
	ResetGame();

	++m_RoundCount;

	// start countdown if there're enough players, otherwise abort to warmup
	if(HasEnoughPlayers())
		SetGameState(IGS_START_COUNTDOWN);
	else
		SetGameState(IGS_WARMUP_GAME, TIMER_INFINITE);
}
//-----------------------------------------------------------------------------------
void TheGame::UpdateGeneration(float deltaSeconds)
{
    UNUSED(deltaSeconds);
    static int currentStep = 0;
    static int currentGeneratorIndex = 0;
    
    int maxGeneratorSteps = m_currentEnvironment->m_generationProcesses.size();
    bool isMapReady = false;
    if (m_autoGenerate)
    {
        while (!isMapReady) 
        {
            isMapReady = m_currentGenerator->GenerateStep(currentStep, m_currentEnvironment->m_generationProcesses.at(currentGeneratorIndex), m_currentMap);
            if (isMapReady && currentGeneratorIndex < (maxGeneratorSteps - 1))
            {
                m_currentGenerator = GeneratorRegistration::CreateGeneratorByName(m_currentEnvironment->m_generationProcesses.at(++currentGeneratorIndex)->m_generatorName);
                isMapReady = false;
                currentStep = 0;
            }
        }
    }
    else if (InputSystem::instance->WasKeyJustPressed(' ') || InputSystem::instance->IsKeyDown('G'))
    {
        isMapReady = m_currentGenerator->GenerateStep(currentStep, m_currentEnvironment->m_generationProcesses.at(currentGeneratorIndex), m_currentMap);
        if (isMapReady && currentGeneratorIndex < (maxGeneratorSteps - 1))
        {
            m_currentGenerator = GeneratorRegistration::CreateGeneratorByName(m_currentEnvironment->m_generationProcesses.at(++currentGeneratorIndex)->m_generatorName);
            isMapReady = false;
            currentStep = 0;
        }
    }

    if (InputSystem::instance->WasKeyJustPressed(InputSystem::ExtraKeys::ESC))
    {
        currentStep = 0;
        currentGeneratorIndex = 0;
        SetGameState(GameState::MAP_SELECTION);
    }

    if (InputSystem::instance->WasKeyJustPressed(InputSystem::ExtraKeys::ENTER))
    {
        m_autoGenerate = true;
    }

    if (isMapReady)
    {
        currentStep = 0;
        currentGeneratorIndex = 0;
        Generator::FinalizeMap(m_currentMap);
        SetGameState(GameState::PLAYING);
    }
}
Exemplo n.º 7
0
	void CTetris::SetGameOver(void)
	{
		EndGame();
		SetGameState(GameOver);
		if (m_gameMusicInstance.isPlaying())
			m_gameMusicInstance.stop();
	}
Exemplo n.º 8
0
void IGameController::ResetGame()
{
	// reset the game
	for(int i=0; i<MOD_NUM_WORLDS; i++)
	{
		GameServer()->m_World[i].m_ResetRequested = true;
	}
	
	SetGameState(IGS_GAME_RUNNING);
	m_GameStartTick = Server()->Tick();
	m_SuddenDeath = 0;

	int MatchNum = (str_length(g_Config.m_SvMaprotation) && g_Config.m_SvMatchesPerMap) ? g_Config.m_SvMatchesPerMap : 0;
	if(MatchNum == 0)
		m_MatchCount = 0;
	bool GameInfoChanged = (m_GameInfo.m_MatchCurrent != m_MatchCount+1) || (m_GameInfo.m_MatchNum != MatchNum) ||
							(m_GameInfo.m_ScoreLimit != g_Config.m_SvScorelimit) || (m_GameInfo.m_TimeLimit != g_Config.m_SvTimelimit);
	m_GameInfo.m_MatchCurrent = m_MatchCount+1;
	m_GameInfo.m_MatchNum = MatchNum;
	m_GameInfo.m_ScoreLimit = g_Config.m_SvScorelimit;
	m_GameInfo.m_TimeLimit = g_Config.m_SvTimelimit;
	if(GameInfoChanged)
		UpdateGameInfo(-1);

	// do team-balancing
	DoTeamBalance();
}
Exemplo n.º 9
0
//---------- Methods ----------
//---------- Create ----------
void Mines::Create() {
#ifdef DEBUG
	cout << "-- DEBUG: ENTER: Mines::Create() --\n";
#endif
// 	Init(height, width, 0);
// 	if(board) {
// 		Destroy();
// 	}
	board = new tile*[height];
	for (int i = 0; i < height; i++) {
		board[i] = new tile[width];
	}
// 	focus.Reset();
	focus.SetCursor(&board[0][0]);
// 	focus.SetMAX(height, width);
// 	focus.SetBoard(this);
	covered_tiles = height * width;
	bombs_checked = 0;
	ConnectTiles();
	CoverUp();
	SetGameState(CONTINUE);
	first_time = true;
#ifdef DEBUG
	cout << "-- DEBUG: EXIT:  Mines::Create() --\n";
#endif
}
Exemplo n.º 10
0
//---------- UnCover ----------
void Mines::UnCover(tile *T) {
#ifdef DEBUG
	cout << "-- DEBUG: ENTER: Mines::UnCover(unsigned int posX, unsigned int posY, bool check) with (" << T->GetXPos() << ", " << T->GetYPos() << " --\n";
#endif
	if (T->GetState() == MARKED) {	//If field is marked as a bomb do nothing
		return;
	}

	if (T->GetState() == COVERED) {
		covered_tiles--;
		T->SetState(UNCOVERED);
	}
	if (!T->GetBomb()) {	//if the current field is not a mine
		if (T->GetValue() == 0) {	//If the current field has no value, uncover those around as well
			if (T->GetXPos() > 0 && T->GetUpper()->GetState() == COVERED) {
				//Uncovers the field above the current
				UnCover(T->GetUpper());
			}
			if (T->GetXPos() < height - 1 && T->GetLower()->GetState() == COVERED) {
				//Uncovers the field below the current
				UnCover(T->GetLower());
			}
			if (T->GetYPos() > 0 && T->GetLeft()->GetState() == COVERED) {
				//Uncovers the field left from the current
				UnCover(T->GetLeft());
			}
			if (T->GetYPos() < width - 1 && T->GetRight()->GetState() == COVERED) {
				//Uncovers the field right from the current
				UnCover(T->GetRight());
			}
			if (T->GetXPos() > 0 && T->GetYPos() > 0 && T->GetUpperLeft()->GetState() == COVERED) {
				//Uncovers the upperleft field
				UnCover(T->GetUpperLeft());
			}
			if (T->GetXPos() > 0 && T->GetYPos() < width - 1 && T->GetUpperRight()->GetState() == COVERED) {
				//Uncovers the upperright field
				UnCover(T->GetUpperRight());
			}
			if (T->GetXPos() < height - 1 && T->GetYPos() > 0 && T->GetLowerLeft()->GetState() == COVERED) {
				//Uncovers the lowerleft field
				UnCover(T->GetLowerLeft());
			}
			if (T->GetXPos() < height - 1 && T->GetYPos() < width - 1 && T->GetLowerRight()->GetState() == COVERED) {
				//UnCovers the lowerright field
				UnCover(T->GetLowerRight());
			}
		}
// 		else {
// 			T->SetState(UNCOVERED);
// 		}
	} else {
		SetGameState(FAIL);
	}
// #ifdef DEBUG
// 	else cout << "-- DEBUG: Board[" << posX << "][" << posY << "] has Value " << board[posX][posY].GetValue() << " --\n";
// #endif
#ifdef DEBUG
	cout << "-- DEBUG: EXIT:  Mines::UnCover(unsigned int posX, unsigned int posY, bool check) --\n";
#endif
}
Exemplo n.º 11
0
int IGameController::GetStartTeam()
{
	// this will force the auto balancer to work overtime aswell
	if(g_Config.m_DbgStress)
		return TEAM_RED;

	if(g_Config.m_SvTournamentMode)
		return TEAM_SPECTATORS;

	// determine new team
	int Team = TEAM_RED;
	if(IsTeamplay())
		Team = m_aTeamSize[TEAM_RED] > m_aTeamSize[TEAM_BLUE] ? TEAM_BLUE : TEAM_RED;

	// check if there're enough player slots left
	if(m_aTeamSize[TEAM_RED]+m_aTeamSize[TEAM_BLUE] < Server()->MaxClients()-g_Config.m_SvSpectatorSlots)
	{
		++m_aTeamSize[Team];
		m_UnbalancedTick = TBALANCE_CHECK;
		if(m_GameState == IGS_WARMUP_GAME && HasEnoughPlayers())
			SetGameState(IGS_WARMUP_GAME, 0);
		return Team;
	}
	return TEAM_SPECTATORS;
}
Exemplo n.º 12
0
	virtual void ResetGame()
	{
		DestroyGameObjects();
		
		m_GameObjectsToDestroy.clear();
		m_GameObjectsToSpawn.clear();

		m_GlobalParameters = GlobalParameters();

		IBlackboardManager* pBBManager = (IBlackboardManager*)IObjectUtils::GetUniqueInterface( "BlackboardManager", IID_IBLACKBOARDMANAGER );
		pBBManager->ResetBlackboards();
		m_pBBGlobal = (BB_Global*)pBBManager->GetBlackboardGlobal();

		if (m_CurrentState != EGS_STARTUP && m_pSplashScreen)
		{
			DestroySplashScreen();
		}

		// Set Initial spawn times
		for (int i=0; i<EGO_COUNT; ++i)
		{
			m_NextSpawnTimes[i] = m_GlobalParameters.go[i].spawn_rate;
		}

		// Notify any listeners that game was reset
		for (size_t i=0; i<m_Listeners.size(); ++i)
		{
			m_Listeners[i]->OnGameReset();
		}

		SetGameState(EGS_NEWGAME);
	}
Exemplo n.º 13
0
void NetworkManager::ResQueue()
{
    if (s_msgResQueue.m_nSuccess == QUEUE_STATUS_ERROR)
    {
        LogError("Error joining queue.");
    }
    else if (s_msgResQueue.m_nSuccess == QUEUE_STATUS_FULL)
    {
        LogError("Could not join queue because it is full.");
    }
    else if (s_msgResQueue.m_nSuccess == QUEUE_STATUS_MATCH_FOUND)
    {
        LogDebug("Match has been found!");
        if (m_pGame == 0)
        {
            m_pGame = new Game(s_msgResQueue.m_nSide);
            reinterpret_cast<Game*>(m_pGame)->m_pNetworkManager = this;
            reinterpret_cast<Game*>(m_pGame)->RegisterScene();
            SetGameState(GAME_STATE_GAME);
            SetGame(m_pGame);
        }
    }
    else
    {
        LogDebug("Unknown queue status received in NetworkManager::ResQueue().");
    }
}
Exemplo n.º 14
0
	void UpdateGameState()
	{
		switch (m_CurrentState)
		{
		case EGS_STARTUP:
			// Created a few dummy RBCs on initial startup to set the scene until a new game is started
			if (!m_pSplashScreen && m_GameObjects[EGO_RBC].size() == 0)
			{
				for (int j=0; j<8; ++j)
				{
					DoSpawnGameObject( GameObjectSpawnParams( EGO_RBC ) );
				}
			}

			break;
		case EGS_NEWGAME:
			if (!m_pSplashScreen)
			{
				CreateInitialGameObjects();

				SetGameState(EGS_PLAYING);
			}

			break;
		case EGS_PLAYING:
			if (m_GameObjects[EGO_WBC].size() == 0)
			{
				SetGameState(EGS_INFECTIONWON);
				CreateSplashScreen( "//GUI/infectionwin.tga", 1.0f, 0.5f, 0.0f, false );
			}
			else if (m_GameObjects[EGO_VIRUS].size() == 0 && m_GameObjects[EGO_INFECTED].size() == 0)
			{
				SetGameState(EGS_IMMUNEWON);
				CreateSplashScreen( "//GUI/immunewin.tga", 1.0f, 0.5f, 0.0f, false );
			}

			break;
		case EGS_IMMUNEWON:
		case EGS_INFECTIONWON:
			if (!m_pSplashScreen)
			{
				ResetGame();
			}

			break;
		}
	}
Exemplo n.º 15
0
BOOL CAIThread::InitInstance()
{
	SetClient( m_pBotDoc );
	SetGameState( m_pBotDoc );
	m_aiGameData.ReadDataFile("gamedata.txt");
	m_pDoMove = &CAIThread::NormalMove;
	return TRUE;
}
//-----------------------------------------------------------------------------------
void TheGame::UpdatePaused(float deltaSeconds)
{
    UNUSED(deltaSeconds);
    if (InputSystem::instance->WasKeyJustPressed(InputSystem::ExtraKeys::ESC))
    {
        SetGameState(GameState::PLAYING);
    }
}
Exemplo n.º 17
0
	void CTetris::UnpauseGame(void)
	{
		if (GetGameState() == GamePaused)
		{
			SetGameState(GameRunning);
			m_gameMusicInstance.play();
		}
	}
Exemplo n.º 18
0
	void CTetris::PauseGame(void)
	{
		if (GetGameState() == GameRunning)
		{
			SetGameState(GamePaused);
			m_gameMusicInstance.stop();
		}
	}
Exemplo n.º 19
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.º 20
0
void IGameController::StartMatch()
{
	ResetGame();

	m_RoundCount = 0;
	m_aTeamscore[TEAM_RED] = 0;
	m_aTeamscore[TEAM_BLUE] = 0;

	// start countdown if there're enough players, otherwise do warmup till there're
	if(HasEnoughPlayers())
		SetGameState(IGS_START_COUNTDOWN);
	else
		SetGameState(IGS_WARMUP_GAME, TIMER_INFINITE);

	Server()->DemoRecorder_HandleAutoStart();
	char aBuf[256];
	str_format(aBuf, sizeof(aBuf), "start match type='%s' teamplay='%d'", m_pGameType, m_GameFlags&GAMEFLAG_TEAMS);
	GameServer()->Console()->Print(IConsole::OUTPUT_LEVEL_DEBUG, "game", aBuf);
}
Exemplo n.º 21
0
void GameManager::Update(float dt){
	// See if a new gamestate is requested
	if(nextGameState){
		SetGameState();
	}
    // Update physics
    //physics->Update(dt);
    // Update current game-state
	currentGameState->Update(dt);
}
Exemplo n.º 22
0
/*
 * Update the given PokerAI's game state
 * ai: the PokerAI to update
 * new_state: JSON representation of the new game state
 */
void UpdateGameState(PokerAI *ai, cJSON *new_state)
{
    ai->action.type = ACTION_UNSET;
    SetGameState(&ai->game, new_state);

    if (ai->loglevel >= LOGLEVEL_INFO)
    {
        PrintTableInfo(&ai->game, ai->logfile);
    }
}
Exemplo n.º 23
0
void IGameController::ResetGame()
{
	// reset the game
	GameServer()->m_World.m_ResetRequested = true;
	
	SetGameState(IGS_GAME_RUNNING);
	m_GameStartTick = Server()->Tick();
	m_SuddenDeath = 0;

	// do team-balancing
	DoTeamBalance();
}
//-----------------------------------------------------------------------------------
void TheGame::UpdateMainMenu(float deltaSeconds)
{
    UNUSED(deltaSeconds);
    if (InputSystem::instance->WasKeyJustPressed('N'))
    {
        SetGameState(GameState::MAP_SELECTION);
    }
    else if (InputSystem::instance->WasKeyJustPressed('Q'))
    {
        g_isQuitting = true;
    }
}
Exemplo n.º 25
0
// This is called every time WriteChatColor is called by MQ2Main or any plugin, 
// IGNORING FILTERS, IF YOU NEED THEM MAKE SURE TO IMPLEMENT THEM. IF YOU DONT 
// CALL CEverQuest::dsp_chat MAKE SURE TO IMPLEMENT EVENTS HERE 
PLUGIN_API DWORD OnWriteChatColor(PCHAR Line, DWORD Color, DWORD Filter) 
{ 
    //DebugSpewAlways("MQ2ChatWnd::OnWriteChatColor(%s)",Line);

	if (!MQChatWnd) 
    { 
        if (gGameState==GAMESTATE_INGAME) 
        { 
            SetGameState(gGameState); 
        } 
        if (!MQChatWnd) 
        { 
            return 0; 
        } 
    } 
    MQChatWnd->dShow=1; 
    PFILTER pFilter=gpFilters; 
    while (pFilter) 
    { 
        if (!pFilter->pEnabled || (*pFilter->pEnabled)) 
        { 
            if (!_strnicmp(Line,pFilter->FilterText,pFilter->Length)) 
            { 
                return 0; 
            } 
        } 
        pFilter = pFilter->pNext; 
    } 
    Color=pChatManager->GetRGBAFromIndex(Color); 
    CHAR szProcessed[MAX_STRING]; 
	
	pPlugins;
    MQToSTML(Line,szProcessed,MAX_STRING,Color); 
	pPlugins;
    strcat_s(szProcessed,"<br>"); 
    CXStr NewText(szProcessed); 
    DebugTry(ConvertItemTags(NewText,FALSE)); 
    ChatBuffer *pNewBuffer = new ChatBuffer; 
    GetCXStr(NewText.Ptr,pNewBuffer->Text,MAX_STRING); 
    pNewBuffer->pPrev=pPendingChatTail; 
    pNewBuffer->pNext=0; 
    if (pPendingChatTail) 
    { 
        pPendingChatTail->pNext=pNewBuffer; 
    } 
    else 
    { 
        pPendingChat=pNewBuffer; 
    } 
    pPendingChatTail=pNewBuffer; 
    PendingChatLines++; 
    return 0; 
} 
Exemplo n.º 26
0
	void CTetris::EndGame(bool stopMusic)
	{
		if (GetGameState() == GameRunning || GetGameState() == GamePaused)
		{
			delete m_curBrick;
			m_curBrick = nullptr;
			m_board = std::vector<std::vector<int>>(22, std::vector<int>(10, 0));
			SetTimeSinceGravity(0.0f);
			m_points = 0;
			if (stopMusic)
				m_gameMusicInstance.stop();
			SetGameState(MainMenu);
		}
	}
Exemplo n.º 27
0
IGameController::IGameController(CGameContext *pGameServer)
{
	m_pGameServer = pGameServer;
	m_pServer = m_pGameServer->Server();

	// balancing
	m_aTeamSize[TEAM_RED] = 0;
	m_aTeamSize[TEAM_BLUE] = 0;
	m_UnbalancedTick = TBALANCE_OK;

	// game
	m_GameState = IGS_GAME_RUNNING;
	m_GameStateTimer = TIMER_INFINITE;
	m_GameStartTick = Server()->Tick();
	m_MatchCount = 0;
	m_RoundCount = 0;
	m_SuddenDeath = 0;
	m_aTeamscore[TEAM_RED] = 0;
	m_aTeamscore[TEAM_BLUE] = 0;
	if(g_Config.m_SvWarmup)
		SetGameState(IGS_WARMUP_USER, g_Config.m_SvWarmup);
	else
		SetGameState(IGS_WARMUP_GAME, TIMER_INFINITE);

	// info
	m_GameFlags = 0;
	m_pGameType = "unknown";

	// map
	m_aMapWish[0] = 0;

	// spawn
	m_aNumSpawnPoints[0] = 0;
	m_aNumSpawnPoints[1] = 0;
	m_aNumSpawnPoints[2] = 0;
}
Exemplo n.º 28
0
void CSoundtrackManager::SetGameState (EGameStates iNewState)

//	SetGameState
//
//	Sets the current game state and determines which track to play.

	{
	//	If our state has not changed, then nothing to do

	if (iNewState == m_iGameState)
		return;

	//	Set new state

	SetGameState(iNewState, CalcTrackToPlay(iNewState));
	}
Exemplo n.º 29
0
void AProjectTapGameMode::StartPlay()
{
    Super::StartPlay();
    auto gameState = GetGameState<AProjectTapGameState>();
    ABallPawn* ball = nullptr;
    if ( UWorld* world = GetWorld() )
    {
        AActor* playerStart = FindPlayerStart( 0 , FString( "Player" ) );
        FTransform playerTransform = playerStart->GetTransform();
        if ( ABallPlayerStart* realPlayerStart = Cast<ABallPlayerStart>( playerStart ) )
        {
            auto possibleCamera = realPlayerStart->camera == nullptr ? nullptr : Cast<UProjectTapCameraComponent>( realPlayerStart->camera->GetComponentByClass( UProjectTapCameraComponent::StaticClass() ) );
            FActorSpawnParameters params;
            ball = world->SpawnActor<ABallPawn>(
                       ABallPawn::StaticClass() ,
                       playerTransform.GetTranslation() ,
                       FRotator( playerTransform.GetRotation() ) ,
                       params );

            if ( ball != nullptr )
            {
                ball->AddVelocity( realPlayerStart->initialVelocity , realPlayerStart->GetActorLocation() );
                if ( possibleCamera != nullptr && realPlayerStart->followPlayer )
                {
                    ball->setCamera( realPlayerStart );
                    possibleCamera = ball->GetCamera();
                }
            }
            gameState->SetCamera( possibleCamera );
            isMenu = realPlayerStart->GameMode == CustomGameMode::GAME_MODE_MAIN_MENU;
            if ( realPlayerStart->music != nullptr )musicPlayer->SetSound( realPlayerStart->music );
        }
        else
        {
            FActorSpawnParameters params;
            ball = world->SpawnActor<ABallPawn>( ABallPawn::StaticClass() , playerTransform.GetTranslation() , FRotator( playerTransform.GetRotation() ) , params );
        }

        gameState->SetPlayer(ball);
    }
    musicPlayer->Play();
    musicPlayer->SetVolumeMultiplier( 0 );

    gameState->SetGameState( CustomGameState::GAME_STATE_PLAYING );
    if ( isMenu ) gameState->SetGameMode( CustomGameMode::GAME_MODE_MAIN_MENU );
}
//-----------------------------------------------------------------------------------
TheGame::TheGame()
    : m_currentMap(nullptr)
    , m_currentGenerator(GeneratorRegistration::CreateGeneratorByName("CellularAutomata"))
    , m_autoGenerate(true)
    , m_player(nullptr)
    , m_mainMenuText(nullptr)
{
    SetGameState(GameState::MAIN_MENU);
    NPCFactory::LoadAllNPCs();
    MessageLog::instance = new MessageLog();
    CombatSystem::instance = new CombatSystem();
    NPC* enemyPointer = NPCFactory::GetNPCAt(0);
    NPC* enemyPointer2 = NPCFactory::GetNPCAt(1);
    AttackData data = AttackData(enemyPointer2, enemyPointer, 1);
    CombatSystem::instance->PrintAttackToMessageLog(data);
    delete enemyPointer;
    delete enemyPointer2;
}