Implemented Base Gadget Tutorial Class
This commit is contained in:
parent
d705e61070
commit
8694b8746b
@ -421,15 +421,16 @@ bool AEndlessVendettaCharacter::GetHasRifle()
|
||||
return bHasRifle;
|
||||
}
|
||||
|
||||
void AEndlessVendettaCharacter::UpdateGadgetType(TSubclassOf<AGadgetBase> NewGadgetClass)
|
||||
bool AEndlessVendettaCharacter::UpdateGadgetType(TSubclassOf<AGadgetBase> NewGadgetClass)
|
||||
{
|
||||
if (NewGadgetClass.GetDefaultObject()->IsA(AReconGadget::StaticClass()) && GadgetManager->CantReplaceReconGadget()) return;
|
||||
if (NewGadgetClass.GetDefaultObject()->IsA(ACombatGadget::StaticClass()) && GadgetManager->CantReplaceCombatGadget()) return;
|
||||
if (NewGadgetClass.GetDefaultObject()->IsA(AReconGadget::StaticClass()) && GadgetManager->CantReplaceReconGadget()) return false;
|
||||
if (NewGadgetClass.GetDefaultObject()->IsA(ACombatGadget::StaticClass()) && GadgetManager->CantReplaceCombatGadget()) return false;
|
||||
|
||||
for (UActorComponent* PlayersCamera : GetComponentsByTag(UCameraComponent::StaticClass(), FName("PlayersCamera")))
|
||||
{
|
||||
GadgetManager->SpawnGadget(NewGadgetClass, Cast<UCameraComponent>(PlayersCamera));
|
||||
break;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -181,5 +181,6 @@ public:
|
||||
UFUNCTION(BlueprintImplementableEvent)
|
||||
void CheckpointCompletedUI();
|
||||
|
||||
void UpdateGadgetType(TSubclassOf<AGadgetBase> NewGadgetClass);
|
||||
// Returns true if successfully changed to a new gadget, can fail if the target gadget to replace is being used
|
||||
bool UpdateGadgetType(TSubclassOf<AGadgetBase> NewGadgetClass);
|
||||
};
|
||||
|
@ -4,6 +4,7 @@
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "EnhancedInputSubsystemInterface.h"
|
||||
#include "GadgetTutorial/BaseGadgetTutorial.h"
|
||||
#include "GameFramework/Actor.h"
|
||||
#include "GadgetBase.generated.h"
|
||||
|
||||
@ -119,6 +120,10 @@ public:
|
||||
{
|
||||
return GadgetInUse;
|
||||
}
|
||||
|
||||
UPROPERTY(EditDefaultsOnly, Category = "Gadget")
|
||||
TSubclassOf<ABaseGadgetTutorial> GadgetTutorialClass;
|
||||
|
||||
// Sets default values for this actor's properties
|
||||
AGadgetBase();
|
||||
|
||||
|
@ -0,0 +1,32 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
|
||||
#include "BaseGadgetTutorial.h"
|
||||
|
||||
// Sets default values
|
||||
ABaseGadgetTutorial::ABaseGadgetTutorial()
|
||||
{
|
||||
// Set this actor to call Tick() every frame. You can turn this off to improve performance if you don't need it.
|
||||
PrimaryActorTick.bCanEverTick = true;
|
||||
|
||||
}
|
||||
|
||||
// Called when the game starts or when spawned
|
||||
void ABaseGadgetTutorial::BeginPlay()
|
||||
{
|
||||
Super::BeginPlay();
|
||||
|
||||
}
|
||||
|
||||
// Called every frame
|
||||
void ABaseGadgetTutorial::Tick(float DeltaTime)
|
||||
{
|
||||
Super::Tick(DeltaTime);
|
||||
|
||||
}
|
||||
|
||||
void ABaseGadgetTutorial::DestroyTutorial()
|
||||
{
|
||||
UE_LOG(LogTemp, Warning, TEXT("Destroyed Tutorial"));
|
||||
Destroy();
|
||||
}
|
@ -0,0 +1,35 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "GameFramework/Actor.h"
|
||||
#include "BaseGadgetTutorial.generated.h"
|
||||
|
||||
UCLASS()
|
||||
class ENDLESSVENDETTA_API ABaseGadgetTutorial : public AActor
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
UPROPERTY(EditDefaultsOnly, Category = "Gadget Tutorial")
|
||||
FTransform SpawnTransform;
|
||||
|
||||
protected:
|
||||
// Called when the game starts or when spawned
|
||||
virtual void BeginPlay() override;
|
||||
|
||||
public:
|
||||
// Sets default values for this actor's properties
|
||||
ABaseGadgetTutorial();
|
||||
|
||||
// Called every frame
|
||||
virtual void Tick(float DeltaTime) override;
|
||||
|
||||
virtual void DestroyTutorial();
|
||||
|
||||
FTransform GetSpawnTransform()
|
||||
{
|
||||
return SpawnTransform;
|
||||
}
|
||||
|
||||
};
|
@ -86,12 +86,17 @@ void AGadgetTutorialStation::PreviousGadget()
|
||||
|
||||
void AGadgetTutorialStation::SelectGadget()
|
||||
{
|
||||
// Give Player the gadget
|
||||
// Despawn current gadgetRange
|
||||
// Spawn in the correct gadget range for the gadget
|
||||
// Eventually expand to give player feedback of being denied if changing gadgets fails
|
||||
if (!EndlessVendettaCharacter->UpdateGadgetType(GadgetsArray[GadgetIndex])) return;
|
||||
|
||||
EndlessVendettaCharacter->UpdateGadgetType(GadgetsArray[GadgetIndex]);
|
||||
if (IsValid(CurrentGadgetTutorial)) CurrentGadgetTutorial->DestroyTutorial();
|
||||
|
||||
FActorSpawnParameters SpawnParams;
|
||||
SpawnParams.SpawnCollisionHandlingOverride = ESpawnActorCollisionHandlingMethod::AlwaysSpawn;
|
||||
TSubclassOf<ABaseGadgetTutorial> GadgetTutorialToSpawnInClass = GadgetsArray[GadgetIndex]->GetDefaultObject<AGadgetBase>()->GadgetTutorialClass;
|
||||
FTransform SpawnTransform = GadgetTutorialToSpawnInClass->GetDefaultObject<ABaseGadgetTutorial>()->GetSpawnTransform();
|
||||
AActor* GadgetTutorialActor = GetWorld()->SpawnActor<AActor>(GadgetTutorialToSpawnInClass, SpawnTransform.GetLocation(), SpawnTransform.GetRotation().Rotator(), SpawnParams);
|
||||
CurrentGadgetTutorial = Cast<ABaseGadgetTutorial>(GadgetTutorialActor);
|
||||
}
|
||||
|
||||
void AGadgetTutorialStation::CloseWidget()
|
||||
|
@ -3,6 +3,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "BaseGadgetTutorial.h"
|
||||
#include "EndlessVendetta/EndlessVendettaCharacter.h"
|
||||
#include "EndlessVendetta/GadgetSystem/GadgetBase.h"
|
||||
#include "EndlessVendetta/InteractionInterface.h"
|
||||
@ -29,6 +30,8 @@ class ENDLESSVENDETTA_API AGadgetTutorialStation : public AActor, public IIntera
|
||||
|
||||
UGadgetMenu* GadgetMenu;
|
||||
|
||||
ABaseGadgetTutorial* CurrentGadgetTutorial;
|
||||
|
||||
protected:
|
||||
// Called when the game starts or when spawned
|
||||
virtual void BeginPlay() override;
|
||||
|
Loading…
Reference in New Issue
Block a user