Post match menu and logic

This commit is contained in:
Kevin Poretti 2023-01-16 15:54:06 -05:00
parent b02344f256
commit 672044445c
11 changed files with 50 additions and 20 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
GravityStomp/Content/Maps/Debug/Test.umap (Stored with Git LFS)

Binary file not shown.

Binary file not shown.

BIN
GravityStomp/Content/UI/InGame/WBP_PostMatchMenu.uasset (Stored with Git LFS) Normal file

Binary file not shown.

View File

@ -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;
}

View File

@ -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)
{

View File

@ -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;
/**

View File

@ -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();

View File

@ -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
*/