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(FireAction, ETriggerEvent::Triggered, this, &ALMPlayerController::Fire);
|
||||
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();
|
||||
}
|
||||
|
||||
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);
|
||||
GEngine->AddOnScreenDebugMessage(1, 1.f, FColor::Cyan, Debug);
|
||||
@ -45,36 +45,47 @@ void ULMWeaponManager::AddAmmoType(uint8 AmmoType, int AmmoCount)
|
||||
for (const auto Weapon : Weapons)
|
||||
{
|
||||
// TODO : match weapon ammo type
|
||||
if (!Weapon)
|
||||
if (Weapon->WeaponDataStructure.AmmoType == AmmoType)
|
||||
continue;
|
||||
|
||||
// TODO
|
||||
// Weapon.AddAmmo(AmmoCount);
|
||||
Weapon->AddAmmo(AmmoCount);
|
||||
}
|
||||
}
|
||||
|
||||
void ULMWeaponManager::Fire()
|
||||
{
|
||||
// ULMWeapon* Weapon = GetCurrentWeapon();
|
||||
ULMWeapon* Weapon = GetCurrentWeapon();
|
||||
|
||||
GEngine->AddOnScreenDebugMessage(2, 1.f, FColor::Cyan, "Fire");
|
||||
// TODO
|
||||
Weapon->Fire();
|
||||
}
|
||||
|
||||
void ULMWeaponManager::Reload()
|
||||
{
|
||||
GEngine->AddOnScreenDebugMessage(3, 1.f, FColor::Cyan, "Reloading");
|
||||
|
||||
|
||||
// ULMWeapon* Weapon = GetCurrentWeapon();
|
||||
// TODO
|
||||
// Weapon->Reload();
|
||||
ULMWeapon* Weapon = GetCurrentWeapon();
|
||||
Weapon->Reload();
|
||||
}
|
||||
|
||||
void ULMWeaponManager::SetWeapon(int Index)
|
||||
void ULMWeaponManager::SwitchWeapon(const int Direction)
|
||||
{
|
||||
UE_LOG(LogTemp, Warning, TEXT("Test"))
|
||||
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");
|
||||
|
@ -42,6 +42,9 @@ private:
|
||||
UPROPERTY(EditAnywhere, BlueprintReadOnly, meta = (AllowPrivateAccess = true))
|
||||
TObjectPtr<UInputAction> ReloadAction;
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadOnly, meta = (AllowPrivateAccess = true))
|
||||
TObjectPtr<UInputAction> ScrollAction;
|
||||
|
||||
UPROPERTY(BlueprintReadOnly, meta = (AllowPrivateAccess = true))
|
||||
TObjectPtr<ALMPlayer> LegumixPlayer;
|
||||
|
||||
@ -51,4 +54,5 @@ private:
|
||||
void Look(const FInputActionValue& InputValue);
|
||||
void Fire(const FInputActionValue& InputValue);
|
||||
void Reload(const FInputActionValue& InputValue);
|
||||
void Scroll(const FInputActionValue& InputValue);
|
||||
};
|
||||
|
@ -3,6 +3,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "LMAmmo.h"
|
||||
#include "Components/ActorComponent.h"
|
||||
#include "LMWeaponManager.generated.h"
|
||||
|
||||
@ -30,13 +31,14 @@ public:
|
||||
void SetWeapon(int Index);
|
||||
|
||||
UFUNCTION(BlueprintCallable, Category="Legumix")
|
||||
void AddAmmoType(uint8 AmmoType, int AmmoCount);
|
||||
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);
|
||||
|
||||
|
Reference in New Issue
Block a user