Merge pull request #35 from Games-Academy-Student-Work-22-23/implimenting-miningcrystals
Implimenting miningcrystals
This commit is contained in:
		
						commit
						8a68ac5213
					
				
							
								
								
									
										
											BIN
										
									
								
								Content/Blueprints/Items/ItemsInWorld/BP_Azos.uasset
									 (Stored with Git LFS)
									
									
									
									
								
							
							
						
						
									
										
											BIN
										
									
								
								Content/Blueprints/Items/ItemsInWorld/BP_Azos.uasset
									 (Stored with Git LFS)
									
									
									
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								Content/Blueprints/Items/ItemsInWorld/BP_Eis.uasset
									 (Stored with Git LFS)
									
									
									
									
								
							
							
						
						
									
										
											BIN
										
									
								
								Content/Blueprints/Items/ItemsInWorld/BP_Eis.uasset
									 (Stored with Git LFS)
									
									
									
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								Content/Blueprints/Items/ItemsInWorld/BP_Iroquoid.uasset
									 (Stored with Git LFS)
									
									
									
									
								
							
							
						
						
									
										
											BIN
										
									
								
								Content/Blueprints/Items/ItemsInWorld/BP_Iroquoid.uasset
									 (Stored with Git LFS)
									
									
									
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								Content/Blueprints/Items/ItemsInWorld/BP_Probertium.uasset
									 (Stored with Git LFS)
									
									
									
									
								
							
							
						
						
									
										
											BIN
										
									
								
								Content/Blueprints/Items/ItemsInWorld/BP_Probertium.uasset
									 (Stored with Git LFS)
									
									
									
									
								
							
										
											Binary file not shown.
										
									
								
							| @ -26,7 +26,6 @@ ATempCharacter::ATempCharacter() | ||||
| void ATempCharacter::BeginPlay() | ||||
| { | ||||
| 	Super::BeginPlay(); | ||||
| 
 | ||||
| 	FirstPlayerController = GetWorld()->GetFirstPlayerController(); | ||||
| 	CombatSystem = Cast<ATurnBaseCombatV2>(GetWorld()->GetGameState()); | ||||
| 	WidgetPointer = Cast<UWidgetInteractionComponent>(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<UCameraComponent>(this->FindComponentByClass<UCameraComponent>()); | ||||
| 	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<UInventoryComponent>()) | ||||
| 		{ | ||||
| 			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<UInventoryComponent>()) | ||||
| 	{ | ||||
| 		UE_LOG(LogTemp, Display, TEXT("Hit Merchant")); | ||||
| 		auto ItemArray = OutHit.GetActor()->FindComponentByClass<UInventoryComponent>()->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
 | ||||
|  | ||||
| @ -128,5 +128,11 @@ public: | ||||
| 	UPROPERTY(EditAnywhere, Category= "Widgets") | ||||
| 	TSubclassOf<UUserWidget> CrossHairSub; | ||||
| 
 | ||||
| private: | ||||
| 	 | ||||
| 	UPROPERTY() | ||||
| 	FHitResult OutHit; | ||||
| 
 | ||||
| 	UFUNCTION() | ||||
| 	void AddToInventory(); | ||||
| }; | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user