Checfk if all keys have been collected in LevelEndTriggerVolume
This commit is contained in:
parent
cffef34d9b
commit
9dc2fff2ed
|
@ -24,16 +24,20 @@ void ALevelEndTriggerVolume::OnOverlapBegin(UPrimitiveComponent* OverlappedCompo
|
||||||
UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep,
|
UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep,
|
||||||
const FHitResult& SweepResult)
|
const FHitResult& SweepResult)
|
||||||
{
|
{
|
||||||
// TODO: Add extra functionality!
|
UNakatomiGameInstance* gameInstance = Cast<UNakatomiGameInstance>(UGameplayStatics::GetGameInstance(GetWorld()));
|
||||||
if (Cast<APlayerCharacter>(OtherActor))
|
if (gameInstance)
|
||||||
{
|
{
|
||||||
GetCollisionComponent()->OnComponentBeginOverlap.Clear();
|
int CollectedLevelKeysCount = gameInstance->GetCurrentLevelManager()->GetCollectedLevelKeysCount();
|
||||||
|
int InitialLevelKeysCount = gameInstance->GetCurrentLevelManager()->GetInitialLevelKeysCount();
|
||||||
|
|
||||||
if (auto gameInstance = Cast<UNakatomiGameInstance>(UGameplayStatics::GetGameInstance(GetWorld())))
|
// TODO: Add extra checks!
|
||||||
|
if (Cast<APlayerCharacter>(OtherActor) && CollectedLevelKeysCount == InitialLevelKeysCount)
|
||||||
{
|
{
|
||||||
gameInstance->GetCurrentLevelManager()->LoadNextLevel();
|
GetCollisionComponent()->OnComponentBeginOverlap.Clear();
|
||||||
}
|
|
||||||
|
|
||||||
this->Destroy();
|
gameInstance->GetCurrentLevelManager()->LoadNextLevel();
|
||||||
|
|
||||||
|
this->Destroy();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,10 +29,20 @@ void UNakatomiLevelManager::LoadNextLevel()
|
||||||
|
|
||||||
void UNakatomiLevelManager::IncrementInitialLevelKeys()
|
void UNakatomiLevelManager::IncrementInitialLevelKeys()
|
||||||
{
|
{
|
||||||
LevelKeys++;
|
InitialLevelKeys++;
|
||||||
}
|
}
|
||||||
|
|
||||||
void UNakatomiLevelManager::IncrementCollectedLevelKeys()
|
void UNakatomiLevelManager::IncrementCollectedLevelKeys()
|
||||||
{
|
{
|
||||||
CollectedLevelKeys++;
|
CollectedLevelKeys++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int UNakatomiLevelManager::GetInitialLevelKeysCount()
|
||||||
|
{
|
||||||
|
return InitialLevelKeys;
|
||||||
|
}
|
||||||
|
|
||||||
|
int UNakatomiLevelManager::GetCollectedLevelKeysCount()
|
||||||
|
{
|
||||||
|
return CollectedLevelKeys;
|
||||||
|
}
|
||||||
|
|
|
@ -19,7 +19,7 @@ private:
|
||||||
UPROPERTY(EditDefaultsOnly, Meta = (AllowPrivateAccess = "true"))
|
UPROPERTY(EditDefaultsOnly, Meta = (AllowPrivateAccess = "true"))
|
||||||
TSoftObjectPtr<UWorld> NextLevel;
|
TSoftObjectPtr<UWorld> NextLevel;
|
||||||
|
|
||||||
int LevelKeys = 0;
|
int InitialLevelKeys = 0;
|
||||||
|
|
||||||
int CollectedLevelKeys = 0;
|
int CollectedLevelKeys = 0;
|
||||||
|
|
||||||
|
@ -33,6 +33,12 @@ public:
|
||||||
UFUNCTION()
|
UFUNCTION()
|
||||||
void IncrementCollectedLevelKeys();
|
void IncrementCollectedLevelKeys();
|
||||||
|
|
||||||
|
UFUNCTION()
|
||||||
|
int GetInitialLevelKeysCount();
|
||||||
|
|
||||||
|
UFUNCTION()
|
||||||
|
int GetCollectedLevelKeysCount();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
UFUNCTION()
|
UFUNCTION()
|
||||||
|
|
Loading…
Reference in New Issue