Updated Combat to Include a Reload Effect
This commit is contained in:
parent
feea306d11
commit
f7c4fdac3f
BIN
Content/Blueprints/Combat_UI/CombatCharacter.uasset
(Stored with Git LFS)
BIN
Content/Blueprints/Combat_UI/CombatCharacter.uasset
(Stored with Git LFS)
Binary file not shown.
BIN
Content/Blueprints/Combat_UI/CombatInit.uasset
(Stored with Git LFS)
BIN
Content/Blueprints/Combat_UI/CombatInit.uasset
(Stored with Git LFS)
Binary file not shown.
@ -28,10 +28,13 @@ void UHoldToInitCombat::BeginPlay()
|
|||||||
{
|
{
|
||||||
Super::BeginPlay();
|
Super::BeginPlay();
|
||||||
InitCombatWidget = CreateWidget<UUserWidget>(GetWorld(), InitCombatWidgetClass);
|
InitCombatWidget = CreateWidget<UUserWidget>(GetWorld(), InitCombatWidgetClass);
|
||||||
|
InitCombatWidget->AddToViewport();
|
||||||
|
InitCombatWidget->SetVisibility(ESlateVisibility::Hidden);
|
||||||
|
|
||||||
|
ReloadSlider = Cast<URadialSlider>(InitCombatWidget->GetWidgetFromName("ReloadSlider"));
|
||||||
|
|
||||||
UInputComponent* PlayerInputComponent = GetWorld()->GetFirstPlayerController()->InputComponent;
|
UInputComponent* PlayerInputComponent = GetWorld()->GetFirstPlayerController()->InputComponent;
|
||||||
PlayerInputComponent->BindAction("RightClick", IE_Pressed, this, &UHoldToInitCombat::OnRightClickDown);
|
PlayerInputComponent->BindAction("Click", IE_Pressed, this, &UHoldToInitCombat::OnClickDown);
|
||||||
PlayerInputComponent->BindAction("RightClick", IE_Released, this, &UHoldToInitCombat::OnRightClickUp);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -39,35 +42,25 @@ void UHoldToInitCombat::BeginPlay()
|
|||||||
void UHoldToInitCombat::TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction)
|
void UHoldToInitCombat::TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction)
|
||||||
{
|
{
|
||||||
Super::TickComponent(DeltaTime, TickType, ThisTickFunction);
|
Super::TickComponent(DeltaTime, TickType, ThisTickFunction);
|
||||||
|
if (ReloadTimer > 0.0f)
|
||||||
|
{
|
||||||
|
ReloadTimer -= DeltaTime;
|
||||||
|
ReloadSlider->SetValue(FMath::Clamp<float>(ReloadTime - ReloadTimer, 0.f, ReloadTime) / ReloadTime);
|
||||||
|
}
|
||||||
|
else if (InitCombatWidget->GetVisibility() == ESlateVisibility::Visible)
|
||||||
|
{
|
||||||
|
InitCombatWidget->SetVisibility(ESlateVisibility::Hidden);
|
||||||
|
}
|
||||||
|
|
||||||
// if (bRightClickDown && RightClickDownTime < 0.1f)
|
if (bClickDown && TargetEnemy != nullptr)
|
||||||
// {
|
|
||||||
// RightClickDownTime += DeltaTime;
|
|
||||||
// }
|
|
||||||
// else if (bRightClickDown && RightClickDownTime >= 0.1f)
|
|
||||||
// {
|
|
||||||
// //Enter Combat Mode
|
|
||||||
// Cast<ATurnBaseCombatV2>(GetWorld()->GetGameState())->StartCombat(TargetEnemy);
|
|
||||||
// //UBlackboardComponent* TargetEnemyBlackboard = Cast<UBlackboardComponent>(TargetEnemy->GetComponentByClass(UBlackboardComponent::StaticClass()));
|
|
||||||
// //TargetEnemyBlackboard->SetValueAsBool("IsInCombat", true);
|
|
||||||
// OnRightClickUp();
|
|
||||||
// }
|
|
||||||
if (bRightClickDown)
|
|
||||||
{
|
{
|
||||||
Cast<ATurnBaseCombatV2>(GetWorld()->GetGameState())->StartCombat(TargetEnemy);
|
Cast<ATurnBaseCombatV2>(GetWorld()->GetGameState())->StartCombat(TargetEnemy);
|
||||||
OnRightClickUp();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void UHoldToInitCombat::OnRightClickDown()
|
void UHoldToInitCombat::OnClickDown()
|
||||||
{
|
{
|
||||||
if (AActor* RightClickHit = LookingAtEnemy(); RightClickHit != nullptr)
|
if (ReloadTimer > 0.0f) return;
|
||||||
{
|
|
||||||
TargetEnemy = RightClickHit;
|
|
||||||
bRightClickDown = true;
|
|
||||||
//InitCombatWidget->AddToViewport();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (GunEffect)
|
if (GunEffect)
|
||||||
{
|
{
|
||||||
const AActor* PlayerActor = GetWorld()->GetFirstPlayerController()->GetPawn();
|
const AActor* PlayerActor = GetWorld()->GetFirstPlayerController()->GetPawn();
|
||||||
@ -75,16 +68,17 @@ void UHoldToInitCombat::OnRightClickDown()
|
|||||||
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());
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
void UHoldToInitCombat::OnRightClickUp()
|
if (AActor* ClickHit = LookingAtEnemy(); ClickHit != nullptr)
|
||||||
{
|
|
||||||
bRightClickDown = false;
|
|
||||||
RightClickDownTime = 0.0f;
|
|
||||||
if (InitCombatWidget->IsInViewport())
|
|
||||||
{
|
{
|
||||||
InitCombatWidget->RemoveFromParent();
|
TargetEnemy = ClickHit;
|
||||||
|
Cast<ATurnBaseCombatV2>(GetWorld()->GetGameState())->StartCombat(TargetEnemy);
|
||||||
|
InitCombatWidget->SetVisibility(ESlateVisibility::Hidden);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ReloadTimer = ReloadTime;
|
||||||
|
InitCombatWidget->SetVisibility(ESlateVisibility::Visible);
|
||||||
}
|
}
|
||||||
|
|
||||||
AActor* UHoldToInitCombat::LookingAtEnemy() const
|
AActor* UHoldToInitCombat::LookingAtEnemy() const
|
||||||
|
@ -4,8 +4,8 @@
|
|||||||
|
|
||||||
#include "CoreMinimal.h"
|
#include "CoreMinimal.h"
|
||||||
#include "Components/ActorComponent.h"
|
#include "Components/ActorComponent.h"
|
||||||
#include "NiagaraComponent.h"
|
|
||||||
#include "NiagaraFunctionLibrary.h"
|
#include "NiagaraFunctionLibrary.h"
|
||||||
|
#include "Components/RadialSlider.h"
|
||||||
#include "HoldToInitCombat.generated.h"
|
#include "HoldToInitCombat.generated.h"
|
||||||
|
|
||||||
class UNiagaraSystem;
|
class UNiagaraSystem;
|
||||||
@ -26,6 +26,9 @@ public:
|
|||||||
UPROPERTY()
|
UPROPERTY()
|
||||||
UNiagaraSystem* GunEffect;
|
UNiagaraSystem* GunEffect;
|
||||||
|
|
||||||
|
UPROPERTY(EditAnywhere)
|
||||||
|
float ReloadTime = 1.0f;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// Called when the game starts
|
// Called when the game starts
|
||||||
virtual void BeginPlay() override;
|
virtual void BeginPlay() override;
|
||||||
@ -35,12 +38,14 @@ public:
|
|||||||
virtual void TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction) override;
|
virtual void TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void OnRightClickDown();
|
void OnClickDown();
|
||||||
void OnRightClickUp();
|
bool bClickDown = false;
|
||||||
bool bRightClickDown = false;
|
float ReloadTimer = 0.0f;
|
||||||
float RightClickDownTime = 0.0f;
|
|
||||||
|
|
||||||
UFUNCTION()
|
UFUNCTION()
|
||||||
AActor* LookingAtEnemy() const;
|
AActor* LookingAtEnemy() const;
|
||||||
AActor* TargetEnemy = nullptr;
|
AActor* TargetEnemy = nullptr;
|
||||||
|
|
||||||
|
UPROPERTY()
|
||||||
|
URadialSlider* ReloadSlider;
|
||||||
};
|
};
|
||||||
|
@ -224,7 +224,7 @@ void ATurnBaseCombatV2::ExecuteCast(FString Combo)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (GunEffect && !bIsInCombat)
|
if (GunEffect)
|
||||||
{
|
{
|
||||||
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));
|
||||||
|
@ -139,48 +139,48 @@ private:
|
|||||||
|
|
||||||
void SwitchTurn();
|
void SwitchTurn();
|
||||||
|
|
||||||
UPROPERTY(VisibleAnywhere)
|
UPROPERTY()
|
||||||
UTextBlock* TurnIndicatorTextBlock;
|
UTextBlock* TurnIndicatorTextBlock;
|
||||||
UPROPERTY(VisibleAnywhere)
|
UPROPERTY()
|
||||||
UTextBlock* CurrentComboTextBlock;
|
UTextBlock* CurrentComboTextBlock;
|
||||||
UPROPERTY(VisibleAnywhere)
|
UPROPERTY()
|
||||||
UTextBlock* CurrentComboTextBlock1;
|
UTextBlock* CurrentComboTextBlock1;
|
||||||
UPROPERTY(VisibleAnywhere)
|
UPROPERTY()
|
||||||
UTextBlock* CurrentComboTextBlock2;
|
UTextBlock* CurrentComboTextBlock2;
|
||||||
UPROPERTY(VisibleAnywhere)
|
UPROPERTY()
|
||||||
UTextBlock* BattleLogTextBlock;
|
UTextBlock* BattleLogTextBlock;
|
||||||
UPROPERTY(VisibleAnywhere)
|
UPROPERTY()
|
||||||
UTextBlock* EscapePercentageTextBlock;
|
UTextBlock* EscapePercentageTextBlock;
|
||||||
|
|
||||||
UPROPERTY(VisibleAnywhere)
|
UPROPERTY()
|
||||||
UProgressBar* PlayerHealthBar;
|
UProgressBar* PlayerHealthBar;
|
||||||
UPROPERTY(VisibleAnywhere)
|
UPROPERTY()
|
||||||
UProgressBar* EnemyHealthBar;
|
UProgressBar* EnemyHealthBar;
|
||||||
|
|
||||||
UPROPERTY(VisibleAnywhere)
|
UPROPERTY()
|
||||||
UProgressBar* ProbertiumResourceBar;
|
UProgressBar* ProbertiumResourceBar;
|
||||||
UPROPERTY(VisibleAnywhere)
|
UPROPERTY()
|
||||||
UProgressBar* EisResourceBar;
|
UProgressBar* EisResourceBar;
|
||||||
UPROPERTY(VisibleAnywhere)
|
UPROPERTY()
|
||||||
UProgressBar* AzosResourceBar;
|
UProgressBar* AzosResourceBar;
|
||||||
UPROPERTY(VisibleAnywhere)
|
UPROPERTY()
|
||||||
UProgressBar* IroquoidResourceBar;
|
UProgressBar* IroquoidResourceBar;
|
||||||
|
|
||||||
UPROPERTY(VisibleAnywhere)
|
UPROPERTY()
|
||||||
UButton* CastButton;
|
UButton* CastButton;
|
||||||
|
|
||||||
UPROPERTY(VisibleAnywhere)
|
UPROPERTY()
|
||||||
UButton* PButton;
|
UButton* PButton;
|
||||||
UPROPERTY(VisibleAnywhere)
|
UPROPERTY()
|
||||||
UButton* EButton;
|
UButton* EButton;
|
||||||
UPROPERTY(VisibleAnywhere)
|
UPROPERTY()
|
||||||
UButton* AButton;
|
UButton* AButton;
|
||||||
UPROPERTY(VisibleAnywhere)
|
UPROPERTY()
|
||||||
UButton* IButton;
|
UButton* IButton;
|
||||||
|
|
||||||
UPROPERTY(VisibleAnywhere)
|
UPROPERTY()
|
||||||
UButton* BackspaceButton;
|
UButton* BackspaceButton;
|
||||||
UPROPERTY(VisibleAnywhere)
|
UPROPERTY()
|
||||||
UButton* RunButton;
|
UButton* RunButton;
|
||||||
|
|
||||||
UFUNCTION()
|
UFUNCTION()
|
||||||
|
@ -10,7 +10,7 @@ public class the_twilight_abyss : ModuleRules
|
|||||||
|
|
||||||
PublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine", "InputCore", "UMG", "Niagara", "AIModule", "Json" });
|
PublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine", "InputCore", "UMG", "Niagara", "AIModule", "Json" });
|
||||||
|
|
||||||
PrivateDependencyModuleNames.AddRange(new string[] { "Slate", "SlateCore" });
|
PrivateDependencyModuleNames.AddRange(new string[] { "Slate", "SlateCore", "AdvancedWidgets" });
|
||||||
|
|
||||||
// Uncomment if you are using Slate UI
|
// Uncomment if you are using Slate UI
|
||||||
// PrivateDependencyModuleNames.AddRange(new string[] { "Slate", "SlateCore" });
|
// PrivateDependencyModuleNames.AddRange(new string[] { "Slate", "SlateCore" });
|
||||||
|
Loading…
Reference in New Issue
Block a user