Skip to content

Commit

Permalink
Merge branch '6-mechanika-ekwipunku' into prod
Browse files Browse the repository at this point in the history
  • Loading branch information
adbednarz committed Dec 15, 2020
2 parents dec260d + db0efeb commit c27854c
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 24 deletions.
1 change: 1 addition & 0 deletions Source/FistsOfSnake/FPSCharacter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,7 @@ void AFPSCharacter::DamageMe(int damage)
if (Health <= 0) {
bAlive = false;
GEngine->AddOnScreenDebugMessage(-1, 1.0f, FColor::Yellow, TEXT("Im dead"));
MyInventory->DestroyItems();
Destroy();

}
Expand Down
37 changes: 19 additions & 18 deletions Source/FistsOfSnake/FPSProjectileGrenade.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,25 +69,26 @@ void AFPSProjectileGrenade::OnDetonate()
{
for (auto& hited : OutHits)
{
if (!&hited)
continue;
// Throw away some static mesh
UStaticMeshComponent *SM = Cast<UStaticMeshComponent>(hited.GetActor()->GetRootComponent());
if (SM)
SM->AddRadialImpulse(GetActorLocation(), 1000.f, 5000.f, ERadialImpulseFalloff::RIF_Linear, true);

// Crash some destructible mesh
ADestructibleActor *DA = Cast<ADestructibleActor>(hited.GetActor());
if (DA)
DA->GetDestructibleComponent()->ApplyRadiusDamage(10.f, hited.ImpactPoint, 500.f, 3000.f, false);

AFPSCharacter *Player = Cast<AFPSCharacter>(hited.GetActor());
if (Player)
// Check if Actor has benn destroyed
if (hited.GetActor())
{
UPrimitiveComponent* ActorComponent = hited.GetActor()->FindComponentByClass<UPrimitiveComponent>();
ActorComponent->AddRadialImpulse(GetActorLocation(), 1000.f, 5000.f, ERadialImpulseFalloff::RIF_Linear, true);
Player->DamageMe(this->Damage);
// notka -> jak gracz spadnie z rowerka to granat, który trzyma w rêku zostaje, bo obiekt gracza nadal istnieje
// Throw away some static mesh
UStaticMeshComponent* SM = Cast<UStaticMeshComponent>(hited.GetActor()->GetRootComponent());
if (SM)
SM->AddRadialImpulse(GetActorLocation(), 1000.f, 5000.f, ERadialImpulseFalloff::RIF_Linear, true);

// Crash some destructible mesh
ADestructibleActor* DA = Cast<ADestructibleActor>(hited.GetActor());
if (DA)
DA->GetDestructibleComponent()->ApplyRadiusDamage(10.f, hited.ImpactPoint, 500.f, 3000.f, false);

AFPSCharacter* Player = Cast<AFPSCharacter>(hited.GetActor());
if (Player)
{
UPrimitiveComponent* ActorComponent = hited.GetActor()->FindComponentByClass<UPrimitiveComponent>();
ActorComponent->AddRadialImpulse(GetActorLocation(), 1000.f, 5000.f, ERadialImpulseFalloff::RIF_Linear, true);
Player->DamageMe(this->Damage);
}
}
}
}
Expand Down
11 changes: 11 additions & 0 deletions Source/FistsOfSnake/Inventory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,17 @@ UTexture2D* Inventory::GetItemIcon(int Index)
return nullptr;
}

void Inventory::DestroyItems()
{
for (int Index = 0; Index != this->Size; ++Index)
{
if (this->ArrayOfItems[Index])
{
this->ArrayOfItems[Index]->Destroy();
}
}
}

Inventory::~Inventory()
{
}
2 changes: 2 additions & 0 deletions Source/FistsOfSnake/Inventory.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,7 @@ class FISTSOFSNAKE_API Inventory

UTexture2D* GetItemIcon(int Index);

void DestroyItems();

~Inventory();
};
21 changes: 15 additions & 6 deletions Source/FistsOfSnake/Item.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,19 @@ void AItem::Tick(float DeltaTime)

for (auto& Player : this->Players)
{
FVector PlayerLocation = Player->GetActorLocation();
FVector Distance = PlayerLocation - this->GetActorLocation();

// When there is collision with someone
if (Distance.Size() < 100)
// Check if Player is dead
if (Player->GetHealth() > 0)
{
OnCollision(Player);
FVector PlayerLocation = Player->GetActorLocation();
FVector Distance = PlayerLocation - this->GetActorLocation();

// When there is collision with someone
if (Distance.Size() < 100)
{
OnCollision(Player);
}
}

}
}

Expand All @@ -62,6 +67,10 @@ void AItem::PickUp(AFPSCharacter *Player)
{
HideOrExposeMe(true);
}
else
{
GEngine->AddOnScreenDebugMessage(-1, 1.0f, FColor::Red, TEXT("The inventory is full"));
}
}

void AItem::HideOrExposeMe(bool bFlag)
Expand Down

0 comments on commit c27854c

Please sign in to comment.