Added StatusEffect Stub for Multiple Status Effects
This commit is contained in:
parent
5dae3b2691
commit
31a6a5d98e
BIN
Content/Blueprints/Combat_UI/BP_TurnBaseCombatV2.uasset
(Stored with Git LFS)
BIN
Content/Blueprints/Combat_UI/BP_TurnBaseCombatV2.uasset
(Stored with Git LFS)
Binary file not shown.
@ -30,9 +30,7 @@ void UHoldToInitCombat::BeginPlay()
|
|||||||
InitCombatWidget = CreateWidget<UUserWidget>(GetWorld(), InitCombatWidgetClass);
|
InitCombatWidget = CreateWidget<UUserWidget>(GetWorld(), InitCombatWidgetClass);
|
||||||
|
|
||||||
UInputComponent* PlayerInputComponent = GetWorld()->GetFirstPlayerController()->InputComponent;
|
UInputComponent* PlayerInputComponent = GetWorld()->GetFirstPlayerController()->InputComponent;
|
||||||
//Bind Right Mouse Button to the function OnRightClickDown
|
|
||||||
PlayerInputComponent->BindAction("RightClick", IE_Pressed, this, &UHoldToInitCombat::OnRightClickDown);
|
PlayerInputComponent->BindAction("RightClick", IE_Pressed, this, &UHoldToInitCombat::OnRightClickDown);
|
||||||
//Bind Right Mouse Button to the function OnRightClickUp
|
|
||||||
PlayerInputComponent->BindAction("RightClick", IE_Released, this, &UHoldToInitCombat::OnRightClickUp);
|
PlayerInputComponent->BindAction("RightClick", IE_Released, this, &UHoldToInitCombat::OnRightClickUp);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -42,7 +40,6 @@ void UHoldToInitCombat::TickComponent(float DeltaTime, ELevelTick TickType, FAct
|
|||||||
{
|
{
|
||||||
Super::TickComponent(DeltaTime, TickType, ThisTickFunction);
|
Super::TickComponent(DeltaTime, TickType, ThisTickFunction);
|
||||||
|
|
||||||
// //If the player is holding down the right mouse button for 3 seconds, then the player will enter combat mode
|
|
||||||
// if (bRightClickDown && RightClickDownTime < 0.1f)
|
// if (bRightClickDown && RightClickDownTime < 0.1f)
|
||||||
// {
|
// {
|
||||||
// RightClickDownTime += DeltaTime;
|
// RightClickDownTime += DeltaTime;
|
||||||
@ -73,9 +70,7 @@ void UHoldToInitCombat::OnRightClickDown()
|
|||||||
|
|
||||||
if (GunEffect)
|
if (GunEffect)
|
||||||
{
|
{
|
||||||
//Get Player Actor
|
|
||||||
const AActor* PlayerActor = GetWorld()->GetFirstPlayerController()->GetPawn();
|
const AActor* PlayerActor = GetWorld()->GetFirstPlayerController()->GetPawn();
|
||||||
//Get Static Mesh Location on the player actor
|
|
||||||
const UStaticMeshComponent* GunComponent = Cast<UStaticMeshComponent>(PlayerActor->GetComponentsByTag(UPrimitiveComponent::StaticClass(), FName("Gun"))[0]);
|
const UStaticMeshComponent* GunComponent = Cast<UStaticMeshComponent>(PlayerActor->GetComponentsByTag(UPrimitiveComponent::StaticClass(), FName("Gun"))[0]);
|
||||||
const FVector GunLocationOffset = GunComponent->GetSocketTransform("Muzzle").TransformPosition(FVector(-100, 0, 0));
|
const FVector GunLocationOffset = GunComponent->GetSocketTransform("Muzzle").TransformPosition(FVector(-100, 0, 0));
|
||||||
UNiagaraFunctionLibrary::SpawnSystemAtLocation(GetWorld(), GunEffect, GunLocationOffset, PlayerActor->GetActorRotation());
|
UNiagaraFunctionLibrary::SpawnSystemAtLocation(GetWorld(), GunEffect, GunLocationOffset, PlayerActor->GetActorRotation());
|
||||||
|
11
Source/the_twilight_abyss/TurnBasedCombatV2/StatusEffect.cpp
Normal file
11
Source/the_twilight_abyss/TurnBasedCombatV2/StatusEffect.cpp
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
// Fill out your copyright notice in the Description page of Project Settings.
|
||||||
|
|
||||||
|
|
||||||
|
#include "StatusEffect.h"
|
||||||
|
|
||||||
|
void UStatusEffect::Invoke(ACharacter* Character)
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
27
Source/the_twilight_abyss/TurnBasedCombatV2/StatusEffect.h
Normal file
27
Source/the_twilight_abyss/TurnBasedCombatV2/StatusEffect.h
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
// Fill out your copyright notice in the Description page of Project Settings.
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "CoreMinimal.h"
|
||||||
|
#include "UObject/NoExportTypes.h"
|
||||||
|
#include "StatusEffect.generated.h"
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
UCLASS(Abstract)
|
||||||
|
class THE_TWILIGHT_ABYSS_API UStatusEffect : public UObject
|
||||||
|
{
|
||||||
|
GENERATED_BODY()
|
||||||
|
|
||||||
|
public:
|
||||||
|
UPROPERTY()
|
||||||
|
FString Name;
|
||||||
|
UPROPERTY()
|
||||||
|
FString Description;
|
||||||
|
UPROPERTY()
|
||||||
|
UStaticMesh* Icon;
|
||||||
|
|
||||||
|
UFUNCTION()
|
||||||
|
virtual void Invoke(ACharacter* Character);
|
||||||
|
};
|
41
Source/the_twilight_abyss/TurnBasedCombatV2/StatusSystem.cpp
Normal file
41
Source/the_twilight_abyss/TurnBasedCombatV2/StatusSystem.cpp
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
// Fill out your copyright notice in the Description page of Project Settings.
|
||||||
|
|
||||||
|
|
||||||
|
#include "StatusSystem.h"
|
||||||
|
#include <Runtime/Engine/Classes/Kismet/GameplayStatics.h>
|
||||||
|
|
||||||
|
// Sets default values for this component's properties
|
||||||
|
UStatusSystem::UStatusSystem()
|
||||||
|
{
|
||||||
|
// Set this component to be initialized when the game starts, and to be ticked every frame. You can turn these features
|
||||||
|
// off to improve performance if you don't need them.
|
||||||
|
PrimaryComponentTick.bCanEverTick = true;
|
||||||
|
|
||||||
|
// ...
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Called when the game starts
|
||||||
|
void UStatusSystem::BeginPlay()
|
||||||
|
{
|
||||||
|
Super::BeginPlay();
|
||||||
|
|
||||||
|
// ...
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Called every frame
|
||||||
|
void UStatusSystem::TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction)
|
||||||
|
{
|
||||||
|
Super::TickComponent(DeltaTime, TickType, ThisTickFunction);
|
||||||
|
|
||||||
|
for (FActiveStatusEffect StatusEffect : ActiveStatusEffects)
|
||||||
|
{
|
||||||
|
if (StatusEffect.TimeTillExpiry > UGameplayStatics::GetRealTimeSeconds(GetWorld()))
|
||||||
|
{
|
||||||
|
//ActiveStatusEffects.RemoveAt(ActiveStatusEffects.Find(StatusEffect));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
45
Source/the_twilight_abyss/TurnBasedCombatV2/StatusSystem.h
Normal file
45
Source/the_twilight_abyss/TurnBasedCombatV2/StatusSystem.h
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
// Fill out your copyright notice in the Description page of Project Settings.
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "CoreMinimal.h"
|
||||||
|
#include "Components/ActorComponent.h"
|
||||||
|
#include "StatusEffect.h"
|
||||||
|
#include "StatusSystem.generated.h"
|
||||||
|
|
||||||
|
USTRUCT()
|
||||||
|
struct FActiveStatusEffect
|
||||||
|
{
|
||||||
|
GENERATED_BODY()
|
||||||
|
|
||||||
|
UPROPERTY()
|
||||||
|
float TimeInitiated;
|
||||||
|
UPROPERTY()
|
||||||
|
float TimeTillExpiry;
|
||||||
|
|
||||||
|
UPROPERTY()
|
||||||
|
UStatusEffect* StatusEffect;
|
||||||
|
};
|
||||||
|
|
||||||
|
UCLASS( ClassGroup=(Custom), meta=(BlueprintSpawnableComponent) )
|
||||||
|
class THE_TWILIGHT_ABYSS_API UStatusSystem : public UActorComponent
|
||||||
|
{
|
||||||
|
GENERATED_BODY()
|
||||||
|
|
||||||
|
public:
|
||||||
|
// Sets default values for this component's properties
|
||||||
|
UStatusSystem();
|
||||||
|
|
||||||
|
UPROPERTY()
|
||||||
|
TArray<FActiveStatusEffect> ActiveStatusEffects;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
// Called when the game starts
|
||||||
|
virtual void BeginPlay() override;
|
||||||
|
|
||||||
|
public:
|
||||||
|
// Called every frame
|
||||||
|
virtual void TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction) override;
|
||||||
|
|
||||||
|
|
||||||
|
};
|
@ -10,7 +10,8 @@
|
|||||||
"LoadingPhase": "Default",
|
"LoadingPhase": "Default",
|
||||||
"AdditionalDependencies": [
|
"AdditionalDependencies": [
|
||||||
"Engine",
|
"Engine",
|
||||||
"UMG"
|
"UMG",
|
||||||
|
"CoreUObject"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
Loading…
Reference in New Issue
Block a user