Compare commits
No commits in common. "8e1dd981ce3741e5c8e1f9a4d0dcb40f74537a15" and "addeb47c042ac06e88e250f04d027432bf6fe2e9" have entirely different histories.
8e1dd981ce
...
addeb47c04
|
@ -17,15 +17,14 @@ void UEXPComponent::IncrementEXP(int value)
|
||||||
{
|
{
|
||||||
// TODO: I should be updating the level here
|
// TODO: I should be updating the level here
|
||||||
CurrentEXP += value;
|
CurrentEXP += value;
|
||||||
OnEXPGained.ExecuteIfBound(value);
|
OnEXPGained.ExecuteIfBound();
|
||||||
OnEXPLevelUp.ExecuteIfBound(CurrentLevel);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void UEXPComponent::SetCurrentEXP(int value)
|
void UEXPComponent::SetCurrentEXP(int value)
|
||||||
{
|
{
|
||||||
// TODO: I should be updating the level here
|
// TODO: I should be updating the level here
|
||||||
CurrentEXP = value;
|
CurrentEXP = value;
|
||||||
OnEXPGained.ExecuteIfBound(value);
|
OnEXPGained.ExecuteIfBound();
|
||||||
}
|
}
|
||||||
|
|
||||||
int UEXPComponent::GetCurrentEXP()
|
int UEXPComponent::GetCurrentEXP()
|
||||||
|
@ -42,8 +41,6 @@ void UEXPComponent::Reset()
|
||||||
{
|
{
|
||||||
CurrentEXP = 0;
|
CurrentEXP = 0;
|
||||||
CurrentLevel = 0;
|
CurrentLevel = 0;
|
||||||
OnEXPGained.ExecuteIfBound(CurrentEXP);
|
|
||||||
OnEXPLevelUp.ExecuteIfBound(CurrentLevel);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Called when the game starts
|
// Called when the game starts
|
||||||
|
|
|
@ -6,8 +6,8 @@
|
||||||
#include "Components/ActorComponent.h"
|
#include "Components/ActorComponent.h"
|
||||||
#include "EXPComponent.generated.h"
|
#include "EXPComponent.generated.h"
|
||||||
|
|
||||||
DECLARE_DELEGATE_OneParam(FOnEXPGainedDelegate, int)
|
DECLARE_DELEGATE(FOnEXPGainedDelegate)
|
||||||
DECLARE_DELEGATE_OneParam(FOnEXPLevelUpDelegate, int)
|
DECLARE_DELEGATE(FOnEXPLevelUpDelegate)
|
||||||
|
|
||||||
UCLASS(ClassGroup=(Custom), meta=(BlueprintSpawnableComponent))
|
UCLASS(ClassGroup=(Custom), meta=(BlueprintSpawnableComponent))
|
||||||
class VAMPIRES_API UEXPComponent : public UActorComponent
|
class VAMPIRES_API UEXPComponent : public UActorComponent
|
||||||
|
|
|
@ -38,9 +38,6 @@ APlayerCharacter::APlayerCharacter()
|
||||||
GarlicSphereComponent = CreateDefaultSubobject<USphereComponent>(TEXT("Garlic Sphere Component"));
|
GarlicSphereComponent = CreateDefaultSubobject<USphereComponent>(TEXT("Garlic Sphere Component"));
|
||||||
GarlicSphereComponent->SetupAttachment(RootComponent);
|
GarlicSphereComponent->SetupAttachment(RootComponent);
|
||||||
GarlicSphereComponent->SetSphereRadius(150.0f);
|
GarlicSphereComponent->SetSphereRadius(150.0f);
|
||||||
|
|
||||||
//Create Weapon Inventory Component
|
|
||||||
WeaponInventoryComponent = CreateDefaultSubobject<UWeaponInventoryComponent>(TEXT("Weapon Inventory Component"));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void APlayerCharacter::BeginPlay()
|
void APlayerCharacter::BeginPlay()
|
||||||
|
|
|
@ -7,7 +7,6 @@
|
||||||
#include "EXPComponent.h"
|
#include "EXPComponent.h"
|
||||||
#include "GoldComponent.h"
|
#include "GoldComponent.h"
|
||||||
#include "VampireCharacter.h"
|
#include "VampireCharacter.h"
|
||||||
#include "WeaponInventoryComponent.h"
|
|
||||||
#include "Camera/CameraComponent.h"
|
#include "Camera/CameraComponent.h"
|
||||||
#include "Components/SphereComponent.h"
|
#include "Components/SphereComponent.h"
|
||||||
#include "GameFramework/SpringArmComponent.h"
|
#include "GameFramework/SpringArmComponent.h"
|
||||||
|
@ -43,21 +42,19 @@ public:
|
||||||
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite)
|
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite)
|
||||||
float GarlicUpdateTime = 1.0f;
|
float GarlicUpdateTime = 1.0f;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
UPROPERTY()
|
||||||
|
UEXPComponent* EXPComponent;
|
||||||
|
|
||||||
UPROPERTY(VisibleAnywhere)
|
UPROPERTY(VisibleAnywhere)
|
||||||
USphereComponent* GarlicSphereComponent;
|
USphereComponent* GarlicSphereComponent;
|
||||||
|
|
||||||
UPROPERTY(EditAnywhere, BlueprintReadWrite)
|
UPROPERTY()
|
||||||
TArray<AEnemyCharacter*> OverlappedEnemies;
|
TArray<AEnemyCharacter*> OverlappedEnemies;
|
||||||
|
|
||||||
UPROPERTY(EditAnywhere, BlueprintReadWrite)
|
UPROPERTY()
|
||||||
UEXPComponent* EXPComponent;
|
|
||||||
|
|
||||||
UPROPERTY(EditAnywhere, BlueprintReadWrite)
|
|
||||||
UGoldComponent* GoldComponent;
|
UGoldComponent* GoldComponent;
|
||||||
|
|
||||||
UPROPERTY(EditAnywhere, BlueprintReadWrite)
|
|
||||||
UWeaponInventoryComponent* WeaponInventoryComponent;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
FTimerHandle GarlicTimerHandle;
|
FTimerHandle GarlicTimerHandle;
|
||||||
|
|
||||||
|
|
|
@ -1,33 +0,0 @@
|
||||||
// Fill out your copyright notice in the Description page of Project Settings.
|
|
||||||
|
|
||||||
|
|
||||||
#include "Weapon.h"
|
|
||||||
|
|
||||||
#include "EXPComponent.h"
|
|
||||||
|
|
||||||
// Sets default values
|
|
||||||
AWeapon::AWeapon()
|
|
||||||
{
|
|
||||||
// Set this actor to call Tick() every frame. You can turn this off to improve performance if you don't need it.
|
|
||||||
PrimaryActorTick.bCanEverTick = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Called when the game starts or when spawned
|
|
||||||
void AWeapon::BeginPlay()
|
|
||||||
{
|
|
||||||
Super::BeginPlay();
|
|
||||||
GetWorldTimerManager().SetTimer(WeaponTimerHandle, this, &AWeapon::FireWeaponAction, WeaponCooldown, true);
|
|
||||||
UEXPComponent* expcomponent = GetOwner()->GetComponentByClass<UEXPComponent>();
|
|
||||||
if (expcomponent)
|
|
||||||
{
|
|
||||||
expcomponent->OnEXPLevelUp.BindUObject(this, &AWeapon::UpgradeWeapon);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void AWeapon::FireWeaponAction()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void AWeapon::UpgradeWeapon(int newLevel)
|
|
||||||
{
|
|
||||||
}
|
|
|
@ -1,36 +0,0 @@
|
||||||
// Fill out your copyright notice in the Description page of Project Settings.
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include "CoreMinimal.h"
|
|
||||||
#include "GameFramework/Actor.h"
|
|
||||||
#include "Weapon.generated.h"
|
|
||||||
|
|
||||||
UCLASS()
|
|
||||||
class VAMPIRES_API AWeapon : public AActor
|
|
||||||
{
|
|
||||||
GENERATED_BODY()
|
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
UPROPERTY()
|
|
||||||
float WeaponCooldown = 1.0f;
|
|
||||||
|
|
||||||
private:
|
|
||||||
FTimerHandle WeaponTimerHandle;
|
|
||||||
|
|
||||||
public:
|
|
||||||
// Sets default values for this actor's properties
|
|
||||||
AWeapon();
|
|
||||||
|
|
||||||
protected:
|
|
||||||
// Called when the game starts or when spawned
|
|
||||||
virtual void BeginPlay() override;
|
|
||||||
public:
|
|
||||||
|
|
||||||
UFUNCTION(BlueprintCallable)
|
|
||||||
virtual void FireWeaponAction();
|
|
||||||
|
|
||||||
UFUNCTION()
|
|
||||||
virtual void UpgradeWeapon(int newLevel);
|
|
||||||
};
|
|
|
@ -1,46 +0,0 @@
|
||||||
// Fill out your copyright notice in the Description page of Project Settings.
|
|
||||||
|
|
||||||
|
|
||||||
#include "WeaponInventoryComponent.h"
|
|
||||||
|
|
||||||
#include "Kismet/GameplayStatics.h"
|
|
||||||
|
|
||||||
// Sets default values for this component's properties
|
|
||||||
UWeaponInventoryComponent::UWeaponInventoryComponent()
|
|
||||||
{
|
|
||||||
// Set this component to be initialized when the game starts, and to be ticked every frame. You can turn these features
|
|
||||||
// off to improve performance if you don't need them.
|
|
||||||
PrimaryComponentTick.bCanEverTick = false;
|
|
||||||
|
|
||||||
// ...
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Called when the game starts
|
|
||||||
void UWeaponInventoryComponent::BeginPlay()
|
|
||||||
{
|
|
||||||
Super::BeginPlay();
|
|
||||||
|
|
||||||
// ...
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void UWeaponInventoryComponent::InitializeInventory()
|
|
||||||
{
|
|
||||||
inventory.Empty();
|
|
||||||
|
|
||||||
for (TSubclassOf<AWeapon> weapon : initialInventory)
|
|
||||||
{
|
|
||||||
AddWeaponToInventory(weapon);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void UWeaponInventoryComponent::AddWeaponToInventory(TSubclassOf<AWeapon> Weapon)
|
|
||||||
{
|
|
||||||
AWeapon* weapon = GetWorld()->SpawnActor<AWeapon>(Weapon);
|
|
||||||
weapon->SetActorTransform(GetOwner()->GetTransform());
|
|
||||||
weapon->SetOwner(GetOwner());
|
|
||||||
weapon->AttachToActor(GetOwner(), FAttachmentTransformRules::KeepRelativeTransform);
|
|
||||||
inventory.Add(weapon);
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,41 +0,0 @@
|
||||||
// Fill out your copyright notice in the Description page of Project Settings.
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include "CoreMinimal.h"
|
|
||||||
#include "Weapon.h"
|
|
||||||
#include "Components/ActorComponent.h"
|
|
||||||
#include "WeaponInventoryComponent.generated.h"
|
|
||||||
|
|
||||||
|
|
||||||
UCLASS( ClassGroup=(Custom), meta=(BlueprintSpawnableComponent) )
|
|
||||||
class VAMPIRES_API UWeaponInventoryComponent : public UActorComponent
|
|
||||||
{
|
|
||||||
GENERATED_BODY()
|
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
UPROPERTY()
|
|
||||||
TArray<TSubclassOf<AWeapon>> initialInventory;
|
|
||||||
|
|
||||||
private:
|
|
||||||
UPROPERTY()
|
|
||||||
TArray<AWeapon*> inventory;
|
|
||||||
|
|
||||||
public:
|
|
||||||
// Sets default values for this component's properties
|
|
||||||
UWeaponInventoryComponent();
|
|
||||||
|
|
||||||
protected:
|
|
||||||
// Called when the game starts
|
|
||||||
virtual void BeginPlay() override;
|
|
||||||
|
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
UFUNCTION()
|
|
||||||
void InitializeInventory();
|
|
||||||
|
|
||||||
UFUNCTION()
|
|
||||||
void AddWeaponToInventory(TSubclassOf<AWeapon> Weapon);
|
|
||||||
};
|
|
Loading…
Reference in New Issue