From e602d83a31f61100d7fc40e162d8b97e87518815 Mon Sep 17 00:00:00 2001 From: MH261677 Date: Tue, 15 Nov 2022 00:04:46 +0000 Subject: [PATCH 1/3] Updated Inventory system for Items in UI The Inventory System is working fully with the healing jelly working --- Content/Blueprints/BP_MyTempCharacter.uasset | 4 ++-- Content/Blueprints/WBP_ItemDisplay.uasset | 4 ++-- Content/Blueprints/WBP_PlayerInventory.uasset | 4 ++-- .../BaseItems/Items/EatableItems.cpp | 11 +++++++++++ .../the_twilight_abyss/BaseItems/Items/EatableItems.h | 2 ++ 5 files changed, 19 insertions(+), 6 deletions(-) diff --git a/Content/Blueprints/BP_MyTempCharacter.uasset b/Content/Blueprints/BP_MyTempCharacter.uasset index ed9200f..f840bf5 100644 --- a/Content/Blueprints/BP_MyTempCharacter.uasset +++ b/Content/Blueprints/BP_MyTempCharacter.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:83b78bc2c32ead48fb4b3986da18675ab1673013673104c5232b504978a0c1ad -size 68346 +oid sha256:d49ff6579e47fa28aa35b87519939d733c3abfca7c388d4be2c900a85157f88e +size 68733 diff --git a/Content/Blueprints/WBP_ItemDisplay.uasset b/Content/Blueprints/WBP_ItemDisplay.uasset index 748f45b..1f2c632 100644 --- a/Content/Blueprints/WBP_ItemDisplay.uasset +++ b/Content/Blueprints/WBP_ItemDisplay.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:b3326b738a1a849cc33276c0a9c12c545dee4510e510848526cc225f939996d5 -size 81310 +oid sha256:4edd0dbf94c6d8cceab4ebfdc061238344833123d145ea292e4e8274d07ce760 +size 80407 diff --git a/Content/Blueprints/WBP_PlayerInventory.uasset b/Content/Blueprints/WBP_PlayerInventory.uasset index f05676b..810d0bf 100644 --- a/Content/Blueprints/WBP_PlayerInventory.uasset +++ b/Content/Blueprints/WBP_PlayerInventory.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:7df9350594b51cf2639b09ee43273d07e56f0328301b51d0c89b70c8edecf450 -size 90586 +oid sha256:0f8371e5880ea4dec24ea399529d04787ab66c9fbc72973cdc964d9bffd94db0 +size 98662 diff --git a/Source/the_twilight_abyss/BaseItems/Items/EatableItems.cpp b/Source/the_twilight_abyss/BaseItems/Items/EatableItems.cpp index 63956df..ccb756f 100644 --- a/Source/the_twilight_abyss/BaseItems/Items/EatableItems.cpp +++ b/Source/the_twilight_abyss/BaseItems/Items/EatableItems.cpp @@ -3,13 +3,24 @@ #include "EatableItems.h" +#include "the_twilight_abyss/BaseItems/InventoryComponent.h" #include "the_twilight_abyss/PlayerTemp/TempCharacter.h" +UEatableItems::UEatableItems() +{ + +} + void UEatableItems::Use(ATempCharacter* Character) { if(Character) { Character->Health += 10; + + if(StoredItems) + { + StoredItems->Remove(this); + } } } diff --git a/Source/the_twilight_abyss/BaseItems/Items/EatableItems.h b/Source/the_twilight_abyss/BaseItems/Items/EatableItems.h index 127041f..d636bcd 100644 --- a/Source/the_twilight_abyss/BaseItems/Items/EatableItems.h +++ b/Source/the_twilight_abyss/BaseItems/Items/EatableItems.h @@ -13,6 +13,8 @@ UCLASS() class THE_TWILIGHT_ABYSS_API UEatableItems : public UBaseItem { GENERATED_BODY() + UEatableItems(); + protected: From 91667f89b2f9ff621abd4cba6891053e6051ee25 Mon Sep 17 00:00:00 2001 From: MH261677 Date: Tue, 15 Nov 2022 00:16:26 +0000 Subject: [PATCH 2/3] Updated MerchantGameMode Added a print string to tell the player to press TAB to open the inventory --- Content/Merchant/BP_MerchantGameMode.uasset | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Content/Merchant/BP_MerchantGameMode.uasset b/Content/Merchant/BP_MerchantGameMode.uasset index 2e44159..972a44a 100644 --- a/Content/Merchant/BP_MerchantGameMode.uasset +++ b/Content/Merchant/BP_MerchantGameMode.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:926719df7176f9678de65e93b192fe07cb79d5f1a3d5f8a49dd4ecb500bbd7b5 -size 20569 +oid sha256:fe64fcaee3f5da07e75c337764207dcdca5f2cdd0bd61681804d8178f703f0e3 +size 27684 From 0c0876770bad1f2f867feaf57781e0046abb61bf Mon Sep 17 00:00:00 2001 From: MH261677 Date: Tue, 15 Nov 2022 03:27:44 +0000 Subject: [PATCH 3/3] Updated Inventory System Added BuffJelly --- Content/Blueprints/BP_HealingJellyItem.uasset | 3 +++ Content/Blueprints/BP_Interaction.uasset | 4 ++-- Content/Blueprints/BP_MyTempCharacter.uasset | 4 ++-- Content/Blueprints/Items/BP_BuffJelly.uasset | 3 +++ Content/Blueprints/WBP_ItemDisplay.uasset | 4 ++-- Content/Blueprints/WBP_PlayerInventory.uasset | 4 ++-- Content/Blueprints/WBP_Shop.uasset | 3 +++ ...0721c6d67f7486dab91235681c-1920-q70.uasset | 3 +++ Content/Levels/MerchantPrototype.umap | 4 ++-- .../BaseItems/InventoryComponent.cpp | 4 +--- .../BaseItems/Items/BaseItem.h | 11 +++++---- .../BaseItems/Items/EatableItems.cpp | 15 ++++++++++++ .../BaseItems/Items/EatableItems.h | 1 + .../BaseItems/Items/ShopItems.cpp | 19 +++++++++++++++ .../BaseItems/Items/ShopItems.h | 20 ++++++++++++++++ .../PlayerTemp/TempCharacter.cpp | 24 +++++++++++++++++++ .../PlayerTemp/TempCharacter.h | 12 +++++++++- 17 files changed, 119 insertions(+), 19 deletions(-) create mode 100644 Content/Blueprints/BP_HealingJellyItem.uasset create mode 100644 Content/Blueprints/Items/BP_BuffJelly.uasset create mode 100644 Content/Blueprints/WBP_Shop.uasset create mode 100644 Content/Images/butterfly-pea-jelly-on-a-plate-9e24c00721c6d67f7486dab91235681c-1920-q70.uasset create mode 100644 Source/the_twilight_abyss/BaseItems/Items/ShopItems.cpp create mode 100644 Source/the_twilight_abyss/BaseItems/Items/ShopItems.h diff --git a/Content/Blueprints/BP_HealingJellyItem.uasset b/Content/Blueprints/BP_HealingJellyItem.uasset new file mode 100644 index 0000000..f66b6a9 --- /dev/null +++ b/Content/Blueprints/BP_HealingJellyItem.uasset @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:f9bb81fd6a904d7139d83d81f2d8fbecf448eda7710959bfa2a32faf2e2eee72 +size 29888 diff --git a/Content/Blueprints/BP_Interaction.uasset b/Content/Blueprints/BP_Interaction.uasset index 36accd5..dcb91cb 100644 --- a/Content/Blueprints/BP_Interaction.uasset +++ b/Content/Blueprints/BP_Interaction.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:4c7a00cbf616d22eba20079c3f1640b3d1c3ef86aee1bcfa4335ca32a5390a80 -size 27630 +oid sha256:42db740853a281bd78c277e9281ab2af4bdf9d0ee834045782e066ee782e9e67 +size 27990 diff --git a/Content/Blueprints/BP_MyTempCharacter.uasset b/Content/Blueprints/BP_MyTempCharacter.uasset index f840bf5..585dc7f 100644 --- a/Content/Blueprints/BP_MyTempCharacter.uasset +++ b/Content/Blueprints/BP_MyTempCharacter.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:d49ff6579e47fa28aa35b87519939d733c3abfca7c388d4be2c900a85157f88e -size 68733 +oid sha256:c720b55a9e91e62f991279ef9d043ef8e41e3282b1b1c640ddb46dd4c8efc543 +size 53356 diff --git a/Content/Blueprints/Items/BP_BuffJelly.uasset b/Content/Blueprints/Items/BP_BuffJelly.uasset new file mode 100644 index 0000000..c1bc784 --- /dev/null +++ b/Content/Blueprints/Items/BP_BuffJelly.uasset @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:334fec1c48b0bb04fe272b83310d5211cd1c78feed1a2adbbd3d13dffdffa90f +size 6726 diff --git a/Content/Blueprints/WBP_ItemDisplay.uasset b/Content/Blueprints/WBP_ItemDisplay.uasset index 1f2c632..6337ca6 100644 --- a/Content/Blueprints/WBP_ItemDisplay.uasset +++ b/Content/Blueprints/WBP_ItemDisplay.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:4edd0dbf94c6d8cceab4ebfdc061238344833123d145ea292e4e8274d07ce760 -size 80407 +oid sha256:7e54ac7119c349323ce6d57b3658300f982eed6ffe9922c47c13448aeb4173e8 +size 84619 diff --git a/Content/Blueprints/WBP_PlayerInventory.uasset b/Content/Blueprints/WBP_PlayerInventory.uasset index 810d0bf..1af5b3c 100644 --- a/Content/Blueprints/WBP_PlayerInventory.uasset +++ b/Content/Blueprints/WBP_PlayerInventory.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:0f8371e5880ea4dec24ea399529d04787ab66c9fbc72973cdc964d9bffd94db0 -size 98662 +oid sha256:38c83f1bddcf376360f7860312744872858e4c43b3c14d5153ae35923d9a8faf +size 96657 diff --git a/Content/Blueprints/WBP_Shop.uasset b/Content/Blueprints/WBP_Shop.uasset new file mode 100644 index 0000000..548aa62 --- /dev/null +++ b/Content/Blueprints/WBP_Shop.uasset @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:2a2f46e884f8c8bcd1bb029db2828769bdbd7a23296896f5a71bda84cd2626c7 +size 24782 diff --git a/Content/Images/butterfly-pea-jelly-on-a-plate-9e24c00721c6d67f7486dab91235681c-1920-q70.uasset b/Content/Images/butterfly-pea-jelly-on-a-plate-9e24c00721c6d67f7486dab91235681c-1920-q70.uasset new file mode 100644 index 0000000..f95b24d --- /dev/null +++ b/Content/Images/butterfly-pea-jelly-on-a-plate-9e24c00721c6d67f7486dab91235681c-1920-q70.uasset @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:9e6d67b2eacb8f089a90ec308158faa73f7c4d2ff319c2b01939517ee2c7d70e +size 225499 diff --git a/Content/Levels/MerchantPrototype.umap b/Content/Levels/MerchantPrototype.umap index 433a8e5..6a6e864 100644 --- a/Content/Levels/MerchantPrototype.umap +++ b/Content/Levels/MerchantPrototype.umap @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:659d40d87576c276667484be63bcb818039f4f8ac40525cdcea92c90eee7aaec -size 23245 +oid sha256:085eef600d9d08558738acea97402875c1b986649999de674e98be2749afe503 +size 24931 diff --git a/Source/the_twilight_abyss/BaseItems/InventoryComponent.cpp b/Source/the_twilight_abyss/BaseItems/InventoryComponent.cpp index 8036177..30156e9 100644 --- a/Source/the_twilight_abyss/BaseItems/InventoryComponent.cpp +++ b/Source/the_twilight_abyss/BaseItems/InventoryComponent.cpp @@ -3,8 +3,7 @@ #include "InventoryComponent.h" #include "Items/BaseItem.h" - - +#include "the_twilight_abyss/PlayerTemp/TempCharacter.h" // Sets default values for this component's properties @@ -36,7 +35,6 @@ bool UInventoryComponent::AddItem(class UBaseItem* BaseItem) { return false; } - BaseItem->StoredItems = this; BaseItem->World = GetWorld(); Items.Add(BaseItem); diff --git a/Source/the_twilight_abyss/BaseItems/Items/BaseItem.h b/Source/the_twilight_abyss/BaseItems/Items/BaseItem.h index 47cdbcc..1b18b3d 100644 --- a/Source/the_twilight_abyss/BaseItems/Items/BaseItem.h +++ b/Source/the_twilight_abyss/BaseItems/Items/BaseItem.h @@ -45,16 +45,14 @@ public: //The cost of the item UPROPERTY(EditDefaultsOnly, BlueprintReadWrite, Category = "Item") - int32 ItemCostPrice; - - //ADD A HEALING ITEM VALUE? - + int ItemCostPrice; + //reference to the UInventoryComponent script UPROPERTY() class UInventoryComponent* StoredItems; //The buy class to purchase the item - virtual void Buy(class UItemPurchaseComponent* PurchaseItem) PURE_VIRTUAL(UBaseItem); // WILL SET THIS UP LATER + virtual void Buy(class ATempCharacter* PurchaseItem) PURE_VIRTUAL(UBaseItem); // WILL SET THIS UP LATER //The use Item class to use the item in the player Inventory virtual void Use(class ATempCharacter* Character); @@ -62,4 +60,7 @@ public: //This is the same as the use item class but its in BP instead UFUNCTION(BlueprintImplementableEvent) void OnUse(class ATempCharacter* Character); + + UFUNCTION(BlueprintImplementableEvent) + void OnBuy(class ATempCharacter* PurchaseItem); }; diff --git a/Source/the_twilight_abyss/BaseItems/Items/EatableItems.cpp b/Source/the_twilight_abyss/BaseItems/Items/EatableItems.cpp index ccb756f..c2a88fb 100644 --- a/Source/the_twilight_abyss/BaseItems/Items/EatableItems.cpp +++ b/Source/the_twilight_abyss/BaseItems/Items/EatableItems.cpp @@ -24,3 +24,18 @@ void UEatableItems::Use(ATempCharacter* Character) } } } + +void UEatableItems::Buy(ATempCharacter* PurchaseItem) +{ + if(PurchaseItem) + { + if(PurchaseItem->GoldBalance <= 0) + { + UE_LOG(LogTemp, Display, TEXT("Not Enough Gold")); + } + else + { + PurchaseItem->GoldBalance -= ItemCostPrice; + } + } +} diff --git a/Source/the_twilight_abyss/BaseItems/Items/EatableItems.h b/Source/the_twilight_abyss/BaseItems/Items/EatableItems.h index d636bcd..e189a6e 100644 --- a/Source/the_twilight_abyss/BaseItems/Items/EatableItems.h +++ b/Source/the_twilight_abyss/BaseItems/Items/EatableItems.h @@ -19,4 +19,5 @@ class THE_TWILIGHT_ABYSS_API UEatableItems : public UBaseItem protected: virtual void Use(class ATempCharacter* Character) override; + virtual void Buy(ATempCharacter* PurchaseItem) override; }; diff --git a/Source/the_twilight_abyss/BaseItems/Items/ShopItems.cpp b/Source/the_twilight_abyss/BaseItems/Items/ShopItems.cpp new file mode 100644 index 0000000..c28f0e3 --- /dev/null +++ b/Source/the_twilight_abyss/BaseItems/Items/ShopItems.cpp @@ -0,0 +1,19 @@ +// Fill out your copyright notice in the Description page of Project Settings. + + +#include "ShopItems.h" + +#include "the_twilight_abyss/PlayerTemp/TempCharacter.h" + +UShopItems::UShopItems() +{ + +} + +// void UShopItems::Buy(ATempCharacter* PurchaseItem) +// { +// if(PurchaseItem) +// { +// PurchaseItem->GoldBalance -= ItemCostPrice; +// } +// } diff --git a/Source/the_twilight_abyss/BaseItems/Items/ShopItems.h b/Source/the_twilight_abyss/BaseItems/Items/ShopItems.h new file mode 100644 index 0000000..85cf445 --- /dev/null +++ b/Source/the_twilight_abyss/BaseItems/Items/ShopItems.h @@ -0,0 +1,20 @@ +// Fill out your copyright notice in the Description page of Project Settings. + +#pragma once + +#include "CoreMinimal.h" +#include "BaseItem.h" +#include "ShopItems.generated.h" + +/** + * + */ +UCLASS() +class THE_TWILIGHT_ABYSS_API UShopItems : public UBaseItem +{ + GENERATED_BODY() + UShopItems(); + +// protected: +// virtual void Buy(ATempCharacter* PurchaseItem) override; +}; diff --git a/Source/the_twilight_abyss/PlayerTemp/TempCharacter.cpp b/Source/the_twilight_abyss/PlayerTemp/TempCharacter.cpp index d21da03..6171a59 100644 --- a/Source/the_twilight_abyss/PlayerTemp/TempCharacter.cpp +++ b/Source/the_twilight_abyss/PlayerTemp/TempCharacter.cpp @@ -77,6 +77,20 @@ void ATempCharacter::LineTraceLogic() { return; } + if(OutHit.GetActor()->ActorHasTag("HealingJelly")) + { + if(GoldBalance >= 100) + { + GoldBalance -= 100; + UE_LOG(LogTemp, Display, TEXT("Item Purchased")); + // UInventoryComponent* tempInventory = GetOwner()->FindComponentByClass(); + // tempInventory->AddItem(ItemToBuy); + } + if(GoldBalance <= 0) + { + UE_LOG(LogTemp, Display, TEXT("Not Enough Gold")); + } + } if (AInteraction* MyInteractable = Cast(OutHit.GetActor())) { DrawDebugLine(GetWorld(), Start, End, FColor::Green, false, 1.0f); @@ -94,3 +108,13 @@ void ATempCharacter::UseItem(class UBaseItem* Item) Item->OnUse(this); //Blueprint Version } } + +void ATempCharacter::BuyItem(UBaseItem* BuyItem) +{ + if(BuyItem) + { + BuyItem->Buy(this); + BuyItem->OnBuy(this); + } +} + diff --git a/Source/the_twilight_abyss/PlayerTemp/TempCharacter.h b/Source/the_twilight_abyss/PlayerTemp/TempCharacter.h index 7cafb29..4760f2c 100644 --- a/Source/the_twilight_abyss/PlayerTemp/TempCharacter.h +++ b/Source/the_twilight_abyss/PlayerTemp/TempCharacter.h @@ -4,6 +4,7 @@ #include "CoreMinimal.h" #include "GameFramework/Character.h" +#include "the_twilight_abyss/BaseItems/Items/BaseItem.h" #include "TempCharacter.generated.h" UCLASS() @@ -43,7 +44,16 @@ public: UPROPERTY(EditAnywhere, BlueprintReadOnly, Category= "Health") float Health; + UPROPERTY(EditAnywhere, BlueprintReadOnly, Category= "Gold") + int GoldBalance; + //Using the item in the inventory UFUNCTION(BlueprintCallable, Category= "Items") - void UseItem(class UBaseItem* Item); // Overriding the BaseItem Class + void UseItem(class UBaseItem* Item); // Overriding the BaseItem Class + + UFUNCTION(BlueprintCallable, Category= "Items") + void BuyItem(class UBaseItem* BuyItem); + + // UPROPERTY(EditAnywhere, Category= "Items") + // UBaseItem ItemToBuy; };