Merge remote-tracking branch 'origin/add-weapon'
# Conflicts: # Binaries/Win64/UnrealEditor-LegumeMix.exp # Binaries/Win64/UnrealEditor-LegumeMix.pdb # Content/Legumix/Player/BP_Player.uasset
This commit is contained in:
commit
28dbc8c95e
@ -21,6 +21,18 @@
|
||||
"BuildId": "37670630"
|
||||
},
|
||||
"BuildProducts": [
|
||||
{
|
||||
"Path": "$(ProjectDir)/Binaries/Win64/UnrealEditor-LegumeMix.dll",
|
||||
"Type": "DynamicLibrary"
|
||||
},
|
||||
{
|
||||
"Path": "$(ProjectDir)/Binaries/Win64/UnrealEditor-LegumeMix.pdb",
|
||||
"Type": "SymbolFile"
|
||||
},
|
||||
{
|
||||
"Path": "$(ProjectDir)/Binaries/Win64/UnrealEditor.modules",
|
||||
"Type": "RequiredResource"
|
||||
},
|
||||
{
|
||||
"Path": "$(EngineDir)/Binaries/ThirdParty/USD/UsdResources/Win64/plugins/ar/resources/plugInfo.json",
|
||||
"Type": "RequiredResource"
|
||||
@ -4804,21 +4816,13 @@
|
||||
{
|
||||
"Path": "$(EngineDir)/Plugins/XGEController/Binaries/Win64/UnrealEditor.modules",
|
||||
"Type": "RequiredResource"
|
||||
},
|
||||
{
|
||||
"Path": "$(ProjectDir)/Binaries/Win64/UnrealEditor-LegumeMix.dll",
|
||||
"Type": "DynamicLibrary"
|
||||
},
|
||||
{
|
||||
"Path": "$(ProjectDir)/Binaries/Win64/UnrealEditor-LegumeMix.pdb",
|
||||
"Type": "SymbolFile"
|
||||
},
|
||||
{
|
||||
"Path": "$(ProjectDir)/Binaries/Win64/UnrealEditor.modules",
|
||||
"Type": "RequiredResource"
|
||||
}
|
||||
],
|
||||
"RuntimeDependencies": [
|
||||
{
|
||||
"Path": "$(ProjectDir)/LegumeMix.uproject",
|
||||
"Type": "UFS"
|
||||
},
|
||||
{
|
||||
"Path": "$(EngineDir)/Binaries/ThirdParty/DbgHelp/dbghelp.dll",
|
||||
"Type": "NonUFS"
|
||||
@ -30542,10 +30546,6 @@
|
||||
{
|
||||
"Path": "$(EngineDir)/Plugins/XGEController/XGEController.uplugin",
|
||||
"Type": "UFS"
|
||||
},
|
||||
{
|
||||
"Path": "$(ProjectDir)/LegumeMix.uproject",
|
||||
"Type": "UFS"
|
||||
}
|
||||
],
|
||||
"BuildPlugins": [
|
||||
|
BIN
Binaries/Win64/UnrealEditor-LegumeMix.exp
(Stored with Git LFS)
BIN
Binaries/Win64/UnrealEditor-LegumeMix.exp
(Stored with Git LFS)
Binary file not shown.
@ -1,3 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:fae58fec73ac589dda932e97a46512579fbd2a0c6d34b3ce1be250f0b29def6c
|
||||
size 60215296
|
||||
oid sha256:bfcad27449bf4813b3c20458b70d67afde0d17f6abcb3d968291708b64a76bd6
|
||||
size 60657664
|
||||
|
@ -1,7 +1,7 @@
|
||||
|
||||
|
||||
[/Script/EngineSettings.GameMapsSettings]
|
||||
GameDefaultMap=/Engine/Maps/Templates/OpenWorld
|
||||
GameDefaultMap=/Engine/Maps/Templates/OpenWorld.OpenWorld
|
||||
GlobalDefaultGameMode=/Game/Legumix/BP_GameMode.BP_GameMode_C
|
||||
|
||||
[/Script/Engine.RendererSettings]
|
||||
|
BIN
Content/Legumix/BP_GameMode.uasset
(Stored with Git LFS)
BIN
Content/Legumix/BP_GameMode.uasset
(Stored with Git LFS)
Binary file not shown.
BIN
Content/Legumix/Player/BP_Player.uasset
(Stored with Git LFS)
BIN
Content/Legumix/Player/BP_Player.uasset
(Stored with Git LFS)
Binary file not shown.
BIN
Content/Legumix/Player/BP_PlayerController.uasset
(Stored with Git LFS)
BIN
Content/Legumix/Player/BP_PlayerController.uasset
(Stored with Git LFS)
Binary file not shown.
BIN
Content/Legumix/Player/Input/IA_Reload.uasset
(Stored with Git LFS)
Normal file
BIN
Content/Legumix/Player/Input/IA_Reload.uasset
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
Content/Legumix/Player/Input/IA_Scroll.uasset
(Stored with Git LFS)
Normal file
BIN
Content/Legumix/Player/Input/IA_Scroll.uasset
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
Content/Legumix/Player/Input/IMC_Default.uasset
(Stored with Git LFS)
BIN
Content/Legumix/Player/Input/IMC_Default.uasset
(Stored with Git LFS)
Binary file not shown.
BIN
Content/Legumix/Weapon/BP_Ammo.uasset
(Stored with Git LFS)
Normal file
BIN
Content/Legumix/Weapon/BP_Ammo.uasset
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
Content/Legumix/Weapon/BP_Bazoucorn.uasset
(Stored with Git LFS)
Normal file
BIN
Content/Legumix/Weapon/BP_Bazoucorn.uasset
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
Content/Legumix/Weapon/BP_Radivolver.uasset
(Stored with Git LFS)
Normal file
BIN
Content/Legumix/Weapon/BP_Radivolver.uasset
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
Content/Legumix/Weapon/BP_WeaponManager.uasset
(Stored with Git LFS)
Normal file
BIN
Content/Legumix/Weapon/BP_WeaponManager.uasset
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
Content/Legumix/Weapon/DT_WeaponData.uasset
(Stored with Git LFS)
Normal file
BIN
Content/Legumix/Weapon/DT_WeaponData.uasset
(Stored with Git LFS)
Normal file
Binary file not shown.
@ -21,5 +21,8 @@
|
||||
"Editor"
|
||||
]
|
||||
}
|
||||
],
|
||||
"TargetPlatforms": [
|
||||
"Windows"
|
||||
]
|
||||
}
|
5
Source/LegumeMix/Private/LMGameMode.cpp
Normal file
5
Source/LegumeMix/Private/LMGameMode.cpp
Normal file
@ -0,0 +1,5 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
|
||||
#include "LMGameMode.h"
|
||||
|
@ -3,12 +3,22 @@
|
||||
|
||||
#include "Player/LMPlayer.h"
|
||||
|
||||
// Sets default values
|
||||
#include "Camera/CameraComponent.h"
|
||||
#include "Weapon/LMAmmo.h"
|
||||
#include "Weapon/LMWeaponManager.h"
|
||||
|
||||
ALMPlayer::ALMPlayer()
|
||||
{
|
||||
// Set this character to call Tick() every frame. You can turn this off to improve performance if you don't need it.
|
||||
PrimaryActorTick.bCanEverTick = true;
|
||||
|
||||
Camera = CreateDefaultSubobject<UCameraComponent>(TEXT("Camera"));
|
||||
Camera->SetupAttachment(RootComponent);
|
||||
Camera->bUsePawnControlRotation = true;
|
||||
Camera->SetRelativeLocation(FVector(20, 0, 90));
|
||||
|
||||
WeaponSkeletalMeshComponent = CreateDefaultSubobject<USkeletalMeshComponent>(TEXT("Weapon Mesh"));
|
||||
WeaponSkeletalMeshComponent->SetupAttachment(Camera);
|
||||
}
|
||||
|
||||
// Called when the game starts or when spawned
|
||||
@ -18,11 +28,33 @@ void ALMPlayer::BeginPlay()
|
||||
|
||||
}
|
||||
|
||||
void ALMPlayer::PickUpAmmo(ALMAmmo* Ammo)
|
||||
{
|
||||
if (GEngine)
|
||||
{
|
||||
FString AmmoAmount = FString::Printf(TEXT("Quantité de munition : %i"), Ammo->GetAmmoAmount());
|
||||
GEngine->AddOnScreenDebugMessage(1, 30.f, FColor::Red, AmmoAmount);
|
||||
}
|
||||
WeaponManager->AddAmmoType(Ammo->GetAmmoType(), Ammo->GetAmmoAmount());
|
||||
}
|
||||
|
||||
void ALMPlayer::SetWeaponManager(ULMWeaponManager* Manager)
|
||||
{
|
||||
UE_LOG(LogTemp, Warning, TEXT("Set weapon manager"))
|
||||
if (!Manager)
|
||||
{
|
||||
GEngine->AddOnScreenDebugMessage(INDEX_NONE, 10.f, FColor::Red, TEXT("No Weapon Manager was given to the player !"));
|
||||
return;
|
||||
}
|
||||
|
||||
WeaponManager = Manager;
|
||||
WeaponManager->Initialize(WeaponSkeletalMeshComponent);
|
||||
}
|
||||
|
||||
// Called every frame
|
||||
void ALMPlayer::Tick(float DeltaTime)
|
||||
{
|
||||
Super::Tick(DeltaTime);
|
||||
|
||||
}
|
||||
|
||||
// Called to bind functionality to input
|
||||
|
@ -5,22 +5,29 @@
|
||||
#include "EnhancedInputSubsystems.h"
|
||||
#include "EnhancedInputComponent.h"
|
||||
#include "GameFramework/Character.h"
|
||||
#include "Player/LMPlayer.h"
|
||||
#include "Weapon/LMWeaponManager.h"
|
||||
|
||||
void ALMPlayerController::BeginPlay()
|
||||
{
|
||||
Super::BeginPlay();
|
||||
EnhancedInputSubsystem = GetLocalPlayer()->GetSubsystem<UEnhancedInputLocalPlayerSubsystem>();
|
||||
EnhancedInputSubsystem->AddMappingContext(DefaultMappingContext, 0);
|
||||
LegumixPlayer = Cast<ACharacter>(GetPawn());
|
||||
LegumixPlayer = Cast<ALMPlayer>(GetPawn());
|
||||
}
|
||||
|
||||
void ALMPlayerController::SetupInputComponent()
|
||||
{
|
||||
Super::SetupInputComponent();
|
||||
UEnhancedInputComponent* Input = Cast<UEnhancedInputComponent>(InputComponent);
|
||||
Input->BindAction(MoveAction, ETriggerEvent::Triggered, this, &ALMPlayerController::Move);
|
||||
Input->BindAction(JumpAction, ETriggerEvent::Triggered, this, &ALMPlayerController::Jump);
|
||||
Input->BindAction(LookAction, ETriggerEvent::Triggered, this, &ALMPlayerController::Look);
|
||||
if(UEnhancedInputComponent* Input = Cast<UEnhancedInputComponent>(InputComponent))
|
||||
{
|
||||
Input->BindAction(MoveAction, ETriggerEvent::Triggered, this, &ALMPlayerController::Move);
|
||||
Input->BindAction(JumpAction, ETriggerEvent::Triggered, this, &ALMPlayerController::Jump);
|
||||
Input->BindAction(LookAction, ETriggerEvent::Triggered, this, &ALMPlayerController::Look);
|
||||
Input->BindAction(FireAction, ETriggerEvent::Triggered, this, &ALMPlayerController::Fire);
|
||||
Input->BindAction(ReloadAction, ETriggerEvent::Triggered, this, &ALMPlayerController::Reload);
|
||||
Input->BindAction(ScrollAction, ETriggerEvent::Triggered, this, &ALMPlayerController::Scroll);
|
||||
}
|
||||
}
|
||||
|
||||
void ALMPlayerController::Move(const FInputActionValue& InputValue)
|
||||
@ -40,4 +47,20 @@ void ALMPlayerController::Look(const FInputActionValue& InputValue)
|
||||
const FVector2d VectorDirection = InputValue.Get<FVector2d>();
|
||||
AddYawInput(VectorDirection.X);
|
||||
AddPitchInput(VectorDirection.Y);
|
||||
}
|
||||
}
|
||||
|
||||
void ALMPlayerController::Fire(const FInputActionValue& InputValue)
|
||||
{
|
||||
LegumixPlayer->GetWeaponManager()->Fire();
|
||||
}
|
||||
|
||||
void ALMPlayerController::Reload(const FInputActionValue& InputValue)
|
||||
{
|
||||
LegumixPlayer->GetWeaponManager()->Reload();
|
||||
}
|
||||
|
||||
void ALMPlayerController::Scroll(const FInputActionValue& InputValue)
|
||||
{
|
||||
const float ScrollAmount = InputValue.Get<float>();
|
||||
LegumixPlayer->GetWeaponManager()->SwitchWeapon(ScrollAmount);
|
||||
}
|
||||
|
43
Source/LegumeMix/Private/Weapon/LMAmmo.cpp
Normal file
43
Source/LegumeMix/Private/Weapon/LMAmmo.cpp
Normal file
@ -0,0 +1,43 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
|
||||
#include "Weapon/LMAmmo.h"
|
||||
|
||||
#include "Components/BoxComponent.h"
|
||||
#include "Components/SphereComponent.h"
|
||||
#include "Player/LMPlayer.h"
|
||||
|
||||
// Sets default values
|
||||
ALMAmmo::ALMAmmo()
|
||||
{
|
||||
PrimaryActorTick.bCanEverTick = true;
|
||||
AmmoMeshComponent = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("AmmoMeshComponent"));
|
||||
RootComponent = AmmoMeshComponent;
|
||||
CollisionSphere = CreateDefaultSubobject<USphereComponent>(TEXT("CollisionSphere"));
|
||||
CollisionSphere->SetupAttachment(RootComponent);
|
||||
CollisionSphere->OnComponentBeginOverlap.AddDynamic(this, &ALMAmmo::OnSphereOverlap);
|
||||
AmmoType = EAmmoType::EAT_RadishAmmo;
|
||||
AmmoAmount = 1;
|
||||
|
||||
}
|
||||
|
||||
void ALMAmmo::BeginPlay()
|
||||
{
|
||||
Super::BeginPlay();
|
||||
}
|
||||
|
||||
void ALMAmmo::OnSphereOverlap(UPrimitiveComponent* OverlappedComponent, AActor* OtherActor,
|
||||
UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult& SweepResult)
|
||||
{
|
||||
if (ALMPlayer* Player = Cast<ALMPlayer>(OtherActor))
|
||||
{
|
||||
Player->PickUpAmmo(this);
|
||||
Destroy();
|
||||
}
|
||||
}
|
||||
|
||||
void ALMAmmo::Tick(float DeltaTime)
|
||||
{
|
||||
Super::Tick(DeltaTime);
|
||||
}
|
||||
|
9
Source/LegumeMix/Private/Weapon/LMBazoucorn.cpp
Normal file
9
Source/LegumeMix/Private/Weapon/LMBazoucorn.cpp
Normal file
@ -0,0 +1,9 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
|
||||
#include "Weapon\LMBazoucorn.h"
|
||||
|
||||
void UBazoucorn::Fire()
|
||||
{
|
||||
//Fire like a Bazoucorn
|
||||
}
|
10
Source/LegumeMix/Private/Weapon/LMRadivolver.cpp
Normal file
10
Source/LegumeMix/Private/Weapon/LMRadivolver.cpp
Normal file
@ -0,0 +1,10 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
|
||||
#include "Weapon/LMRadivolver.h"
|
||||
|
||||
void ULMRadivolver::Fire()
|
||||
{
|
||||
//Fire like a Radivolver
|
||||
}
|
||||
|
59
Source/LegumeMix/Private/Weapon/LMWeapon.cpp
Normal file
59
Source/LegumeMix/Private/Weapon/LMWeapon.cpp
Normal file
@ -0,0 +1,59 @@
|
||||
#include "Weapon/LMWeapon.h"
|
||||
|
||||
#include "Weapon/LMWeaponDataStructure.h"
|
||||
|
||||
void ULMWeapon::Initialize(FVector MeshLocation)
|
||||
{
|
||||
WeaponDataStructure =* WeaponRow.GetRow<FLMWeaponDataStructure>(TEXT(""));
|
||||
|
||||
//Get FVector de la position de l'arme
|
||||
|
||||
}
|
||||
|
||||
bool ULMWeapon::HasAmmoInClip()
|
||||
{
|
||||
if(CurrentClipAmmo > 0)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool ULMWeapon::HasAmmoInInventory()
|
||||
{
|
||||
if (CurrentAmmoInInventory > 0)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void ULMWeapon::Reload()
|
||||
{
|
||||
//Do design reload logic
|
||||
OnReload();
|
||||
if(HasAmmoInClip())
|
||||
{
|
||||
if(CurrentAmmoInInventory >= WeaponDataStructure.MaxClipAmmo)
|
||||
{
|
||||
CurrentClipAmmo = WeaponDataStructure.MaxClipAmmo;
|
||||
CurrentAmmoInInventory -= WeaponDataStructure.MaxClipAmmo;
|
||||
}
|
||||
else
|
||||
{
|
||||
CurrentClipAmmo = CurrentAmmoInInventory;
|
||||
CurrentAmmoInInventory = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ULMWeapon::AddAmmo(int AmountOfAmmoToGet)
|
||||
{
|
||||
CurrentAmmoInInventory += AmountOfAmmoToGet;
|
||||
}
|
||||
|
||||
void ULMWeapon::Fire()
|
||||
{
|
||||
//Fire
|
||||
}
|
||||
|
@ -0,0 +1 @@
|
||||
#include "Weapon/LMWeaponDataStructure.h"
|
103
Source/LegumeMix/Private/Weapon/LMWeaponManager.cpp
Normal file
103
Source/LegumeMix/Private/Weapon/LMWeaponManager.cpp
Normal file
@ -0,0 +1,103 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
|
||||
#include "Weapon/LMWeaponManager.h"
|
||||
|
||||
#include "Weapon/LMWeapon.h"
|
||||
|
||||
|
||||
ULMWeaponManager::ULMWeaponManager()
|
||||
{
|
||||
PrimaryComponentTick.bCanEverTick = false;
|
||||
}
|
||||
|
||||
void ULMWeaponManager::BeginPlay()
|
||||
{
|
||||
Super::BeginPlay();
|
||||
}
|
||||
|
||||
void ULMWeaponManager::Initialize(USkeletalMeshComponent* Mesh)
|
||||
{
|
||||
SetWeaponMeshComponent(Mesh);
|
||||
|
||||
for (auto Weapon : StartingWeapons)
|
||||
{
|
||||
if (Weapon)
|
||||
{
|
||||
ULMWeapon* Instance = NewObject<ULMWeapon>(this, Weapon);
|
||||
Weapons.Add(Instance);
|
||||
|
||||
Instance->Initialize(Mesh->GetRelativeLocation());
|
||||
}
|
||||
}
|
||||
|
||||
if (!Weapons.IsEmpty())
|
||||
{
|
||||
SetWeapon(CurrentWeaponIndex);
|
||||
}
|
||||
}
|
||||
|
||||
void ULMWeaponManager::AddAmmoType(EAmmoType AmmoType, int AmmoCount)
|
||||
{
|
||||
FString Debug = FString::Printf(TEXT("Adding %i ammo of type %i"), AmmoCount, AmmoType);
|
||||
GEngine->AddOnScreenDebugMessage(1, 1.f, FColor::Cyan, Debug);
|
||||
|
||||
for (const auto Weapon : Weapons)
|
||||
{
|
||||
if (Weapon->WeaponDataStructure.AmmoType != AmmoType)
|
||||
continue;
|
||||
|
||||
Weapon->AddAmmo(AmmoCount);
|
||||
}
|
||||
}
|
||||
|
||||
void ULMWeaponManager::Fire()
|
||||
{
|
||||
ULMWeapon* Weapon = GetCurrentWeapon();
|
||||
|
||||
GEngine->AddOnScreenDebugMessage(2, 1.f, FColor::Cyan, "Fire");
|
||||
Weapon->Fire();
|
||||
}
|
||||
|
||||
void ULMWeaponManager::Reload()
|
||||
{
|
||||
GEngine->AddOnScreenDebugMessage(3, 1.f, FColor::Cyan, "Reloading");
|
||||
|
||||
ULMWeapon* Weapon = GetCurrentWeapon();
|
||||
Weapon->Reload();
|
||||
}
|
||||
|
||||
void ULMWeaponManager::SwitchWeapon(const int Direction)
|
||||
{
|
||||
const int NewIndex = Direction + CurrentWeaponIndex;
|
||||
if (NewIndex >= 0 && NewIndex < Weapons.Num())
|
||||
{
|
||||
SetWeapon(NewIndex);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (NewIndex < 0)
|
||||
SetWeapon(Weapons.Num() - 1);
|
||||
else
|
||||
SetWeapon(0);
|
||||
}
|
||||
}
|
||||
|
||||
void ULMWeaponManager::SetWeapon(const int Index)
|
||||
{
|
||||
if (Index < 0 || Index >= Weapons.Num())
|
||||
{
|
||||
GEngine->AddOnScreenDebugMessage(INDEX_NONE, 5, FColor::Red, "Invalid Weapon Index");
|
||||
return;
|
||||
}
|
||||
|
||||
CurrentWeaponIndex = Index;
|
||||
|
||||
if (WeaponMeshComponent)
|
||||
{
|
||||
GEngine->AddOnScreenDebugMessage(INDEX_NONE, 5, FColor::Red, "Has Mesh");
|
||||
|
||||
WeaponMeshComponent->SetSkeletalMeshAsset(GetCurrentWeapon()->WeaponDataStructure.MeshWeapon);
|
||||
}
|
||||
}
|
||||
|
17
Source/LegumeMix/Public/LMGameMode.h
Normal file
17
Source/LegumeMix/Public/LMGameMode.h
Normal file
@ -0,0 +1,17 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "GameFramework/GameModeBase.h"
|
||||
#include "LMGameMode.generated.h"
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
UCLASS()
|
||||
class LEGUMEMIX_API ALMGameMode : public AGameModeBase
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
};
|
@ -6,6 +6,11 @@
|
||||
#include "GameFramework/Character.h"
|
||||
#include "LMPlayer.generated.h"
|
||||
|
||||
class UCameraComponent;
|
||||
class ULMWeaponManager;
|
||||
|
||||
class ALMAmmo;
|
||||
|
||||
UCLASS()
|
||||
class LEGUMEMIX_API ALMPlayer : public ACharacter
|
||||
{
|
||||
@ -14,16 +19,30 @@ class LEGUMEMIX_API ALMPlayer : public ACharacter
|
||||
public:
|
||||
// Sets default values for this character's properties
|
||||
ALMPlayer();
|
||||
virtual void Tick(float DeltaTime) override;
|
||||
virtual void SetupPlayerInputComponent(class UInputComponent* PlayerInputComponent) override;
|
||||
|
||||
UFUNCTION()
|
||||
void PickUpAmmo(ALMAmmo* Ammo);
|
||||
|
||||
protected:
|
||||
// Called when the game starts or when spawned
|
||||
virtual void BeginPlay() override;
|
||||
|
||||
public:
|
||||
// Called every frame
|
||||
virtual void Tick(float DeltaTime) override;
|
||||
UFUNCTION(BlueprintCallable)
|
||||
ULMWeaponManager* GetWeaponManager() { return WeaponManager; }
|
||||
|
||||
// Called to bind functionality to input
|
||||
virtual void SetupPlayerInputComponent(class UInputComponent* PlayerInputComponent) override;
|
||||
UFUNCTION(BlueprintCallable)
|
||||
void SetWeaponManager(ULMWeaponManager* Manager);
|
||||
|
||||
private:
|
||||
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category="Legumix", meta = (AllowPrivateAccess = true))
|
||||
TObjectPtr<ULMWeaponManager> WeaponManager;
|
||||
|
||||
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category="Legumix", meta = (AllowPrivateAccess = true))
|
||||
TObjectPtr<USkeletalMeshComponent> WeaponSkeletalMeshComponent;
|
||||
|
||||
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category="Legumix", meta = (AllowPrivateAccess = true))
|
||||
TObjectPtr<UCameraComponent> Camera;
|
||||
};
|
||||
|
@ -7,6 +7,8 @@
|
||||
#include "EnhancedInputSubsystems.h"
|
||||
#include "LMPlayerController.generated.h"
|
||||
|
||||
class ALMPlayer;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@ -34,11 +36,23 @@ private:
|
||||
UPROPERTY(EditAnywhere, BlueprintReadOnly, meta = (AllowPrivateAccess = true))
|
||||
TObjectPtr<UInputAction> JumpAction;
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadOnly, meta = (AllowPrivateAccess = true))
|
||||
TObjectPtr<UInputAction> FireAction;
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadOnly, meta = (AllowPrivateAccess = true))
|
||||
TObjectPtr<UInputAction> ReloadAction;
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadOnly, meta = (AllowPrivateAccess = true))
|
||||
TObjectPtr<UInputAction> ScrollAction;
|
||||
|
||||
UPROPERTY(BlueprintReadOnly, meta = (AllowPrivateAccess = true))
|
||||
TObjectPtr<ACharacter> LegumixPlayer;
|
||||
TObjectPtr<ALMPlayer> LegumixPlayer;
|
||||
|
||||
virtual void SetupInputComponent() override;
|
||||
void Move(const FInputActionValue& InputValue);
|
||||
void Jump(const FInputActionValue& InputValue);
|
||||
void Look(const FInputActionValue& InputValue);
|
||||
void Fire(const FInputActionValue& InputValue);
|
||||
void Reload(const FInputActionValue& InputValue);
|
||||
void Scroll(const FInputActionValue& InputValue);
|
||||
};
|
||||
|
50
Source/LegumeMix/Public/Weapon/LMAmmo.h
Normal file
50
Source/LegumeMix/Public/Weapon/LMAmmo.h
Normal file
@ -0,0 +1,50 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "GameFramework/Actor.h"
|
||||
#include "LMAmmo.generated.h"
|
||||
|
||||
class USphereComponent;
|
||||
|
||||
UENUM(BlueprintType)
|
||||
enum class EAmmoType : uint8
|
||||
{
|
||||
EAT_RadishAmmo UMETA(DisplayName = "Radish Ammo"),
|
||||
EAT_CornAmmo UMETA(DisplayName = "Corn Ammo")
|
||||
};
|
||||
|
||||
UCLASS()
|
||||
class LEGUMEMIX_API ALMAmmo : public AActor
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
ALMAmmo();
|
||||
virtual void Tick(float DeltaTime) override;
|
||||
|
||||
UFUNCTION(BlueprintCallable)
|
||||
inline int GetAmmoAmount() { return AmmoAmount; }
|
||||
|
||||
UFUNCTION(BlueprintCallable)
|
||||
inline EAmmoType GetAmmoType() { return AmmoType; }
|
||||
|
||||
protected:
|
||||
virtual void BeginPlay() override;
|
||||
|
||||
UPROPERTY(EditAnywhere)
|
||||
TObjectPtr<UStaticMeshComponent> AmmoMeshComponent;
|
||||
|
||||
UPROPERTY(EditAnywhere)
|
||||
TObjectPtr<USphereComponent> CollisionSphere;
|
||||
|
||||
UPROPERTY(EditAnywhere)
|
||||
EAmmoType AmmoType;
|
||||
|
||||
UPROPERTY(EditAnywhere)
|
||||
int AmmoAmount;
|
||||
|
||||
UFUNCTION(BlueprintCallable)
|
||||
void OnSphereOverlap(UPrimitiveComponent* OverlappedComponent, AActor* OtherActor, UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult& SweepResult);
|
||||
};
|
17
Source/LegumeMix/Public/Weapon/LMBazoucorn.h
Normal file
17
Source/LegumeMix/Public/Weapon/LMBazoucorn.h
Normal file
@ -0,0 +1,17 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "LMWeapon.h"
|
||||
#include "LMBazoucorn.generated.h"
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
UCLASS(BlueprintType, Blueprintable)
|
||||
class LEGUMEMIX_API UBazoucorn : public ULMWeapon
|
||||
{
|
||||
GENERATED_BODY()
|
||||
virtual void Fire() override;
|
||||
};
|
17
Source/LegumeMix/Public/Weapon/LMRadivolver.h
Normal file
17
Source/LegumeMix/Public/Weapon/LMRadivolver.h
Normal file
@ -0,0 +1,17 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "LMWeapon.h"
|
||||
#include "LMRadivolver.generated.h"
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
UCLASS(BlueprintType, Blueprintable)
|
||||
class LEGUMEMIX_API ULMRadivolver : public ULMWeapon
|
||||
{
|
||||
GENERATED_BODY()
|
||||
virtual void Fire() override;
|
||||
};
|
40
Source/LegumeMix/Public/Weapon/LMWeapon.h
Normal file
40
Source/LegumeMix/Public/Weapon/LMWeapon.h
Normal file
@ -0,0 +1,40 @@
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "LMWeaponDataStructure.h"
|
||||
#include "LMWeapon.generated.h"
|
||||
|
||||
struct FLMWeaponDataStructure;
|
||||
|
||||
UCLASS(BlueprintType, Blueprintable)
|
||||
class LEGUMEMIX_API ULMWeapon : public UObject
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
|
||||
UPROPERTY()
|
||||
FLMWeaponDataStructure WeaponDataStructure;
|
||||
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Legumix")
|
||||
FDataTableRowHandle WeaponRow;
|
||||
|
||||
UPROPERTY()
|
||||
int CurrentClipAmmo;
|
||||
|
||||
UPROPERTY()
|
||||
int CurrentAmmoInInventory;
|
||||
|
||||
void Initialize(FVector MeshLocation);
|
||||
|
||||
virtual void Fire();
|
||||
|
||||
UFUNCTION(BlueprintCallable)
|
||||
void Reload(); //Reload current clip to max ammo in clip
|
||||
UFUNCTION(BlueprintCallable, BlueprintImplementableEvent)
|
||||
void OnReload(); //To call in blueprint for design utilities
|
||||
|
||||
void AddAmmo(int AmountOfAmmoToGet); //Add ammo in inventory
|
||||
|
||||
bool HasAmmoInClip(); //Check if there is ammo in clip (return a bool)
|
||||
bool HasAmmoInInventory(); //Check if there is ammo in "inventory" (return a bool)
|
||||
};
|
25
Source/LegumeMix/Public/Weapon/LMWeaponDataStructure.h
Normal file
25
Source/LegumeMix/Public/Weapon/LMWeaponDataStructure.h
Normal file
@ -0,0 +1,25 @@
|
||||
#pragma once
|
||||
|
||||
#include "LMAmmo.h"
|
||||
#include "LMWeaponDataStructure.generated.h"
|
||||
|
||||
USTRUCT(BlueprintType)
|
||||
struct FLMWeaponDataStructure : public FTableRowBase
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite)
|
||||
int MaxAmmo; // Max ammo in "inventory"
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite)
|
||||
int MaxClipAmmo; // Max ammo in clip
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite)
|
||||
TObjectPtr<USkeletalMesh> MeshWeapon; //Mesh of the weapon display in the scene
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite)
|
||||
EAmmoType AmmoType; //Type of ammo, which ammo this weapon is using
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite)
|
||||
TObjectPtr<UAnimBlueprint> AnimationBluePrint; //The animation blueprint to animate the mesh
|
||||
};
|
61
Source/LegumeMix/Public/Weapon/LMWeaponManager.h
Normal file
61
Source/LegumeMix/Public/Weapon/LMWeaponManager.h
Normal file
@ -0,0 +1,61 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "LMAmmo.h"
|
||||
#include "Components/ActorComponent.h"
|
||||
#include "LMWeaponManager.generated.h"
|
||||
|
||||
|
||||
class ULMWeapon;
|
||||
|
||||
UCLASS(Blueprintable, BlueprintType, ClassGroup="Legumix", meta=(BlueprintSpawnableComponent))
|
||||
class LEGUMEMIX_API ULMWeaponManager : public UActorComponent
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
ULMWeaponManager();
|
||||
void SetWeaponMeshComponent(USkeletalMeshComponent* Mesh) { WeaponMeshComponent = Mesh; }
|
||||
|
||||
public:
|
||||
/**
|
||||
* Get the Weapon currently equipped.
|
||||
* @return The Current Weapon.
|
||||
*/
|
||||
UFUNCTION(BlueprintCallable, Category="Legumix")
|
||||
ULMWeapon* GetCurrentWeapon() { return Weapons[CurrentWeaponIndex]; }
|
||||
|
||||
UFUNCTION(BlueprintCallable, Category="Legumix")
|
||||
void SetWeapon(int Index);
|
||||
|
||||
UFUNCTION(BlueprintCallable, Category="Legumix")
|
||||
void AddAmmoType(EAmmoType AmmoType, int AmmoCount);
|
||||
|
||||
UFUNCTION(BlueprintCallable, Category="Legumix")
|
||||
void Fire();
|
||||
|
||||
UFUNCTION(BlueprintCallable, Category="Legumix")
|
||||
void Reload();
|
||||
void SwitchWeapon(int Direction);
|
||||
|
||||
void Initialize(USkeletalMeshComponent* Mesh);
|
||||
|
||||
protected:
|
||||
virtual void BeginPlay() override;
|
||||
|
||||
private:
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Legumix", meta = (AllowPrivateAccess = "true"))
|
||||
TObjectPtr<USkeletalMeshComponent> WeaponMeshComponent;
|
||||
|
||||
/** The weapons the player starts with. */
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Legumix", meta=(AllowPrivateAccess=true))
|
||||
TArray<TSubclassOf<ULMWeapon>> StartingWeapons;
|
||||
|
||||
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category="Legumix", meta=(AllowPrivateAccess=true))
|
||||
TArray<TObjectPtr<ULMWeapon>> Weapons;
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Legumix", meta=(AllowPrivateAccess=true))
|
||||
int CurrentWeaponIndex = 0;
|
||||
};
|
Reference in New Issue
Block a user