Exemplo n.º 1
0
void ANimModGameState::OnRestartTimerExpired()
{
	GetWorld()->GetTimerManager().ClearTimer(restartHandle);

	if (ISSERVER)
	{
		UNimModGameInstance *gameInstance = Cast<UNimModGameInstance>(GetGameInstance());
		if (gameInstance)
		{
			gameInstance->SaveTeamsForRoundRestart(this->Teams);
		}
	}

	UWorld *world = GetWorld();
	if (world != nullptr)
	{
		for (FConstControllerIterator Iterator = world->GetControllerIterator(); Iterator; ++Iterator)
		{
			AController* Controller = *Iterator;
			ANimModPlayerController* PlayerController = Cast<ANimModPlayerController>(Controller);
			if (PlayerController)
				PlayerController->ClientRestartRound();
		}
	}

	RestartRound();
	UnfreezePlayers();
}
void FAIMessage::Broadcast(UObject* WorldContextObject, const FAIMessage& Message)
{
	UWorld* MyWorld = GEngine->GetWorldFromContextObject(WorldContextObject);
	if (MyWorld)
	{
		for (FConstControllerIterator It = MyWorld->GetControllerIterator(); It; ++It)
		{
			FAIMessage::Send(*It, Message);
		}
	}
}
Exemplo n.º 3
0
void AShooterGameMode::StartBots()
{
	// checking number of existing human player.
	int32 NumPlayers = 0;
	int32 NumBots = 0;
	UWorld* World = GetWorld();
	for (FConstControllerIterator It = World->GetControllerIterator(); It; ++It)
	{		
		AShooterAIController* AIC = Cast<AShooterAIController>(*It);
		if (AIC)
		{
			RestartPlayer(AIC);
		}
	}	
}
Exemplo n.º 4
0
void AShooterGameMode::CreateBotControllers()
{
	UWorld* World = GetWorld();
	int32 ExistingBots = 0;
	for (FConstControllerIterator It = World->GetControllerIterator(); It; ++It)
	{		
		AShooterAIController* AIC = Cast<AShooterAIController>(*It);
		if (AIC)
		{
			++ExistingBots;
		}
	}

	// Create any necessary AIControllers.  Hold off on Pawn creation until pawns are actually necessary or need recreating.	
	int32 BotNum = ExistingBots;
	for (int32 i = 0; i < MaxBots - ExistingBots; ++i)
	{
		CreateBot(BotNum + i);
	}
}
Exemplo n.º 5
0
void AShooterPlayerController::OnToggleInGameMenu()
{
	// this is not ideal, but necessary to prevent both players from pausing at the same time on the same frame
	UWorld* GameWorld = GEngine->GameViewport->GetWorld();

	for(auto It = GameWorld->GetControllerIterator(); It; ++It)
	{
		AShooterPlayerController* Controller = Cast<AShooterPlayerController>(*It);
		if(Controller && Controller->IsPaused())
		{
			return;
		}
	}

	// if no one's paused, pause
	if (ShooterIngameMenu.IsValid())
	{
		ShooterIngameMenu->ToggleGameMenu();
	}
}
Exemplo n.º 6
0
void ANimModGameState::FreezePlayers_Implementation()
{
	/*if (!ISSERVER)
	return;*/

	//Freeze the players
	UWorld *world = GetWorld();
	if (!world)
		return;

	for (FConstControllerIterator Iterator = world->GetControllerIterator(); Iterator; ++Iterator)
	{
		AController* Controller = *Iterator;
		ANimModPlayerController* PlayerController = Cast<ANimModPlayerController>(Controller);
		if (PlayerController)
		{
			PlayerController->SetFrozen(true);
			/*PlayerController->SetIgnoreMoveInput(true);
			PlayerController->SetIgnoreLookInput(true);*/
		}
	}
}