// Copyright Epic Games, Inc. All Rights Reserved. #include "FunnyPrinceGameMode.h" #include "UObject/ConstructorHelpers.h" #include "EngineUtils.h" #include "FighterAIController.h" AFunnyPrinceGameMode::AFunnyPrinceGameMode() { } void AFunnyPrinceGameMode::PawnKilled(APawn* PawnKilled) { if (!PawnKilled) { return; } APlayerController* PlayerController = Cast(PawnKilled->GetController()); if (PlayerController) { PlayerController->GameHasEnded(nullptr, false); } // Check for win condition for (AFighterAIController* Controller : TActorRange(GetWorld())) { if (!Controller->IsDead()) { return; } } // All AI is dead, game is won EndGame(true); } void AFunnyPrinceGameMode::EndGame(bool bIsPlayerWinner) { for (AController* Controller : TActorRange(GetWorld())) { bool bWon = (bIsPlayerWinner == Controller->IsPlayerController()); Controller->GameHasEnded(Controller->GetPawn(), bWon); } }