Implemented Ring Module Gadget Tutorial

This commit is contained in:
Rafal Swierczek 2023-11-02 18:57:01 +00:00
parent 7ee592f1f0
commit 971e28bb61
14 changed files with 109 additions and 61 deletions

View File

@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:935f7575eb8438f8e3320206e83e54c726aacd8ba9dae894dcea2dfdeca4cb70
size 130514

View File

@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:4dfc52ea68790fe41a2183cebf9f3f1760c3cd066efe8459f7f116673f524040
size 212777
oid sha256:0caa776d680dfb23ead998fcd2fbc0c7a46ecf2ff4edff73e98c3e152a79088d
size 213629

Binary file not shown.

View File

@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:eccb9b1edb192ea701130918efac376eee57496ac65768f76a09f95c956d84e6
oid sha256:4c448a399e03e820c5867766611f78910e2811b96a3370f79410574bbaaf7279
size 607443

View File

@ -2,6 +2,7 @@
#include "BaseGadgetTutorial.h"
#include "EndlessVendetta/EndlessVendettaCharacter.h"
// Sets default values
ABaseGadgetTutorial::ABaseGadgetTutorial()
@ -16,14 +17,8 @@ ABaseGadgetTutorial::ABaseGadgetTutorial()
void ABaseGadgetTutorial::BeginPlay()
{
Super::BeginPlay();
}
// Called every frame
void ABaseGadgetTutorial::Tick(float DeltaTime)
{
Super::Tick(DeltaTime);
SetupTutorial();
SetActorTickInterval(0.2);
}
void ABaseGadgetTutorial::SpawnNewWaypoint(FVector Loc, FString Desc)
@ -36,8 +31,15 @@ void ABaseGadgetTutorial::SpawnNewWaypoint(FVector Loc, FString Desc)
WaypointActor->SetupWaypoint(WaypointIcon, Desc);
}
void ABaseGadgetTutorial::FinishedTutorial()
{
if (IsValid(WaypointActor)) WaypointActor->Destroy();
CompletedGadgetTutorial.Broadcast();
}
void ABaseGadgetTutorial::DestroyTutorial()
{
if (IsValid(WaypointActor)) WaypointActor->Destroy();
DespawnEnemies();
Destroy();
}

View File

@ -15,30 +15,37 @@ class ENDLESSVENDETTA_API ABaseGadgetTutorial : public AActor
GENERATED_BODY()
protected:
AWaypointActor* WaypointActor;
UPROPERTY(EditDefaultsOnly, Category = "Gadget Tutorial")
TSubclassOf<AWaypointActor> WaypointClass;
AWaypointActor* WaypointActor;
UPROPERTY(EditDefaultsOnly, Category = "Gadget Tutorial")
UTexture2D* WaypointIcon;
void SpawnNewWaypoint(FVector Loc, FString Desc);
// Called when the game starts or when spawned
virtual void BeginPlay() override;
void SpawnNewWaypoint(FVector Loc, FString Desc);
// Stops tutorial clues from appearing and broadcasts completion
void FinishedTutorial();
// Spawns Enemies, sets waypoint locations, etc...
UFUNCTION(BlueprintImplementableEvent)
void SetupTutorial();
// Destroy's enemies and other separate spawned in elements by this tutorial class
UFUNCTION(BlueprintImplementableEvent)
void DespawnEnemies();
public:
// Sets default values for this actor's properties
ABaseGadgetTutorial();
FCompletedGadgetTutorial CompletedGadgetTutorial;
// Called every frame
virtual void Tick(float DeltaTime) override;
virtual void DestroyTutorial();
void DestroyTutorial();
};

View File

@ -0,0 +1,27 @@
// Fill out your copyright notice in the Description page of Project Settings.
#include "RingModuleTutorial.h"
#include "EndlessVendetta/EndlessVendettaCharacter.h"
void ARingModuleTutorial::BeginPlay()
{
Super::BeginPlay();
GadgetManager = Cast<AEndlessVendettaCharacter>(GetWorld()->GetFirstPlayerController()->GetPawn())->GadgetManager;
SpawnNewWaypoint(HackTargetWaypointLoc, HackTargetWaypointDesc);
}
void ARingModuleTutorial::Tick(float DeltaSeconds)
{
Super::Tick(DeltaSeconds);
if (!GadgetManager->ReconInUse()) return;
SpawnNewWaypoint(ResultWaypointLoc, ResultWaypointDesc);
SetActorTickEnabled(false);
FTimerHandle TimerHandle;
GetWorld()->GetTimerManager().SetTimer(TimerHandle, this, &ARingModuleTutorial::FinishedTutorial, 7.5);
}

View File

@ -0,0 +1,35 @@
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "BaseGadgetTutorial.h"
#include "EndlessVendetta/GadgetSystem/GadgetManager.h"
#include "RingModuleTutorial.generated.h"
/**
*
*/
UCLASS()
class ENDLESSVENDETTA_API ARingModuleTutorial : public ABaseGadgetTutorial
{
GENERATED_BODY()
AGadgetManager* GadgetManager;
void BeginPlay() override;
void Tick(float DeltaSeconds) override;
protected:
UPROPERTY(EditDefaultsOnly, Category = "Gadget Tutorial")
FString HackTargetWaypointDesc;
UPROPERTY(EditDefaultsOnly, Category = "Gadget Tutorial")
FString ResultWaypointDesc;
UPROPERTY(BlueprintReadWrite, Category = "Gadget Tutorial")
FVector HackTargetWaypointLoc;
UPROPERTY(BlueprintReadWrite, Category = "Gadget Tutorial")
FVector ResultWaypointLoc;
};

View File

@ -4,15 +4,13 @@
#include "VisionLinkTutorial.h"
#include "EndlessVendetta/EndlessVendettaCharacter.h"
#include "EndlessVendetta/GadgetSystem/GadgetManager.h"
#include "Kismet/KismetMathLibrary.h"
void AVisionLinkTutorial::BeginPlay()
{
Super::BeginPlay();
SpawnEnemiesAndSetupDefaults();
GadgetManager = Cast<AEndlessVendettaCharacter>(GetWorld()->GetFirstPlayerController()->GetPawn())->GadgetManager;
SpawnNewWaypoint(GoToAreaWaypointLoc, GoToAreaWaypointDesc);
SetActorTickInterval(0.2);
}
void AVisionLinkTutorial::Tick(float DeltaSeconds)
@ -30,12 +28,10 @@ void AVisionLinkTutorial::Tick(float DeltaSeconds)
PlayerWasInTutZone = true;
// Check if players recon gadget (vision link) is in active
APawn* PlayerPawn = GetWorld()->GetFirstPlayerController()->GetPawn();
AEndlessVendettaCharacter* EndlessVendettaCharacter = Cast<AEndlessVendettaCharacter>(PlayerPawn);
AGadgetManager* GadgetManager = EndlessVendettaCharacter->GadgetManager;
if (!GadgetManager->ReconInUse()) return;
// Check if the player is roughly looking at their target
APawn* PlayerPawn = GetWorld()->GetFirstPlayerController()->GetPawn();
FRotator LookAtRot = UKismetMathLibrary::FindLookAtRotation(PlayerPawn->GetActorLocation(), TargetLoc);
FRotator PlayersRotator = PlayerPawn->GetActorRotation();
// Keep all yaw values between -180 and 180 to simplify the comparison
@ -53,19 +49,5 @@ void AVisionLinkTutorial::Tick(float DeltaSeconds)
void AVisionLinkTutorial::DestroyTutorial()
{
if (IsValid(WaypointActor)) WaypointActor->Destroy();
DespawnEnemies();
Super::DestroyTutorial();
}
void AVisionLinkTutorial::FinishedTutorial()
{
if (IsValid(WaypointActor)) WaypointActor->Destroy();
CompletedGadgetTutorial.Broadcast();
}

View File

@ -4,6 +4,7 @@
#include "CoreMinimal.h"
#include "BaseGadgetTutorial.h"
#include "EndlessVendetta/GadgetSystem/GadgetManager.h"
#include "VisionLinkTutorial.generated.h"
UCLASS()
@ -11,16 +12,15 @@ class ENDLESSVENDETTA_API AVisionLinkTutorial : public ABaseGadgetTutorial
{
GENERATED_BODY()
bool PlayerInTutorialZone = false;
AGadgetManager* GadgetManager;
bool PlayerInTutorialZone = false;
bool PlayerWasInTutZone = false;
void BeginPlay() override;
void Tick(float DeltaSeconds) override;
void DestroyTutorial() override;
protected:
UPROPERTY(EditDefaultsOnly)
FString GoToAreaWaypointDesc;
@ -39,12 +39,6 @@ protected:
UPROPERTY(BlueprintReadWrite)
FVector TargetLoc;
// Spawns enemies, sets up waypoint locs, and target loc
UFUNCTION(BlueprintImplementableEvent)
void SpawnEnemiesAndSetupDefaults();
UFUNCTION(BlueprintImplementableEvent)
void DespawnEnemies();
UFUNCTION(BlueprintCallable)
void PlayerEnteredTutorialZone()
{
@ -55,6 +49,4 @@ protected:
{
PlayerInTutorialZone = false;
}
void FinishedTutorial();
};