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 "GameFramework/PlayerStart.h"
|
||||||
#include "Kismet/GameplayStatics.h"
|
#include "Kismet/GameplayStatics.h"
|
||||||
|
|
||||||
|
|
||||||
|
namespace MatchState
|
||||||
|
{
|
||||||
|
const FName Cooldown = FName("Cooldown");
|
||||||
|
}
|
||||||
|
|
||||||
ABlasterGameMode::ABlasterGameMode()
|
ABlasterGameMode::ABlasterGameMode()
|
||||||
{
|
{
|
||||||
bDelayedStart = true;
|
bDelayedStart = true;
|
||||||
|
@ -28,11 +34,19 @@ void ABlasterGameMode::Tick(float DeltaSeconds)
|
||||||
if (MatchState == MatchState::WaitingToStart)
|
if (MatchState == MatchState::WaitingToStart)
|
||||||
{
|
{
|
||||||
CountDownTime = WarmupTime - GetWorld()->GetTimeSeconds() + LevelStartingTime;
|
CountDownTime = WarmupTime - GetWorld()->GetTimeSeconds() + LevelStartingTime;
|
||||||
if (CountDownTime < 0.f)
|
if (CountDownTime <= 0.f)
|
||||||
{
|
{
|
||||||
StartMatch();
|
StartMatch();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if (MatchState == MatchState::InProgress)
|
||||||
|
{
|
||||||
|
CountDownTime = WarmupTime + MatchTime - GetWorld()->GetTimeSeconds() + LevelStartingTime;
|
||||||
|
if (CountDownTime <= 0.f)
|
||||||
|
{
|
||||||
|
SetMatchState(MatchState::Cooldown);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ABlasterGameMode::OnMatchStateSet()
|
void ABlasterGameMode::OnMatchStateSet()
|
||||||
|
|
|
@ -6,6 +6,12 @@
|
||||||
#include "GameFramework/GameMode.h"
|
#include "GameFramework/GameMode.h"
|
||||||
#include "BlasterGameMode.generated.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,9 +29,13 @@ public:
|
||||||
|
|
||||||
UPROPERTY(EditDefaultsOnly)
|
UPROPERTY(EditDefaultsOnly)
|
||||||
float WarmupTime = 10.f;
|
float WarmupTime = 10.f;
|
||||||
|
|
||||||
UPROPERTY(EditDefaultsOnly)
|
UPROPERTY(EditDefaultsOnly)
|
||||||
float MatchTime = 120.f;
|
float MatchTime = 120.f;
|
||||||
|
|
||||||
|
UPROPERTY(EditDefaultsOnly)
|
||||||
|
float CooldownTime = 10.f;
|
||||||
|
|
||||||
float LevelStartingTime = 0.f;
|
float LevelStartingTime = 0.f;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
|
@ -22,4 +22,7 @@ public:
|
||||||
UPROPERTY(meta = (BindWidget))
|
UPROPERTY(meta = (BindWidget))
|
||||||
UTextBlock* WarmupTime;
|
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)
|
void ABlasterPlayerController::OnMatchStateSet(FName State)
|
||||||
{
|
{
|
||||||
MatchState = State;
|
MatchState = State;
|
||||||
|
@ -97,6 +110,10 @@ void ABlasterPlayerController::OnMatchStateSet(FName State)
|
||||||
{
|
{
|
||||||
HandleMatchHasStarted();
|
HandleMatchHasStarted();
|
||||||
}
|
}
|
||||||
|
else if (MatchState == MatchState::Cooldown)
|
||||||
|
{
|
||||||
|
HandleCooldown();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ABlasterPlayerController::OnRep_MatchState()
|
void ABlasterPlayerController::OnRep_MatchState()
|
||||||
|
@ -105,6 +122,10 @@ void ABlasterPlayerController::OnRep_MatchState()
|
||||||
{
|
{
|
||||||
HandleMatchHasStarted();
|
HandleMatchHasStarted();
|
||||||
}
|
}
|
||||||
|
else if (MatchState == MatchState::Cooldown)
|
||||||
|
{
|
||||||
|
HandleCooldown();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ABlasterPlayerController::ServerCheckMatchState_Implementation()
|
void ABlasterPlayerController::ServerCheckMatchState_Implementation()
|
||||||
|
|
|
@ -33,6 +33,7 @@ public:
|
||||||
virtual float GetServerTime();
|
virtual float GetServerTime();
|
||||||
|
|
||||||
void OnMatchStateSet(FName State);
|
void OnMatchStateSet(FName State);
|
||||||
|
void HandleCooldown();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue