Implemented weapon switching
This commit is contained in:
parent
4361f1ebf2
commit
f380b6c358
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_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.
@ -26,6 +26,7 @@ void ALMPlayerController::SetupInputComponent()
|
|||||||
Input->BindAction(LookAction, ETriggerEvent::Triggered, this, &ALMPlayerController::Look);
|
Input->BindAction(LookAction, ETriggerEvent::Triggered, this, &ALMPlayerController::Look);
|
||||||
Input->BindAction(FireAction, ETriggerEvent::Triggered, this, &ALMPlayerController::Fire);
|
Input->BindAction(FireAction, ETriggerEvent::Triggered, this, &ALMPlayerController::Fire);
|
||||||
Input->BindAction(ReloadAction, ETriggerEvent::Triggered, this, &ALMPlayerController::Reload);
|
Input->BindAction(ReloadAction, ETriggerEvent::Triggered, this, &ALMPlayerController::Reload);
|
||||||
|
Input->BindAction(ScrollAction, ETriggerEvent::Triggered, this, &ALMPlayerController::Scroll);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -57,3 +58,9 @@ void ALMPlayerController::Reload(const FInputActionValue& InputValue)
|
|||||||
{
|
{
|
||||||
LegumixPlayer->GetWeaponManager()->Reload();
|
LegumixPlayer->GetWeaponManager()->Reload();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ALMPlayerController::Scroll(const FInputActionValue& InputValue)
|
||||||
|
{
|
||||||
|
const float ScrollAmount = InputValue.Get<float>();
|
||||||
|
LegumixPlayer->GetWeaponManager()->SwitchWeapon(ScrollAmount);
|
||||||
|
}
|
||||||
|
@ -37,7 +37,7 @@ void ULMWeaponManager::Initialize(USkeletalMeshComponent* Mesh)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ULMWeaponManager::AddAmmoType(uint8 AmmoType, int AmmoCount)
|
void ULMWeaponManager::AddAmmoType(EAmmoType AmmoType, int AmmoCount)
|
||||||
{
|
{
|
||||||
FString Debug = FString::Printf(TEXT("Adding %i ammo of type %i"), AmmoCount, AmmoType);
|
FString Debug = FString::Printf(TEXT("Adding %i ammo of type %i"), AmmoCount, AmmoType);
|
||||||
GEngine->AddOnScreenDebugMessage(1, 1.f, FColor::Cyan, Debug);
|
GEngine->AddOnScreenDebugMessage(1, 1.f, FColor::Cyan, Debug);
|
||||||
@ -45,36 +45,47 @@ void ULMWeaponManager::AddAmmoType(uint8 AmmoType, int AmmoCount)
|
|||||||
for (const auto Weapon : Weapons)
|
for (const auto Weapon : Weapons)
|
||||||
{
|
{
|
||||||
// TODO : match weapon ammo type
|
// TODO : match weapon ammo type
|
||||||
if (!Weapon)
|
if (Weapon->WeaponDataStructure.AmmoType == AmmoType)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
// TODO
|
Weapon->AddAmmo(AmmoCount);
|
||||||
// Weapon.AddAmmo(AmmoCount);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ULMWeaponManager::Fire()
|
void ULMWeaponManager::Fire()
|
||||||
{
|
{
|
||||||
// ULMWeapon* Weapon = GetCurrentWeapon();
|
ULMWeapon* Weapon = GetCurrentWeapon();
|
||||||
|
|
||||||
GEngine->AddOnScreenDebugMessage(2, 1.f, FColor::Cyan, "Fire");
|
GEngine->AddOnScreenDebugMessage(2, 1.f, FColor::Cyan, "Fire");
|
||||||
// TODO
|
Weapon->Fire();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ULMWeaponManager::Reload()
|
void ULMWeaponManager::Reload()
|
||||||
{
|
{
|
||||||
GEngine->AddOnScreenDebugMessage(3, 1.f, FColor::Cyan, "Reloading");
|
GEngine->AddOnScreenDebugMessage(3, 1.f, FColor::Cyan, "Reloading");
|
||||||
|
|
||||||
|
|
||||||
// ULMWeapon* Weapon = GetCurrentWeapon();
|
ULMWeapon* Weapon = GetCurrentWeapon();
|
||||||
// TODO
|
Weapon->Reload();
|
||||||
// Weapon->Reload();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ULMWeaponManager::SetWeapon(int Index)
|
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)
|
||||||
{
|
{
|
||||||
UE_LOG(LogTemp, Warning, TEXT("Test"))
|
|
||||||
|
|
||||||
if (Index < 0 || Index >= Weapons.Num())
|
if (Index < 0 || Index >= Weapons.Num())
|
||||||
{
|
{
|
||||||
GEngine->AddOnScreenDebugMessage(INDEX_NONE, 5, FColor::Red, "Invalid Weapon Index");
|
GEngine->AddOnScreenDebugMessage(INDEX_NONE, 5, FColor::Red, "Invalid Weapon Index");
|
||||||
|
@ -41,6 +41,9 @@ private:
|
|||||||
|
|
||||||
UPROPERTY(EditAnywhere, BlueprintReadOnly, meta = (AllowPrivateAccess = true))
|
UPROPERTY(EditAnywhere, BlueprintReadOnly, meta = (AllowPrivateAccess = true))
|
||||||
TObjectPtr<UInputAction> ReloadAction;
|
TObjectPtr<UInputAction> ReloadAction;
|
||||||
|
|
||||||
|
UPROPERTY(EditAnywhere, BlueprintReadOnly, meta = (AllowPrivateAccess = true))
|
||||||
|
TObjectPtr<UInputAction> ScrollAction;
|
||||||
|
|
||||||
UPROPERTY(BlueprintReadOnly, meta = (AllowPrivateAccess = true))
|
UPROPERTY(BlueprintReadOnly, meta = (AllowPrivateAccess = true))
|
||||||
TObjectPtr<ALMPlayer> LegumixPlayer;
|
TObjectPtr<ALMPlayer> LegumixPlayer;
|
||||||
@ -51,4 +54,5 @@ private:
|
|||||||
void Look(const FInputActionValue& InputValue);
|
void Look(const FInputActionValue& InputValue);
|
||||||
void Fire(const FInputActionValue& InputValue);
|
void Fire(const FInputActionValue& InputValue);
|
||||||
void Reload(const FInputActionValue& InputValue);
|
void Reload(const FInputActionValue& InputValue);
|
||||||
|
void Scroll(const FInputActionValue& InputValue);
|
||||||
};
|
};
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "CoreMinimal.h"
|
#include "CoreMinimal.h"
|
||||||
|
#include "LMAmmo.h"
|
||||||
#include "Components/ActorComponent.h"
|
#include "Components/ActorComponent.h"
|
||||||
#include "LMWeaponManager.generated.h"
|
#include "LMWeaponManager.generated.h"
|
||||||
|
|
||||||
@ -30,14 +31,15 @@ public:
|
|||||||
void SetWeapon(int Index);
|
void SetWeapon(int Index);
|
||||||
|
|
||||||
UFUNCTION(BlueprintCallable, Category="Legumix")
|
UFUNCTION(BlueprintCallable, Category="Legumix")
|
||||||
void AddAmmoType(uint8 AmmoType, int AmmoCount);
|
void AddAmmoType(EAmmoType AmmoType, int AmmoCount);
|
||||||
|
|
||||||
UFUNCTION(BlueprintCallable, Category="Legumix")
|
UFUNCTION(BlueprintCallable, Category="Legumix")
|
||||||
void Fire();
|
void Fire();
|
||||||
|
|
||||||
UFUNCTION(BlueprintCallable, Category="Legumix")
|
UFUNCTION(BlueprintCallable, Category="Legumix")
|
||||||
void Reload();
|
void Reload();
|
||||||
|
void SwitchWeapon(int Direction);
|
||||||
|
|
||||||
void Initialize(USkeletalMeshComponent* Mesh);
|
void Initialize(USkeletalMeshComponent* Mesh);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
Reference in New Issue
Block a user