diff --git a/Content/Blueprints/Items/ItemsInWorld/BP_Azos.uasset b/Content/Blueprints/Items/ItemsInWorld/BP_Azos.uasset index b258efa..143e77a 100644 --- a/Content/Blueprints/Items/ItemsInWorld/BP_Azos.uasset +++ b/Content/Blueprints/Items/ItemsInWorld/BP_Azos.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:0bbd54a7ea6d9bb800d06bf1534e9c2c34d573df79b09621984714de201fa9f7 -size 32219 +oid sha256:9e4a5a27055688ae5dd4677261d21d5fca582bf3ab9e51db438164de8a48aebb +size 29367 diff --git a/Content/Blueprints/Items/ItemsInWorld/BP_Eis.uasset b/Content/Blueprints/Items/ItemsInWorld/BP_Eis.uasset index 2c22049..69e0b03 100644 --- a/Content/Blueprints/Items/ItemsInWorld/BP_Eis.uasset +++ b/Content/Blueprints/Items/ItemsInWorld/BP_Eis.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:40b1b3aba3e44f2ae79359b14e31f68e79ca1dd18de2737374f36c4c6d9711b4 -size 31932 +oid sha256:abd42ce36414c2273ef4f2a220b0923a01c019c6d6d3c725c3750fb2ed82a9b7 +size 30253 diff --git a/Content/Blueprints/Items/ItemsInWorld/BP_Iroquoid.uasset b/Content/Blueprints/Items/ItemsInWorld/BP_Iroquoid.uasset index 38cdd02..4e91987 100644 --- a/Content/Blueprints/Items/ItemsInWorld/BP_Iroquoid.uasset +++ b/Content/Blueprints/Items/ItemsInWorld/BP_Iroquoid.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:8978cc1273cc732a6c994b47f40eec7facd06989723ee169bca4f3be98a9aeed -size 32668 +oid sha256:22c938e0f7c03dff887dcfdeb66b9b17a6abf0623f7ae0b95e2a10779b8240d2 +size 29472 diff --git a/Content/Blueprints/Items/ItemsInWorld/BP_Probertium.uasset b/Content/Blueprints/Items/ItemsInWorld/BP_Probertium.uasset index a83b723..20b25f2 100644 --- a/Content/Blueprints/Items/ItemsInWorld/BP_Probertium.uasset +++ b/Content/Blueprints/Items/ItemsInWorld/BP_Probertium.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:0134465b90f3930c3f007072f3d6f10aec678577f2d00ed32858d0d3aa0b3f5e -size 32046 +oid sha256:89ac9fd992de872aa3c69bd388f455780a3c6e59ad3c64bcc4a35912eabc86a8 +size 29350 diff --git a/Source/the_twilight_abyss/PlayerTemp/TempCharacter.cpp b/Source/the_twilight_abyss/PlayerTemp/TempCharacter.cpp index 644df2d..e358e9e 100644 --- a/Source/the_twilight_abyss/PlayerTemp/TempCharacter.cpp +++ b/Source/the_twilight_abyss/PlayerTemp/TempCharacter.cpp @@ -26,7 +26,6 @@ ATempCharacter::ATempCharacter() void ATempCharacter::BeginPlay() { Super::BeginPlay(); - FirstPlayerController = GetWorld()->GetFirstPlayerController(); CombatSystem = Cast(GetWorld()->GetGameState()); WidgetPointer = Cast(this->GetComponentByClass(UWidgetInteractionComponent::StaticClass())); @@ -136,22 +135,38 @@ void ATempCharacter::LineTraceLogic() { //UE_LOG(LogTemp, Display, TEXT("LineTraceLogic activated")); float GlobalTrace = TraceDistance; - FHitResult OutHit; ThisCamera = Cast(this->FindComponentByClass()); FVector Start = ThisCamera->GetComponentLocation(); FVector End = Start + GlobalTrace * ThisCamera->GetForwardVector(); FCollisionQueryParams TraceParams; TraceParams.AddIgnoredActor(this); - bHit = GetWorld()->LineTraceSingleByChannel(OutHit, Start, End, ECC_Pawn, TraceParams); if (bHit) { - //we store the GetItem function from InventoryComponent into ItemArray variable - if (OutHit.GetActor() == nullptr) { return; } + if(OutHit.GetActor()->ActorHasTag(TEXT("Probertium"))) + { + AddToInventory(); + return; + } + if(OutHit.GetActor()->ActorHasTag(TEXT("Iroquid"))) + { + AddToInventory(); + return; + } + if (OutHit.GetActor()->ActorHasTag(TEXT("Azos"))) + { + AddToInventory(); + return; + } + if (OutHit.GetActor()->ActorHasTag(TEXT("Eis"))) + { + AddToInventory(); + return; + } if (OutHit.GetActor()->FindComponentByClass()) { UE_LOG(LogTemp, Display, TEXT("Hit Merchant")); @@ -166,10 +181,6 @@ void ATempCharacter::LineTraceLogic() { UE_LOG(LogTemp, Display, TEXT("Not Enough Gold")); } - if (OutHit.GetActor()->ActorHasTag(Ammo)) - { - OutHit.GetActor()->Destroy(); - } } // if the actor hit has the interaction component/script then it will activate the code @@ -210,6 +221,26 @@ void ATempCharacter::LineTraceLogic() } } +void ATempCharacter::AddToInventory() +{ + if (OutHit.GetActor()->FindComponentByClass()) + { + UE_LOG(LogTemp, Display, TEXT("Hit Merchant")); + auto ItemArray = OutHit.GetActor()->FindComponentByClass()->GetItem(0); + if (GoldBalance >= ItemArray->ItemCostPrice) + { + GoldBalance -= ItemArray->ItemCostPrice; + Inventory->AddItem(ItemArray); + UE_LOG(LogTemp, Display, TEXT("Item Purchased")); + } + if (GoldBalance <= 0) + { + UE_LOG(LogTemp, Display, TEXT("Not Enough Gold")); + } + OutHit.GetActor()->Destroy(); + } +} + void ATempCharacter::InputDisabler() { //Disable Character Movement diff --git a/Source/the_twilight_abyss/PlayerTemp/TempCharacter.h b/Source/the_twilight_abyss/PlayerTemp/TempCharacter.h index eaf8e2c..1a8b284 100644 --- a/Source/the_twilight_abyss/PlayerTemp/TempCharacter.h +++ b/Source/the_twilight_abyss/PlayerTemp/TempCharacter.h @@ -128,5 +128,11 @@ public: UPROPERTY(EditAnywhere, Category= "Widgets") TSubclassOf CrossHairSub; +private: + UPROPERTY() + FHitResult OutHit; + + UFUNCTION() + void AddToInventory(); };