From 672044445c5b3059dcf99180044be4fa933d4863 Mon Sep 17 00:00:00 2001 From: Kevin Poretti Date: Mon, 16 Jan 2023 15:54:06 -0500 Subject: [PATCH] Post match menu and logic --- .../Content/Characters/BP_GSCharacter.uasset | 4 ++-- .../Content/Core/BP_GSDefaultGameMode.uasset | 4 ++-- .../Content/Core/BP_GSPlayerController.uasset | 4 ++-- GravityStomp/Content/Maps/Debug/Test.umap | 2 +- .../Content/UI/InGame/WBP_PauseMenu.uasset | 4 ++-- .../UI/InGame/WBP_PostMatchMenu.uasset | 3 +++ .../Character/GSCharacter.cpp | 4 ++-- .../GameModes/GSGameModeBase.cpp | 23 +++++++++++++------ .../GameModes/GSGameModeBase.h | 9 ++++++++ .../Player/GSPlayerController.cpp | 8 +++++-- .../Player/GSPlayerController.h | 5 ++++ 11 files changed, 50 insertions(+), 20 deletions(-) create mode 100644 GravityStomp/Content/UI/InGame/WBP_PostMatchMenu.uasset diff --git a/GravityStomp/Content/Characters/BP_GSCharacter.uasset b/GravityStomp/Content/Characters/BP_GSCharacter.uasset index d06debc..db410b9 100644 --- a/GravityStomp/Content/Characters/BP_GSCharacter.uasset +++ b/GravityStomp/Content/Characters/BP_GSCharacter.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:42116c51f8207e548b8546fa87ad3848cd8a23ea5d754875443bf5e8c88daf87 -size 280698 +oid sha256:da6a33ef8abb144aceb20cc7c662775a86c5ce4002061421da0f04ef25f1b6a7 +size 289653 diff --git a/GravityStomp/Content/Core/BP_GSDefaultGameMode.uasset b/GravityStomp/Content/Core/BP_GSDefaultGameMode.uasset index 0c808fa..f1dea48 100644 --- a/GravityStomp/Content/Core/BP_GSDefaultGameMode.uasset +++ b/GravityStomp/Content/Core/BP_GSDefaultGameMode.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:d839738bc1cfa5f17ffb11a722d985fc43528f0855174f76d6023a891ffe8148 -size 55458 +oid sha256:c9eb0322900b84c3182df90f894d86da2bcc58de9c7f9ffc6de75ac487d36c83 +size 100861 diff --git a/GravityStomp/Content/Core/BP_GSPlayerController.uasset b/GravityStomp/Content/Core/BP_GSPlayerController.uasset index d0eb6c0..5a47164 100644 --- a/GravityStomp/Content/Core/BP_GSPlayerController.uasset +++ b/GravityStomp/Content/Core/BP_GSPlayerController.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:e7f06796e2e6efea4c62476097d961e1be96d26fc3cfa48310560f35e2a1ec23 -size 108597 +oid sha256:9c6b01121ce3e7e32f21b87cc432bb4b5f44a39b480a3d29aae89e74fc6ea734 +size 111008 diff --git a/GravityStomp/Content/Maps/Debug/Test.umap b/GravityStomp/Content/Maps/Debug/Test.umap index 3770bfd..d04b80f 100644 --- a/GravityStomp/Content/Maps/Debug/Test.umap +++ b/GravityStomp/Content/Maps/Debug/Test.umap @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:d2ec801ff291f8f3afc303088714ffd667f5b20dc365b9d2cf11cba3226e384a +oid sha256:1e513547ba553453d376b3ea1b8e86090cd59c3d838c4a1266aa63e607531cbb size 52147 diff --git a/GravityStomp/Content/UI/InGame/WBP_PauseMenu.uasset b/GravityStomp/Content/UI/InGame/WBP_PauseMenu.uasset index 4a77868..d60e070 100644 --- a/GravityStomp/Content/UI/InGame/WBP_PauseMenu.uasset +++ b/GravityStomp/Content/UI/InGame/WBP_PauseMenu.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:4e94405909ce1a312a619db39f56844beee4a17e67a21c987d0d03a455c721c0 -size 139072 +oid sha256:af4e2307f45b95aa8c4ba538a2c8404de448cba91c49207b157986ea5fb35d2e +size 137615 diff --git a/GravityStomp/Content/UI/InGame/WBP_PostMatchMenu.uasset b/GravityStomp/Content/UI/InGame/WBP_PostMatchMenu.uasset new file mode 100644 index 0000000..abc3cf4 --- /dev/null +++ b/GravityStomp/Content/UI/InGame/WBP_PostMatchMenu.uasset @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:78aa3748741e25a6ed7002925796a1e5852907956e6b9266f75c3872d6f8b325 +size 133208 diff --git a/GravityStomp/Source/GravityStompGame/Character/GSCharacter.cpp b/GravityStomp/Source/GravityStompGame/Character/GSCharacter.cpp index 0a12d5e..7a83764 100644 --- a/GravityStomp/Source/GravityStompGame/Character/GSCharacter.cpp +++ b/GravityStomp/Source/GravityStompGame/Character/GSCharacter.cpp @@ -97,7 +97,7 @@ void AGSCharacter::SetupPlayerInputComponent(class UInputComponent* PlayerInputC void AGSCharacter::Move(const FInputActionValue& Value) { - if(UGameplayStatics::GetGlobalTimeDilation(this) < 1.0f) + if(UGameplayStatics::GetGlobalTimeDilation(this) < 1.0f || IsMoveInputIgnored()) { return; } @@ -113,7 +113,7 @@ void AGSCharacter::Move(const FInputActionValue& Value) void AGSCharacter::ChangeGravityDirection(const FInputActionValue& Value) { - if(!bCanChangeGravity || UGameplayStatics::GetGlobalTimeDilation(this) < 1.0f) + if(!bCanChangeGravity || UGameplayStatics::GetGlobalTimeDilation(this) < 1.0f || IsMoveInputIgnored()) { return; } diff --git a/GravityStomp/Source/GravityStompGame/GameModes/GSGameModeBase.cpp b/GravityStomp/Source/GravityStompGame/GameModes/GSGameModeBase.cpp index 6bd0b71..1e29af7 100644 --- a/GravityStomp/Source/GravityStompGame/GameModes/GSGameModeBase.cpp +++ b/GravityStomp/Source/GravityStompGame/GameModes/GSGameModeBase.cpp @@ -166,11 +166,7 @@ void AGSGameModeBase::DefaultTimer() GS->SetRemainingTime(GS->GetRemainingTime() - 1); if(GS->GetRemainingTime() <= 0) { - if(GetMatchState() == MatchState::WaitingPostMatch) - { - RestartGame(); - } - else if (GetMatchState() == MatchState::InProgress) + if (GetMatchState() == MatchState::InProgress) { FinishMatch(); } @@ -208,9 +204,18 @@ void AGSGameModeBase::FinishMatch() Pawn->TurnOff(); } - // set game state remaining time to time between matches - GS->SetRemainingTime(TimeBetweenRounds); + GetWorldTimerManager().ClearTimer(TimerHandle_DefaultTimer); GS->ResetTeamScores(); + + OnMatchFinished(); + } +} + +void AGSGameModeBase::OnMatchRestartRequest() +{ + if(GetMatchState() == MatchState::WaitingPostMatch) + { + RestartGame(); } } @@ -286,8 +291,12 @@ void AGSGameModeBase::HandleMatchHasStarted() } } + void AGSGameModeBase::RestartGame() { + // Setup timer for match tick + GetWorldTimerManager().SetTimer(TimerHandle_DefaultTimer, this, &AGSGameModeBase::DefaultTimer, GetWorldSettings()->GetEffectiveTimeDilation(), true); + // notify players game has restarted for(FConstPlayerControllerIterator It = GetWorld()->GetPlayerControllerIterator(); It; ++It) { diff --git a/GravityStomp/Source/GravityStompGame/GameModes/GSGameModeBase.h b/GravityStomp/Source/GravityStompGame/GameModes/GSGameModeBase.h index 5448c06..28f29d1 100644 --- a/GravityStomp/Source/GravityStompGame/GameModes/GSGameModeBase.h +++ b/GravityStomp/Source/GravityStompGame/GameModes/GSGameModeBase.h @@ -80,6 +80,15 @@ public: */ void FinishMatch(); + UFUNCTION(BlueprintImplementableEvent) + void OnMatchFinished(); + + /** + * If the match is in the post match state calling this restarts the game + */ + UFUNCTION(BlueprintCallable) + virtual void OnMatchRestartRequest(); + virtual void HandleStartingNewPlayer_Implementation(APlayerController* NewPlayer) override; /** diff --git a/GravityStomp/Source/GravityStompGame/Player/GSPlayerController.cpp b/GravityStomp/Source/GravityStompGame/Player/GSPlayerController.cpp index 1e5f0a3..a7a627f 100644 --- a/GravityStomp/Source/GravityStompGame/Player/GSPlayerController.cpp +++ b/GravityStomp/Source/GravityStompGame/Player/GSPlayerController.cpp @@ -41,10 +41,14 @@ void AGSPlayerController::Client_GameRestarted_Implementation() OnGameRestarted(); } +void AGSPlayerController::GameHasEnded(AActor* EndGameFocus, bool bIsWinner) +{ + // don't set a view target + ClientGameEnded(EndGameFocus, bIsWinner); +} + void AGSPlayerController::ClientGameEnded_Implementation(AActor* EndGameFocus, bool bIsWinner) { - Super::ClientGameEnded_Implementation(EndGameFocus, bIsWinner); - SetIgnoreMoveInput(true); APawn* MyPawn = GetPawn(); diff --git a/GravityStomp/Source/GravityStompGame/Player/GSPlayerController.h b/GravityStomp/Source/GravityStompGame/Player/GSPlayerController.h index 753fe83..e1d69cb 100644 --- a/GravityStomp/Source/GravityStompGame/Player/GSPlayerController.h +++ b/GravityStomp/Source/GravityStompGame/Player/GSPlayerController.h @@ -81,6 +81,11 @@ public: void OnGameRestarted(); // APlayerController interface + /** + * Override so no view target is set + */ + virtual void GameHasEnded(AActor* EndGameFocus, bool bIsWinner) override; + /** * Does character cleanup when the game ends */