-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtrigger.cpp
More file actions
55 lines (41 loc) · 1.23 KB
/
Copy pathtrigger.cpp
File metadata and controls
55 lines (41 loc) · 1.23 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
#include "trigger.h"
#include "Kismet/GameplayStatics.h"
#include "GameFramework/Actor.h"
#include "WGCharacter.h"
#include "Traps/Trap_Hiding_comp.h"
#include "WG/Traps/TrapBase.h"
#include "WG/Traps/Trap_MovingPlatform_comp.h"
Atrigger::Atrigger()
{
}
void Atrigger::BeginPlay()
{
Super::BeginPlay();
OnActorBeginOverlap.AddDynamic(this, &Atrigger::OnOverlapBegin);
}
void Atrigger::OnOverlapBegin(class AActor* OverlappedActor, class AActor* OtherActor)
{
APlayerController* Controller = UGameplayStatics::GetPlayerController(GetWorld(), 0);
AWGCharacter* Player = Cast<AWGCharacter>(Controller->GetPawn());
if (Player && Player == OtherActor){
if (this->ActorHasTag("Win")){
OnGameOver.Broadcast(true);
return;
}
if (this->ActorHasTag("Lose"))
{
OnGameOver.Broadcast(false);
return;
}
if (this->ActorHasTag("Start"))
{
if (!bTriggerActivated)
{
TrapsStart.Broadcast();
OnStart.Broadcast(UGameplayStatics::GetRealTimeSeconds(GetWorld()));
bTriggerActivated = true;
}
return;
}
}
}