Implement basic combat system

This commit is contained in:
2025-02-17 23:24:04 +05:30
parent 4b588e8667
commit 939e851c37
14 changed files with 293 additions and 112 deletions

View File

@@ -1,41 +1,40 @@
#pragma once
#include "CoreMinimal.h"
#include "GameFramework/Pawn.h"
#include "GameFramework/Actor.h"
#include "EnemySpaceship.generated.h"
UCLASS()
class MYPROJECT3_API AEnemySpaceship : public APawn
class MYPROJECT3_API AEnemySpaceship : public AActor
{
GENERATED_BODY()
public:
AEnemySpaceship();
virtual void Tick(float DeltaTime) override;
protected:
virtual void BeginPlay() override;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Components")
class UStaticMeshComponent* ShipMesh;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "AI")
float DetectionRange = 1500.0f;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "AI")
float FireRate = 2.0f;
UStaticMeshComponent* EnemyMesh;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Movement")
float MovementSpeed = 500.0f;
float MovementSpeed = 300.0f;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Combat")
float MaxHealth = 100.0f;
float CurrentHealth;
FTimerHandle FireTimerHandle;
class ASpaceshipPawn* PlayerPawn;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Combat")
float CurrentHealth = 100.0f;
void FireAtPlayer();
virtual float TakeDamage(float Damage, struct FDamageEvent const& DamageEvent,
AController* EventInstigator, AActor* DamageCauser) override;
public:
virtual void Tick(float DeltaTime) override;
// Override TakeDamage to handle damage taken
virtual float TakeDamage(float DamageAmount, struct FDamageEvent const& DamageEvent,
class AController* EventInstigator, AActor* DamageCauser) override;
private:
AActor* PlayerPawn;
void Die();
};