diff --git a/Content/Blueprints/Combat_UI/CombatCharacter.uasset b/Content/Blueprints/Combat_UI/CombatCharacter.uasset index bdcc2d3..69a4360 100644 --- a/Content/Blueprints/Combat_UI/CombatCharacter.uasset +++ b/Content/Blueprints/Combat_UI/CombatCharacter.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:2288fc028031dde43dddc963534df07aabf9d878a4c0f0ae4c7bd2bc88b9be16 -size 142363 +oid sha256:1a2bddd56882aae8e60f9dd852ca2b7b1a5a3996871f9be2e8ebacc3d961b413 +size 142557 diff --git a/Content/Blueprints/Combat_UI/CombatInit.uasset b/Content/Blueprints/Combat_UI/CombatInit.uasset index 3c61b7c..9d7eec8 100644 --- a/Content/Blueprints/Combat_UI/CombatInit.uasset +++ b/Content/Blueprints/Combat_UI/CombatInit.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:1a362f19c5501c2b4112c3e0e94d5ce56f0c0a09cd6f68dc798e7c9d303780b3 -size 28160 +oid sha256:a775d9f184f3cc994b611c19d229cb421849876734bf25b2c32a621203d348d2 +size 25308 diff --git a/Source/the_twilight_abyss/TurnBasedCombatV2/HoldToInitCombat.cpp b/Source/the_twilight_abyss/TurnBasedCombatV2/HoldToInitCombat.cpp index a4253a2..854f2ce 100644 --- a/Source/the_twilight_abyss/TurnBasedCombatV2/HoldToInitCombat.cpp +++ b/Source/the_twilight_abyss/TurnBasedCombatV2/HoldToInitCombat.cpp @@ -28,10 +28,13 @@ void UHoldToInitCombat::BeginPlay() { Super::BeginPlay(); InitCombatWidget = CreateWidget(GetWorld(), InitCombatWidgetClass); + InitCombatWidget->AddToViewport(); + InitCombatWidget->SetVisibility(ESlateVisibility::Hidden); + + ReloadSlider = Cast(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(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(GetWorld()->GetGameState())->StartCombat(TargetEnemy); - // //UBlackboardComponent* TargetEnemyBlackboard = Cast(TargetEnemy->GetComponentByClass(UBlackboardComponent::StaticClass())); - // //TargetEnemyBlackboard->SetValueAsBool("IsInCombat", true); - // OnRightClickUp(); - // } - if (bRightClickDown) + if (bClickDown && TargetEnemy != nullptr) { Cast(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(GetWorld()->GetGameState())->StartCombat(TargetEnemy); + InitCombatWidget->SetVisibility(ESlateVisibility::Hidden); + return; } + + ReloadTimer = ReloadTime; + InitCombatWidget->SetVisibility(ESlateVisibility::Visible); } AActor* UHoldToInitCombat::LookingAtEnemy() const diff --git a/Source/the_twilight_abyss/TurnBasedCombatV2/HoldToInitCombat.h b/Source/the_twilight_abyss/TurnBasedCombatV2/HoldToInitCombat.h index 6ac7e3c..b72dfd8 100644 --- a/Source/the_twilight_abyss/TurnBasedCombatV2/HoldToInitCombat.h +++ b/Source/the_twilight_abyss/TurnBasedCombatV2/HoldToInitCombat.h @@ -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; }; diff --git a/Source/the_twilight_abyss/TurnBasedCombatV2/TurnBaseCombatV2.cpp b/Source/the_twilight_abyss/TurnBasedCombatV2/TurnBaseCombatV2.cpp index 48fc123..0dac807 100644 --- a/Source/the_twilight_abyss/TurnBasedCombatV2/TurnBaseCombatV2.cpp +++ b/Source/the_twilight_abyss/TurnBasedCombatV2/TurnBaseCombatV2.cpp @@ -224,7 +224,7 @@ void ATurnBaseCombatV2::ExecuteCast(FString Combo) } } - if (GunEffect && !bIsInCombat) + if (GunEffect) { const UStaticMeshComponent* GunComponent = Cast(PlayerActor->GetComponentsByTag(UPrimitiveComponent::StaticClass(), FName("Gun"))[0]); const FVector GunLocationOffset = GunComponent->GetSocketTransform("Muzzle").TransformPosition(FVector(-100, 0, 0)); diff --git a/Source/the_twilight_abyss/TurnBasedCombatV2/TurnBaseCombatV2.h b/Source/the_twilight_abyss/TurnBasedCombatV2/TurnBaseCombatV2.h index 830859d..80754d0 100644 --- a/Source/the_twilight_abyss/TurnBasedCombatV2/TurnBaseCombatV2.h +++ b/Source/the_twilight_abyss/TurnBasedCombatV2/TurnBaseCombatV2.h @@ -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() diff --git a/Source/the_twilight_abyss/the_twilight_abyss.Build.cs b/Source/the_twilight_abyss/the_twilight_abyss.Build.cs index 53967db..9d9a118 100644 --- a/Source/the_twilight_abyss/the_twilight_abyss.Build.cs +++ b/Source/the_twilight_abyss/the_twilight_abyss.Build.cs @@ -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" });