Add Upgrades to Lightning Ring
This commit is contained in:
parent
a05a24dc62
commit
7497f8edce
BIN
Content/Weapons/LightningRing/BP_LightningRingWeapon.uasset
(Stored with Git LFS)
BIN
Content/Weapons/LightningRing/BP_LightningRingWeapon.uasset
(Stored with Git LFS)
Binary file not shown.
@ -35,30 +35,69 @@ void ALightningRingWeapon::FireWeaponAction_Implementation()
|
|||||||
{
|
{
|
||||||
AEnemyCharacter* target = targetableEnemies[FMath::RandRange(0, targetableEnemies.Num() - 1)];
|
AEnemyCharacter* target = targetableEnemies[FMath::RandRange(0, targetableEnemies.Num() - 1)];
|
||||||
|
|
||||||
TArray<AActor*> actorsToIgnore = TArray<AActor*>({ GetOwner() });
|
TArray<TEnumAsByte<EObjectTypeQuery>> traceObjectTypes;
|
||||||
TArray<FHitResult> hitResults;
|
traceObjectTypes.Add(UEngineTypes::ConvertToObjectType(ECC_Pawn));
|
||||||
UKismetSystemLibrary::SphereTraceMultiByProfile(GetWorld(),
|
|
||||||
target->GetActorLocation(),
|
|
||||||
target->GetActorLocation(),
|
|
||||||
500.0f,
|
|
||||||
FName(TEXT("Funny")),
|
|
||||||
false,
|
|
||||||
actorsToIgnore,
|
|
||||||
EDrawDebugTrace::ForDuration,
|
|
||||||
hitResults,
|
|
||||||
true);
|
|
||||||
|
|
||||||
for (FHitResult EnemyHitResult : hitResults)
|
TArray<AActor*> actorsToIgnore = TArray<AActor*>({ GetOwner() });
|
||||||
|
|
||||||
|
TArray<AActor*> hitResults;
|
||||||
|
|
||||||
|
UKismetSystemLibrary::SphereOverlapActors(GetWorld(),
|
||||||
|
target->GetActorLocation(),
|
||||||
|
LightingBoltRadius,
|
||||||
|
traceObjectTypes,
|
||||||
|
AEnemyCharacter::StaticClass(),
|
||||||
|
actorsToIgnore,
|
||||||
|
hitResults);
|
||||||
|
|
||||||
|
for (AActor* EnemyHitResult : hitResults)
|
||||||
{
|
{
|
||||||
UGameplayStatics::ApplyDamage(EnemyHitResult.GetActor(), Damage, nullptr, this, nullptr);
|
UGameplayStatics::ApplyDamage(EnemyHitResult, Damage, nullptr, this, nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
targetableEnemies.Remove(target);
|
targetableEnemies.Remove(target);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool ALightningRingWeapon::UpgradeWeapon_Implementation()
|
||||||
|
{
|
||||||
|
if (!Super::UpgradeWeapon_Implementation()) return false;
|
||||||
|
|
||||||
|
switch (CurrentLevel)
|
||||||
|
{
|
||||||
|
case 1:
|
||||||
|
LightningBolts++;
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
LightingBoltRadius += LightingBoltRadius;
|
||||||
|
Damage += 10;
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
LightningBolts++;
|
||||||
|
break;
|
||||||
|
case 4:
|
||||||
|
LightingBoltRadius += LightingBoltRadius;
|
||||||
|
Damage += 20;
|
||||||
|
break;
|
||||||
|
case 5:
|
||||||
|
LightningBolts++;
|
||||||
|
break;
|
||||||
|
case 6:
|
||||||
|
LightingBoltRadius += LightingBoltRadius;
|
||||||
|
Damage += 20;
|
||||||
|
break;
|
||||||
|
case 7:
|
||||||
|
LightningBolts++;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
void ALightningRingWeapon::OnBeginOverlap(UPrimitiveComponent* OverlappedComponent, AActor* OtherActor,
|
void ALightningRingWeapon::OnBeginOverlap(UPrimitiveComponent* OverlappedComponent, AActor* OtherActor,
|
||||||
UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult& SweepResult)
|
UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult& SweepResult)
|
||||||
{
|
{
|
||||||
if (AEnemyCharacter* Enemy = Cast<AEnemyCharacter>(OtherActor))
|
if (AEnemyCharacter* Enemy = Cast<AEnemyCharacter>(OtherActor))
|
||||||
{
|
{
|
||||||
|
@ -25,6 +25,9 @@ public:
|
|||||||
UPROPERTY(EditAnywhere, BlueprintReadWrite)
|
UPROPERTY(EditAnywhere, BlueprintReadWrite)
|
||||||
int LightningBolts = 1;
|
int LightningBolts = 1;
|
||||||
|
|
||||||
|
UPROPERTY(EditAnywhere, BlueprintReadWrite)
|
||||||
|
float LightingBoltRadius = 200.0f;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ALightningRingWeapon();
|
ALightningRingWeapon();
|
||||||
|
|
||||||
@ -34,6 +37,8 @@ protected:
|
|||||||
public:
|
public:
|
||||||
virtual void FireWeaponAction_Implementation() override;
|
virtual void FireWeaponAction_Implementation() override;
|
||||||
|
|
||||||
|
virtual bool UpgradeWeapon_Implementation() override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
UFUNCTION()
|
UFUNCTION()
|
||||||
void OnBeginOverlap(UPrimitiveComponent* OverlappedComponent, AActor* OtherActor,
|
void OnBeginOverlap(UPrimitiveComponent* OverlappedComponent, AActor* OtherActor,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user