Merge branch 'Book-UI' into dev

This commit is contained in:
Philip W 2023-04-25 04:31:26 +01:00
commit fde1537dc0
32 changed files with 177 additions and 57 deletions

View File

@ -81,7 +81,7 @@ DoubleClickTime=0.200000
+ActionMappings=(ActionName="Jump",bShift=False,bCtrl=False,bAlt=False,bCmd=False,Key=Gamepad_FaceButton_Bottom) +ActionMappings=(ActionName="Jump",bShift=False,bCtrl=False,bAlt=False,bCmd=False,Key=Gamepad_FaceButton_Bottom)
+ActionMappings=(ActionName="Jump",bShift=False,bCtrl=False,bAlt=False,bCmd=False,Key=SpaceBar) +ActionMappings=(ActionName="Jump",bShift=False,bCtrl=False,bAlt=False,bCmd=False,Key=SpaceBar)
+ActionMappings=(ActionName="Interact",bShift=False,bCtrl=False,bAlt=False,bCmd=False,Key=E) +ActionMappings=(ActionName="Interact",bShift=False,bCtrl=False,bAlt=False,bCmd=False,Key=E)
+ActionMappings=(ActionName="RightClick",bShift=False,bCtrl=False,bAlt=False,bCmd=False,Key=LeftMouseButton) +ActionMappings=(ActionName="Click",bShift=False,bCtrl=False,bAlt=False,bCmd=False,Key=LeftMouseButton)
+ActionMappings=(ActionName="Sneak",bShift=False,bCtrl=False,bAlt=False,bCmd=False,Key=LeftControl) +ActionMappings=(ActionName="Sneak",bShift=False,bCtrl=False,bAlt=False,bCmd=False,Key=LeftControl)
+AxisMappings=(AxisName="Look Up / Down Gamepad",Scale=1.000000,Key=Gamepad_RightY) +AxisMappings=(AxisName="Look Up / Down Gamepad",Scale=1.000000,Key=Gamepad_RightY)
+AxisMappings=(AxisName="Look Up / Down Mouse",Scale=-1.000000,Key=MouseY) +AxisMappings=(AxisName="Look Up / Down Mouse",Scale=-1.000000,Key=MouseY)

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
Content/Blueprints/Combat_UI/Iconage/Azos.uasset (Stored with Git LFS) Normal file

Binary file not shown.

BIN
Content/Blueprints/Combat_UI/Iconage/AzosFaded.uasset (Stored with Git LFS) Normal file

Binary file not shown.

BIN
Content/Blueprints/Combat_UI/Iconage/Eis.uasset (Stored with Git LFS) Normal file

Binary file not shown.

BIN
Content/Blueprints/Combat_UI/Iconage/EisFaded.uasset (Stored with Git LFS) Normal file

Binary file not shown.

BIN
Content/Blueprints/Combat_UI/Iconage/Escape.uasset (Stored with Git LFS) Normal file

Binary file not shown.

BIN
Content/Blueprints/Combat_UI/Iconage/EscapeFaded.uasset (Stored with Git LFS) Normal file

Binary file not shown.

BIN
Content/Blueprints/Combat_UI/Iconage/Iroquoiod.uasset (Stored with Git LFS) Normal file

Binary file not shown.

BIN
Content/Blueprints/Combat_UI/Iconage/IroquoiodFaded.uasset (Stored with Git LFS) Normal file

Binary file not shown.

BIN
Content/Blueprints/Combat_UI/Iconage/Probertium.uasset (Stored with Git LFS) Normal file

Binary file not shown.

BIN
Content/Blueprints/Combat_UI/Iconage/ProbertiumFaded.uasset (Stored with Git LFS) Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -28,6 +28,11 @@ ATempCharacter::ATempCharacter()
void ATempCharacter::BeginPlay() void ATempCharacter::BeginPlay()
{ {
Super::BeginPlay(); Super::BeginPlay();
FirstPlayerController = GetWorld()->GetFirstPlayerController();
CombatSystem = Cast<ATurnBaseCombatV2>(GetWorld()->GetGameState());
WidgetPointer = Cast<UWidgetInteractionComponent>(this->GetComponentByClass(UWidgetInteractionComponent::StaticClass()));
Health = 100; Health = 100;
ThisCamera = Cast<UCameraComponent>(this->FindComponentByClass<UCameraComponent>()); ThisCamera = Cast<UCameraComponent>(this->FindComponentByClass<UCameraComponent>());
PlayerCapsule = GetCapsuleComponent(); PlayerCapsule = GetCapsuleComponent();
@ -93,6 +98,13 @@ void ATempCharacter::Sneak()
void ATempCharacter::Tick(float DeltaTime) void ATempCharacter::Tick(float DeltaTime)
{ {
Super::Tick(DeltaTime); Super::Tick(DeltaTime);
if (CombatSystem->bIsInCombat)
{
FVector VectorRotation;
FVector WidgetLocation;
FirstPlayerController->DeprojectMousePositionToWorld(WidgetLocation, VectorRotation);
WidgetPointer->SetWorldLocationAndRotation(WidgetLocation, VectorRotation.Rotation().Quaternion());
}
} }
// Gives the character the functionality // Gives the character the functionality

View File

@ -7,6 +7,8 @@
#include "the_twilight_abyss/BaseItems/Items/BaseItem.h" #include "the_twilight_abyss/BaseItems/Items/BaseItem.h"
#include "Camera/CameraComponent.h" #include "Camera/CameraComponent.h"
#include "Engine/PostProcessVolume.h" #include "Engine/PostProcessVolume.h"
#include "Components/WidgetInteractionComponent.h"
#include "../TurnBasedCombatV2/TurnBaseCombatV2.h"
#include "TempCharacter.generated.h" #include "TempCharacter.generated.h"
UCLASS() UCLASS()
@ -29,6 +31,12 @@ protected:
void Sneak(); void Sneak();
UCapsuleComponent* PlayerCapsule; UCapsuleComponent* PlayerCapsule;
UPROPERTY()
APlayerController* FirstPlayerController;
UPROPERTY()
UWidgetInteractionComponent* WidgetPointer;
UPROPERTY()
ATurnBaseCombatV2* CombatSystem;
public: public:
// Called every frame // Called every frame

View File

@ -9,7 +9,6 @@
#include "BehaviorTree/BlackboardComponent.h" #include "BehaviorTree/BlackboardComponent.h"
#include "Components/TextBlock.h" #include "Components/TextBlock.h"
#include "Components/ProgressBar.h" #include "Components/ProgressBar.h"
#include "GameFramework/Character.h"
#include "Kismet/GameplayStatics.h" #include "Kismet/GameplayStatics.h"
#include "the_twilight_abyss/PlayerTemp/TempCharacter.h" #include "the_twilight_abyss/PlayerTemp/TempCharacter.h"
@ -36,6 +35,12 @@ ATurnBaseCombatV2::ATurnBaseCombatV2()
void ATurnBaseCombatV2::StartCombat(AActor* Enemy) void ATurnBaseCombatV2::StartCombat(AActor* Enemy)
{ {
if (Enemy == nullptr) return; if (Enemy == nullptr) return;
if (bIsInCombat) return;
EscapePercentage = CalculateEscapePercentage();
EscapePercentageTextBlock->SetText(FText::Join(FText::FromString(""), FText::FromString(FString::FromInt(EscapePercentage * 100)), FText::FromString("%")));
const FVector2D ViewportSize = FVector2D(GEngine->GameViewport->Viewport->GetSizeXY());
GetWorld()->GetFirstPlayerController()->SetMouseLocation(ViewportSize.X / 2, ViewportSize.Y / 2);
bIsInCombat = true;
UBlackboardComponent* EnemyBlackboard = Cast<AAIController>(Enemy->GetInstigatorController())->GetBlackboardComponent(); UBlackboardComponent* EnemyBlackboard = Cast<AAIController>(Enemy->GetInstigatorController())->GetBlackboardComponent();
if (!HasSeenTutorial) if (!HasSeenTutorial)
{ {
@ -62,7 +67,7 @@ void ATurnBaseCombatV2::StartCombat(AActor* Enemy)
} }
if (HUD->IsInViewport()) return; if (HUD->IsInViewport()) return;
HUD->AddToViewport(); //HUD->AddToViewport();
EnemyActor = Enemy; EnemyActor = Enemy;
ProbertiumResource = 10; ProbertiumResource = 10;
@ -71,13 +76,10 @@ void ATurnBaseCombatV2::StartCombat(AActor* Enemy)
IroquoidResource = 10; IroquoidResource = 10;
//Disable Character Movement //Disable Character Movement
if (ACharacter* PlayerCharacter = Cast<ACharacter>(GetWorld()->GetFirstPlayerController()->GetPawn()))
{
PlayerCharacter->DisableInput(GetWorld()->GetFirstPlayerController());
}
//Set to UI Mode Only
APlayerController* PlayerController = GetWorld()->GetFirstPlayerController(); APlayerController* PlayerController = GetWorld()->GetFirstPlayerController();
PlayerController->SetInputMode(FInputModeUIOnly()); PlayerController->SetIgnoreMoveInput(true);
PlayerController->SetIgnoreLookInput(true);
PlayerController->SetInputMode(FInputModeGameAndUI());
PlayerController->bShowMouseCursor = true; PlayerController->bShowMouseCursor = true;
FVector Direction = Enemy->GetActorLocation() - PlayerActor->GetActorLocation(); FVector Direction = Enemy->GetActorLocation() - PlayerActor->GetActorLocation();
@ -98,8 +100,12 @@ void ATurnBaseCombatV2::StartCombat(AActor* Enemy)
void ATurnBaseCombatV2::EndCombat() void ATurnBaseCombatV2::EndCombat()
{ {
const FVector2D ViewportSize = FVector2D(GEngine->GameViewport->Viewport->GetSizeXY());
TurnIndicatorTextBlock->SetText(FText::FromString(""));
GetWorld()->GetFirstPlayerController()->SetMouseLocation(ViewportSize.X / 2, ViewportSize.Y / 2);
bEnemyHasExtraTurn = false; bEnemyHasExtraTurn = false;
bPlayerHasExtraTurn = false; bPlayerHasExtraTurn = false;
bIsInCombat = false;
for (UStatusEffect* StatusEffect : StatusEffects) for (UStatusEffect* StatusEffect : StatusEffects)
{ {
StatusEffect->OnExpiry(PlayerActor); StatusEffect->OnExpiry(PlayerActor);
@ -110,12 +116,10 @@ void ATurnBaseCombatV2::EndCombat()
PlayerPawn->bUseControllerRotationYaw = true; PlayerPawn->bUseControllerRotationYaw = true;
PlayerPawn->bUseControllerRotationPitch = true; PlayerPawn->bUseControllerRotationPitch = true;
//Enable Character Movement //Enable Character Movement
if (ACharacter* PlayerCharacter = Cast<ACharacter>(GetWorld()->GetFirstPlayerController()->GetPawn()))
{
PlayerCharacter->EnableInput(GetWorld()->GetFirstPlayerController());
}
//Set to Game Mode Only //Set to Game Mode Only
APlayerController* PlayerController = GetWorld()->GetFirstPlayerController(); APlayerController* PlayerController = GetWorld()->GetFirstPlayerController();
PlayerController->SetIgnoreMoveInput(false);
PlayerController->SetIgnoreLookInput(false);
PlayerController->SetInputMode(FInputModeGameOnly()); PlayerController->SetInputMode(FInputModeGameOnly());
PlayerController->bShowMouseCursor = false; PlayerController->bShowMouseCursor = false;
} }
@ -123,6 +127,8 @@ void ATurnBaseCombatV2::EndCombat()
void ATurnBaseCombatV2::BeginPlay() void ATurnBaseCombatV2::BeginPlay()
{ {
Super::BeginPlay(); Super::BeginPlay();
const FVector2D ViewportSize = FVector2D(GEngine->GameViewport->Viewport->GetSizeXY());
GetWorld()->GetFirstPlayerController()->SetMouseLocation(ViewportSize.X / 2, ViewportSize.Y / 2);
TArray<AActor*> AllCharacterActorsInScene; TArray<AActor*> AllCharacterActorsInScene;
@ -140,24 +146,25 @@ void ATurnBaseCombatV2::BeginPlay()
PlayerWidget->InitWidget(); PlayerWidget->InitWidget();
BookHUD = PlayerWidget->GetWidget(); BookHUD = PlayerWidget->GetWidget();
TurnIndicatorTextBlock = Cast<UTextBlock>(HUD->GetWidgetFromName("TurnIndicator")); TurnIndicatorTextBlock = Cast<UTextBlock>(BookHUD->GetWidgetFromName("TurnIndicator"));
CurrentComboTextBlock = Cast<UTextBlock>(BookHUD->GetWidgetFromName("CurrentCombo")); CurrentComboTextBlock = Cast<UTextBlock>(BookHUD->GetWidgetFromName("CurrentCombo"));
CurrentComboTextBlock1 = Cast<UTextBlock>(BookHUD->GetWidgetFromName("CurrentCombo_1")); CurrentComboTextBlock1 = Cast<UTextBlock>(BookHUD->GetWidgetFromName("CurrentCombo_1"));
CurrentComboTextBlock2 = Cast<UTextBlock>(BookHUD->GetWidgetFromName("CurrentCombo_2")); CurrentComboTextBlock2 = Cast<UTextBlock>(BookHUD->GetWidgetFromName("CurrentCombo_2"));
BattleLogTextBlock = Cast<UTextBlock>(HUD->GetWidgetFromName("BattleLog")); BattleLogTextBlock = Cast<UTextBlock>(HUD->GetWidgetFromName("BattleLog"));
EscapePercentageTextBlock = Cast<UTextBlock>(BookHUD->GetWidgetFromName("EscapePercentage_Text"));
PlayerHealthBar = Cast<UProgressBar>(BookHUD->GetWidgetFromName("PlayerHealthBar")); PlayerHealthBar = Cast<UProgressBar>(BookHUD->GetWidgetFromName("PlayerHealthBar"));
EnemyHealthBar = Cast<UProgressBar>(HUD->GetWidgetFromName("EnemyHealthBar")); EnemyHealthBar = Cast<UProgressBar>(HUD->GetWidgetFromName("EnemyHealthBar"));
ProbertiumResourceBar = Cast<UProgressBar>(BookHUD->GetWidgetFromName("ProbertiumResourceBar")); ProbertiumResourceBar = Cast<UProgressBar>(BookHUD->GetWidgetFromName("ProbertiumResourceBar"));
EisResourceBar = Cast<UProgressBar>(BookHUD->GetWidgetFromName("EisResourceBar")); EisResourceBar = Cast<UProgressBar>(BookHUD->GetWidgetFromName("EisResourceBar"));
AzosResourceBar = Cast<UProgressBar>(BookHUD->GetWidgetFromName("AzosResourceBar")); AzosResourceBar = Cast<UProgressBar>(BookHUD->GetWidgetFromName("AzosResourceBar"));
IroquoidResourceBar = Cast<UProgressBar>(BookHUD->GetWidgetFromName("IroquoidResourceBar")); IroquoidResourceBar = Cast<UProgressBar>(BookHUD->GetWidgetFromName("IroquoidResourceBar"));
CastButton = Cast<UButton>(HUD->GetWidgetFromName("CastButton")); CastButton = Cast<UButton>(BookHUD->GetWidgetFromName("Cast_Button"));
PButton = Cast<UButton>(HUD->GetWidgetFromName("PButton")); PButton = Cast<UButton>(BookHUD->GetWidgetFromName("Probertium_Button"));
EButton = Cast<UButton>(HUD->GetWidgetFromName("EButton")); EButton = Cast<UButton>(BookHUD->GetWidgetFromName("Eis_Button"));
AButton = Cast<UButton>(HUD->GetWidgetFromName("AButton")); AButton = Cast<UButton>(BookHUD->GetWidgetFromName("Azos_Button"));
IButton = Cast<UButton>(HUD->GetWidgetFromName("IButton")); IButton = Cast<UButton>(BookHUD->GetWidgetFromName("Iroquoid_Button"));
BackspaceButton = Cast<UButton>(HUD->GetWidgetFromName("BackspaceButton")); BackspaceButton = Cast<UButton>(BookHUD->GetWidgetFromName("Clear_Button"));
RunButton = Cast<UButton>(HUD->GetWidgetFromName("RunButton")); RunButton = Cast<UButton>(BookHUD->GetWidgetFromName("Escape_Button"));
CastButton->OnClicked.AddDynamic(this, &ATurnBaseCombatV2::CastButtonOnClick); CastButton->OnClicked.AddDynamic(this, &ATurnBaseCombatV2::CastButtonOnClick);
PButton->OnClicked.AddDynamic(this, &ATurnBaseCombatV2::PButtonOnClick); PButton->OnClicked.AddDynamic(this, &ATurnBaseCombatV2::PButtonOnClick);
EButton->OnClicked.AddDynamic(this, &ATurnBaseCombatV2::EButtonOnClick); EButton->OnClicked.AddDynamic(this, &ATurnBaseCombatV2::EButtonOnClick);
@ -217,7 +224,7 @@ void ATurnBaseCombatV2::ExecuteCast(FString Combo)
} }
} }
if (GunEffect) if (GunEffect && !bIsInCombat)
{ {
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));
@ -300,10 +307,14 @@ void ATurnBaseCombatV2::DamageEnemy(int Damage, FString DamageType)
void ATurnBaseCombatV2::UpdateProgressBars() const void ATurnBaseCombatV2::UpdateProgressBars() const
{ {
//PlayerHealthBar->SetPercent(*PlayerHealth / 100.0f);
EnemyHealthBar->SetPercent(*EnemyHealth / 100.0f); EnemyHealthBar->SetPercent(*EnemyHealth / 100.0f);
} }
float ATurnBaseCombatV2::CalculateEscapePercentage() const
{
return FMath::RandRange(0.1f, 0.9f);
}
bool ATurnBaseCombatV2::IsValidCombo(const FString Combo) const bool ATurnBaseCombatV2::IsValidCombo(const FString Combo) const
{ {
return ValidCombos.Contains(Combo); return ValidCombos.Contains(Combo);
@ -415,32 +426,63 @@ void ATurnBaseCombatV2::BackspaceButtonOnClick()
GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, TEXT("Blank Combo")); GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, TEXT("Blank Combo"));
return; return;
} }
ReuseActionPoint(); for (int i = 0; i < CurrentComboString.Len(); i++)
if (CurrentComboString.Right(1) == "P")
{ {
ProbertiumResource += 1; if (CurrentComboString[i] == 'P')
{
ProbertiumResource += 1;
}
else if (CurrentComboString[i] == 'E')
{
EisResource += 1;
}
else if (CurrentComboString[i] == 'A')
{
AzosResource += 1;
}
else if (CurrentComboString[i] == 'I')
{
IroquoidResource += 1;
}
} }
else if (CurrentComboString.Right(1) == "E") CurrentComboString = "";
{
EisResource += 1;
}
else if (CurrentComboString.Right(1) == "A")
{
AzosResource += 1;
}
else if (CurrentComboString.Right(1) == "I")
{
IroquoidResource += 1;
}
CurrentComboString.RemoveAt(CurrentComboString.Len() - 1);
UpdateComboString(CurrentComboString); UpdateComboString(CurrentComboString);
RevertActionPoints();
UpdateActionPoints();
UpdateResourceBars(); UpdateResourceBars();
// ReuseActionPoint();
// if (CurrentComboString.Right(1) == "P")
// {
// ProbertiumResource += 1;
// }
// else if (CurrentComboString.Right(1) == "E")
// {
// EisResource += 1;
// }
// else if (CurrentComboString.Right(1) == "A")
// {
// AzosResource += 1;
// }
// else if (CurrentComboString.Right(1) == "I")
// {
// IroquoidResource += 1;
// }
// CurrentComboString.RemoveAt(CurrentComboString.Len() - 1);
// UpdateComboString(CurrentComboString);
// UpdateResourceBars();
} }
void ATurnBaseCombatV2::RunButtonOnClick() void ATurnBaseCombatV2::RunButtonOnClick()
{ {
if (FMath::RandRange(0.0f, 1.0f) >= EscapePercentage)
{
EscapePercentage = CalculateEscapePercentage();
EscapePercentageTextBlock->SetText(FText::Join(FText::FromString(""), FText::FromString(FString::FromInt(EscapePercentage * 100)), FText::FromString("%")));
SwitchTurn();
return;
}
UBlackboardComponent* EnemyBlackboard = Cast<AAIController>(EnemyActor->GetInstigatorController())->GetBlackboardComponent(); UBlackboardComponent* EnemyBlackboard = Cast<AAIController>(EnemyActor->GetInstigatorController())->GetBlackboardComponent();
EscapePercentageTextBlock->SetText(FText::Join(FText::FromString(""), FText::FromString("--"), FText::FromString("%")));
EnemyBlackboard->SetValueAsBool("IsInCombat", false); EnemyBlackboard->SetValueAsBool("IsInCombat", false);
EnemyBlackboard->SetValueAsBool("WasInCombat", true); EnemyBlackboard->SetValueAsBool("WasInCombat", true);
EndCombat(); EndCombat();

View File

@ -26,6 +26,8 @@ public:
int* EnemyHealth = nullptr; int* EnemyHealth = nullptr;
float* PlayerHealth = nullptr; float* PlayerHealth = nullptr;
bool bIsInCombat = false;
UPROPERTY(EditDefaultsOnly) UPROPERTY(EditDefaultsOnly)
int DefaultActionPoints = 2; int DefaultActionPoints = 2;
UPROPERTY(EditDefaultsOnly) UPROPERTY(EditDefaultsOnly)
@ -126,6 +128,9 @@ protected:
bool bPlayerHasExtraTurn = false; bool bPlayerHasExtraTurn = false;
bool bEnemyHasExtraTurn = false; bool bEnemyHasExtraTurn = false;
float EscapePercentage = 0.0f;
float CalculateEscapePercentage() const;
private: private:
bool IsValidCombo(FString Combo) const; bool IsValidCombo(FString Combo) const;
bool IsSpecialCombo(FString Combo) const; bool IsSpecialCombo(FString Combo) const;
@ -156,6 +161,8 @@ private:
UTextBlock* CurrentComboTextBlock2; UTextBlock* CurrentComboTextBlock2;
UPROPERTY(VisibleAnywhere) UPROPERTY(VisibleAnywhere)
UTextBlock* BattleLogTextBlock; UTextBlock* BattleLogTextBlock;
UPROPERTY(VisibleAnywhere)
UTextBlock* EscapePercentageTextBlock;
UPROPERTY(VisibleAnywhere) UPROPERTY(VisibleAnywhere)
UProgressBar* PlayerHealthBar; UProgressBar* PlayerHealthBar;

BIN
UI designs/Azos.png (Stored with Git LFS) Normal file

Binary file not shown.

BIN
UI designs/AzosFaded.png (Stored with Git LFS) Normal file

Binary file not shown.

BIN
UI designs/Eis.png (Stored with Git LFS) Normal file

Binary file not shown.

BIN
UI designs/EisFaded.png (Stored with Git LFS) Normal file

Binary file not shown.

BIN
UI designs/Escape.png (Stored with Git LFS) Normal file

Binary file not shown.

BIN
UI designs/EscapeFaded.png (Stored with Git LFS) Normal file

Binary file not shown.

BIN
UI designs/Iroquoiod.png (Stored with Git LFS) Normal file

Binary file not shown.

BIN
UI designs/IroquoiodFaded.png (Stored with Git LFS) Normal file

Binary file not shown.

BIN
UI designs/Probertium.png (Stored with Git LFS) Normal file

Binary file not shown.

BIN
UI designs/ProbertiumFaded.png (Stored with Git LFS) Normal file

Binary file not shown.