diff --git a/Content/Blueprints/GameModes/BP_BlasterGameMode.uasset b/Content/Blueprints/GameModes/BP_BlasterGameMode.uasset index 4731c5a..6185c49 100644 Binary files a/Content/Blueprints/GameModes/BP_BlasterGameMode.uasset and b/Content/Blueprints/GameModes/BP_BlasterGameMode.uasset differ diff --git a/Content/Blueprints/HUD/WBP_Announcement.uasset b/Content/Blueprints/HUD/WBP_Announcement.uasset index 506fcd8..b31d1e3 100644 Binary files a/Content/Blueprints/HUD/WBP_Announcement.uasset and b/Content/Blueprints/HUD/WBP_Announcement.uasset differ diff --git a/Source/Blaster/GameMode/BlasterGameMode.cpp b/Source/Blaster/GameMode/BlasterGameMode.cpp index 304d8e7..012418d 100644 --- a/Source/Blaster/GameMode/BlasterGameMode.cpp +++ b/Source/Blaster/GameMode/BlasterGameMode.cpp @@ -9,6 +9,12 @@ #include "GameFramework/PlayerStart.h" #include "Kismet/GameplayStatics.h" + +namespace MatchState +{ + const FName Cooldown = FName("Cooldown"); +} + ABlasterGameMode::ABlasterGameMode() { bDelayedStart = true; @@ -28,11 +34,19 @@ void ABlasterGameMode::Tick(float DeltaSeconds) if (MatchState == MatchState::WaitingToStart) { CountDownTime = WarmupTime - GetWorld()->GetTimeSeconds() + LevelStartingTime; - if (CountDownTime < 0.f) + if (CountDownTime <= 0.f) { StartMatch(); } } + else if (MatchState == MatchState::InProgress) + { + CountDownTime = WarmupTime + MatchTime - GetWorld()->GetTimeSeconds() + LevelStartingTime; + if (CountDownTime <= 0.f) + { + SetMatchState(MatchState::Cooldown); + } + } } void ABlasterGameMode::OnMatchStateSet() diff --git a/Source/Blaster/GameMode/BlasterGameMode.h b/Source/Blaster/GameMode/BlasterGameMode.h index 862148b..1be767a 100644 --- a/Source/Blaster/GameMode/BlasterGameMode.h +++ b/Source/Blaster/GameMode/BlasterGameMode.h @@ -6,6 +6,12 @@ #include "GameFramework/GameMode.h" #include "BlasterGameMode.generated.h" + +namespace MatchState +{ + extern BLASTER_API const FName Cooldown; // Match duration has been reached. Display winner and begin cooldown timer +} + /** * */ @@ -23,8 +29,12 @@ public: UPROPERTY(EditDefaultsOnly) float WarmupTime = 10.f; + UPROPERTY(EditDefaultsOnly) float MatchTime = 120.f; + + UPROPERTY(EditDefaultsOnly) + float CooldownTime = 10.f; float LevelStartingTime = 0.f; diff --git a/Source/Blaster/HUD/Announcement.h b/Source/Blaster/HUD/Announcement.h index c307478..d9e28e7 100644 --- a/Source/Blaster/HUD/Announcement.h +++ b/Source/Blaster/HUD/Announcement.h @@ -22,4 +22,7 @@ public: UPROPERTY(meta = (BindWidget)) UTextBlock* WarmupTime; + UPROPERTY(meta = (BindWidget)) + UTextBlock* AnnouncementMessage; + }; diff --git a/Source/Blaster/PlayerController/BlasterPlayerController.cpp b/Source/Blaster/PlayerController/BlasterPlayerController.cpp index 3d9c1c8..43394ef 100644 --- a/Source/Blaster/PlayerController/BlasterPlayerController.cpp +++ b/Source/Blaster/PlayerController/BlasterPlayerController.cpp @@ -89,6 +89,19 @@ void ABlasterPlayerController::HandleMatchHasStarted() } } +void ABlasterPlayerController::HandleCooldown() +{ + BlasterHUD = BlasterHUD == nullptr ? Cast(GetHUD()) : BlasterHUD; + if (BlasterHUD) + { + BlasterHUD->CharacterOverlay->RemoveFromParent(); + if (BlasterHUD->Announcement) + { + BlasterHUD->Announcement->SetVisibility(ESlateVisibility::Visible); + } + } +} + void ABlasterPlayerController::OnMatchStateSet(FName State) { MatchState = State; @@ -97,6 +110,10 @@ void ABlasterPlayerController::OnMatchStateSet(FName State) { HandleMatchHasStarted(); } + else if (MatchState == MatchState::Cooldown) + { + HandleCooldown(); + } } void ABlasterPlayerController::OnRep_MatchState() @@ -105,6 +122,10 @@ void ABlasterPlayerController::OnRep_MatchState() { HandleMatchHasStarted(); } + else if (MatchState == MatchState::Cooldown) + { + HandleCooldown(); + } } void ABlasterPlayerController::ServerCheckMatchState_Implementation() diff --git a/Source/Blaster/PlayerController/BlasterPlayerController.h b/Source/Blaster/PlayerController/BlasterPlayerController.h index 2ddc676..0d47584 100644 --- a/Source/Blaster/PlayerController/BlasterPlayerController.h +++ b/Source/Blaster/PlayerController/BlasterPlayerController.h @@ -33,6 +33,7 @@ public: virtual float GetServerTime(); void OnMatchStateSet(FName State); + void HandleCooldown(); protected: