Compare commits

..

No commits in common. "532bcc7e66b4e3c94ee990c5dcb241361c2aff81" and "29246357dc43a0a7eda70b61035c3ff2b2b7d233" have entirely different histories.

7 changed files with 4 additions and 163 deletions

View File

@ -5,7 +5,6 @@
#include <Kismet/GameplayStatics.h>
#include "NakatomiGameInstance.h"
#include "PlayerCharacter.h"
void ALevelEndTriggerVolume::BeginPlay()
@ -29,9 +28,9 @@ void ALevelEndTriggerVolume::OnOverlapBegin(UPrimitiveComponent* OverlappedCompo
{
GetCollisionComponent()->OnComponentBeginOverlap.Clear();
if (auto gameInstance = Cast<UNakatomiGameInstance>(UGameplayStatics::GetGameInstance(GetWorld())))
if (!NextGameLevel.IsNull())
{
gameInstance->GetCurrentLevelManager()->LoadNextLevel();
UGameplayStatics::OpenLevelBySoftObjectPtr(GetWorld(), NextGameLevel);
}
this->Destroy();

View File

@ -1,33 +0,0 @@
// Fill out your copyright notice in the Description page of Project Settings.
#include "LevelKeyPickup.h"
#include "NakatomiGameInstance.h"
#include "Kismet/GameplayStatics.h"
void ALevelKeyPickup::BeginPlay()
{
Super::BeginPlay();
if (auto gameInstance = Cast<UNakatomiGameInstance>(UGameplayStatics::GetGameInstance(GetWorld())))
{
gameInstance->GetCurrentLevelManager()->IncrementInitialLevelKeys();
}
}
void ALevelKeyPickup::Tick(float DeltaTime)
{
Super::Tick(DeltaTime);
}
void ALevelKeyPickup::OnOverlapBegin(UPrimitiveComponent* OverlappedComponent, AActor* OtherActor,
UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult& SweepResult)
{
if (auto gameInstance = Cast<UNakatomiGameInstance>(UGameplayStatics::GetGameInstance(GetWorld())))
{
gameInstance->GetCurrentLevelManager()->IncrementInitialLevelKeys();
}
Super::OnOverlapBegin(OverlappedComponent, OtherActor, OtherComp, OtherBodyIndex, bFromSweep, SweepResult);
}

View File

@ -1,25 +0,0 @@
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "Pickup.h"
#include "LevelKeyPickup.generated.h"
/**
*
*/
UCLASS()
class NAKATOMI_API ALevelKeyPickup : public APickup
{
GENERATED_BODY()
protected:
virtual void BeginPlay() override;
public:
virtual void Tick(float DeltaTime) override;
virtual void OnOverlapBegin(UPrimitiveComponent* OverlappedComponent, AActor* OtherActor,
UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult& SweepResult) override;
};

View File

@ -7,15 +7,3 @@ UNakatomiAIAttackTokenManager* UNakatomiGameInstance::GetAIAttackTokenManager()
{
return IsValid(AIAttackTokenManager) ? AIAttackTokenManager : (AIAttackTokenManager = NewObject<UNakatomiAIAttackTokenManager>(this, TEXT("AI Attack Token Manager")));
}
UNakatomiLevelManager* UNakatomiGameInstance::GetCurrentLevelManager()
{
return IsValid(currentLevelManager)
? currentLevelManager
: currentLevelManager = NewObject<UNakatomiLevelManager>(this, TEXT("Level Manager"));
}
void UNakatomiGameInstance::SetCurrentLevelManager(UNakatomiLevelManager* NewLevelManager)
{
currentLevelManager = NewLevelManager;
}

View File

@ -5,7 +5,6 @@
#include "CoreMinimal.h"
#include "Engine/GameInstance.h"
#include "NakatomiAIAttackTokenManager.h"
#include "NakatomiLevelManager.h"
#include "NakatomiGameInstance.generated.h"
/**
@ -16,10 +15,6 @@ class NAKATOMI_API UNakatomiGameInstance : public UGameInstance
{
GENERATED_BODY()
private:
UNakatomiLevelManager* currentLevelManager;
private:
UPROPERTY()
@ -30,9 +25,4 @@ public:
UFUNCTION(BlueprintCallable)
UNakatomiAIAttackTokenManager* GetAIAttackTokenManager();
UFUNCTION(BlueprintCallable)
UNakatomiLevelManager* GetCurrentLevelManager();
UFUNCTION(BlueprintCallable)
void SetCurrentLevelManager(UNakatomiLevelManager* NewLevelManager);
};

View File

@ -1,38 +0,0 @@
// Fill out your copyright notice in the Description page of Project Settings.
#include "NakatomiLevelManager.h"
#include "NakatomiGameInstance.h"
#include "Kismet/GameplayStatics.h"
UNakatomiLevelManager::UNakatomiLevelManager()
{
FWorldDelegates::OnPostWorldCreation.AddUObject(this, &UNakatomiLevelManager::BeginPlay);
}
void UNakatomiLevelManager::BeginPlay(UWorld* world)
{
if (auto gameInstance = Cast<UNakatomiGameInstance>(UGameplayStatics::GetGameInstance(GetWorld())))
{
gameInstance->SetCurrentLevelManager(this);
}
}
void UNakatomiLevelManager::LoadNextLevel()
{
if (!NextLevel.IsNull())
{
UGameplayStatics::OpenLevelBySoftObjectPtr(GetWorld(), NextLevel);
}
}
void UNakatomiLevelManager::IncrementInitialLevelKeys()
{
LevelKeys++;
}
void UNakatomiLevelManager::IncrementCollectedLevelKeys()
{
CollectedLevelKeys++;
}

View File

@ -1,40 +0,0 @@
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "NakatomiLevelManager.generated.h"
/**
*
*/
UCLASS()
class NAKATOMI_API UNakatomiLevelManager : public UObject
{
GENERATED_BODY()
UNakatomiLevelManager();
private:
UPROPERTY(EditDefaultsOnly, Meta = (AllowPrivateAccess = "true"))
TSoftObjectPtr<UWorld> NextLevel;
int LevelKeys = 0;
int CollectedLevelKeys = 0;
public:
UFUNCTION()
void LoadNextLevel();
UFUNCTION()
void IncrementInitialLevelKeys();
UFUNCTION()
void IncrementCollectedLevelKeys();
private:
UFUNCTION()
void BeginPlay(UWorld* world);
};