125 - Custom Match States
This commit is contained in:
parent
85f667c086
commit
fa53d656d9
Binary file not shown.
Binary file not shown.
|
@ -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()
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -22,4 +22,7 @@ public:
|
|||
UPROPERTY(meta = (BindWidget))
|
||||
UTextBlock* WarmupTime;
|
||||
|
||||
UPROPERTY(meta = (BindWidget))
|
||||
UTextBlock* AnnouncementMessage;
|
||||
|
||||
};
|
||||
|
|
|
@ -89,6 +89,19 @@ void ABlasterPlayerController::HandleMatchHasStarted()
|
|||
}
|
||||
}
|
||||
|
||||
void ABlasterPlayerController::HandleCooldown()
|
||||
{
|
||||
BlasterHUD = BlasterHUD == nullptr ? Cast<ABlasterHUD>(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()
|
||||
|
|
|
@ -33,6 +33,7 @@ public:
|
|||
virtual float GetServerTime();
|
||||
|
||||
void OnMatchStateSet(FName State);
|
||||
void HandleCooldown();
|
||||
|
||||
protected:
|
||||
|
||||
|
|
Loading…
Reference in New Issue