Merge branch 'dev' into merchant-system
This commit is contained in:
commit
ba2b6b599c
1
Config/DefaultEditor.ini
Normal file
1
Config/DefaultEditor.ini
Normal file
@ -0,0 +1 @@
|
||||
|
@ -17,7 +17,7 @@ ManualIPAddress=
|
||||
+ActiveGameNameRedirects=(OldGameName="TP_ThirdPerson",NewGameName="/Script/the_twilight_abyss")
|
||||
|
||||
[/Script/EngineSettings.GameMapsSettings]
|
||||
EditorStartupMap=/Game/Levels/Main.Main
|
||||
EditorStartupMap=/Game/Levels/Prototype.Prototype
|
||||
LocalMapOptions=
|
||||
TransitionMap=None
|
||||
bUseSplitscreen=True
|
||||
@ -26,7 +26,7 @@ ThreePlayerSplitscreenLayout=FavorTop
|
||||
FourPlayerSplitscreenLayout=Grid
|
||||
bOffsetPlayerGamepadIds=False
|
||||
GameInstanceClass=/Script/Engine.GameInstance
|
||||
GameDefaultMap=/Game/Levels/Main.Main
|
||||
GameDefaultMap=/Game/Levels/Prototype.Prototype
|
||||
ServerDefaultMap=/Engine/Maps/Entry.Entry
|
||||
GlobalDefaultGameMode=/Game/Merchant/BP_MerchantGameMode.BP_MerchantGameMode_C
|
||||
GlobalDefaultServerGameMode=None
|
||||
@ -88,3 +88,13 @@ GlobalDefaultServerGameMode=None
|
||||
+CollisionChannelRedirects=(OldName="VehicleMovement",NewName="Vehicle")
|
||||
+CollisionChannelRedirects=(OldName="PawnMovement",NewName="Pawn")
|
||||
|
||||
|
||||
[CoreRedirects]
|
||||
+PropertyRedirects=(OldName="/Script/the_twilight_abyss.TurnBaseCombat.isPlayerTurn",NewName="/Script/the_twilight_abyss.TurnBaseCombat.bIsPlayerTurn")
|
||||
+PropertyRedirects=(OldName="/Script/the_twilight_abyss.TurnBaseCombat.playerHealth",NewName="/Script/the_twilight_abyss.TurnBaseCombat.PlayerHealth")
|
||||
+PropertyRedirects=(OldName="/Script/the_twilight_abyss.TurnBaseCombat.enemyHealth",NewName="/Script/the_twilight_abyss.TurnBaseCombat.EnemyHealth")
|
||||
+PropertyRedirects=(OldName="/Script/the_twilight_abyss.TurnBaseCombat.defaultActionPoints",NewName="/Script/the_twilight_abyss.TurnBaseCombat.DefaultActionPoints")
|
||||
+PropertyRedirects=(OldName="/Script/the_twilight_abyss.TurnBaseCombat.TestButton",NewName="/Script/the_twilight_abyss.TurnBaseCombat.CastButton")
|
||||
+PropertyRedirects=(OldName="/Script/the_twilight_abyss.TurnBaseCombat.CurrentCombo",NewName="/Script/the_twilight_abyss.TurnBaseCombat.CurrentComboTextBlock")
|
||||
+PropertyRedirects=(OldName="/Script/the_twilight_abyss.TurnBaseCombat.TurnIndicator",NewName="/Script/the_twilight_abyss.TurnBaseCombat.TurnIndicatorTextBlock")
|
||||
|
||||
|
9
Config/DefaultGame.ini
Normal file
9
Config/DefaultGame.ini
Normal file
@ -0,0 +1,9 @@
|
||||
|
||||
|
||||
[/Script/EngineSettings.GeneralProjectSettings]
|
||||
ProjectID=F2B2881E401D78B424BDDF9BBE633AFD
|
||||
ProjectVersion=0.2.0
|
||||
CompanyName=Team 2:13
|
||||
ProjectDisplayedTitle=NSLOCTEXT("[/Script/EngineSettings]", "3415E4AF4ECD4236C9C61DA55D72AA2A", "The Twilight Abyss")
|
||||
ProjectName=The Twilight Abyss
|
||||
|
BIN
Content/Blueprints/Combat_UI/CombatCharacter.uasset
(Stored with Git LFS)
Normal file
BIN
Content/Blueprints/Combat_UI/CombatCharacter.uasset
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
Content/Blueprints/Combat_UI/Combat_Test.uasset
(Stored with Git LFS)
Normal file
BIN
Content/Blueprints/Combat_UI/Combat_Test.uasset
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
Content/Blueprints/Combat_UI/Combat_UI.uasset
(Stored with Git LFS)
Normal file
BIN
Content/Blueprints/Combat_UI/Combat_UI.uasset
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
Content/Blueprints/Combat_UI/Gun/Gun.uasset
(Stored with Git LFS)
Normal file
BIN
Content/Blueprints/Combat_UI/Gun/Gun.uasset
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
Content/Blueprints/Combat_UI/Gun/GunProto.uasset
(Stored with Git LFS)
Normal file
BIN
Content/Blueprints/Combat_UI/Gun/GunProto.uasset
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
Content/Blueprints/Combat_UI/Gun/image__1_.uasset
(Stored with Git LFS)
Normal file
BIN
Content/Blueprints/Combat_UI/Gun/image__1_.uasset
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
Content/Blueprints/Combat_UI/TestEnemy.uasset
(Stored with Git LFS)
Normal file
BIN
Content/Blueprints/Combat_UI/TestEnemy.uasset
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
Content/BungeeMan/CR_BungeeMan.uasset
(Stored with Git LFS)
Normal file
BIN
Content/BungeeMan/CR_BungeeMan.uasset
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
Content/BungeeMan/LS_BungeeManCycle.uasset
(Stored with Git LFS)
Normal file
BIN
Content/BungeeMan/LS_BungeeManCycle.uasset
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
Content/BungeeMan/LS_BungeeMan_Poses.uasset
(Stored with Git LFS)
Normal file
BIN
Content/BungeeMan/LS_BungeeMan_Poses.uasset
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
Content/BungeeMan/Main.umap
(Stored with Git LFS)
Normal file
BIN
Content/BungeeMan/Main.umap
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
Content/BungeeMan/Mat_BungeeMan_Body.uasset
(Stored with Git LFS)
Normal file
BIN
Content/BungeeMan/Mat_BungeeMan_Body.uasset
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
Content/BungeeMan/Mat_BungeeMan_Rubber.uasset
(Stored with Git LFS)
Normal file
BIN
Content/BungeeMan/Mat_BungeeMan_Rubber.uasset
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
Content/BungeeMan/SKM_BungeeMan.uasset
(Stored with Git LFS)
Normal file
BIN
Content/BungeeMan/SKM_BungeeMan.uasset
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
Content/BungeeMan/SK_BungeeMan.uasset
(Stored with Git LFS)
Normal file
BIN
Content/BungeeMan/SK_BungeeMan.uasset
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
Content/Environment/Material.uasset
(Stored with Git LFS)
Normal file
BIN
Content/Environment/Material.uasset
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
Content/Environment/Prototype_level_Cube.uasset
(Stored with Git LFS)
Normal file
BIN
Content/Environment/Prototype_level_Cube.uasset
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
Content/Environment/Prototype_level_Cube_001.uasset
(Stored with Git LFS)
Normal file
BIN
Content/Environment/Prototype_level_Cube_001.uasset
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
Content/Environment/Prototype_level_Cube_002.uasset
(Stored with Git LFS)
Normal file
BIN
Content/Environment/Prototype_level_Cube_002.uasset
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
Content/Environment/Prototype_level_Cube_003.uasset
(Stored with Git LFS)
Normal file
BIN
Content/Environment/Prototype_level_Cube_003.uasset
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
Content/Environment/Prototype_level_Cube_004.uasset
(Stored with Git LFS)
Normal file
BIN
Content/Environment/Prototype_level_Cube_004.uasset
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
Content/Environment/Prototype_level_Cube_005.uasset
(Stored with Git LFS)
Normal file
BIN
Content/Environment/Prototype_level_Cube_005.uasset
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
Content/Environment/Prototype_level_Cube_006.uasset
(Stored with Git LFS)
Normal file
BIN
Content/Environment/Prototype_level_Cube_006.uasset
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
Content/Environment/Prototype_level_Cube_007.uasset
(Stored with Git LFS)
Normal file
BIN
Content/Environment/Prototype_level_Cube_007.uasset
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
Content/Environment/Prototype_level_Cube_008.uasset
(Stored with Git LFS)
Normal file
BIN
Content/Environment/Prototype_level_Cube_008.uasset
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
Content/Environment/Prototype_level_Cube_009.uasset
(Stored with Git LFS)
Normal file
BIN
Content/Environment/Prototype_level_Cube_009.uasset
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
Content/Environment/Prototype_level_Cylinder_001.uasset
(Stored with Git LFS)
Normal file
BIN
Content/Environment/Prototype_level_Cylinder_001.uasset
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
Content/Environment/Prototype_level_Cylinder_002.uasset
(Stored with Git LFS)
Normal file
BIN
Content/Environment/Prototype_level_Cylinder_002.uasset
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
Content/Environment/Prototype_level_Cylinder_004.uasset
(Stored with Git LFS)
Normal file
BIN
Content/Environment/Prototype_level_Cylinder_004.uasset
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
Content/Environment/Prototype_level_Cylinder_005.uasset
(Stored with Git LFS)
Normal file
BIN
Content/Environment/Prototype_level_Cylinder_005.uasset
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
Content/Environment/Prototype_level_Cylinder_006.uasset
(Stored with Git LFS)
Normal file
BIN
Content/Environment/Prototype_level_Cylinder_006.uasset
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
Content/Environment/Prototype_level_Cylinder_007.uasset
(Stored with Git LFS)
Normal file
BIN
Content/Environment/Prototype_level_Cylinder_007.uasset
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
Content/Environment/Prototype_level_Cylinder_008.uasset
(Stored with Git LFS)
Normal file
BIN
Content/Environment/Prototype_level_Cylinder_008.uasset
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
Content/Environment/Prototype_level_Cylinder_009.uasset
(Stored with Git LFS)
Normal file
BIN
Content/Environment/Prototype_level_Cylinder_009.uasset
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
Content/Environment/Prototype_level_Cylinder_010.uasset
(Stored with Git LFS)
Normal file
BIN
Content/Environment/Prototype_level_Cylinder_010.uasset
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
Content/Environment/Prototype_level_Cylinder_011.uasset
(Stored with Git LFS)
Normal file
BIN
Content/Environment/Prototype_level_Cylinder_011.uasset
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
Content/Environment/Prototype_level_Cylinder_012.uasset
(Stored with Git LFS)
Normal file
BIN
Content/Environment/Prototype_level_Cylinder_012.uasset
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
Content/Environment/Prototype_level_Cylinder_013.uasset
(Stored with Git LFS)
Normal file
BIN
Content/Environment/Prototype_level_Cylinder_013.uasset
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
Content/Environment/Prototype_level_Cylinder_014.uasset
(Stored with Git LFS)
Normal file
BIN
Content/Environment/Prototype_level_Cylinder_014.uasset
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
Content/Environment/Prototype_level_Cylinder_015.uasset
(Stored with Git LFS)
Normal file
BIN
Content/Environment/Prototype_level_Cylinder_015.uasset
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
Content/Environment/Prototype_level_Cylinder_016.uasset
(Stored with Git LFS)
Normal file
BIN
Content/Environment/Prototype_level_Cylinder_016.uasset
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
Content/Environment/Prototype_level_Cylinder_017.uasset
(Stored with Git LFS)
Normal file
BIN
Content/Environment/Prototype_level_Cylinder_017.uasset
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
Content/Environment/Prototype_level_Plane.uasset
(Stored with Git LFS)
Normal file
BIN
Content/Environment/Prototype_level_Plane.uasset
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
Content/Environment/Prototype_level_Plane_001.uasset
(Stored with Git LFS)
Normal file
BIN
Content/Environment/Prototype_level_Plane_001.uasset
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
Content/Environment/Prototype_level_Plane_002.uasset
(Stored with Git LFS)
Normal file
BIN
Content/Environment/Prototype_level_Plane_002.uasset
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
Content/Environment/Prototype_level_Plane_003.uasset
(Stored with Git LFS)
Normal file
BIN
Content/Environment/Prototype_level_Plane_003.uasset
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
Content/Environment/Prototype_level_Plane_004.uasset
(Stored with Git LFS)
Normal file
BIN
Content/Environment/Prototype_level_Plane_004.uasset
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
Content/Environment/Prototype_level_Plane_005.uasset
(Stored with Git LFS)
Normal file
BIN
Content/Environment/Prototype_level_Plane_005.uasset
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
Content/Levels/CombatTest.umap
(Stored with Git LFS)
Normal file
BIN
Content/Levels/CombatTest.umap
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
Content/Levels/Prototype.umap
(Stored with Git LFS)
Normal file
BIN
Content/Levels/Prototype.umap
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
Content/Merchant/BP_MerchantGameMode.uasset
(Stored with Git LFS)
BIN
Content/Merchant/BP_MerchantGameMode.uasset
(Stored with Git LFS)
Binary file not shown.
@ -1,37 +0,0 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
|
||||
#include "TurnBaseCombat.h"
|
||||
#include "Kismet/GameplayStatics.h"
|
||||
|
||||
void ATurnBaseCombat::BeginPlay()
|
||||
{
|
||||
Super::BeginPlay();
|
||||
TArray<AActor*> AllCharacterActorsInScene;
|
||||
UGameplayStatics::GetAllActorsOfClassWithTag(GetWorld(), AActor::StaticClass(), FName("Character"), AllCharacterActorsInScene);
|
||||
activeActionPoints = defaultActionPoints;
|
||||
}
|
||||
|
||||
void ATurnBaseCombat::useActionPoint()
|
||||
{
|
||||
activeActionPoints -= 1;
|
||||
activeActionPoints = FMath::Clamp(activeActionPoints, 0, defaultActionPoints);
|
||||
}
|
||||
|
||||
void ATurnBaseCombat::reuseActionPoint()
|
||||
{
|
||||
activeActionPoints += 1;
|
||||
activeActionPoints = FMath::Clamp(activeActionPoints, 0, defaultActionPoints);
|
||||
}
|
||||
|
||||
void ATurnBaseCombat::revertActionPoints()
|
||||
{
|
||||
activeActionPoints = defaultActionPoints;
|
||||
}
|
||||
|
||||
void ATurnBaseCombat::switchTurn()
|
||||
{
|
||||
activeActor = (isPlayerTurn) ? enemyActor : playerActor;
|
||||
}
|
||||
|
||||
|
@ -1,50 +0,0 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "GameFramework/GameStateBase.h"
|
||||
#include "TurnBaseCombat.generated.h"
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
UCLASS()
|
||||
class THE_TWILIGHT_ABYSS_API ATurnBaseCombat : public AGameStateBase
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
ATurnBaseCombat() = default;
|
||||
|
||||
UPROPERTY(EditDefaultsOnly)
|
||||
int playerHealth = 100;
|
||||
UPROPERTY(EditDefaultsOnly)
|
||||
int enemyHealth = 100;
|
||||
UPROPERTY(EditDefaultsOnly)
|
||||
int defaultActionPoints = 3;
|
||||
int activeActionPoints = 0;
|
||||
|
||||
AActor* playerActor;
|
||||
AActor* enemyActor;
|
||||
AActor* activeActor;
|
||||
|
||||
/*
|
||||
TODO:
|
||||
Reference Blueprint HUD
|
||||
Reference Action Library
|
||||
Reference Player Inventory
|
||||
Reference Combat Logging System
|
||||
*/
|
||||
|
||||
protected:
|
||||
virtual void BeginPlay() override;
|
||||
void useActionPoint();
|
||||
void reuseActionPoint();
|
||||
void revertActionPoints();
|
||||
|
||||
private:
|
||||
UPROPERTY(EditDefaultsOnly)
|
||||
bool isPlayerTurn = true;
|
||||
void switchTurn();
|
||||
};
|
@ -0,0 +1,35 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
|
||||
#include "PlayerCharacterCombatTest.h"
|
||||
|
||||
// Sets default values
|
||||
APlayerCharacterCombatTest::APlayerCharacterCombatTest()
|
||||
{
|
||||
// Set this character to call Tick() every frame. You can turn this off to improve performance if you don't need it.
|
||||
PrimaryActorTick.bCanEverTick = true;
|
||||
|
||||
Tags.Add(FName("Character"));
|
||||
}
|
||||
|
||||
// Called when the game starts or when spawned
|
||||
void APlayerCharacterCombatTest::BeginPlay()
|
||||
{
|
||||
Super::BeginPlay();
|
||||
|
||||
}
|
||||
|
||||
// Called every frame
|
||||
void APlayerCharacterCombatTest::Tick(float DeltaTime)
|
||||
{
|
||||
Super::Tick(DeltaTime);
|
||||
|
||||
}
|
||||
|
||||
// Called to bind functionality to input
|
||||
void APlayerCharacterCombatTest::SetupPlayerInputComponent(UInputComponent* PlayerInputComponent)
|
||||
{
|
||||
Super::SetupPlayerInputComponent(PlayerInputComponent);
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,29 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "GameFramework/Character.h"
|
||||
#include "PlayerCharacterCombatTest.generated.h"
|
||||
|
||||
UCLASS()
|
||||
class THE_TWILIGHT_ABYSS_API APlayerCharacterCombatTest : public ACharacter
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
// Sets default values for this character's properties
|
||||
APlayerCharacterCombatTest();
|
||||
|
||||
protected:
|
||||
// Called when the game starts or when spawned
|
||||
virtual void BeginPlay() override;
|
||||
|
||||
public:
|
||||
// Called every frame
|
||||
virtual void Tick(float DeltaTime) override;
|
||||
|
||||
// Called to bind functionality to input
|
||||
virtual void SetupPlayerInputComponent(class UInputComponent* PlayerInputComponent) override;
|
||||
|
||||
};
|
297
Source/the_twilight_abyss/TurnBasedCombat/TurnBaseCombat.cpp
Normal file
297
Source/the_twilight_abyss/TurnBasedCombat/TurnBaseCombat.cpp
Normal file
@ -0,0 +1,297 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
|
||||
#include "TurnBaseCombat.h"
|
||||
#include "CoreMinimal.h"
|
||||
#include "Blueprint/UserWidget.h"
|
||||
#include "Components/TextBlock.h"
|
||||
#include "Components/ProgressBar.h"
|
||||
#include "Kismet/GameplayStatics.h"
|
||||
|
||||
ATurnBaseCombat::ATurnBaseCombat()
|
||||
{
|
||||
if (HUDWidget == nullptr)
|
||||
{
|
||||
// Load the HUD widget from the specified path
|
||||
static ConstructorHelpers::FClassFinder<UUserWidget> HUDWidgetClass(TEXT("/Game/Blueprints/Combat_UI/Combat_UI"));
|
||||
HUDWidget = HUDWidgetClass.Class;
|
||||
}
|
||||
}
|
||||
|
||||
void ATurnBaseCombat::StartCombat(AActor* Enemy)
|
||||
{
|
||||
if (HUD->IsInViewport()) return;
|
||||
HUD->AddToViewport();
|
||||
EnemyActor = Enemy;
|
||||
|
||||
if (APlayerController* PC = Cast<APlayerController>(GetWorld()->GetFirstPlayerController()))
|
||||
{
|
||||
PC->bShowMouseCursor = true;
|
||||
PC->bEnableClickEvents = true;
|
||||
PC->bEnableMouseOverEvents = true;
|
||||
}
|
||||
}
|
||||
|
||||
void ATurnBaseCombat::EndCombat()
|
||||
{
|
||||
//Remove the HUD from the viewport
|
||||
HUD->RemoveFromViewport();
|
||||
}
|
||||
|
||||
void ATurnBaseCombat::BeginPlay()
|
||||
{
|
||||
Super::BeginPlay();
|
||||
|
||||
TArray<AActor*> AllCharacterActorsInScene;
|
||||
UGameplayStatics::GetAllActorsOfClassWithTag(GetWorld(), AActor::StaticClass(), FName("Character"), AllCharacterActorsInScene);
|
||||
|
||||
HUD = CreateWidget<UUserWidget>(GetWorld(), HUDWidget);
|
||||
|
||||
TurnIndicatorTextBlock = Cast<UTextBlock>(HUD->GetWidgetFromName("TurnIndicator"));
|
||||
CurrentComboTextBlock = Cast<UTextBlock>(HUD->GetWidgetFromName("CurrentCombo"));
|
||||
ActionPointsTextBlock = Cast<UTextBlock>(HUD->GetWidgetFromName("ActionPoints"));
|
||||
BattleLogTextBlock = Cast<UTextBlock>(HUD->GetWidgetFromName("BattleLog"));
|
||||
PlayerHealthBar = Cast<UProgressBar>(HUD->GetWidgetFromName("PlayerHealthBar"));
|
||||
EnemyHealthBar = Cast<UProgressBar>(HUD->GetWidgetFromName("EnemyHealthBar"));
|
||||
IronResourceBar = Cast<UProgressBar>(HUD->GetWidgetFromName("IronResourceBar"));
|
||||
SulfurResourceBar = Cast<UProgressBar>(HUD->GetWidgetFromName("SulfurResourceBar"));
|
||||
CastButton = Cast<UButton>(HUD->GetWidgetFromName("CastButton"));
|
||||
FButton = Cast<UButton>(HUD->GetWidgetFromName("FButton"));
|
||||
WButton = Cast<UButton>(HUD->GetWidgetFromName("WButton"));
|
||||
BackspaceButton = Cast<UButton>(HUD->GetWidgetFromName("BackspaceButton"));
|
||||
CastButton->OnClicked.AddDynamic(this, &ATurnBaseCombat::CastButtonOnClick);
|
||||
FButton->OnClicked.AddDynamic(this, &ATurnBaseCombat::FButtonOnClick);
|
||||
WButton->OnClicked.AddDynamic(this, &ATurnBaseCombat::WButtonOnClick);
|
||||
BackspaceButton->OnClicked.AddDynamic(this, &ATurnBaseCombat::BackspaceButtonOnClick);
|
||||
}
|
||||
|
||||
void ATurnBaseCombat::ExecuteCast(FString Combo)
|
||||
{
|
||||
if (!IsValidCombo(Combo))
|
||||
{
|
||||
GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, TEXT("Invalid Combo"));
|
||||
//For each character in the current combo add back the resource
|
||||
for (int i = 0; i < Combo.Len(); i++)
|
||||
{
|
||||
if (Combo[i] == 'F')
|
||||
{
|
||||
IronResource += 1;
|
||||
}
|
||||
else if (Combo[i] == 'W')
|
||||
{
|
||||
SulfurResource += 1;
|
||||
}
|
||||
}
|
||||
CurrentComboString = "";
|
||||
UpdateComboString(CurrentComboString);
|
||||
RevertActionPoints();
|
||||
UpdateActionPoints();
|
||||
UpdateResourceBars();
|
||||
return;
|
||||
}
|
||||
|
||||
CurrentComboString = "";
|
||||
UpdateComboString(CurrentComboString);
|
||||
RevertActionPoints();
|
||||
UpdateActionPoints();
|
||||
|
||||
switch (bIsPlayerTurn)
|
||||
{
|
||||
case true:
|
||||
// Player Turn
|
||||
DamageEnemy(*ValidCombos.Find(Combo));
|
||||
GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Green, FString::Printf(TEXT("Enemy Damaged %d"), *ValidCombos.Find(Combo)));
|
||||
break;
|
||||
case false:
|
||||
// Enemy Turn
|
||||
DamagePlayer(*ValidCombos.Find(Combo));
|
||||
GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Green, FString::Printf(TEXT("Player Damaged %d"), *ValidCombos.Find(Combo)));
|
||||
break;
|
||||
}
|
||||
//End Combat if either the player or enemy is dead
|
||||
if (EnemyHealth <= 0)
|
||||
{
|
||||
EndCombat();
|
||||
EnemyActor->Destroy();
|
||||
return;
|
||||
}
|
||||
if (PlayerHealth <= 0)
|
||||
{
|
||||
EndCombat();
|
||||
return;
|
||||
}
|
||||
|
||||
SwitchTurn();
|
||||
}
|
||||
|
||||
void ATurnBaseCombat::UseActionPoint()
|
||||
{
|
||||
ActiveActionPoints += 1;
|
||||
UpdateActionPoints();
|
||||
}
|
||||
|
||||
void ATurnBaseCombat::ReuseActionPoint()
|
||||
{
|
||||
ActiveActionPoints -= 1;
|
||||
UpdateActionPoints();
|
||||
}
|
||||
|
||||
void ATurnBaseCombat::RevertActionPoints()
|
||||
{
|
||||
ActiveActionPoints = 0;
|
||||
UpdateActionPoints();
|
||||
}
|
||||
|
||||
void ATurnBaseCombat::DamagePlayer(int Damage)
|
||||
{
|
||||
PlayerHealth -= FMath::Clamp(Damage, 0, 100);
|
||||
UpdateProgressBars();
|
||||
AddBattleLogMessage("Player was damaged for " + FString::FromInt(Damage) + " damage.");
|
||||
}
|
||||
|
||||
void ATurnBaseCombat::DamageEnemy(int Damage)
|
||||
{
|
||||
EnemyHealth -= FMath::Clamp(Damage, 0, 100);
|
||||
UpdateProgressBars();
|
||||
AddBattleLogMessage("Enemy was damaged for " + FString::FromInt(Damage) + " damage.");
|
||||
}
|
||||
|
||||
void ATurnBaseCombat::UpdateProgressBars() const
|
||||
{
|
||||
PlayerHealthBar->SetPercent(PlayerHealth / 100.0f);
|
||||
EnemyHealthBar->SetPercent(EnemyHealth / 100.0f);
|
||||
}
|
||||
|
||||
bool ATurnBaseCombat::IsValidCombo(FString Combo) const
|
||||
{
|
||||
return ValidCombos.Contains(Combo);
|
||||
}
|
||||
|
||||
void ATurnBaseCombat::SwitchTurn()
|
||||
{
|
||||
//TurnIndicatorTextBlock->SetText(FText::FromString(bIsPlayerTurn ? "Enemy Turn" : "Player Turn"));
|
||||
//bIsPlayerTurn = !bIsPlayerTurn;
|
||||
TurnIndicatorTextBlock->SetText(FText::FromString("Enemy Turn"));
|
||||
ToggleButtons();
|
||||
//wait for 2 seconds
|
||||
FTimerHandle UnusedHandle;
|
||||
GetWorldTimerManager().SetTimer(UnusedHandle, this, &ATurnBaseCombat::EnemyTurn, 2.0f, false);
|
||||
|
||||
//activeActor = bIsPlayerTurn ? enemyActor : playerActor;
|
||||
}
|
||||
|
||||
void ATurnBaseCombat::CastButtonOnClick()
|
||||
{
|
||||
ExecuteCast(CurrentComboString);
|
||||
}
|
||||
|
||||
void ATurnBaseCombat::FButtonOnClick()
|
||||
{
|
||||
if (ActiveActionPoints >= DefaultActionPoints)
|
||||
{
|
||||
GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, TEXT("No More Action Points"));
|
||||
return;
|
||||
}
|
||||
if (IronResource <= 0)
|
||||
{
|
||||
GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, TEXT("No More Iron"));
|
||||
return;
|
||||
}
|
||||
UseActionPoint();
|
||||
CurrentComboString.AppendChar('F');
|
||||
UpdateComboString(CurrentComboString);
|
||||
IronResource -= 1;
|
||||
UpdateResourceBars();
|
||||
}
|
||||
|
||||
void ATurnBaseCombat::WButtonOnClick()
|
||||
{
|
||||
if (ActiveActionPoints >= DefaultActionPoints)
|
||||
{
|
||||
GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, TEXT("No More Action Points"));
|
||||
return;
|
||||
}
|
||||
if (SulfurResource <= 0)
|
||||
{
|
||||
GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, TEXT("No More Sulfur"));
|
||||
return;
|
||||
}
|
||||
UseActionPoint();
|
||||
CurrentComboString.AppendChar('W');
|
||||
UpdateComboString(CurrentComboString);
|
||||
SulfurResource -= 1;
|
||||
UpdateResourceBars();
|
||||
}
|
||||
|
||||
void ATurnBaseCombat::BackspaceButtonOnClick()
|
||||
{
|
||||
if (CurrentComboString.Len() <= 0)
|
||||
{
|
||||
GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, TEXT("Blank Combo"));
|
||||
return;
|
||||
}
|
||||
ReuseActionPoint();
|
||||
if (CurrentComboString.Right(1) == "F")
|
||||
{
|
||||
IronResource += 1;
|
||||
}
|
||||
else if (CurrentComboString.Right(1) == "W")
|
||||
{
|
||||
SulfurResource += 1;
|
||||
}
|
||||
CurrentComboString.RemoveAt(CurrentComboString.Len() - 1);
|
||||
UpdateComboString(CurrentComboString);
|
||||
UpdateResourceBars();
|
||||
}
|
||||
|
||||
void ATurnBaseCombat::UpdateComboString(FString NewCombo) const
|
||||
{
|
||||
CurrentComboTextBlock->SetText(FText::FromString(NewCombo));
|
||||
}
|
||||
|
||||
void ATurnBaseCombat::UpdateActionPoints() const
|
||||
{
|
||||
ActionPointsTextBlock->SetText(FText::FromString(FString::FromInt(ActiveActionPoints)));
|
||||
}
|
||||
|
||||
void ATurnBaseCombat::AddBattleLogMessage(FString Message)
|
||||
{
|
||||
BattleLog.Append(Message + "\n");
|
||||
UpdateBattleLog();
|
||||
}
|
||||
|
||||
void ATurnBaseCombat::ClearBattleLog()
|
||||
{
|
||||
BattleLog = "";
|
||||
}
|
||||
|
||||
void ATurnBaseCombat::UpdateBattleLog()
|
||||
{
|
||||
TArray<FString> TempArray;
|
||||
if (const int32 LineCount = BattleLog.ParseIntoArray(TempArray, TEXT("\n"), true); LineCount > 10)
|
||||
{
|
||||
ClearBattleLog();
|
||||
}
|
||||
BattleLogTextBlock->SetText(FText::FromString(BattleLog));
|
||||
}
|
||||
|
||||
void ATurnBaseCombat::UpdateResourceBars() const
|
||||
{
|
||||
IronResourceBar->SetPercent(IronResource / 10.0f);
|
||||
SulfurResourceBar->SetPercent(SulfurResource / 10.0f);
|
||||
}
|
||||
|
||||
void ATurnBaseCombat::ToggleButtons() const
|
||||
{
|
||||
FButton->SetIsEnabled(!FButton->bIsEnabled);
|
||||
WButton->SetIsEnabled(!WButton->bIsEnabled);
|
||||
BackspaceButton->SetIsEnabled(!BackspaceButton->bIsEnabled);
|
||||
CastButton->SetIsEnabled(!CastButton->bIsEnabled);
|
||||
}
|
||||
|
||||
void ATurnBaseCombat::EnemyTurn()
|
||||
{
|
||||
DamagePlayer(10);
|
||||
TurnIndicatorTextBlock->SetText(FText::FromString("Player Turn"));
|
||||
ToggleButtons();
|
||||
}
|
143
Source/the_twilight_abyss/TurnBasedCombat/TurnBaseCombat.h
Normal file
143
Source/the_twilight_abyss/TurnBasedCombat/TurnBaseCombat.h
Normal file
@ -0,0 +1,143 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "Components/Button.h"
|
||||
#include "Components/ProgressBar.h"
|
||||
#include "Components/TextBlock.h"
|
||||
#include "GameFramework/GameStateBase.h"
|
||||
#include "TurnBaseCombat.generated.h"
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
UCLASS()
|
||||
class THE_TWILIGHT_ABYSS_API ATurnBaseCombat : public AGameStateBase
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
ATurnBaseCombat();
|
||||
|
||||
UPROPERTY(EditDefaultsOnly)
|
||||
int PlayerHealth = 100;
|
||||
UPROPERTY(EditDefaultsOnly)
|
||||
int EnemyHealth = 100;
|
||||
UPROPERTY(EditDefaultsOnly)
|
||||
int DefaultActionPoints = 3;
|
||||
UPROPERTY(EditDefaultsOnly)
|
||||
int ActiveActionPoints = 0;
|
||||
UPROPERTY(EditDefaultsOnly)
|
||||
int IronResource = 10; // F
|
||||
UPROPERTY(EditDefaultsOnly)
|
||||
int SulfurResource = 10; // W
|
||||
|
||||
// AActor* PlayerActor;
|
||||
UPROPERTY(VisibleAnywhere)
|
||||
AActor* EnemyActor;
|
||||
// AActor* ActiveActor;
|
||||
|
||||
/*
|
||||
TODO:
|
||||
Reference Player Inventory
|
||||
*/
|
||||
UPROPERTY(EditAnywhere)
|
||||
TSubclassOf<UUserWidget> HUDWidget;
|
||||
UPROPERTY(EditAnywhere)
|
||||
TMap<FString, int32> ValidCombos =
|
||||
{
|
||||
{"F", 10},
|
||||
{"W", 10},
|
||||
{"WW", 15},
|
||||
{"FW", 20},
|
||||
{"FFW", 30}
|
||||
};
|
||||
|
||||
FString BattleLog;
|
||||
|
||||
UFUNCTION(BlueprintCallable)
|
||||
void StartCombat(AActor* Enemy);
|
||||
UFUNCTION(BlueprintCallable)
|
||||
void EndCombat();
|
||||
|
||||
protected:
|
||||
virtual void BeginPlay() override;
|
||||
void ExecuteCast(FString Combo);
|
||||
void UseActionPoint();
|
||||
void ReuseActionPoint();
|
||||
void RevertActionPoints();
|
||||
void DamagePlayer(int Damage);
|
||||
void DamageEnemy(int Damage);
|
||||
void UpdateProgressBars() const;
|
||||
|
||||
private:
|
||||
bool IsValidCombo(FString Combo) const;
|
||||
UUserWidget* HUD;
|
||||
|
||||
UPROPERTY(VisibleAnywhere)
|
||||
bool bIsPlayerTurn = true;
|
||||
|
||||
UPROPERTY(VisibleAnywhere)
|
||||
FString CurrentComboString = "";
|
||||
|
||||
void SwitchTurn();
|
||||
|
||||
UPROPERTY(VisibleAnywhere)
|
||||
UTextBlock* TurnIndicatorTextBlock;
|
||||
|
||||
UPROPERTY(VisibleAnywhere)
|
||||
UTextBlock* CurrentComboTextBlock;
|
||||
|
||||
UPROPERTY(VisibleAnywhere)
|
||||
UTextBlock* BattleLogTextBlock;
|
||||
|
||||
UPROPERTY(VisibleAnywhere)
|
||||
UTextBlock* ActionPointsTextBlock;
|
||||
|
||||
UPROPERTY(VisibleAnywhere)
|
||||
UProgressBar* PlayerHealthBar;
|
||||
|
||||
UPROPERTY(VisibleAnywhere)
|
||||
UProgressBar* EnemyHealthBar;
|
||||
|
||||
UPROPERTY(VisibleAnywhere)
|
||||
UProgressBar* IronResourceBar;
|
||||
|
||||
UPROPERTY(VisibleAnywhere)
|
||||
UProgressBar* SulfurResourceBar;
|
||||
|
||||
UPROPERTY(VisibleAnywhere)
|
||||
UButton* CastButton;
|
||||
|
||||
UPROPERTY(VisibleAnywhere)
|
||||
UButton* FButton;
|
||||
|
||||
UPROPERTY(VisibleAnywhere)
|
||||
UButton* WButton;
|
||||
|
||||
UPROPERTY(VisibleAnywhere)
|
||||
UButton* BackspaceButton;
|
||||
|
||||
UFUNCTION()
|
||||
void CastButtonOnClick();
|
||||
|
||||
UFUNCTION()
|
||||
void FButtonOnClick();
|
||||
|
||||
UFUNCTION()
|
||||
void WButtonOnClick();
|
||||
|
||||
UFUNCTION()
|
||||
void BackspaceButtonOnClick();
|
||||
|
||||
void UpdateComboString(FString NewCombo) const;
|
||||
void UpdateActionPoints() const;
|
||||
|
||||
void AddBattleLogMessage(FString Message);
|
||||
void ClearBattleLog();
|
||||
void UpdateBattleLog();
|
||||
void UpdateResourceBars() const;
|
||||
void ToggleButtons() const;
|
||||
void EnemyTurn();
|
||||
};
|
Loading…
x
Reference in New Issue
Block a user