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();
|
||||
InitCombatWidget = CreateWidget<UUserWidget>(GetWorld(), InitCombatWidgetClass);
|
||||
InitCombatWidget->AddToViewport();
|
||||
InitCombatWidget->SetVisibility(ESlateVisibility::Hidden);
|
||||
|
||||
ReloadSlider = Cast<URadialSlider>(InitCombatWidget->GetWidgetFromName("ReloadSlider"));
|
||||
|
||||
UInputComponent* PlayerInputComponent = GetWorld()->GetFirstPlayerController()->InputComponent;
|
||||
PlayerInputComponent->BindAction("RightClick", IE_Pressed, this, &UHoldToInitCombat::OnRightClickDown);
|
||||
PlayerInputComponent->BindAction("RightClick", IE_Released, this, &UHoldToInitCombat::OnRightClickUp);
|
||||
PlayerInputComponent->BindAction("Click", IE_Pressed, this, &UHoldToInitCombat::OnClickDown);
|
||||
}
|
||||
|
||||
|
||||
@ -39,35 +42,25 @@ void UHoldToInitCombat::BeginPlay()
|
||||
void UHoldToInitCombat::TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* 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)
|
||||
// {
|
||||
// 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)
|
||||
if (bClickDown && TargetEnemy != nullptr)
|
||||
{
|
||||
Cast<ATurnBaseCombatV2>(GetWorld()->GetGameState())->StartCombat(TargetEnemy);
|
||||
OnRightClickUp();
|
||||
}
|
||||
}
|
||||
|
||||
void UHoldToInitCombat::OnRightClickDown()
|
||||
void UHoldToInitCombat::OnClickDown()
|
||||
{
|
||||
if (AActor* RightClickHit = LookingAtEnemy(); RightClickHit != nullptr)
|
||||
{
|
||||
TargetEnemy = RightClickHit;
|
||||
bRightClickDown = true;
|
||||
//InitCombatWidget->AddToViewport();
|
||||
}
|
||||
|
||||
if (ReloadTimer > 0.0f) return;
|
||||
if (GunEffect)
|
||||
{
|
||||
const AActor* PlayerActor = GetWorld()->GetFirstPlayerController()->GetPawn();
|
||||
@ -75,16 +68,17 @@ void UHoldToInitCombat::OnRightClickDown()
|
||||
const FVector GunLocationOffset = GunComponent->GetSocketTransform("Muzzle").TransformPosition(FVector(-100, 0, 0));
|
||||
UNiagaraFunctionLibrary::SpawnSystemAtLocation(GetWorld(), GunEffect, GunLocationOffset, PlayerActor->GetActorRotation());
|
||||
}
|
||||
}
|
||||
|
||||
void UHoldToInitCombat::OnRightClickUp()
|
||||
{
|
||||
bRightClickDown = false;
|
||||
RightClickDownTime = 0.0f;
|
||||
if (InitCombatWidget->IsInViewport())
|
||||
if (AActor* ClickHit = LookingAtEnemy(); ClickHit != nullptr)
|
||||
{
|
||||
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
|
||||
|
@ -4,8 +4,8 @@
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "Components/ActorComponent.h"
|
||||
#include "NiagaraComponent.h"
|
||||
#include "NiagaraFunctionLibrary.h"
|
||||
#include "Components/RadialSlider.h"
|
||||
#include "HoldToInitCombat.generated.h"
|
||||
|
||||
class UNiagaraSystem;
|
||||
@ -26,6 +26,9 @@ public:
|
||||
UPROPERTY()
|
||||
UNiagaraSystem* GunEffect;
|
||||
|
||||
UPROPERTY(EditAnywhere)
|
||||
float ReloadTime = 1.0f;
|
||||
|
||||
protected:
|
||||
// Called when the game starts
|
||||
virtual void BeginPlay() override;
|
||||
@ -35,12 +38,14 @@ public:
|
||||
virtual void TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction) override;
|
||||
|
||||
private:
|
||||
void OnRightClickDown();
|
||||
void OnRightClickUp();
|
||||
bool bRightClickDown = false;
|
||||
float RightClickDownTime = 0.0f;
|
||||
|
||||
void OnClickDown();
|
||||
bool bClickDown = false;
|
||||
float ReloadTimer = 0.0f;
|
||||
|
||||
UFUNCTION()
|
||||
AActor* LookingAtEnemy() const;
|
||||
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 FVector GunLocationOffset = GunComponent->GetSocketTransform("Muzzle").TransformPosition(FVector(-100, 0, 0));
|
||||
|
@ -139,48 +139,48 @@ private:
|
||||
|
||||
void SwitchTurn();
|
||||
|
||||
UPROPERTY(VisibleAnywhere)
|
||||
UPROPERTY()
|
||||
UTextBlock* TurnIndicatorTextBlock;
|
||||
UPROPERTY(VisibleAnywhere)
|
||||
UPROPERTY()
|
||||
UTextBlock* CurrentComboTextBlock;
|
||||
UPROPERTY(VisibleAnywhere)
|
||||
UPROPERTY()
|
||||
UTextBlock* CurrentComboTextBlock1;
|
||||
UPROPERTY(VisibleAnywhere)
|
||||
UPROPERTY()
|
||||
UTextBlock* CurrentComboTextBlock2;
|
||||
UPROPERTY(VisibleAnywhere)
|
||||
UPROPERTY()
|
||||
UTextBlock* BattleLogTextBlock;
|
||||
UPROPERTY(VisibleAnywhere)
|
||||
UPROPERTY()
|
||||
UTextBlock* EscapePercentageTextBlock;
|
||||
|
||||
UPROPERTY(VisibleAnywhere)
|
||||
UPROPERTY()
|
||||
UProgressBar* PlayerHealthBar;
|
||||
UPROPERTY(VisibleAnywhere)
|
||||
UPROPERTY()
|
||||
UProgressBar* EnemyHealthBar;
|
||||
|
||||
UPROPERTY(VisibleAnywhere)
|
||||
UPROPERTY()
|
||||
UProgressBar* ProbertiumResourceBar;
|
||||
UPROPERTY(VisibleAnywhere)
|
||||
UPROPERTY()
|
||||
UProgressBar* EisResourceBar;
|
||||
UPROPERTY(VisibleAnywhere)
|
||||
UPROPERTY()
|
||||
UProgressBar* AzosResourceBar;
|
||||
UPROPERTY(VisibleAnywhere)
|
||||
UPROPERTY()
|
||||
UProgressBar* IroquoidResourceBar;
|
||||
|
||||
UPROPERTY(VisibleAnywhere)
|
||||
UPROPERTY()
|
||||
UButton* CastButton;
|
||||
|
||||
UPROPERTY(VisibleAnywhere)
|
||||
UPROPERTY()
|
||||
UButton* PButton;
|
||||
UPROPERTY(VisibleAnywhere)
|
||||
UPROPERTY()
|
||||
UButton* EButton;
|
||||
UPROPERTY(VisibleAnywhere)
|
||||
UPROPERTY()
|
||||
UButton* AButton;
|
||||
UPROPERTY(VisibleAnywhere)
|
||||
UPROPERTY()
|
||||
UButton* IButton;
|
||||
|
||||
UPROPERTY(VisibleAnywhere)
|
||||
UPROPERTY()
|
||||
UButton* BackspaceButton;
|
||||
UPROPERTY(VisibleAnywhere)
|
||||
UPROPERTY()
|
||||
UButton* RunButton;
|
||||
|
||||
UFUNCTION()
|
||||
|
@ -10,7 +10,7 @@ public class the_twilight_abyss : ModuleRules
|
||||
|
||||
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
|
||||
// PrivateDependencyModuleNames.AddRange(new string[] { "Slate", "SlateCore" });
|
||||
|
Loading…
Reference in New Issue
Block a user