Updated Character to Convert Screen Space to World for Interaction
This commit is contained in:
parent
3e34ab4c5c
commit
18ceedfa03
BIN
Content/Blueprints/Combat_UI/BookCombat_UI.uasset
(Stored with Git LFS)
BIN
Content/Blueprints/Combat_UI/BookCombat_UI.uasset
(Stored with Git LFS)
Binary file not shown.
BIN
Content/Blueprints/Combat_UI/BookWorldWidget.uasset
(Stored with Git LFS)
BIN
Content/Blueprints/Combat_UI/BookWorldWidget.uasset
(Stored with Git LFS)
Binary file not shown.
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/CombatTutorial.uasset
(Stored with Git LFS)
BIN
Content/Blueprints/Combat_UI/CombatTutorial.uasset
(Stored with Git LFS)
Binary file not shown.
@ -28,6 +28,10 @@ ATempCharacter::ATempCharacter()
|
||||
void ATempCharacter::BeginPlay()
|
||||
{
|
||||
Super::BeginPlay();
|
||||
|
||||
FirstPlayerController = GetWorld()->GetFirstPlayerController();
|
||||
WidgetPointer = Cast<UWidgetInteractionComponent>(this->GetComponentByClass(UWidgetInteractionComponent::StaticClass()));
|
||||
|
||||
Health = 100;
|
||||
ThisCamera = Cast<UCameraComponent>(this->FindComponentByClass<UCameraComponent>());
|
||||
PlayerCapsule = GetCapsuleComponent();
|
||||
@ -93,6 +97,13 @@ void ATempCharacter::Sneak()
|
||||
void ATempCharacter::Tick(float 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
|
||||
|
@ -7,6 +7,8 @@
|
||||
#include "the_twilight_abyss/BaseItems/Items/BaseItem.h"
|
||||
#include "Camera/CameraComponent.h"
|
||||
#include "Engine/PostProcessVolume.h"
|
||||
#include "Components/WidgetInteractionComponent.h"
|
||||
#include "../TurnBasedCombatV2/TurnBaseCombatV2.h"
|
||||
#include "TempCharacter.generated.h"
|
||||
|
||||
UCLASS()
|
||||
@ -29,6 +31,12 @@ protected:
|
||||
void Sneak();
|
||||
|
||||
UCapsuleComponent* PlayerCapsule;
|
||||
UPROPERTY()
|
||||
APlayerController* FirstPlayerController;
|
||||
UPROPERTY()
|
||||
UWidgetInteractionComponent* WidgetPointer;
|
||||
UPROPERTY()
|
||||
ATurnBaseCombatV2* CombatSystem;
|
||||
|
||||
public:
|
||||
// Called every frame
|
||||
|
@ -36,6 +36,7 @@ ATurnBaseCombatV2::ATurnBaseCombatV2()
|
||||
void ATurnBaseCombatV2::StartCombat(AActor* Enemy)
|
||||
{
|
||||
if (Enemy == nullptr) return;
|
||||
bIsInCombat = true;
|
||||
UBlackboardComponent* EnemyBlackboard = Cast<AAIController>(Enemy->GetInstigatorController())->GetBlackboardComponent();
|
||||
if (!HasSeenTutorial)
|
||||
{
|
||||
@ -62,7 +63,7 @@ void ATurnBaseCombatV2::StartCombat(AActor* Enemy)
|
||||
}
|
||||
|
||||
if (HUD->IsInViewport()) return;
|
||||
HUD->AddToViewport();
|
||||
//HUD->AddToViewport();
|
||||
EnemyActor = Enemy;
|
||||
|
||||
ProbertiumResource = 10;
|
||||
@ -77,6 +78,7 @@ void ATurnBaseCombatV2::StartCombat(AActor* Enemy)
|
||||
}
|
||||
//Set to UI Mode Only
|
||||
APlayerController* PlayerController = GetWorld()->GetFirstPlayerController();
|
||||
|
||||
PlayerController->SetInputMode(FInputModeUIOnly());
|
||||
PlayerController->bShowMouseCursor = true;
|
||||
|
||||
@ -100,6 +102,7 @@ void ATurnBaseCombatV2::EndCombat()
|
||||
{
|
||||
bEnemyHasExtraTurn = false;
|
||||
bPlayerHasExtraTurn = false;
|
||||
bIsInCombat = false;
|
||||
for (UStatusEffect* StatusEffect : StatusEffects)
|
||||
{
|
||||
StatusEffect->OnExpiry(PlayerActor);
|
||||
@ -516,3 +519,4 @@ void ATurnBaseCombatV2::EnemyTurn()
|
||||
TurnIndicatorTextBlock->SetText(FText::FromString("Player Turn"));
|
||||
ToggleButtons();
|
||||
}
|
||||
|
||||
|
@ -26,6 +26,8 @@ public:
|
||||
|
||||
int* EnemyHealth = nullptr;
|
||||
float* PlayerHealth = nullptr;
|
||||
bool bIsInCombat = false;
|
||||
|
||||
UPROPERTY(EditDefaultsOnly)
|
||||
int DefaultActionPoints = 2;
|
||||
UPROPERTY(EditDefaultsOnly)
|
||||
|
Loading…
Reference in New Issue
Block a user