42 lines
866 B
C++
42 lines
866 B
C++
// Fill out your copyright notice in the Description page of Project Settings.
|
|
|
|
|
|
#include "FunnyPrinceController.h"
|
|
#include "Blueprint/UserWidget.h"
|
|
|
|
void AFunnyPrinceController::BeginPlay()
|
|
{
|
|
Super::BeginPlay();
|
|
|
|
HUD = CreateWidget(this, HUDClass);
|
|
if (HUD != nullptr)
|
|
{
|
|
HUD->AddToViewport();
|
|
}
|
|
}
|
|
|
|
void AFunnyPrinceController::GameHasEnded(AActor* EndGameFocus, bool bIsWinner)
|
|
{
|
|
Super::GameHasEnded(EndGameFocus, bIsWinner);
|
|
HUD->RemoveFromParent();
|
|
|
|
if (bIsWinner)
|
|
{
|
|
UUserWidget* WinScreen = CreateWidget(this, WinScreenClass);
|
|
if (WinScreen != nullptr)
|
|
{
|
|
WinScreen->AddToViewport();
|
|
}
|
|
}
|
|
else
|
|
{
|
|
UUserWidget* LoseScreen = CreateWidget(this, LoseScreenClass);
|
|
if (LoseScreen != nullptr)
|
|
{
|
|
LoseScreen->AddToViewport();
|
|
}
|
|
}
|
|
|
|
GetWorldTimerManager().SetTimer(RestartTimer, this, &APlayerController::RestartLevel, RestartDelay);
|
|
}
|