220 - Updating Team Scores
This commit is contained in:
parent
efbb1d9269
commit
5a34578647
|
@ -72,7 +72,6 @@ void ABlasterGameMode::OnMatchStateSet()
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
float ABlasterGameMode::CalculateDamage(AController* Attacker, AController* Victim, float BaseDamage)
|
||||
{
|
||||
return BaseDamage;
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
#include "TeamsGameMode.h"
|
||||
|
||||
#include "Blaster/GameState/BlasterGameState.h"
|
||||
#include "Blaster/PlayerController/BlasterPlayerController.h"
|
||||
#include "Kismet/GameplayStatics.h"
|
||||
|
||||
ATeamsGameMode::ATeamsGameMode()
|
||||
|
@ -82,3 +83,23 @@ float ATeamsGameMode::CalculateDamage(AController* Attacker, AController* Victim
|
|||
|
||||
return BaseDamage;
|
||||
}
|
||||
|
||||
void ATeamsGameMode::PlayerEliminated(ABlasterCharacter* EliminatedCharacter, ABlasterPlayerController* VictimController,
|
||||
ABlasterPlayerController* AttackerController)
|
||||
{
|
||||
Super::PlayerEliminated(EliminatedCharacter, VictimController, AttackerController);
|
||||
|
||||
BGameState = (BGameState == nullptr) ? Cast<ABlasterGameState>(UGameplayStatics::GetGameState(this)) : BGameState;
|
||||
const ABlasterPlayerState* AttackerPlayerState = AttackerController ? AttackerController->GetPlayerState<ABlasterPlayerState>() : nullptr;
|
||||
if (BGameState && AttackerPlayerState)
|
||||
{
|
||||
if (AttackerPlayerState->GetTeam() == ETeam::ET_BlueTeam)
|
||||
{
|
||||
BGameState->BlueTeamScores();
|
||||
}
|
||||
if (AttackerPlayerState->GetTeam() == ETeam::ET_RedTeam)
|
||||
{
|
||||
BGameState->RedTeamScores();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,7 +19,8 @@ public:
|
|||
virtual void PostLogin(APlayerController* NewPlayer) override;
|
||||
virtual void Logout(AController* Exiting) override;
|
||||
virtual float CalculateDamage(AController* Attacker, AController* Victim, float BaseDamage) override;
|
||||
|
||||
virtual void PlayerEliminated(class ABlasterCharacter* EliminatedCharacter, class ABlasterPlayerController* VictimController,
|
||||
class ABlasterPlayerController* AttackerController) override;
|
||||
protected:
|
||||
virtual void HandleMatchHasStarted() override;
|
||||
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
|
||||
#include "BlasterGameState.h"
|
||||
|
||||
#include "Blaster/PlayerController/BlasterPlayerController.h"
|
||||
#include "Blaster/PlayerState/BlasterPlayerState.h"
|
||||
#include "Net/UnrealNetwork.h"
|
||||
|
||||
|
@ -37,19 +38,33 @@ void ABlasterGameState::UpdateTopScore(ABlasterPlayerState* ScoringPlayer)
|
|||
void ABlasterGameState::RedTeamScores()
|
||||
{
|
||||
++RedTeamScore;
|
||||
if (ABlasterPlayerController* BController = Cast<ABlasterPlayerController>(GetWorld()->GetFirstPlayerController()))
|
||||
{
|
||||
BController->SetHUDRedTeamScore(RedTeamScore);
|
||||
}
|
||||
}
|
||||
|
||||
void ABlasterGameState::BlueTeamScores()
|
||||
{
|
||||
++BlueTeamScore;
|
||||
if (ABlasterPlayerController* BController = Cast<ABlasterPlayerController>(GetWorld()->GetFirstPlayerController()))
|
||||
{
|
||||
BController->SetHUDBlueTeamScore(BlueTeamScore);
|
||||
}
|
||||
}
|
||||
|
||||
void ABlasterGameState::OnRep_RedTeamScore()
|
||||
{
|
||||
|
||||
if (ABlasterPlayerController* BController = Cast<ABlasterPlayerController>(GetWorld()->GetFirstPlayerController()))
|
||||
{
|
||||
BController->SetHUDRedTeamScore(RedTeamScore);
|
||||
}
|
||||
}
|
||||
|
||||
void ABlasterGameState::OnRep_BlueTeamScore()
|
||||
{
|
||||
|
||||
if (ABlasterPlayerController* BController = Cast<ABlasterPlayerController>(GetWorld()->GetFirstPlayerController()))
|
||||
{
|
||||
BController->SetHUDBlueTeamScore(BlueTeamScore);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -660,7 +660,6 @@ void ABlasterPlayerController::OnRep_MatchState()
|
|||
void ABlasterPlayerController::HandleMatchHasStarted(bool bTeamsMatch)
|
||||
{
|
||||
if (HasAuthority()) bShowTeamScores = bTeamsMatch;
|
||||
|
||||
BlasterHUD = BlasterHUD == nullptr ? Cast<ABlasterHUD>(GetHUD()) : BlasterHUD;
|
||||
if (BlasterHUD)
|
||||
{
|
||||
|
@ -668,7 +667,7 @@ void ABlasterPlayerController::HandleMatchHasStarted(bool bTeamsMatch)
|
|||
if (BlasterHUD->Announcement)
|
||||
{
|
||||
BlasterHUD->Announcement->SetVisibility(ESlateVisibility::Hidden);
|
||||
|
||||
}
|
||||
if (!HasAuthority()) return;
|
||||
if (bTeamsMatch)
|
||||
{
|
||||
|
@ -680,7 +679,6 @@ void ABlasterPlayerController::HandleMatchHasStarted(bool bTeamsMatch)
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ABlasterPlayerController::HandleCooldown()
|
||||
{
|
||||
|
@ -723,9 +721,9 @@ void ABlasterPlayerController::HandleCooldown()
|
|||
else if (TopPlayers.Num() > 1)
|
||||
{
|
||||
InfoTextString = FString("Players tied for the win:\n");
|
||||
for (auto TiedPlayers : TopPlayers)
|
||||
for (auto TiedPlayer : TopPlayers)
|
||||
{
|
||||
InfoTextString.Append(FString::Printf(TEXT("%s\n"), *TiedPlayers->GetPlayerName()));
|
||||
InfoTextString.Append(FString::Printf(TEXT("%s\n"), *TiedPlayer->GetPlayerName()));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue