-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGameOver.cpp
More file actions
76 lines (70 loc) · 2.04 KB
/
Copy pathGameOver.cpp
File metadata and controls
76 lines (70 loc) · 2.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#include "GameOver.h"
#include "WG/Traps/TrapBase.h"
#include "Components/TextBlock.h"
#include "Kismet/GameplayStatics.h"
void UGameOver::RestartLevel()
{
APlayerController* PlayerController = UGameplayStatics::GetPlayerController(GetWorld(),0);
if (PlayerController)
{
PlayerController->bShowMouseCursor = false;
PlayerController->bEnableClickEvents = false;
PlayerController->SetInputMode(FInputModeGameOnly());
TArray<AActor*> TrapBases;
UGameplayStatics::GetAllActorsOfClass(GetWorld(),ATrapBase::StaticClass(),TrapBases);
for (AActor* Traps: TrapBases)
{
ATrapBase* Trap = Cast<ATrapBase>(Traps);
if (Trap)
{
Trap->ResetTimers();
}
}
UGameplayStatics::OpenLevel(GetWorld(), "ThirdPersonMap", false);
}
else
{
UE_LOG(LogTemp,Error,TEXT("RestartLevel() in GameOver.cpp error finding playercontroller/gamemode "));
}
}
void UGameOver::PlaygroundStart()
{
APlayerController* PlayerController = UGameplayStatics::GetPlayerController(GetWorld(),0);
if (PlayerController)
{
PlayerController->bShowMouseCursor = false;
PlayerController->bEnableClickEvents = false;
PlayerController->SetInputMode(FInputModeGameOnly());
TArray<AActor*> TrapBases;
UGameplayStatics::GetAllActorsOfClass(GetWorld(),ATrapBase::StaticClass(),TrapBases);
for (AActor* Traps: TrapBases)
{
ATrapBase* Trap = Cast<ATrapBase>(Traps);
if (Trap)
{
Trap->ResetTimers();
}
}
UGameplayStatics::OpenLevel(GetWorld(), "TrapPlayground", false);
}
else
{
UE_LOG(LogTemp,Error,TEXT("PlaygroundStart() in GameOver.cpp error finding playercontroller/gamemode "));
}
}
void UGameOver::SetGameDuration(double GameStarTime, double GameEndtime)
{
double DurationCount = GameEndtime - GameStarTime;
Duration->SetText(FText::Format(FText::FromString("{0}{1}"),FText::FromString(TEXT("Your Run time is: ")),FText::AsNumber(DurationCount)));
}
void UGameOver::SetWinLose(bool bWin)
{
if (bWin)
{
WinLose->SetText(FText::FromString(TEXT("YOU WON!!!")));
}
if (!bWin)
{
WinLose->SetText((FText::FromString(TEXT("YOU LOSE :C"))));
}
}