From 5907d5dbe8d08bc61bdfe9f1a2b3db52efa3f398 Mon Sep 17 00:00:00 2001 From: PHILIP White Date: Wed, 9 Nov 2022 21:03:47 +0000 Subject: [PATCH] Updated TurnBaseCombat for Switching Active Roles Added Switching Active Roles and Constrained Active Action Points --- Source/the_twilight_abyss/TurnBaseCombat.cpp | 12 ++++++++++++ Source/the_twilight_abyss/TurnBaseCombat.h | 6 +++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/Source/the_twilight_abyss/TurnBaseCombat.cpp b/Source/the_twilight_abyss/TurnBaseCombat.cpp index 11409af..c28f852 100644 --- a/Source/the_twilight_abyss/TurnBaseCombat.cpp +++ b/Source/the_twilight_abyss/TurnBaseCombat.cpp @@ -14,6 +14,13 @@ void ATurnBaseCombat::BeginPlay() 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() @@ -21,4 +28,9 @@ void ATurnBaseCombat::revertActionPoints() activeActionPoints = defaultActionPoints; } +void ATurnBaseCombat::switchTurn() +{ + activeActor = (isPlayerTurn) ? enemyActor : playerActor; +} + diff --git a/Source/the_twilight_abyss/TurnBaseCombat.h b/Source/the_twilight_abyss/TurnBaseCombat.h index 3416810..68a6284 100644 --- a/Source/the_twilight_abyss/TurnBaseCombat.h +++ b/Source/the_twilight_abyss/TurnBaseCombat.h @@ -27,20 +27,24 @@ public: AActor* playerActor; AActor* enemyActor; + AActor* activeActor; /* TODO: Reference Blueprint HUD Reference Action Library - Reference Player Inventory + 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(); };