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