Updated BaseItem,Jelly1,Inventory Component,Temp
Updated all the scripts adding more functionality, Currently just added a very basic Use item and it giving the character health.
This commit is contained in:
parent
8f0a770bfb
commit
83d4d16588
@ -26,8 +26,7 @@ void UInventoryComponent::BeginPlay()
|
|||||||
|
|
||||||
|
|
||||||
// Called every frame
|
// Called every frame
|
||||||
void UInventoryComponent::TickComponent(float DeltaTime, ELevelTick TickType,
|
void UInventoryComponent::TickComponent(float DeltaTime, ELevelTick TickType,FActorComponentTickFunction* ThisTickFunction)
|
||||||
FActorComponentTickFunction* ThisTickFunction)
|
|
||||||
{
|
{
|
||||||
Super::TickComponent(DeltaTime, TickType, ThisTickFunction);
|
Super::TickComponent(DeltaTime, TickType, ThisTickFunction);
|
||||||
|
|
||||||
|
@ -23,7 +23,4 @@ protected:
|
|||||||
public:
|
public:
|
||||||
// Called every frame
|
// Called every frame
|
||||||
virtual void TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction) override;
|
virtual void TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction) override;
|
||||||
|
|
||||||
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite)
|
|
||||||
int32 GoldBalance = 500;
|
|
||||||
};
|
};
|
||||||
|
@ -2,3 +2,10 @@
|
|||||||
|
|
||||||
|
|
||||||
#include "BaseItem.h"
|
#include "BaseItem.h"
|
||||||
|
|
||||||
|
//constructor
|
||||||
|
UBaseItem::UBaseItem()
|
||||||
|
{
|
||||||
|
ItemDisplayName = FText::FromString("ItemName");
|
||||||
|
ItemUseAction = FText::FromString("UseAction");
|
||||||
|
}
|
||||||
|
@ -15,6 +15,8 @@ class THE_TWILIGHT_ABYSS_API UBaseItem : public UObject
|
|||||||
GENERATED_BODY()
|
GENERATED_BODY()
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
UBaseItem();
|
||||||
//The text that will be displayed for using the item (Equip, Eat)
|
//The text that will be displayed for using the item (Equip, Eat)
|
||||||
UPROPERTY(EditDefaultsOnly,BlueprintReadWrite, Category = "Item")
|
UPROPERTY(EditDefaultsOnly,BlueprintReadWrite, Category = "Item")
|
||||||
FText ItemUseAction;
|
FText ItemUseAction;
|
||||||
@ -46,8 +48,12 @@ public:
|
|||||||
class UInventoryComponent* StoredItems;
|
class UInventoryComponent* StoredItems;
|
||||||
|
|
||||||
//The buy class to purchase the item
|
//The buy class to purchase the item
|
||||||
virtual void Buy(class UItemPurchaseComponent* PurchaseItem) PURE_VIRTUAL(UBaseItem);
|
virtual void Buy(class UItemPurchaseComponent* PurchaseItem) PURE_VIRTUAL(UBaseItem); // WILL SET THIS UP LATER
|
||||||
|
|
||||||
//The use Item class to use the item in the player Inventory
|
//The use Item class to use the item in the player Inventory
|
||||||
virtual void Use(class ATempCharacter* Character) PURE_VIRTUAL(UBaseItem);
|
virtual void Use(class ATempCharacter* Character) PURE_VIRTUAL(UBaseItem);
|
||||||
|
|
||||||
|
//This is the same as the use item class but its in BP instead
|
||||||
|
UFUNCTION(BlueprintImplementableEvent)
|
||||||
|
void OnUse (class ATempCharacter* Character);
|
||||||
};
|
};
|
||||||
|
@ -3,12 +3,13 @@
|
|||||||
|
|
||||||
#include "Jelly1.h"
|
#include "Jelly1.h"
|
||||||
|
|
||||||
void UJelly1::Buy(UItemPurchaseComponent* PurchaseItem)
|
#include "the_twilight_abyss/PlayerTemp/TempCharacter.h"
|
||||||
{
|
|
||||||
Super::Buy(PurchaseItem);
|
|
||||||
}
|
|
||||||
|
|
||||||
void UJelly1::Use(ATempCharacter* Character)
|
void UJelly1::Use(ATempCharacter* Character)
|
||||||
{
|
{
|
||||||
Super::Use(Character);
|
if(Character)
|
||||||
|
{
|
||||||
|
Character->Health += 10;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -15,7 +15,6 @@ class THE_TWILIGHT_ABYSS_API UJelly1 : public UBaseItem
|
|||||||
GENERATED_BODY()
|
GENERATED_BODY()
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void Buy(class UItemPurchaseComponent* PurchaseItem) override;
|
|
||||||
|
|
||||||
virtual void Use(class ATempCharacter* Character) override;
|
virtual void Use(class ATempCharacter* Character) override;
|
||||||
};
|
};
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
#include "Engine/GameViewportClient.h"
|
#include "Engine/GameViewportClient.h"
|
||||||
#include "Blueprint/UserWidget.h"
|
#include "Blueprint/UserWidget.h"
|
||||||
#include "../../../Plugins/Developer/RiderLink/Source/RD/thirdparty/clsocket/src/ActiveSocket.h"
|
#include "../../../Plugins/Developer/RiderLink/Source/RD/thirdparty/clsocket/src/ActiveSocket.h"
|
||||||
|
#include "the_twilight_abyss/BaseItems/Items/BaseItem.h"
|
||||||
#include "the_twilight_abyss/MerchantInteraction/Interaction.h"
|
#include "the_twilight_abyss/MerchantInteraction/Interaction.h"
|
||||||
|
|
||||||
|
|
||||||
@ -41,7 +42,7 @@ void ATempCharacter::Tick(float DeltaTime)
|
|||||||
Super::Tick(DeltaTime);
|
Super::Tick(DeltaTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Called to bind functionality to input
|
// Gives the character the functionality
|
||||||
void ATempCharacter::SetupPlayerInputComponent(UInputComponent* PlayerInputComponent)
|
void ATempCharacter::SetupPlayerInputComponent(UInputComponent* PlayerInputComponent)
|
||||||
{
|
{
|
||||||
Super::SetupPlayerInputComponent(PlayerInputComponent);
|
Super::SetupPlayerInputComponent(PlayerInputComponent);
|
||||||
@ -50,14 +51,15 @@ void ATempCharacter::SetupPlayerInputComponent(UInputComponent* PlayerInputCompo
|
|||||||
PlayerInputComponent->BindAxis(TEXT("Turn Right / Left Mouse"), this, &ATempCharacter::AddControllerYawInput);
|
PlayerInputComponent->BindAxis(TEXT("Turn Right / Left Mouse"), this, &ATempCharacter::AddControllerYawInput);
|
||||||
PlayerInputComponent->BindAxis(TEXT("Look Up / Down Mouse"), this, &ATempCharacter::AddControllerPitchInput);
|
PlayerInputComponent->BindAxis(TEXT("Look Up / Down Mouse"), this, &ATempCharacter::AddControllerPitchInput);
|
||||||
PlayerInputComponent->BindAction("Interact", IE_Pressed, this, &ATempCharacter::KeyPressed);
|
PlayerInputComponent->BindAction("Interact", IE_Pressed, this, &ATempCharacter::KeyPressed);
|
||||||
// custom keybind Interact
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// When the player presses the E key
|
||||||
void ATempCharacter::KeyPressed()
|
void ATempCharacter::KeyPressed()
|
||||||
{
|
{
|
||||||
LineTraceLogic();
|
LineTraceLogic();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Line trace logic
|
||||||
void ATempCharacter::LineTraceLogic()
|
void ATempCharacter::LineTraceLogic()
|
||||||
{
|
{
|
||||||
float GlobalTrace = TraceDistance;
|
float GlobalTrace = TraceDistance;
|
||||||
@ -84,3 +86,12 @@ void ATempCharacter::LineTraceLogic()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ATempCharacter::UseItem(class UBaseItem* Item)
|
||||||
|
{
|
||||||
|
if(Item)
|
||||||
|
{
|
||||||
|
Item->Use(this);
|
||||||
|
Item->OnUse(this); //Blueprint Version
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -38,4 +38,8 @@ public:
|
|||||||
|
|
||||||
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category= "Health")
|
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category= "Health")
|
||||||
float Health;
|
float Health;
|
||||||
|
|
||||||
|
//Using the item in the inventory
|
||||||
|
UFUNCTION(BlueprintCallable, Category= "Items")
|
||||||
|
void UseItem(class UBaseItem* Item);
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user