Merge branch 'merchant-system' into Turn-Base-System-V2
# Conflicts: # Config/DefaultEngine.ini # Content/Blueprints/Combat_UI/CombatCharacter.uasset # Content/Merchant/BP_MerchantGameMode.uasset
This commit is contained in:
commit
af1813fd9a
BIN
Content/Blueprints/BP_CrossHair.uasset
(Stored with Git LFS)
BIN
Content/Blueprints/BP_CrossHair.uasset
(Stored with Git LFS)
Binary file not shown.
BIN
Content/Blueprints/BP_HealingJellyItem.uasset
(Stored with Git LFS)
BIN
Content/Blueprints/BP_HealingJellyItem.uasset
(Stored with Git LFS)
Binary file not shown.
BIN
Content/Blueprints/BP_Interaction.uasset
(Stored with Git LFS)
BIN
Content/Blueprints/BP_Interaction.uasset
(Stored with Git LFS)
Binary file not shown.
BIN
Content/Blueprints/BP_MyTempCharacter.uasset
(Stored with Git LFS)
BIN
Content/Blueprints/BP_MyTempCharacter.uasset
(Stored with Git LFS)
Binary file not shown.
BIN
Content/Blueprints/Display_UI/BP_CrossHair.uasset
(Stored with Git LFS)
Normal file
BIN
Content/Blueprints/Display_UI/BP_CrossHair.uasset
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
Content/Blueprints/Display_UI/WBP_Health.uasset
(Stored with Git LFS)
Normal file
BIN
Content/Blueprints/Display_UI/WBP_Health.uasset
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
Content/Blueprints/Inventory_UI/WBP_ItemDisplay.uasset
(Stored with Git LFS)
Normal file
BIN
Content/Blueprints/Inventory_UI/WBP_ItemDisplay.uasset
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
Content/Blueprints/Inventory_UI/WBP_PlayerInventory.uasset
(Stored with Git LFS)
Normal file
BIN
Content/Blueprints/Inventory_UI/WBP_PlayerInventory.uasset
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
Content/Blueprints/Items/BP_BuffJelly.uasset
(Stored with Git LFS)
BIN
Content/Blueprints/Items/BP_BuffJelly.uasset
(Stored with Git LFS)
Binary file not shown.
BIN
Content/Blueprints/Items/BP_BuffPlacedItem.uasset
(Stored with Git LFS)
Normal file
BIN
Content/Blueprints/Items/BP_BuffPlacedItem.uasset
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
Content/Blueprints/Items/BP_HealingJelly.uasset
(Stored with Git LFS)
BIN
Content/Blueprints/Items/BP_HealingJelly.uasset
(Stored with Git LFS)
Binary file not shown.
BIN
Content/Blueprints/Items/ItemsInWorld/BP_BuffPlacedItem.uasset
(Stored with Git LFS)
Normal file
BIN
Content/Blueprints/Items/ItemsInWorld/BP_BuffPlacedItem.uasset
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
Content/Blueprints/Items/ItemsInWorld/BP_HealingJellyItem.uasset
(Stored with Git LFS)
Normal file
BIN
Content/Blueprints/Items/ItemsInWorld/BP_HealingJellyItem.uasset
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
Content/Blueprints/Merchant/BP_Interaction.uasset
(Stored with Git LFS)
Normal file
BIN
Content/Blueprints/Merchant/BP_Interaction.uasset
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
Content/Blueprints/Merchant/BP_MerchantGameMode.uasset
(Stored with Git LFS)
Normal file
BIN
Content/Blueprints/Merchant/BP_MerchantGameMode.uasset
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
Content/Blueprints/Merchant/Merchant_Blueprint.uasset
(Stored with Git LFS)
Normal file
BIN
Content/Blueprints/Merchant/Merchant_Blueprint.uasset
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
Content/Blueprints/Merchant/Merchant_UI/BP_OPENDIAL.uasset
(Stored with Git LFS)
Normal file
BIN
Content/Blueprints/Merchant/Merchant_UI/BP_OPENDIAL.uasset
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
Content/Blueprints/Player/BP_MyTempCharacter.uasset
(Stored with Git LFS)
Normal file
BIN
Content/Blueprints/Player/BP_MyTempCharacter.uasset
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
Content/Blueprints/WBP_ItemDisplay.uasset
(Stored with Git LFS)
BIN
Content/Blueprints/WBP_ItemDisplay.uasset
(Stored with Git LFS)
Binary file not shown.
BIN
Content/Blueprints/WBP_PlayerInventory.uasset
(Stored with Git LFS)
BIN
Content/Blueprints/WBP_PlayerInventory.uasset
(Stored with Git LFS)
Binary file not shown.
BIN
Content/Blueprints/WBP_Shop.uasset
(Stored with Git LFS)
BIN
Content/Blueprints/WBP_Shop.uasset
(Stored with Git LFS)
Binary file not shown.
BIN
Content/Levels/MerchantPrototype.umap
(Stored with Git LFS)
BIN
Content/Levels/MerchantPrototype.umap
(Stored with Git LFS)
Binary file not shown.
BIN
Content/Merchant/BP_OPENDIAL.uasset
(Stored with Git LFS)
BIN
Content/Merchant/BP_OPENDIAL.uasset
(Stored with Git LFS)
Binary file not shown.
BIN
Content/Merchant_Blueprint.uasset
(Stored with Git LFS)
BIN
Content/Merchant_Blueprint.uasset
(Stored with Git LFS)
Binary file not shown.
@ -22,6 +22,7 @@ void UInventoryComponent::BeginPlay()
|
|||||||
{
|
{
|
||||||
Super::BeginPlay();
|
Super::BeginPlay();
|
||||||
|
|
||||||
|
//activates the AddItem function for every DefaultItem that inherits BaseItem
|
||||||
for(auto & BaseItem : DefaultItems)
|
for(auto & BaseItem : DefaultItems)
|
||||||
{
|
{
|
||||||
AddItem(BaseItem);
|
AddItem(BaseItem);
|
||||||
@ -33,28 +34,48 @@ bool UInventoryComponent::AddItem(class UBaseItem* BaseItem)
|
|||||||
//if the items is over the maxinventoryslots then it wont add the item
|
//if the items is over the maxinventoryslots then it wont add the item
|
||||||
if (Items.Num() >= MaxItemSlots || !BaseItem)
|
if (Items.Num() >= MaxItemSlots || !BaseItem)
|
||||||
{
|
{
|
||||||
|
UE_LOG(LogTemp, Display, TEXT("THERE ARE MORE ITEMS THAN THE INVENTORY SLOTS"));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
BaseItem->StoredItems = this;
|
BaseItem->StoredItems = this;
|
||||||
BaseItem->World = GetWorld();
|
BaseItem->World = GetWorld();
|
||||||
Items.Add(BaseItem);
|
Items.Add(BaseItem);
|
||||||
|
BaseItem->SubItemID++;
|
||||||
|
UE_LOG(LogTemp, Display, TEXT("ITEM HAS BEEN ADDED"));
|
||||||
|
//log the itemid
|
||||||
|
UE_LOG(LogTemp, Display, TEXT("ITEM ID: %d"), BaseItem->ItemID);
|
||||||
|
UE_LOG(LogTemp, Display, TEXT("SUBITEM ID: %d"), BaseItem->SubItemID);
|
||||||
|
|
||||||
//Update UI
|
//Refreshes the inventory
|
||||||
OnInventoryUpdated.Broadcast();
|
OnInventoryUpdated.Broadcast();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool UInventoryComponent::Remove(UBaseItem* BaseItem)
|
// 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;
|
BaseItem->StoredItems = nullptr;
|
||||||
BaseItem->World = nullptr;
|
BaseItem->World = nullptr;
|
||||||
Items.RemoveSingle(BaseItem);
|
if(BaseItem->SubItemID < Items.Num())
|
||||||
|
{
|
||||||
|
Items.RemoveSingle(BaseItem);
|
||||||
|
BaseItem->SubItemID --;
|
||||||
|
UE_LOG(LogTemp, Display, TEXT("ItemRemoved"));
|
||||||
|
UE_LOG(LogTemp, Display, TEXT("SUBITEM ID: %d"), BaseItem->SubItemID);
|
||||||
|
}
|
||||||
|
//Items.RemoveSingle(BaseItem);
|
||||||
OnInventoryUpdated.Broadcast(); // Updates UI
|
OnInventoryUpdated.Broadcast(); // Updates UI
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
UBaseItem* UInventoryComponent::GetItem(int Index)
|
||||||
|
{
|
||||||
|
return Items[Index];
|
||||||
|
}
|
||||||
|
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
|
|
||||||
#include "CoreMinimal.h"
|
#include "CoreMinimal.h"
|
||||||
#include "Components/ActorComponent.h"
|
#include "Components/ActorComponent.h"
|
||||||
|
#include "Items/EatableItems.h"
|
||||||
#include "InventoryComponent.generated.h"
|
#include "InventoryComponent.generated.h"
|
||||||
|
|
||||||
//OUR DELEGATE IS CALLED FONINVENTORYUPDATED
|
//OUR DELEGATE IS CALLED FONINVENTORYUPDATED
|
||||||
@ -33,9 +34,16 @@ public:
|
|||||||
UPROPERTY(EditDefaultsOnly, Category= "Inventory")
|
UPROPERTY(EditDefaultsOnly, Category= "Inventory")
|
||||||
int32 MaxItemSlots;
|
int32 MaxItemSlots;
|
||||||
|
|
||||||
|
UPROPERTY(EditDefaultsOnly, Category = "Inventory")
|
||||||
|
int MaxItemStack;
|
||||||
|
|
||||||
UPROPERTY(BlueprintAssignable, Category= "Inventory")
|
UPROPERTY(BlueprintAssignable, Category= "Inventory")
|
||||||
FOnInventoryUpdated OnInventoryUpdated; //This is our delegate
|
FOnInventoryUpdated OnInventoryUpdated; //This is our delegate
|
||||||
|
|
||||||
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category= "Items")
|
UPROPERTY(VisibleAnywhere, BlueprintReadWrite, Category= "Items")
|
||||||
TArray<class UBaseItem*> Items; // The items currently in the inventory
|
TArray<class UBaseItem*> Items; // The items currently in the inventory
|
||||||
|
|
||||||
|
UFUNCTION(BlueprintCallable, Category= "Inventory")
|
||||||
|
class UBaseItem* GetItem(int Index);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
@ -47,6 +47,18 @@ public:
|
|||||||
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite, Category = "Item")
|
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite, Category = "Item")
|
||||||
int ItemCostPrice;
|
int ItemCostPrice;
|
||||||
|
|
||||||
|
UPROPERTY(EditAnywhere, Category = "Item")
|
||||||
|
bool isHealingItem;
|
||||||
|
|
||||||
|
UPROPERTY(EditAnywhere, Category = "Item")
|
||||||
|
bool isDamageBuffItem;
|
||||||
|
|
||||||
|
UPROPERTY(EditAnywhere, Category = "Item")
|
||||||
|
int ItemID;
|
||||||
|
|
||||||
|
UPROPERTY(EditAnywhere, Category = "Item")
|
||||||
|
int SubItemID;
|
||||||
|
|
||||||
//reference to the UInventoryComponent script
|
//reference to the UInventoryComponent script
|
||||||
UPROPERTY()
|
UPROPERTY()
|
||||||
class UInventoryComponent* StoredItems;
|
class UInventoryComponent* StoredItems;
|
||||||
@ -60,7 +72,4 @@ public:
|
|||||||
//This is the same as the use item class but its in BP instead
|
//This is the same as the use item class but its in BP instead
|
||||||
UFUNCTION(BlueprintImplementableEvent)
|
UFUNCTION(BlueprintImplementableEvent)
|
||||||
void OnUse(class ATempCharacter* Character);
|
void OnUse(class ATempCharacter* Character);
|
||||||
|
|
||||||
UFUNCTION(BlueprintImplementableEvent)
|
|
||||||
void OnBuy(class ATempCharacter* PurchaseItem);
|
|
||||||
};
|
};
|
||||||
|
@ -9,33 +9,34 @@
|
|||||||
|
|
||||||
UEatableItems::UEatableItems()
|
UEatableItems::UEatableItems()
|
||||||
{
|
{
|
||||||
|
ItemID;
|
||||||
|
SubItemID;
|
||||||
}
|
}
|
||||||
|
|
||||||
void UEatableItems::Use(ATempCharacter* Character)
|
void UEatableItems::Use(ATempCharacter* Character)
|
||||||
{
|
{
|
||||||
if(Character)
|
if(Character)
|
||||||
{
|
{
|
||||||
Character->Health += 10;
|
if(isHealingItem == true)
|
||||||
|
{
|
||||||
|
Character->Health += 10;
|
||||||
|
UE_LOG(LogTemp, Display, TEXT("Healed"));
|
||||||
|
}
|
||||||
|
if(isDamageBuffItem == true)
|
||||||
|
{
|
||||||
|
// need to add the damage buff functionality here
|
||||||
|
UE_LOG(LogTemp, Display, TEXT("Damage Buffed"));
|
||||||
|
}
|
||||||
if(StoredItems)
|
if(StoredItems)
|
||||||
{
|
{
|
||||||
StoredItems->Remove(this);
|
StoredItems->Remove(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
when player uses the item syrengine to debuff enemies
|
||||||
|
detect what enemie actors the player is fighting with
|
||||||
|
lower their damage by a value.
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
void UEatableItems::Buy(ATempCharacter* PurchaseItem)
|
|
||||||
{
|
|
||||||
if(PurchaseItem)
|
|
||||||
{
|
|
||||||
if(PurchaseItem->GoldBalance <= 0)
|
|
||||||
{
|
|
||||||
UE_LOG(LogTemp, Display, TEXT("Not Enough Gold"));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
PurchaseItem->GoldBalance -= ItemCostPrice;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
@ -19,5 +19,4 @@ class THE_TWILIGHT_ABYSS_API UEatableItems : public UBaseItem
|
|||||||
protected:
|
protected:
|
||||||
|
|
||||||
virtual void Use(class ATempCharacter* Character) override;
|
virtual void Use(class ATempCharacter* Character) override;
|
||||||
virtual void Buy(ATempCharacter* PurchaseItem) override;
|
|
||||||
};
|
};
|
||||||
|
@ -30,7 +30,13 @@ void AInteraction::Tick(float DeltaTime)
|
|||||||
|
|
||||||
void AInteraction::OnInteract()
|
void AInteraction::OnInteract()
|
||||||
{
|
{
|
||||||
UUserWidget* spawnedWidget = CreateWidget<UUserWidget>(GetWorld(), Widget);
|
CurrentWidget = CreateWidget<UUserWidget>(GetWorld(), Widget);
|
||||||
spawnedWidget->AddToViewport(0);
|
CurrentWidget->AddToViewport(0);
|
||||||
|
FTimerHandle WidgetTimer;
|
||||||
|
GetWorldTimerManager().SetTimer(WidgetTimer, this, &AInteraction::RemoveWidget, WaitTimer, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AInteraction::RemoveWidget()
|
||||||
|
{
|
||||||
|
CurrentWidget->RemoveFromViewport();
|
||||||
|
}
|
@ -27,5 +27,10 @@ public:
|
|||||||
TSubclassOf<UUserWidget> Widget;
|
TSubclassOf<UUserWidget> Widget;
|
||||||
|
|
||||||
virtual void OnInteract();
|
virtual void OnInteract();
|
||||||
|
virtual void RemoveWidget();
|
||||||
|
UPROPERTY()
|
||||||
|
UUserWidget* CurrentWidget;
|
||||||
|
UPROPERTY(EditAnywhere)
|
||||||
|
float WaitTimer = 8.0f;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
// Fill out your copyright notice in the Description page of Project Settings.
|
// Fill out your copyright notice in the Description page of Project Settings.
|
||||||
|
|
||||||
#include "TempCharacter.h"
|
#include "TempCharacter.h"
|
||||||
|
|
||||||
|
#include "IDetailTreeNode.h"
|
||||||
#include "Blueprint/UserWidget.h"
|
#include "Blueprint/UserWidget.h"
|
||||||
#include "the_twilight_abyss/BaseItems/InventoryComponent.h"
|
#include "the_twilight_abyss/BaseItems/InventoryComponent.h"
|
||||||
#include "the_twilight_abyss/BaseItems/Items/BaseItem.h"
|
#include "the_twilight_abyss/BaseItems/Items/BaseItem.h"
|
||||||
@ -14,6 +16,8 @@ ATempCharacter::ATempCharacter()
|
|||||||
PrimaryActorTick.bCanEverTick = true;
|
PrimaryActorTick.bCanEverTick = true;
|
||||||
Inventory = CreateDefaultSubobject<UInventoryComponent>("Inventory");
|
Inventory = CreateDefaultSubobject<UInventoryComponent>("Inventory");
|
||||||
Inventory->MaxItemSlots = 10;
|
Inventory->MaxItemSlots = 10;
|
||||||
|
GoldBalance = GoldBalance;
|
||||||
|
Health = Health;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Called when the game starts or when spawned
|
// Called when the game starts or when spawned
|
||||||
@ -70,21 +74,22 @@ void ATempCharacter::LineTraceLogic()
|
|||||||
|
|
||||||
TraceParams.AddIgnoredActor(this);
|
TraceParams.AddIgnoredActor(this);
|
||||||
|
|
||||||
bool bHit = GetWorld()->LineTraceSingleByChannel(OutHit, Start, End, ECC_Visibility, TraceParams);
|
bHit = GetWorld()->LineTraceSingleByChannel(OutHit, Start, End, ECC_Visibility, TraceParams);
|
||||||
if (bHit)
|
if (bHit)
|
||||||
{
|
{
|
||||||
|
//we store the GetItem function from InventoryComponent into ItemArray variable
|
||||||
|
auto ItemArray = OutHit.GetActor()->FindComponentByClass<UInventoryComponent>()->GetItem(0);
|
||||||
if(OutHit.GetActor() == nullptr)
|
if(OutHit.GetActor() == nullptr)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(OutHit.GetActor()->ActorHasTag("HealingJelly"))
|
if(OutHit.GetActor()->FindComponentByClass<UInventoryComponent>())
|
||||||
{
|
{
|
||||||
if(GoldBalance >= 100)
|
if(GoldBalance >= ItemArray->ItemCostPrice)
|
||||||
{
|
{
|
||||||
GoldBalance -= 100;
|
GoldBalance -= ItemArray->ItemCostPrice;
|
||||||
|
Inventory->AddItem(ItemArray);
|
||||||
UE_LOG(LogTemp, Display, TEXT("Item Purchased"));
|
UE_LOG(LogTemp, Display, TEXT("Item Purchased"));
|
||||||
// UInventoryComponent* tempInventory = GetOwner()->FindComponentByClass<UInventoryComponent>();
|
|
||||||
// tempInventory->AddItem(ItemToBuy);
|
|
||||||
}
|
}
|
||||||
if(GoldBalance <= 0)
|
if(GoldBalance <= 0)
|
||||||
{
|
{
|
||||||
@ -109,12 +114,3 @@ void ATempCharacter::UseItem(class UBaseItem* Item)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ATempCharacter::BuyItem(UBaseItem* BuyItem)
|
|
||||||
{
|
|
||||||
if(BuyItem)
|
|
||||||
{
|
|
||||||
BuyItem->Buy(this);
|
|
||||||
BuyItem->OnBuy(this);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
@ -41,19 +41,16 @@ public:
|
|||||||
|
|
||||||
void LineTraceLogic();
|
void LineTraceLogic();
|
||||||
|
|
||||||
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category= "Health")
|
UPROPERTY(BlueprintReadWrite, EditAnywhere, Category= "Health")
|
||||||
float Health;
|
float Health;
|
||||||
|
|
||||||
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category= "Gold")
|
UPROPERTY(BlueprintReadWrite, EditAnywhere, Category= "Gold")
|
||||||
int GoldBalance;
|
int GoldBalance;
|
||||||
|
|
||||||
|
UPROPERTY(VisibleDefaultsOnly, Category = "LineTrace")
|
||||||
|
bool bHit;
|
||||||
|
|
||||||
//Using the item in the inventory
|
//Using the item in the inventory
|
||||||
UFUNCTION(BlueprintCallable, Category= "Items")
|
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;
|
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user