Updated Combat System to Include Healing During Combat
This commit is contained in:
parent
cef7b1895b
commit
487c46d7b8
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/CombatCharacter.uasset
(Stored with Git LFS)
BIN
Content/Blueprints/Combat_UI/CombatCharacter.uasset
(Stored with Git LFS)
Binary file not shown.
BIN
Content/Blueprints/Items/BP_Azos.uasset
(Stored with Git LFS)
BIN
Content/Blueprints/Items/BP_Azos.uasset
(Stored with Git LFS)
Binary file not shown.
BIN
Content/Blueprints/Items/BP_Eis.uasset
(Stored with Git LFS)
BIN
Content/Blueprints/Items/BP_Eis.uasset
(Stored with Git LFS)
Binary file not shown.
BIN
Content/Blueprints/Items/BP_Iroquoid.uasset
(Stored with Git LFS)
BIN
Content/Blueprints/Items/BP_Iroquoid.uasset
(Stored with Git LFS)
Binary file not shown.
BIN
Content/Blueprints/Items/BP_Probertium.uasset
(Stored with Git LFS)
BIN
Content/Blueprints/Items/BP_Probertium.uasset
(Stored with Git LFS)
Binary file not shown.
@ -3,7 +3,6 @@
|
||||
|
||||
#include "InventoryComponent.h"
|
||||
#include "Items/BaseItem.h"
|
||||
#include "the_twilight_abyss/PlayerTemp/TempCharacter.h"
|
||||
|
||||
|
||||
// Sets default values for this component's properties
|
||||
@ -23,12 +22,12 @@ void UInventoryComponent::BeginPlay()
|
||||
Super::BeginPlay();
|
||||
|
||||
//activates the AddItem function for every DefaultItem that inherits BaseItem
|
||||
for(auto & BaseItem : DefaultItems)
|
||||
for (auto& BaseItem : DefaultItems)
|
||||
{
|
||||
AddItem(BaseItem);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
bool UInventoryComponent::AddItem(class UBaseItem* BaseItem)
|
||||
{
|
||||
//if the items is over the maxinventoryslots then it wont add the item
|
||||
@ -40,7 +39,7 @@ bool UInventoryComponent::AddItem(class UBaseItem* BaseItem)
|
||||
BaseItem->StoredItems = this;
|
||||
BaseItem->World = GetWorld();
|
||||
bool isNewItem = true;
|
||||
for (auto & Item : Items)
|
||||
for (auto& Item : Items)
|
||||
{
|
||||
//if the item is the same as the item that is being added
|
||||
if (Item->ItemDisplayName.ToString() == BaseItem->ItemDisplayName.ToString())
|
||||
@ -58,13 +57,13 @@ bool UInventoryComponent::AddItem(class UBaseItem* BaseItem)
|
||||
}
|
||||
//Refreshes the inventory
|
||||
OnInventoryUpdated.Broadcast();
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
|
||||
// remove only gets called once on the same item
|
||||
bool UInventoryComponent::Remove(class UBaseItem* BaseItem)
|
||||
{
|
||||
if(BaseItem)
|
||||
if (BaseItem)
|
||||
{
|
||||
UE_LOG(LogTemp, Display, TEXT("ItEM HAS BEEN REMOVED"));
|
||||
BaseItem->StoredItems = nullptr;
|
||||
@ -91,3 +90,46 @@ void UInventoryComponent::RemoveItem(UEatableItems* Item)
|
||||
OnInventoryUpdated.Broadcast();
|
||||
}
|
||||
|
||||
int UInventoryComponent::GetItemAmount(const int& ItemID)
|
||||
{
|
||||
if (Items.Num() > 0)
|
||||
{
|
||||
for (UBaseItem* const& Item : Items)
|
||||
{
|
||||
if (Item->ItemID == ItemID)
|
||||
{
|
||||
return Item->StackCount;
|
||||
}
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
void UInventoryComponent::RemoveItemID(const int& ItemID)
|
||||
{
|
||||
if (Items.Num() > 0)
|
||||
{
|
||||
for (UBaseItem* const& Item : Items)
|
||||
{
|
||||
if (Item->ItemID == ItemID)
|
||||
{
|
||||
RemoveItem(Cast<UEatableItems>(Item));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
UBaseItem* UInventoryComponent::GetItemByID(const int& ItemID)
|
||||
{
|
||||
if (Items.Num() > 0)
|
||||
{
|
||||
for (UBaseItem* const& Item : Items)
|
||||
{
|
||||
if (Item->ItemID == ItemID)
|
||||
{
|
||||
return Item;
|
||||
}
|
||||
}
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -45,4 +45,13 @@ public:
|
||||
|
||||
UFUNCTION()
|
||||
void RemoveItem(UEatableItems* Item);
|
||||
|
||||
UFUNCTION()
|
||||
int GetItemAmount(const int& ItemID);
|
||||
|
||||
UFUNCTION()
|
||||
void RemoveItemID(const int& ItemID);
|
||||
|
||||
UFUNCTION()
|
||||
UBaseItem* GetItemByID(const int& ItemID);
|
||||
};
|
||||
|
@ -22,8 +22,9 @@ void UEatableItems::Use(ATempCharacter* Character)
|
||||
{
|
||||
if (Character->Health < 100)
|
||||
{
|
||||
UStatusSystem* StatusSystem = Character->FindComponentByClass<UStatusSystem>();
|
||||
StatusSystem->AddStatusEffect(NewObject<UStatusEffect>(Character, HealOverTimeStatusEffect));
|
||||
// UStatusSystem* StatusSystem = Character->FindComponentByClass<UStatusSystem>();
|
||||
// StatusSystem->AddStatusEffect(NewObject<UStatusEffect>(Character, HealOverTimeStatusEffect));
|
||||
Character->Health += 20;
|
||||
Character->Inventory->RemoveItem(this);
|
||||
}
|
||||
else if (Character->Health >= 100)
|
||||
|
@ -25,6 +25,6 @@ protected:
|
||||
TSubclassOf<UStatusEffect> HealOverTimeStatusEffect;
|
||||
|
||||
private:
|
||||
|
||||
UPROPERTY()
|
||||
ATurnBaseCombatV2* TurnBaseCombat;
|
||||
};
|
||||
|
@ -48,7 +48,8 @@ void ATurnBaseCombatV2::StartCombat(AActor* Enemy, const bool bWasShot)
|
||||
bIsInCombat = true;
|
||||
UBlackboardComponent* EnemyBlackboard = Cast<AAIController>(Enemy->GetInstigatorController())->GetBlackboardComponent();
|
||||
Cast<UQuestSystem>(PlayerActor->GetComponentByClass(UQuestSystem::StaticClass()))->QuestWidgetInstance->SetVisibility(ESlateVisibility::Hidden);
|
||||
|
||||
HealingJellyAmountTextBlock->SetText(FText::FromString(FString::FromInt(FMath::Clamp(Cast<ATempCharacter>(PlayerActor)->Inventory->GetItemAmount(0), 0, 99))));
|
||||
|
||||
//Disable Character Movement
|
||||
APlayerController* PlayerController = GetWorld()->GetFirstPlayerController();
|
||||
PlayerController->SetIgnoreMoveInput(true);
|
||||
@ -237,6 +238,7 @@ void ATurnBaseCombatV2::BeginPlay()
|
||||
BattleLogTextBlock = Cast<UTextBlock>(HUD->GetWidgetFromName("BattleLog"));
|
||||
EscapePercentageTextBlock = Cast<UTextBlock>(BookHUD->GetWidgetFromName("EscapePercentage_Text"));
|
||||
DamageMultiplierTextBlock = Cast<UTextBlock>(BookHUD->GetWidgetFromName("DamageMultiplier_Text"));
|
||||
HealingJellyAmountTextBlock = Cast<UTextBlock>(BookHUD->GetWidgetFromName("HealingAmount_Text"));
|
||||
PlayerHealthBar = Cast<UProgressBar>(BookHUD->GetWidgetFromName("PlayerHealthBar"));
|
||||
EnemyHealthBar = Cast<UProgressBar>(HUD->GetWidgetFromName("EnemyHealthBar"));
|
||||
ProbertiumResourceBar = Cast<UProgressBar>(BookHUD->GetWidgetFromName("ProbertiumResourceBar"));
|
||||
@ -250,6 +252,7 @@ void ATurnBaseCombatV2::BeginPlay()
|
||||
IButton = Cast<UButton>(BookHUD->GetWidgetFromName("Iroquoid_Button"));
|
||||
BackspaceButton = Cast<UButton>(BookHUD->GetWidgetFromName("Clear_Button"));
|
||||
RunButton = Cast<UButton>(BookHUD->GetWidgetFromName("Escape_Button"));
|
||||
HealButton = Cast<UButton>(BookHUD->GetWidgetFromName("Heal_Button"));
|
||||
CastButton->OnClicked.AddDynamic(this, &ATurnBaseCombatV2::CastButtonOnClick);
|
||||
PButton->OnClicked.AddDynamic(this, &ATurnBaseCombatV2::PButtonOnClick);
|
||||
EButton->OnClicked.AddDynamic(this, &ATurnBaseCombatV2::EButtonOnClick);
|
||||
@ -257,6 +260,7 @@ void ATurnBaseCombatV2::BeginPlay()
|
||||
IButton->OnClicked.AddDynamic(this, &ATurnBaseCombatV2::IButtonOnClick);
|
||||
BackspaceButton->OnClicked.AddDynamic(this, &ATurnBaseCombatV2::BackspaceButtonOnClick);
|
||||
RunButton->OnClicked.AddDynamic(this, &ATurnBaseCombatV2::RunButtonOnClick);
|
||||
HealButton->OnClicked.AddDynamic(this, &ATurnBaseCombatV2::HealButtonOnClick);
|
||||
}
|
||||
|
||||
void ATurnBaseCombatV2::ExecuteCast(FString Combo)
|
||||
@ -607,6 +611,7 @@ void ATurnBaseCombatV2::RunButtonOnClick()
|
||||
{
|
||||
if (FMath::RandRange(0.0f, 1.0f) >= EscapePercentage)
|
||||
{
|
||||
GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, TEXT("Escape Failed"));
|
||||
EscapePercentage = CalculateEscapePercentage();
|
||||
EscapePercentageTextBlock->SetText(FText::Join(FText::FromString(""), FText::FromString(FString::FromInt(EscapePercentage * 100)), FText::FromString("%")));
|
||||
SwitchTurn();
|
||||
@ -620,6 +625,17 @@ void ATurnBaseCombatV2::RunButtonOnClick()
|
||||
EndCombat();
|
||||
}
|
||||
|
||||
void ATurnBaseCombatV2::HealButtonOnClick()
|
||||
{
|
||||
if (Cast<ATempCharacter>(PlayerActor)->Inventory->GetItemAmount(0) >= 1)
|
||||
{
|
||||
Cast<ATempCharacter>(PlayerActor)->Inventory->GetItemByID(0)->Use(Cast<ATempCharacter>(PlayerActor));
|
||||
HealingJellyAmountTextBlock->SetText(FText::FromString(FString::FromInt(FMath::Clamp(Cast<ATempCharacter>(PlayerActor)->Inventory->GetItemAmount(0), 0, 99))));
|
||||
UpdateResourceBars();
|
||||
SwitchTurn();
|
||||
}
|
||||
}
|
||||
|
||||
void ATurnBaseCombatV2::UpdateComboString(const FString& NewCombo) const
|
||||
{
|
||||
CurrentComboTextBlock->SetText(FText::FromString("?"));
|
||||
@ -693,6 +709,7 @@ void ATurnBaseCombatV2::DisableButtons() const
|
||||
BackspaceButton->SetIsEnabled(false);
|
||||
CastButton->SetIsEnabled(false);
|
||||
RunButton->SetIsEnabled(false);
|
||||
HealButton->SetIsEnabled(false);
|
||||
}
|
||||
|
||||
void ATurnBaseCombatV2::EnableButtons() const
|
||||
@ -721,4 +738,6 @@ void ATurnBaseCombatV2::ToggleButtonIfResourceAvailable() const
|
||||
else AButton->SetIsEnabled(false);
|
||||
if (IroquoidResource >= 1) IButton->SetIsEnabled(true);
|
||||
else IButton->SetIsEnabled(false);
|
||||
if (Cast<ATempCharacter>(PlayerActor)->Inventory->GetItemAmount(0) >= 1) HealButton->SetIsEnabled(true);
|
||||
else HealButton->SetIsEnabled(false);
|
||||
}
|
||||
|
@ -167,6 +167,8 @@ private:
|
||||
UTextBlock* EscapePercentageTextBlock;
|
||||
UPROPERTY()
|
||||
UTextBlock* DamageMultiplierTextBlock;
|
||||
UPROPERTY()
|
||||
UTextBlock* HealingJellyAmountTextBlock;
|
||||
|
||||
UPROPERTY()
|
||||
UProgressBar* PlayerHealthBar;
|
||||
@ -198,6 +200,8 @@ private:
|
||||
UButton* BackspaceButton;
|
||||
UPROPERTY()
|
||||
UButton* RunButton;
|
||||
UPROPERTY()
|
||||
UButton* HealButton;
|
||||
|
||||
UFUNCTION()
|
||||
void CastButtonOnClick();
|
||||
@ -215,6 +219,8 @@ private:
|
||||
void BackspaceButtonOnClick();
|
||||
UFUNCTION()
|
||||
void RunButtonOnClick();
|
||||
UFUNCTION()
|
||||
void HealButtonOnClick();
|
||||
|
||||
void UpdateComboString(const FString& NewCombo) const;
|
||||
static void UpdateActionPoints();
|
||||
|
Loading…
Reference in New Issue
Block a user