From d185f032bb1a938d2a89c09eac355c32a0ab0b06 Mon Sep 17 00:00:00 2001 From: baz Date: Thu, 18 Jul 2024 01:39:49 +0100 Subject: [PATCH] Add Weapon class --- Source/vampires/Weapon.cpp | 33 +++++++++++++++++++++++++++++++++ Source/vampires/Weapon.h | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 69 insertions(+) create mode 100644 Source/vampires/Weapon.cpp create mode 100644 Source/vampires/Weapon.h diff --git a/Source/vampires/Weapon.cpp b/Source/vampires/Weapon.cpp new file mode 100644 index 0000000..8871eb8 --- /dev/null +++ b/Source/vampires/Weapon.cpp @@ -0,0 +1,33 @@ +// 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(); + if (expcomponent) + { + expcomponent->OnEXPLevelUp.BindUObject(this, &AWeapon::UpgradeWeapon); + } +} + +void AWeapon::FireWeaponAction() +{ +} + +void AWeapon::UpgradeWeapon(int newLevel) +{ +} diff --git a/Source/vampires/Weapon.h b/Source/vampires/Weapon.h new file mode 100644 index 0000000..4fa9ac3 --- /dev/null +++ b/Source/vampires/Weapon.h @@ -0,0 +1,36 @@ +// 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); +};