Implement enemy shooting and scale down for more arcade game feel
This commit is contained in:
@@ -4,6 +4,16 @@
|
||||
#include "GameFramework/Actor.h"
|
||||
#include "EnemySpaceship.generated.h"
|
||||
|
||||
// Define AI behavior states
|
||||
UENUM(BlueprintType)
|
||||
enum class EEnemyBehaviorState : uint8
|
||||
{
|
||||
Chase, // Actively pursue the player
|
||||
Attack, // Stop and shoot at the player
|
||||
Retreat, // Move away from player when too close
|
||||
Strafe // Move sideways while attacking
|
||||
};
|
||||
|
||||
UCLASS()
|
||||
class MYPROJECT3_API AEnemySpaceship : public AActor
|
||||
{
|
||||
@@ -18,8 +28,21 @@ protected:
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Components")
|
||||
UStaticMeshComponent* EnemyMesh;
|
||||
|
||||
// Projectile spawn points
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Combat")
|
||||
USceneComponent* ProjectileSpawnPoint;
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Movement")
|
||||
float MovementSpeed = 300.0f;
|
||||
float MovementSpeed = 500.0f;
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Movement")
|
||||
float AttackRange = 1500.0f;
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Movement")
|
||||
float MinDistanceToPlayer = 500.0f;
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Movement")
|
||||
float StrafeSpeed = 300.0f;
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Combat")
|
||||
float MaxHealth = 100.0f;
|
||||
@@ -27,6 +50,30 @@ protected:
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Combat")
|
||||
float CurrentHealth = 100.0f;
|
||||
|
||||
// Projectile class to spawn
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Combat")
|
||||
TSubclassOf<class AEnemyProjectile> ProjectileClass;
|
||||
|
||||
// Firing properties
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Combat")
|
||||
float FireRate = 1.0f;
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Combat")
|
||||
float ProjectileSpeed = 2000.0f;
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Combat")
|
||||
float ProjectileDamage = 10.0f;
|
||||
|
||||
// AI behavior properties
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "AI")
|
||||
EEnemyBehaviorState CurrentBehaviorState = EEnemyBehaviorState::Chase;
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "AI")
|
||||
float BehaviorChangeTime = 3.0f;
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "AI")
|
||||
float StateChangeChance = 0.3f;
|
||||
|
||||
public:
|
||||
virtual void Tick(float DeltaTime) override;
|
||||
|
||||
@@ -35,6 +82,32 @@ public:
|
||||
class AController* EventInstigator, AActor* DamageCauser) override;
|
||||
|
||||
private:
|
||||
AActor* PlayerPawn;
|
||||
// Reference to player
|
||||
class ASpaceshipPawn* PlayerPawn;
|
||||
|
||||
// Distance to player
|
||||
float DistanceToPlayer;
|
||||
|
||||
// Fire control
|
||||
FTimerHandle FireTimerHandle;
|
||||
bool bCanFire = true;
|
||||
|
||||
// Strafe direction (1 = right, -1 = left)
|
||||
float StrafeDirection = 1.0f;
|
||||
|
||||
// Timer for changing behavior
|
||||
FTimerHandle BehaviorTimerHandle;
|
||||
|
||||
// Helper functions
|
||||
void Fire();
|
||||
void ResetFire();
|
||||
void UpdateBehaviorState();
|
||||
void ChangeBehaviorState();
|
||||
void Die();
|
||||
|
||||
// AI behavior implementation functions
|
||||
void PerformChase(float DeltaTime);
|
||||
void PerformAttack(float DeltaTime);
|
||||
void PerformRetreat(float DeltaTime);
|
||||
void PerformStrafe(float DeltaTime);
|
||||
};
|
||||
Reference in New Issue
Block a user