Newer
Older
SkyFrontier-Project-IADE-UE4-3D / Source / SkyFrontier / Private / DamageSystem.cpp
@Genexuz Genexuz on 2 Dec 2022 946 bytes Overcharge item (new dmg system script)
  1. // Fill out your copyright notice in the Description page of Project Settings.
  2. #include "DamageSystem.h"
  3. // Sets default values for this component's properties
  4. UDamageSystem::UDamageSystem()
  5. {
  6. PrimaryComponentTick.bCanEverTick = false;
  7. PrimaryComponentTick.bStartWithTickEnabled = false;
  8. }
  9. // Called when the game starts
  10. void UDamageSystem::BeginPlay()
  11. {
  12. Super::BeginPlay();
  13. ShootingDamage = 20;
  14. MissileDamage = 50;
  15. }
  16. float UDamageSystem::GetShootingDamage() const
  17. {
  18. return ShootingDamage;
  19. }
  20. float UDamageSystem::GetMissileDamage() const
  21. {
  22. return MissileDamage;
  23. }
  24. void UDamageSystem::MultiplyDamage(const float Amount)
  25. {
  26. if(Amount >= 0)
  27. {
  28. ShootingDamage *= Amount;
  29. MissileDamage *= Amount;
  30. OnIncreaseDamageEvent.Broadcast(Amount);
  31. }
  32. }
  33. void UDamageSystem::RestoreDamage(const float Amount)
  34. {
  35. if(Amount >= 0)
  36. {
  37. ShootingDamage /= Amount;
  38. MissileDamage /= Amount;
  39. OnIncreaseDamageEvent.Broadcast(Amount);
  40. }
  41. }