Implement enemy shooting and scale down for more arcade game feel
This commit is contained in:
@@ -25,6 +25,18 @@ public:
|
||||
virtual void Tick(float DeltaTime) override;
|
||||
virtual void SetupPlayerInputComponent(class UInputComponent* PlayerInputComponent) override;
|
||||
|
||||
// Override TakeDamage to handle player damage
|
||||
virtual float TakeDamage(float DamageAmount, struct FDamageEvent const& DamageEvent,
|
||||
class AController* EventInstigator, AActor* DamageCauser) override;
|
||||
|
||||
// Get current health percentage
|
||||
UFUNCTION(BlueprintCallable, Category = "Combat")
|
||||
float GetHealthPercentage() const { return CurrentHealth / MaxHealth; }
|
||||
|
||||
// Get current shield percentage
|
||||
UFUNCTION(BlueprintCallable, Category = "Combat")
|
||||
float GetShieldPercentage() const { return CurrentShield / MaxShield; }
|
||||
|
||||
protected:
|
||||
virtual void BeginPlay() override;
|
||||
|
||||
@@ -48,12 +60,20 @@ protected:
|
||||
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Input")
|
||||
class UInputAction* MouseLookAction;
|
||||
|
||||
// Add a strafe input to allow lateral movement
|
||||
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Input")
|
||||
class UInputAction* StrafeAction;
|
||||
|
||||
// Input action for shooting
|
||||
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Input")
|
||||
class UInputAction* ShootAction;
|
||||
|
||||
// Movement Parameters
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Movement")
|
||||
EShipMovementMode MovementMode = EShipMovementMode::Arcade;
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Movement")
|
||||
float MaxSpeed = 2000.0f;
|
||||
float MaxSpeed = 3000.0f;
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Movement")
|
||||
float Acceleration = 2000.0f;
|
||||
@@ -86,10 +106,6 @@ protected:
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Movement")
|
||||
float AutoBrakeStrength = 3.0f;
|
||||
|
||||
// Add a strafe input to allow lateral movement
|
||||
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Input")
|
||||
class UInputAction* StrafeAction;
|
||||
|
||||
// Shooting properties
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Combat")
|
||||
TSubclassOf<class ASpaceshipProjectile> ProjectileClass;
|
||||
@@ -100,10 +116,6 @@ protected:
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Combat")
|
||||
USceneComponent* ProjectileSpawnPoint;
|
||||
|
||||
// Input action for shooting
|
||||
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Input")
|
||||
class UInputAction* ShootAction;
|
||||
|
||||
UPROPERTY(EditDefaultsOnly, Category = "UI")
|
||||
TSubclassOf<UUserWidget> CrosshairWidgetClass;
|
||||
|
||||
@@ -115,6 +127,43 @@ protected:
|
||||
void HandleStrafeInput(const FInputActionValue& Value);
|
||||
void HandleMouseLook(const FInputActionValue& Value);
|
||||
|
||||
// Health properties
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Combat")
|
||||
float MaxHealth = 100.0f;
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Combat")
|
||||
float CurrentHealth = 100.0f;
|
||||
|
||||
// Shield properties
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Combat")
|
||||
float MaxShield = 100.0f;
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Combat")
|
||||
float CurrentShield = 100.0f;
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Combat")
|
||||
float ShieldRechargeRate = 5.0f;
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Combat")
|
||||
float ShieldRechargeDelay = 3.0f;
|
||||
|
||||
// Impact effects
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Effects")
|
||||
UParticleSystem* ImpactEffect;
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Effects")
|
||||
class USoundBase* ImpactSound;
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Effects")
|
||||
class UCameraShakeBase* DamageShake;
|
||||
|
||||
// Damage flash effect for the ship
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Effects")
|
||||
float DamageFlashDuration = 0.2f;
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Effects")
|
||||
FLinearColor DamageFlashColor = FLinearColor(1.0f, 0.0f, 0.0f, 0.5f);
|
||||
|
||||
private:
|
||||
// Movement state
|
||||
float CurrentThrottleInput;
|
||||
@@ -143,4 +192,17 @@ private:
|
||||
void UpdateAssistedMovement(float DeltaTime);
|
||||
void UpdateRealisticMovement(float DeltaTime);
|
||||
void UpdateShipRotation(float DeltaTime);
|
||||
|
||||
// Damage handling
|
||||
void ApplyDamageFlash();
|
||||
void ResetDamageFlash();
|
||||
|
||||
FTimerHandle ShieldRechargeTimerHandle;
|
||||
FTimerHandle DamageFlashTimerHandle;
|
||||
float LastDamageTime;
|
||||
|
||||
void StartShieldRecharge();
|
||||
void RechargeShield();
|
||||
bool IsDead() const { return CurrentHealth <= 0.0f; }
|
||||
void Die();
|
||||
};
|
||||
Reference in New Issue
Block a user