127 - Restart Game
This commit is contained in:
parent
9d0dc5d0ac
commit
cdca489c56
|
@ -183,7 +183,7 @@ void ABlasterPlayerController::ServerRequestServerTime_Implementation(float Time
|
||||||
void ABlasterPlayerController::ClientReportServerTime_Implementation(float TimeOfClientRequest, float TimeServerReceivedClientRequest)
|
void ABlasterPlayerController::ClientReportServerTime_Implementation(float TimeOfClientRequest, float TimeServerReceivedClientRequest)
|
||||||
{
|
{
|
||||||
const float RoundTripTime = GetWorld()->GetTimeSeconds() - TimeOfClientRequest;
|
const float RoundTripTime = GetWorld()->GetTimeSeconds() - TimeOfClientRequest;
|
||||||
const float CurrentServerTime = TimeServerReceivedClientRequest + 0.5f * RoundTripTime;
|
const float CurrentServerTime = TimeServerReceivedClientRequest + (0.5f * RoundTripTime);
|
||||||
|
|
||||||
ClientServerDelta = CurrentServerTime - GetWorld()->GetTimeSeconds();
|
ClientServerDelta = CurrentServerTime - GetWorld()->GetTimeSeconds();
|
||||||
}
|
}
|
||||||
|
@ -195,7 +195,7 @@ void ABlasterPlayerController::SetHUDTime()
|
||||||
else if (MatchState == MatchState::InProgress) TimeLeft = WarmupTime + MatchTime - GetServerTime() + LevelStartingTime;
|
else if (MatchState == MatchState::InProgress) TimeLeft = WarmupTime + MatchTime - GetServerTime() + LevelStartingTime;
|
||||||
else if (MatchState == MatchState::Cooldown) TimeLeft = WarmupTime + MatchTime + CooldownTime - GetServerTime() + LevelStartingTime;
|
else if (MatchState == MatchState::Cooldown) TimeLeft = WarmupTime + MatchTime + CooldownTime - GetServerTime() + LevelStartingTime;
|
||||||
uint32 SecondsLeft = FMath::CeilToInt(TimeLeft);
|
uint32 SecondsLeft = FMath::CeilToInt(TimeLeft);
|
||||||
|
|
||||||
if (HasAuthority())
|
if (HasAuthority())
|
||||||
{
|
{
|
||||||
BlasterGameMode = BlasterGameMode == nullptr ? Cast<ABlasterGameMode>(UGameplayStatics::GetGameMode(this)) : BlasterGameMode;
|
BlasterGameMode = BlasterGameMode == nullptr ? Cast<ABlasterGameMode>(UGameplayStatics::GetGameMode(this)) : BlasterGameMode;
|
||||||
|
@ -204,7 +204,7 @@ void ABlasterPlayerController::SetHUDTime()
|
||||||
SecondsLeft = FMath::CeilToInt(BlasterGameMode->GetCountdownTime() + LevelStartingTime);
|
SecondsLeft = FMath::CeilToInt(BlasterGameMode->GetCountdownTime() + LevelStartingTime);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (CountdownInt != SecondsLeft)
|
if (CountdownInt != SecondsLeft)
|
||||||
{
|
{
|
||||||
if (MatchState == MatchState::WaitingToStart || MatchState == MatchState::Cooldown) SetHUDAnnouncementCountdown(TimeLeft);
|
if (MatchState == MatchState::WaitingToStart || MatchState == MatchState::Cooldown) SetHUDAnnouncementCountdown(TimeLeft);
|
||||||
|
@ -234,7 +234,11 @@ void ABlasterPlayerController::PollInit()
|
||||||
void ABlasterPlayerController::SetHUDHealth(float Health, float MaxHealth)
|
void ABlasterPlayerController::SetHUDHealth(float Health, float MaxHealth)
|
||||||
{
|
{
|
||||||
BlasterHUD = BlasterHUD == nullptr ? Cast<ABlasterHUD>(GetHUD()) : BlasterHUD;
|
BlasterHUD = BlasterHUD == nullptr ? Cast<ABlasterHUD>(GetHUD()) : BlasterHUD;
|
||||||
bool bHUDValid = CharacterOverlay && CharacterOverlay->HealthBar && CharacterOverlay->HealthText;
|
bool bHUDValid =
|
||||||
|
BlasterHUD &&
|
||||||
|
BlasterHUD->CharacterOverlay &&
|
||||||
|
BlasterHUD->CharacterOverlay->HealthBar &&
|
||||||
|
BlasterHUD->CharacterOverlay->HealthText;
|
||||||
|
|
||||||
if (bHUDValid)
|
if (bHUDValid)
|
||||||
{
|
{
|
||||||
|
@ -254,7 +258,10 @@ void ABlasterPlayerController::SetHUDHealth(float Health, float MaxHealth)
|
||||||
void ABlasterPlayerController::SetHUDScore(float Score)
|
void ABlasterPlayerController::SetHUDScore(float Score)
|
||||||
{
|
{
|
||||||
BlasterHUD = BlasterHUD == nullptr ? Cast<ABlasterHUD>(GetHUD()) : BlasterHUD;
|
BlasterHUD = BlasterHUD == nullptr ? Cast<ABlasterHUD>(GetHUD()) : BlasterHUD;
|
||||||
bool bHUDValid = CharacterOverlay && CharacterOverlay->ScoreValue;
|
bool bHUDValid =
|
||||||
|
BlasterHUD &&
|
||||||
|
BlasterHUD->CharacterOverlay &&
|
||||||
|
BlasterHUD->CharacterOverlay->ScoreValue;
|
||||||
|
|
||||||
if (bHUDValid)
|
if (bHUDValid)
|
||||||
{
|
{
|
||||||
|
@ -271,7 +278,10 @@ void ABlasterPlayerController::SetHUDScore(float Score)
|
||||||
void ABlasterPlayerController::SetHUDDefeats(int32 Defeats)
|
void ABlasterPlayerController::SetHUDDefeats(int32 Defeats)
|
||||||
{
|
{
|
||||||
BlasterHUD = BlasterHUD == nullptr ? Cast<ABlasterHUD>(GetHUD()) : BlasterHUD;
|
BlasterHUD = BlasterHUD == nullptr ? Cast<ABlasterHUD>(GetHUD()) : BlasterHUD;
|
||||||
bool bHUDValid = CharacterOverlay && CharacterOverlay->DefeatsValue;
|
bool bHUDValid =
|
||||||
|
BlasterHUD &&
|
||||||
|
BlasterHUD->CharacterOverlay &&
|
||||||
|
BlasterHUD->CharacterOverlay->DefeatsValue;
|
||||||
|
|
||||||
if (bHUDValid)
|
if (bHUDValid)
|
||||||
{
|
{
|
||||||
|
@ -288,7 +298,10 @@ void ABlasterPlayerController::SetHUDDefeats(int32 Defeats)
|
||||||
void ABlasterPlayerController::SetHUDWeaponAmmo(int32 Ammo)
|
void ABlasterPlayerController::SetHUDWeaponAmmo(int32 Ammo)
|
||||||
{
|
{
|
||||||
BlasterHUD = BlasterHUD == nullptr ? Cast<ABlasterHUD>(GetHUD()) : BlasterHUD;
|
BlasterHUD = BlasterHUD == nullptr ? Cast<ABlasterHUD>(GetHUD()) : BlasterHUD;
|
||||||
bool bHUDValid = CharacterOverlay && CharacterOverlay->WeaponAmmoValue;
|
bool bHUDValid =
|
||||||
|
BlasterHUD &&
|
||||||
|
BlasterHUD->CharacterOverlay &&
|
||||||
|
BlasterHUD->CharacterOverlay->WeaponAmmoValue;
|
||||||
|
|
||||||
if (bHUDValid)
|
if (bHUDValid)
|
||||||
{
|
{
|
||||||
|
@ -300,7 +313,10 @@ void ABlasterPlayerController::SetHUDWeaponAmmo(int32 Ammo)
|
||||||
void ABlasterPlayerController::SetHUDCarriedAmmo(int32 Ammo)
|
void ABlasterPlayerController::SetHUDCarriedAmmo(int32 Ammo)
|
||||||
{
|
{
|
||||||
BlasterHUD = BlasterHUD == nullptr ? Cast<ABlasterHUD>(GetHUD()) : BlasterHUD;
|
BlasterHUD = BlasterHUD == nullptr ? Cast<ABlasterHUD>(GetHUD()) : BlasterHUD;
|
||||||
bool bHUDValid = CharacterOverlay && CharacterOverlay->CarriedAmmoValue;
|
bool bHUDValid =
|
||||||
|
BlasterHUD &&
|
||||||
|
BlasterHUD->CharacterOverlay &&
|
||||||
|
BlasterHUD->CharacterOverlay->CarriedAmmoValue;
|
||||||
|
|
||||||
if (bHUDValid)
|
if (bHUDValid)
|
||||||
{
|
{
|
||||||
|
@ -312,7 +328,10 @@ void ABlasterPlayerController::SetHUDCarriedAmmo(int32 Ammo)
|
||||||
void ABlasterPlayerController::SetHUDMatchCountdown(float CountdownTime)
|
void ABlasterPlayerController::SetHUDMatchCountdown(float CountdownTime)
|
||||||
{
|
{
|
||||||
BlasterHUD = BlasterHUD == nullptr ? Cast<ABlasterHUD>(GetHUD()) : BlasterHUD;
|
BlasterHUD = BlasterHUD == nullptr ? Cast<ABlasterHUD>(GetHUD()) : BlasterHUD;
|
||||||
bool bHUDValid = CharacterOverlay && CharacterOverlay->MatchCountdownText;
|
bool bHUDValid =
|
||||||
|
BlasterHUD &&
|
||||||
|
BlasterHUD->CharacterOverlay &&
|
||||||
|
BlasterHUD->CharacterOverlay->MatchCountdownText;
|
||||||
|
|
||||||
if (bHUDValid)
|
if (bHUDValid)
|
||||||
{
|
{
|
||||||
|
@ -335,7 +354,6 @@ void ABlasterPlayerController::SetHUDAnnouncementCountdown(float CountdownTime)
|
||||||
bool bHUDValid =
|
bool bHUDValid =
|
||||||
BlasterHUD &&
|
BlasterHUD &&
|
||||||
BlasterHUD->Announcement &&
|
BlasterHUD->Announcement &&
|
||||||
BlasterHUD->Announcement->AnnouncementText &&
|
|
||||||
BlasterHUD->Announcement->CountdownText;
|
BlasterHUD->Announcement->CountdownText;
|
||||||
|
|
||||||
if (bHUDValid)
|
if (bHUDValid)
|
||||||
|
|
Loading…
Reference in New Issue