Added BaseWeaponClass, WeaponInventory, WeaponItemClass, Character basic functionality
This commit is contained in:
parent
10eb04fa77
commit
09b22ff33d
@ -3,6 +3,8 @@
|
|||||||
|
|
||||||
#include "BaseWeaponClass.h"
|
#include "BaseWeaponClass.h"
|
||||||
|
|
||||||
|
#include "Components/CapsuleComponent.h"
|
||||||
|
|
||||||
|
|
||||||
// Sets default values
|
// Sets default values
|
||||||
ABaseWeaponClass::ABaseWeaponClass()
|
ABaseWeaponClass::ABaseWeaponClass()
|
||||||
|
@ -6,6 +6,8 @@
|
|||||||
#include "WeaponItemClass.h"
|
#include "WeaponItemClass.h"
|
||||||
#include "BaseWeaponClass.generated.h"
|
#include "BaseWeaponClass.generated.h"
|
||||||
|
|
||||||
|
class UCapsuleComponent;
|
||||||
|
|
||||||
UCLASS()
|
UCLASS()
|
||||||
class ENDLESSVENDETTA_API ABaseWeaponClass : public AWeaponItemClass
|
class ENDLESSVENDETTA_API ABaseWeaponClass : public AWeaponItemClass
|
||||||
{
|
{
|
||||||
@ -22,4 +24,20 @@ protected:
|
|||||||
public:
|
public:
|
||||||
// Called every frame
|
// Called every frame
|
||||||
virtual void Tick(float DeltaTime) override;
|
virtual void Tick(float DeltaTime) override;
|
||||||
|
|
||||||
|
UPROPERTY(EditAnywhere)
|
||||||
|
FName WeaponName;
|
||||||
|
|
||||||
|
UPROPERTY(EditAnywhere)
|
||||||
|
int WeaponDamage;
|
||||||
|
|
||||||
|
UPROPERTY(EditAnywhere)
|
||||||
|
float FireRate;
|
||||||
|
|
||||||
|
UPROPERTY(EditAnywhere)
|
||||||
|
int MagazineSize;
|
||||||
|
|
||||||
|
UPROPERTY(EditAnywhere)
|
||||||
|
UTexture2D* WeaponImage;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
@ -69,6 +69,9 @@ void AEndlessVendettaCharacter::SetupPlayerInputComponent(class UInputComponent*
|
|||||||
|
|
||||||
//Looking
|
//Looking
|
||||||
EnhancedInputComponent->BindAction(LookAction, ETriggerEvent::Triggered, this, &AEndlessVendettaCharacter::Look);
|
EnhancedInputComponent->BindAction(LookAction, ETriggerEvent::Triggered, this, &AEndlessVendettaCharacter::Look);
|
||||||
|
|
||||||
|
//Weapon Switching
|
||||||
|
EnhancedInputComponent->BindAction(WeaponEquipAction, ETriggerEvent::Triggered, this, &AEndlessVendettaCharacter::WeaponEquip);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -99,6 +102,11 @@ void AEndlessVendettaCharacter::Look(const FInputActionValue& Value)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AEndlessVendettaCharacter::WeaponEquip()
|
||||||
|
{
|
||||||
|
UE_LOG(LogTemp, Display, TEXT("EQUIPPING WEAPONS"));
|
||||||
|
}
|
||||||
|
|
||||||
void AEndlessVendettaCharacter::SetHasRifle(bool bNewHasRifle)
|
void AEndlessVendettaCharacter::SetHasRifle(bool bNewHasRifle)
|
||||||
{
|
{
|
||||||
bHasRifle = bNewHasRifle;
|
bHasRifle = bNewHasRifle;
|
||||||
|
@ -7,6 +7,7 @@
|
|||||||
#include "InputActionValue.h"
|
#include "InputActionValue.h"
|
||||||
#include "EndlessVendettaCharacter.generated.h"
|
#include "EndlessVendettaCharacter.generated.h"
|
||||||
|
|
||||||
|
class UWeaponInventory;
|
||||||
class UInputComponent;
|
class UInputComponent;
|
||||||
class USkeletalMeshComponent;
|
class USkeletalMeshComponent;
|
||||||
class USceneComponent;
|
class USceneComponent;
|
||||||
@ -39,6 +40,10 @@ class AEndlessVendettaCharacter : public ACharacter
|
|||||||
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category=Input, meta=(AllowPrivateAccess = "true"))
|
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category=Input, meta=(AllowPrivateAccess = "true"))
|
||||||
class UInputAction* MoveAction;
|
class UInputAction* MoveAction;
|
||||||
|
|
||||||
|
/** Weapon Equip Action */
|
||||||
|
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category=Input, meta=(AllowPrivateAccess = "true"))
|
||||||
|
class UInputAction* WeaponEquipAction;
|
||||||
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
AEndlessVendettaCharacter();
|
AEndlessVendettaCharacter();
|
||||||
@ -71,6 +76,8 @@ protected:
|
|||||||
/** Called for looking input */
|
/** Called for looking input */
|
||||||
void Look(const FInputActionValue& Value);
|
void Look(const FInputActionValue& Value);
|
||||||
|
|
||||||
|
void WeaponEquip();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// APawn interface
|
// APawn interface
|
||||||
virtual void SetupPlayerInputComponent(UInputComponent* InputComponent) override;
|
virtual void SetupPlayerInputComponent(UInputComponent* InputComponent) override;
|
||||||
@ -82,6 +89,9 @@ public:
|
|||||||
/** Returns FirstPersonCameraComponent subobject **/
|
/** Returns FirstPersonCameraComponent subobject **/
|
||||||
UCameraComponent* GetFirstPersonCameraComponent() const { return FirstPersonCameraComponent; }
|
UCameraComponent* GetFirstPersonCameraComponent() const { return FirstPersonCameraComponent; }
|
||||||
|
|
||||||
|
private:
|
||||||
|
UWeaponInventory* WeaponInventory;
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -3,6 +3,8 @@
|
|||||||
|
|
||||||
#include "WeaponInventory.h"
|
#include "WeaponInventory.h"
|
||||||
|
|
||||||
|
#include "WeaponItemClass.h"
|
||||||
|
|
||||||
|
|
||||||
// Sets default values for this component's properties
|
// Sets default values for this component's properties
|
||||||
UWeaponInventory::UWeaponInventory()
|
UWeaponInventory::UWeaponInventory()
|
||||||
@ -11,7 +13,6 @@ UWeaponInventory::UWeaponInventory()
|
|||||||
// off to improve performance if you don't need them.
|
// off to improve performance if you don't need them.
|
||||||
PrimaryComponentTick.bCanEverTick = true;
|
PrimaryComponentTick.bCanEverTick = true;
|
||||||
|
|
||||||
// ...
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -33,3 +34,11 @@ void UWeaponInventory::TickComponent(float DeltaTime, ELevelTick TickType, FActo
|
|||||||
// ...
|
// ...
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Called from blueprints from the player
|
||||||
|
void UWeaponInventory::WeaponPickup(AActor* WeaponPickedUp)
|
||||||
|
{
|
||||||
|
AWeaponItemClass* WeaponItemClass = Cast<AWeaponItemClass>(WeaponPickedUp);
|
||||||
|
WeaponsArray.Add(WeaponItemClass);
|
||||||
|
WeaponPickedUp->Destroy();
|
||||||
|
}
|
||||||
|
|
||||||
|
@ -7,6 +7,8 @@
|
|||||||
#include "WeaponInventory.generated.h"
|
#include "WeaponInventory.generated.h"
|
||||||
|
|
||||||
|
|
||||||
|
class AWeaponItemClass;
|
||||||
|
|
||||||
UCLASS(ClassGroup=(Custom), meta=(BlueprintSpawnableComponent))
|
UCLASS(ClassGroup=(Custom), meta=(BlueprintSpawnableComponent))
|
||||||
class ENDLESSVENDETTA_API UWeaponInventory : public UActorComponent
|
class ENDLESSVENDETTA_API UWeaponInventory : public UActorComponent
|
||||||
{
|
{
|
||||||
@ -20,7 +22,23 @@ protected:
|
|||||||
// Called when the game starts
|
// Called when the game starts
|
||||||
virtual void BeginPlay() override;
|
virtual void BeginPlay() override;
|
||||||
|
|
||||||
|
UPROPERTY(VisibleAnywhere, Category = "Weapon System")
|
||||||
|
TArray<AWeaponItemClass*> WeaponsArray;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// Called every frame
|
// Called every frame
|
||||||
virtual void TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction) override;
|
virtual void TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction) override;
|
||||||
|
|
||||||
|
//Using a getter to get the protected weaponsArray
|
||||||
|
UFUNCTION()
|
||||||
|
TArray<AWeaponItemClass*> GetWeaponArray() const { return WeaponsArray; }
|
||||||
|
|
||||||
|
//Using a Setter to set the protected weapons array to the getter
|
||||||
|
UFUNCTION()
|
||||||
|
void SetArray(const TArray<AWeaponItemClass*> weaponArray) { WeaponsArray = weaponArray; }
|
||||||
|
|
||||||
|
private:
|
||||||
|
//Called from blueprints from the player
|
||||||
|
UFUNCTION(BlueprintCallable)
|
||||||
|
void WeaponPickup(AActor* WeaponPickedUp);
|
||||||
};
|
};
|
||||||
|
@ -24,3 +24,18 @@ void AWeaponItemClass::Tick(float DeltaTime)
|
|||||||
Super::Tick(DeltaTime);
|
Super::Tick(DeltaTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Called from WeaponInventory actor component class
|
||||||
|
void AWeaponItemClass::Equip(ABaseWeaponClass* PickedUpWeapon)
|
||||||
|
{
|
||||||
|
//get the weapons in the array from component
|
||||||
|
//whatever input is being pressed add that to the player socket
|
||||||
|
//if there is no gun simply add it to the socket
|
||||||
|
//if there is a weapon remove from socket and add the requested one
|
||||||
|
}
|
||||||
|
|
||||||
|
//Called from WeaponInventory actor component class
|
||||||
|
void AWeaponItemClass::Unequip(ABaseWeaponClass* PickedUpWeapon)
|
||||||
|
{
|
||||||
|
//same as equip but
|
||||||
|
}
|
||||||
|
|
||||||
|
@ -6,6 +6,8 @@
|
|||||||
#include "GameFramework/Actor.h"
|
#include "GameFramework/Actor.h"
|
||||||
#include "WeaponItemClass.generated.h"
|
#include "WeaponItemClass.generated.h"
|
||||||
|
|
||||||
|
class ABaseWeaponClass;
|
||||||
|
|
||||||
UCLASS()
|
UCLASS()
|
||||||
class ENDLESSVENDETTA_API AWeaponItemClass : public AActor
|
class ENDLESSVENDETTA_API AWeaponItemClass : public AActor
|
||||||
{
|
{
|
||||||
@ -22,4 +24,12 @@ protected:
|
|||||||
public:
|
public:
|
||||||
// Called every frame
|
// Called every frame
|
||||||
virtual void Tick(float DeltaTime) override;
|
virtual void Tick(float DeltaTime) override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
UFUNCTION()
|
||||||
|
void Equip(ABaseWeaponClass* PickedUpWeapon);
|
||||||
|
|
||||||
|
UFUNCTION()
|
||||||
|
void Unequip(ABaseWeaponClass* PickedUpWeapon);
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user