Added Win and Lose State Screens

This commit is contained in:
Philip W 2023-03-23 03:14:18 +00:00
parent 3a1a2a106d
commit c752b2fa36
7 changed files with 21 additions and 18 deletions

Binary file not shown.

Binary file not shown.

BIN
COMP250_1_2101327_AI/Content/Main.umap (Stored with Git LFS)

Binary file not shown.

View File

@ -7,6 +7,5 @@ void UDefaultAttack::Init()
{ {
ActionCost = 5.0f; ActionCost = 5.0f;
ActionName = "Punch"; ActionName = "Punch";
PreConditions.Add("PlayerHealth", 1);
Effects.Add("PlayerHealth", 1); Effects.Add("PlayerHealth", 1);
} }

View File

@ -28,6 +28,10 @@ ATurnBaseCombatV2::ATurnBaseCombatV2()
static ConstructorHelpers::FClassFinder<UStatusEffect> StatusEffectDotClassFinder(TEXT("/Game/Blueprints/StatusEffects/BP_DamageOverTime")); static ConstructorHelpers::FClassFinder<UStatusEffect> StatusEffectDotClassFinder(TEXT("/Game/Blueprints/StatusEffects/BP_DamageOverTime"));
DOTStatusEffect = StatusEffectDotClassFinder.Class; DOTStatusEffect = StatusEffectDotClassFinder.Class;
static ConstructorHelpers::FClassFinder<UUserWidget> WinClassFinder(TEXT("/Game/Blueprints/WinLoseStates/Win"));
WinWidget = WinClassFinder.Class;
static ConstructorHelpers::FClassFinder<UUserWidget> LoseClassFinder(TEXT("/Game/Blueprints/WinLoseStates/Lose"));
LoseWidget = LoseClassFinder.Class;
//static ConstructorHelpers::FClassFinder<UUserWidget> DeathScreenWidgetClass(TEXT("/Game/Blueprints/Death_UI/Death_UI")); //static ConstructorHelpers::FClassFinder<UUserWidget> DeathScreenWidgetClass(TEXT("/Game/Blueprints/Death_UI/Death_UI"));
//DeathScreenWidgetSubclass = DeathScreenWidgetClass.Class; //DeathScreenWidgetSubclass = DeathScreenWidgetClass.Class;
} }
@ -86,18 +90,6 @@ void ATurnBaseCombatV2::EndCombat()
} }
HUD->RemoveFromParent(); HUD->RemoveFromParent();
APawn* PlayerPawn = Cast<APawn>(GetWorld()->GetFirstPlayerController()->GetPawn());
PlayerPawn->bUseControllerRotationYaw = true;
PlayerPawn->bUseControllerRotationPitch = true;
//Enable Character Movement
if (ACharacter* PlayerCharacter = Cast<ACharacter>(GetWorld()->GetFirstPlayerController()->GetPawn()))
{
PlayerCharacter->EnableInput(GetWorld()->GetFirstPlayerController());
}
//Set to Game Mode Only
APlayerController* PlayerController = GetWorld()->GetFirstPlayerController();
PlayerController->SetInputMode(FInputModeGameOnly());
PlayerController->bShowMouseCursor = false;
} }
void ATurnBaseCombatV2::BeginPlay() void ATurnBaseCombatV2::BeginPlay()
@ -231,12 +223,13 @@ void ATurnBaseCombatV2::ExecuteCast(FString Combo)
{ {
EndCombat(); EndCombat();
EnemyActor->Destroy(); EnemyActor->Destroy();
CreateWidget<UUserWidget>(GetWorld(), WinWidget)->AddToViewport();
return; return;
} }
if (*PlayerHealth <= 0) if (*PlayerHealth <= 0)
{ {
DeathScreenWidget = CreateWidget<UUserWidget>(GetWorld(), DeathScreenWidgetSubclass); EndCombat();
DeathScreenWidget->AddToViewport(); CreateWidget<UUserWidget>(GetWorld(), LoseWidget)->AddToViewport();
return; return;
} }

View File

@ -247,4 +247,9 @@ private:
void ClearActionPlanWidget(); void ClearActionPlanWidget();
UFUNCTION() UFUNCTION()
void StealButtonOnClick(); void StealButtonOnClick();
UPROPERTY()
TSubclassOf<UUserWidget> WinWidget;
UPROPERTY()
TSubclassOf<UUserWidget> LoseWidget;
}; };