diff --git a/Content/Blueprints/Combat_UI/BookCombat_UI.uasset b/Content/Blueprints/Combat_UI/BookCombat_UI.uasset index 60537e7..cf2c7b8 100644 --- a/Content/Blueprints/Combat_UI/BookCombat_UI.uasset +++ b/Content/Blueprints/Combat_UI/BookCombat_UI.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:fc37cf1330393e50bba7b1a0b4f118db2cccef60002e9fa93e6f69620097e72c -size 132103 +oid sha256:cb66d3238cf77ec921c1c701cd00b532350a140ce65838cea041bf62b47e506e +size 132101 diff --git a/Content/Blueprints/Combat_UI/CombatCharacter.uasset b/Content/Blueprints/Combat_UI/CombatCharacter.uasset index c805727..3eaacc3 100644 --- a/Content/Blueprints/Combat_UI/CombatCharacter.uasset +++ b/Content/Blueprints/Combat_UI/CombatCharacter.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:ea5733b446028d56d56b6540c9061981e36ff55dab5288af945c15efc82599db -size 175180 +oid sha256:82f683699a5cf17c3cd137bdc3bf7a02a048848f3ee42e164116455249075e26 +size 173373 diff --git a/Content/Blueprints/Items/BP_Azos.uasset b/Content/Blueprints/Items/BP_Azos.uasset index d6b8604..c1a7f95 100644 --- a/Content/Blueprints/Items/BP_Azos.uasset +++ b/Content/Blueprints/Items/BP_Azos.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:234c3634a776d904e4b0641b0f1252ae5fcf7cd7c427467793bf8aded7f28a28 -size 6089 +oid sha256:629d71a4b6deb9ad05ab3ee399036f4b238a81fa87af0ff93d4acb9519d359e3 +size 6133 diff --git a/Content/Blueprints/Items/BP_Eis.uasset b/Content/Blueprints/Items/BP_Eis.uasset index d504056..8d45111 100644 --- a/Content/Blueprints/Items/BP_Eis.uasset +++ b/Content/Blueprints/Items/BP_Eis.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:8e2bde130e60fb78f77bccd26a57a0bb6e4cba83b788cb331720b202dc6f9b54 -size 6083 +oid sha256:90ffa64c83364a9999a3464678523f24dfb586b655da7f128bfff17701fa5449 +size 6127 diff --git a/Content/Blueprints/Items/BP_Iroquoid.uasset b/Content/Blueprints/Items/BP_Iroquoid.uasset index 422470d..d31609c 100644 --- a/Content/Blueprints/Items/BP_Iroquoid.uasset +++ b/Content/Blueprints/Items/BP_Iroquoid.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:746d9a0978283b0776f92252768a7e50e883a80552c05265e3545778171826c2 -size 6148 +oid sha256:47fc25228df785ac6aeeb60b554b5692dd4a737df60a32809b317bfa1b65e6f4 +size 6192 diff --git a/Content/Blueprints/Items/BP_Probertium.uasset b/Content/Blueprints/Items/BP_Probertium.uasset index 9bacdf5..e39fed3 100644 --- a/Content/Blueprints/Items/BP_Probertium.uasset +++ b/Content/Blueprints/Items/BP_Probertium.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:f05fac1edb1f8eb1183644863c27eebf70582a7bcfa28f9d3db744dca17f8c12 -size 6193 +oid sha256:4f5a371a80b03bd6a9136a800a908d8b5422c22efbdbcc587f6160c4fce3b98e +size 6237 diff --git a/Source/the_twilight_abyss/BaseItems/InventoryComponent.cpp b/Source/the_twilight_abyss/BaseItems/InventoryComponent.cpp index 2c808c8..28670ec 100644 --- a/Source/the_twilight_abyss/BaseItems/InventoryComponent.cpp +++ b/Source/the_twilight_abyss/BaseItems/InventoryComponent.cpp @@ -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(Item)); + } + } + } +} + +UBaseItem* UInventoryComponent::GetItemByID(const int& ItemID) +{ + if (Items.Num() > 0) + { + for (UBaseItem* const& Item : Items) + { + if (Item->ItemID == ItemID) + { + return Item; + } + } + } + return nullptr; +} diff --git a/Source/the_twilight_abyss/BaseItems/InventoryComponent.h b/Source/the_twilight_abyss/BaseItems/InventoryComponent.h index 1800160..95513ca 100644 --- a/Source/the_twilight_abyss/BaseItems/InventoryComponent.h +++ b/Source/the_twilight_abyss/BaseItems/InventoryComponent.h @@ -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); }; diff --git a/Source/the_twilight_abyss/BaseItems/Items/EatableItems.cpp b/Source/the_twilight_abyss/BaseItems/Items/EatableItems.cpp index b47c565..0271615 100644 --- a/Source/the_twilight_abyss/BaseItems/Items/EatableItems.cpp +++ b/Source/the_twilight_abyss/BaseItems/Items/EatableItems.cpp @@ -22,8 +22,9 @@ void UEatableItems::Use(ATempCharacter* Character) { if (Character->Health < 100) { - UStatusSystem* StatusSystem = Character->FindComponentByClass(); - StatusSystem->AddStatusEffect(NewObject(Character, HealOverTimeStatusEffect)); + // UStatusSystem* StatusSystem = Character->FindComponentByClass(); + // StatusSystem->AddStatusEffect(NewObject(Character, HealOverTimeStatusEffect)); + Character->Health += 20; Character->Inventory->RemoveItem(this); } else if (Character->Health >= 100) diff --git a/Source/the_twilight_abyss/BaseItems/Items/EatableItems.h b/Source/the_twilight_abyss/BaseItems/Items/EatableItems.h index 7bb6ddc..419f8e3 100644 --- a/Source/the_twilight_abyss/BaseItems/Items/EatableItems.h +++ b/Source/the_twilight_abyss/BaseItems/Items/EatableItems.h @@ -25,6 +25,6 @@ protected: TSubclassOf HealOverTimeStatusEffect; private: - + UPROPERTY() ATurnBaseCombatV2* TurnBaseCombat; }; diff --git a/Source/the_twilight_abyss/TurnBasedCombatV2/TurnBaseCombatV2.cpp b/Source/the_twilight_abyss/TurnBasedCombatV2/TurnBaseCombatV2.cpp index defe1f4..a0d1ba1 100644 --- a/Source/the_twilight_abyss/TurnBasedCombatV2/TurnBaseCombatV2.cpp +++ b/Source/the_twilight_abyss/TurnBasedCombatV2/TurnBaseCombatV2.cpp @@ -48,7 +48,8 @@ void ATurnBaseCombatV2::StartCombat(AActor* Enemy, const bool bWasShot) bIsInCombat = true; UBlackboardComponent* EnemyBlackboard = Cast(Enemy->GetInstigatorController())->GetBlackboardComponent(); Cast(PlayerActor->GetComponentByClass(UQuestSystem::StaticClass()))->QuestWidgetInstance->SetVisibility(ESlateVisibility::Hidden); - + HealingJellyAmountTextBlock->SetText(FText::FromString(FString::FromInt(FMath::Clamp(Cast(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(HUD->GetWidgetFromName("BattleLog")); EscapePercentageTextBlock = Cast(BookHUD->GetWidgetFromName("EscapePercentage_Text")); DamageMultiplierTextBlock = Cast(BookHUD->GetWidgetFromName("DamageMultiplier_Text")); + HealingJellyAmountTextBlock = Cast(BookHUD->GetWidgetFromName("HealingAmount_Text")); PlayerHealthBar = Cast(BookHUD->GetWidgetFromName("PlayerHealthBar")); EnemyHealthBar = Cast(HUD->GetWidgetFromName("EnemyHealthBar")); ProbertiumResourceBar = Cast(BookHUD->GetWidgetFromName("ProbertiumResourceBar")); @@ -250,6 +252,7 @@ void ATurnBaseCombatV2::BeginPlay() IButton = Cast(BookHUD->GetWidgetFromName("Iroquoid_Button")); BackspaceButton = Cast(BookHUD->GetWidgetFromName("Clear_Button")); RunButton = Cast(BookHUD->GetWidgetFromName("Escape_Button")); + HealButton = Cast(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(PlayerActor)->Inventory->GetItemAmount(0) >= 1) + { + Cast(PlayerActor)->Inventory->GetItemByID(0)->Use(Cast(PlayerActor)); + HealingJellyAmountTextBlock->SetText(FText::FromString(FString::FromInt(FMath::Clamp(Cast(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(PlayerActor)->Inventory->GetItemAmount(0) >= 1) HealButton->SetIsEnabled(true); + else HealButton->SetIsEnabled(false); } diff --git a/Source/the_twilight_abyss/TurnBasedCombatV2/TurnBaseCombatV2.h b/Source/the_twilight_abyss/TurnBasedCombatV2/TurnBaseCombatV2.h index b891b7f..a857da3 100644 --- a/Source/the_twilight_abyss/TurnBasedCombatV2/TurnBaseCombatV2.h +++ b/Source/the_twilight_abyss/TurnBasedCombatV2/TurnBaseCombatV2.h @@ -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();