diff --git a/Content/Assets/Sounds/AR/AR_Equip_Cue.uasset b/Content/Assets/Sounds/AR/AR_Equip_Cue.uasset new file mode 100644 index 0000000..236e399 Binary files /dev/null and b/Content/Assets/Sounds/AR/AR_Equip_Cue.uasset differ diff --git a/Content/Assets/Sounds/AR/sw_Wep_AR_Equip_01.uasset b/Content/Assets/Sounds/AR/sw_Wep_AR_Equip_01.uasset new file mode 100644 index 0000000..f227641 Binary files /dev/null and b/Content/Assets/Sounds/AR/sw_Wep_AR_Equip_01.uasset differ diff --git a/Content/Assets/Sounds/AR/sw_Wep_AR_Equip_02.uasset b/Content/Assets/Sounds/AR/sw_Wep_AR_Equip_02.uasset new file mode 100644 index 0000000..237e683 Binary files /dev/null and b/Content/Assets/Sounds/AR/sw_Wep_AR_Equip_02.uasset differ diff --git a/Content/Assets/Sounds/AR/sw_Wep_AR_Equip_03.uasset b/Content/Assets/Sounds/AR/sw_Wep_AR_Equip_03.uasset new file mode 100644 index 0000000..6ac599b Binary files /dev/null and b/Content/Assets/Sounds/AR/sw_Wep_AR_Equip_03.uasset differ diff --git a/Content/Blueprints/Pickups/BP_ARAmmo.uasset b/Content/Blueprints/Pickups/BP_ARAmmo.uasset new file mode 100644 index 0000000..fbb2868 Binary files /dev/null and b/Content/Blueprints/Pickups/BP_ARAmmo.uasset differ diff --git a/Content/Blueprints/Pickups/BP_GrenadeLauncherAmmo.uasset b/Content/Blueprints/Pickups/BP_GrenadeLauncherAmmo.uasset new file mode 100644 index 0000000..f9d176b Binary files /dev/null and b/Content/Blueprints/Pickups/BP_GrenadeLauncherAmmo.uasset differ diff --git a/Content/Blueprints/Pickups/BP_Pickup.uasset b/Content/Blueprints/Pickups/BP_Pickup.uasset index dbee46e..25319c0 100644 Binary files a/Content/Blueprints/Pickups/BP_Pickup.uasset and b/Content/Blueprints/Pickups/BP_Pickup.uasset differ diff --git a/Content/Blueprints/Pickups/BP_PistolAmmo.uasset b/Content/Blueprints/Pickups/BP_PistolAmmo.uasset new file mode 100644 index 0000000..37aec5f Binary files /dev/null and b/Content/Blueprints/Pickups/BP_PistolAmmo.uasset differ diff --git a/Content/Blueprints/Pickups/BP_RocketAmmo.uasset b/Content/Blueprints/Pickups/BP_RocketAmmo.uasset new file mode 100644 index 0000000..0ac9ace Binary files /dev/null and b/Content/Blueprints/Pickups/BP_RocketAmmo.uasset differ diff --git a/Content/Blueprints/Pickups/BP_SMGAmmo.uasset b/Content/Blueprints/Pickups/BP_SMGAmmo.uasset new file mode 100644 index 0000000..bf3d54a Binary files /dev/null and b/Content/Blueprints/Pickups/BP_SMGAmmo.uasset differ diff --git a/Content/Blueprints/Pickups/BP_ShotgunAmmo.uasset b/Content/Blueprints/Pickups/BP_ShotgunAmmo.uasset new file mode 100644 index 0000000..fe213ac Binary files /dev/null and b/Content/Blueprints/Pickups/BP_ShotgunAmmo.uasset differ diff --git a/Content/Blueprints/Pickups/BP_SniperAmmo.uasset b/Content/Blueprints/Pickups/BP_SniperAmmo.uasset new file mode 100644 index 0000000..0823f59 Binary files /dev/null and b/Content/Blueprints/Pickups/BP_SniperAmmo.uasset differ diff --git a/Content/Blueprints/Weapon/BP_SubmachineGun.uasset b/Content/Blueprints/Weapon/BP_SubmachineGun.uasset index 56ee940..b221452 100644 Binary files a/Content/Blueprints/Weapon/BP_SubmachineGun.uasset and b/Content/Blueprints/Weapon/BP_SubmachineGun.uasset differ diff --git a/Content/Maps/BlasterMap.umap b/Content/Maps/BlasterMap.umap index d73b8b8..23a92ae 100644 Binary files a/Content/Maps/BlasterMap.umap and b/Content/Maps/BlasterMap.umap differ diff --git a/Source/Blaster/Components/CombatComponent.cpp b/Source/Blaster/Components/CombatComponent.cpp index a64e32a..8e9aeb9 100644 --- a/Source/Blaster/Components/CombatComponent.cpp +++ b/Source/Blaster/Components/CombatComponent.cpp @@ -31,6 +31,19 @@ void UCombatComponent::GetLifetimeReplicatedProps(TArray& Out DOREPLIFETIME(UCombatComponent, Grenades); } +void UCombatComponent::PickupAmmo(EWeaponType WeaponType, int32 AmmoAmount) +{ + if (CarriedAmmoMap.Contains(WeaponType)) + { + CarriedAmmoMap[WeaponType] = FMath::Clamp(CarriedAmmoMap[WeaponType] + AmmoAmount, 0, MaxCarriedAmmo); + UpdateCarriedAmmo(); + } + if (EquippedWeapon && EquippedWeapon->IsEmpty() && EquippedWeapon->GetWeaponType() == WeaponType) + { + Reload(); + } +} + void UCombatComponent::BeginPlay() { Super::BeginPlay(); diff --git a/Source/Blaster/Components/CombatComponent.h b/Source/Blaster/Components/CombatComponent.h index dda632e..a023908 100644 --- a/Source/Blaster/Components/CombatComponent.h +++ b/Source/Blaster/Components/CombatComponent.h @@ -44,6 +44,8 @@ public: void ServerLaunchGrenade(const FVector_NetQuantize& Target); FORCEINLINE int32 GetGrenades() const { return Grenades; } + + void PickupAmmo(EWeaponType WeaponType, int32 AmmoAmount); protected: virtual void BeginPlay() override; @@ -151,6 +153,9 @@ private: TMap CarriedAmmoMap; + UPROPERTY(EditAnywhere) + int32 MaxCarriedAmmo = 500; + UPROPERTY(EditAnywhere) int32 StartingARAmmo = 30; diff --git a/Source/Blaster/Pickups/AmmoPickup.cpp b/Source/Blaster/Pickups/AmmoPickup.cpp new file mode 100644 index 0000000..4dedbdb --- /dev/null +++ b/Source/Blaster/Pickups/AmmoPickup.cpp @@ -0,0 +1,27 @@ +// Fill out your copyright notice in the Description page of Project Settings. + + +#include "AmmoPickup.h" + +#include "Blaster/Character/BlasterCharacter.h" +#include "Blaster/Components/CombatComponent.h" + +void AAmmoPickup::OnSphereOverlap(UPrimitiveComponent* OverlappedComponent, AActor* OtherActor, UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, + bool bFromSweep, const FHitResult& SweepResult) +{ + UE_LOG(LogTemp, Warning, TEXT("AmmoPickup Overlap")); + + Super::OnSphereOverlap(OverlappedComponent, OtherActor, OtherComp, OtherBodyIndex, bFromSweep, SweepResult); + + ABlasterCharacter* BlasterCharacter = Cast(OtherActor); + if (BlasterCharacter) + { + UCombatComponent* Combat = BlasterCharacter->GetCombat(); + if (Combat) + { + Combat->PickupAmmo(WeaponType, AmmoAmount); + } + } + + Destroy(); +} diff --git a/Source/Blaster/Pickups/AmmoPickup.h b/Source/Blaster/Pickups/AmmoPickup.h new file mode 100644 index 0000000..cb230c4 --- /dev/null +++ b/Source/Blaster/Pickups/AmmoPickup.h @@ -0,0 +1,35 @@ +// Fill out your copyright notice in the Description page of Project Settings. + +#pragma once + +#include "CoreMinimal.h" +#include "Pickup.h" +#include "Blaster/Weapon/WeaponTypes.h" +#include "AmmoPickup.generated.h" + +/** + * + */ +UCLASS() +class BLASTER_API AAmmoPickup : public APickup +{ + GENERATED_BODY() + +protected: + virtual void OnSphereOverlap( + UPrimitiveComponent* OverlappedComponent, + AActor* OtherActor, + UPrimitiveComponent* OtherComp, + int32 OtherBodyIndex, + bool bFromSweep, + const FHitResult& SweepResult + ); + +private: + UPROPERTY(EditAnywhere) + int32 AmmoAmount = 30; + + UPROPERTY(EditAnywhere) + EWeaponType WeaponType; + +}; diff --git a/Source/Blaster/Pickups/Pickup.cpp b/Source/Blaster/Pickups/Pickup.cpp index 7e6ce1f..6d765d7 100644 --- a/Source/Blaster/Pickups/Pickup.cpp +++ b/Source/Blaster/Pickups/Pickup.cpp @@ -3,6 +3,7 @@ #include "Pickup.h" +#include "Blaster/Weapon/WeaponTypes.h" #include "Components/SphereComponent.h" #include "Kismet/GameplayStatics.h" #include "Sound/SoundCue.h" @@ -20,10 +21,14 @@ APickup::APickup() OverlapSphere->SetCollisionEnabled(ECollisionEnabled::QueryOnly); OverlapSphere->SetCollisionResponseToAllChannels(ECollisionResponse::ECR_Ignore); OverlapSphere->SetCollisionResponseToChannel(ECollisionChannel::ECC_Pawn, ECollisionResponse::ECR_Overlap); + OverlapSphere->AddLocalOffset(FVector(0.f, 0.f, 85.f)); PickupMesh = CreateDefaultSubobject(TEXT("PickupMesh")); PickupMesh->SetupAttachment(OverlapSphere); PickupMesh->SetCollisionEnabled(ECollisionEnabled::NoCollision); + PickupMesh->SetRelativeScale3D(FVector(5.f, 5.f, 5.f)); + PickupMesh->SetRenderCustomDepth(true); + PickupMesh->SetCustomDepthStencilValue(CUSTOM_DEPTH_PURPLE); } void APickup::BeginPlay() @@ -39,13 +44,17 @@ void APickup::BeginPlay() void APickup::OnSphereOverlap(UPrimitiveComponent* OverlappedComponent, AActor* OtherActor, UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult& SweepResult) { - + UE_LOG(LogTemp, Warning, TEXT("Pickup Overlap")); } void APickup::Tick(float DeltaTime) { Super::Tick(DeltaTime); + if (PickupMesh) + { + PickupMesh->AddWorldRotation(FRotator(0.f, BaseTurnRate * DeltaTime, 0.f)); + } } void APickup::Destroyed() diff --git a/Source/Blaster/Pickups/Pickup.h b/Source/Blaster/Pickups/Pickup.h index ffda03c..12775d2 100644 --- a/Source/Blaster/Pickups/Pickup.h +++ b/Source/Blaster/Pickups/Pickup.h @@ -29,6 +29,9 @@ protected: const FHitResult& SweepResult ); + UPROPERTY(EditAnywhere) + float BaseTurnRate = 45.f; + private: UPROPERTY(EditAnywhere) class USphereComponent* OverlapSphere;