From fa53d656d96b112843488c405c60cbca2692a14a Mon Sep 17 00:00:00 2001 From: Kingsmedia Date: Tue, 10 May 2022 14:55:02 +0200 Subject: [PATCH] 125 - Custom Match States --- .../GameModes/BP_BlasterGameMode.uasset | Bin 20243 -> 20243 bytes .../Blueprints/HUD/WBP_Announcement.uasset | Bin 28665 -> 30996 bytes Source/Blaster/GameMode/BlasterGameMode.cpp | 16 ++++++++++++- Source/Blaster/GameMode/BlasterGameMode.h | 10 +++++++++ Source/Blaster/HUD/Announcement.h | 3 +++ .../BlasterPlayerController.cpp | 21 ++++++++++++++++++ .../BlasterPlayerController.h | 1 + 7 files changed, 50 insertions(+), 1 deletion(-) diff --git a/Content/Blueprints/GameModes/BP_BlasterGameMode.uasset b/Content/Blueprints/GameModes/BP_BlasterGameMode.uasset index 4731c5aeff8411103adede256dae525260899b81..6185c49710a543e48a746ae06620cc278f2790d9 100644 GIT binary patch delta 60 zcmV-C0K@;2o&l4d0kBR15c1v(<_e5@K!KC|kwNdBEVEt##}NTBvnCT~HnZJJZUK`Q SOU9FCO0|=MNY%4TO~?Tm1{w$e delta 60 zcmV-C0K@;2o&l4d0kBR15IH~e$%81TOsnBpYlI8pinCq;#}NTJvnCT~Hj{Qt)swwT Sxs(4&!n2J@ZUM7PO~?Tf=o)7L diff --git a/Content/Blueprints/HUD/WBP_Announcement.uasset b/Content/Blueprints/HUD/WBP_Announcement.uasset index 506fcd879e0b76d4898d04c6f49a18d811419c26..b31d1e3b11301b067737fc91bbf24cdc6142c456 100644 GIT binary patch delta 7453 zcmds5dvsLA8NYW!APZTt&un%R$U7`atHGf1%3Bi1ZZ>c7AWK}rCgi!~MZh3S00Aii z$w&K#JVgJHK906D;G?C2wj4Z2BUm|9i-OvM7$8AGidED3?#^6p$mVf4J*mgu<92m)&&&)W)o0ZlXC&p;$sAWb zmE(9)e=C^dPLii&8pk=xw8u3coJ~0p-CuI(!2a2JH@$18W=`NxMCEzE5wn`fjIIfCBin>7RZ^b@o3T(+6{{) z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(zF3Yv=mGJ?($yqGaFpjoa3?}+;h7ASSv()y z?1Ep#nZ#>lF~kcL=#U&TV{4n`XlKlsJ?|RAZ@HN~!r@Ak%{-*vS|LM~3wY?S#Aa50)crK?!tf(Jt+9*v5f6DLkAxE*Lox4hAQKSr3#T*3 zJNiLCsEy0ACy(xLZ?dI4^NHU*wwM!4TQdCWn+4Ldr9}bPPv6?P==E3khCUL%&yc40 zbd-grFP*Je`C;n|mFC0A_fC6v*?S@1GM=nX?jPwpyX4ZyqNmCaU;E(Dp`L@9msjsU z|4RSKfWne2UBE}H^~a(jv`a?c?odT3pO-~9O2 z8(E*|zTfkM^KTC<$+$dn;CTAdQ@?&|6We>?rE{Uyvp=r5nbYMr0>#C-Eb`y@)G0k1 z!cMMFy0E(S*&|t*J9BfHdC?nxw?}We`8}|$yIhdDY-q^HzB9$2eX1Sa;m&$k%mN=*n*C6I+BdPKpLGT(l z(J@Oh!r&WyK zcAO{Sr&Et?f!i9$Sr5tFs zBn3Be&R?R0D-G39)o7*5F!P5O8|FERH)cpqq}1p*T)#weJYV}$g{$T%%dooz!Zq9Ys_YZqwRqZU{xzcQ!8nn_{X5F307It zmDMs2E>`%siB9Nu+Y;0QORC$RGFmpfJk?IZlgzJk@pC_}!@&>EG$)|L=dJp29RBx0 z`(5jlhUR}eG@K~CotYkYo(A|ur!nPd1+0=C5a~X;h#C7c#VlILkzPACJsD@haNaDq)jh*` z7$od$cT`+eJJ#*c9$GwdE^4tLArA45HN%PKNGT94wOV(*cs(l+YlZ_o@i4tb?N1j{ z24@mAaJ?rY*M+}Mx;T~p2# xW+>~O3;jibX~L=e;+0S>Ucm0Ax6SC(eZ4n~Op`oJsgZQixbyV=`Htj+{{jYsRD=Kk 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: