Compare commits

...

6 Commits

10 changed files with 50 additions and 9 deletions

Binary file not shown.

BIN
Content/UI/Pause/PauseMenu.uasset (Stored with Git LFS)

Binary file not shown.

View File

@ -29,6 +29,7 @@ void ALevelKeyPickup::OnOverlapBegin(UPrimitiveComponent* OverlappedComponent, A
if (auto gameInstance = Cast<UNakatomiGameInstance>(UGameplayStatics::GetGameInstance(GetWorld()))) if (auto gameInstance = Cast<UNakatomiGameInstance>(UGameplayStatics::GetGameInstance(GetWorld())))
{ {
gameInstance->GetCurrentLevelManager()->IncrementCollectedLevelKeys(); gameInstance->GetCurrentLevelManager()->IncrementCollectedLevelKeys();
gameInstance->SaveGame();
} }
Super::OnOverlapBegin(OverlappedComponent, OtherActor, OtherComp, OtherBodyIndex, bFromSweep, SweepResult); Super::OnOverlapBegin(OverlappedComponent, OtherActor, OtherComp, OtherBodyIndex, bFromSweep, SweepResult);

View File

@ -3,6 +3,7 @@
#include "MainMenuUIWidget.h" #include "MainMenuUIWidget.h"
#include "NakatomiGameInstance.h"
#include "Blueprint/WidgetBlueprintLibrary.h" #include "Blueprint/WidgetBlueprintLibrary.h"
#include "Kismet/GameplayStatics.h" #include "Kismet/GameplayStatics.h"
#include "UI/LoadGameUserWidget.h" #include "UI/LoadGameUserWidget.h"
@ -68,9 +69,11 @@ void UMainMenuUIWidget::NativeConstruct()
void UMainMenuUIWidget::NewGameButtonOnClicked() void UMainMenuUIWidget::NewGameButtonOnClicked()
{ {
// TODO: Replace this is a menu to confirm the user wants to start a new game
if (!NewGameLevel.IsNull()) if (!NewGameLevel.IsNull())
{ {
UNakatomiGameInstance* gameInstance = Cast<UNakatomiGameInstance>(UGameplayStatics::GetGameInstance(GetWorld()));
gameInstance->CreateNewSaveGame("test1");
UGameplayStatics::OpenLevelBySoftObjectPtr(GetWorld(), NewGameLevel); UGameplayStatics::OpenLevelBySoftObjectPtr(GetWorld(), NewGameLevel);
} }

View File

@ -4,6 +4,8 @@
#include "NakatomiCharacter.h" #include "NakatomiCharacter.h"
#include "NakatomiCMC.h" #include "NakatomiCMC.h"
#include "NakatomiGameInstance.h"
#include "Kismet/GameplayStatics.h"
// Sets default values // Sets default values
ANakatomiCharacter::ANakatomiCharacter(const FObjectInitializer& ObjectInitializer) : Super( ANakatomiCharacter::ANakatomiCharacter(const FObjectInitializer& ObjectInitializer) : Super(
@ -30,6 +32,15 @@ void ANakatomiCharacter::BeginPlay()
SetInventoryToDefault(); SetInventoryToDefault();
NakatomiCMC = Cast<UNakatomiCMC>(GetCharacterMovement()); NakatomiCMC = Cast<UNakatomiCMC>(GetCharacterMovement());
if (UNakatomiGameInstance* gameInstance = Cast<UNakatomiGameInstance>(UGameplayStatics::GetGameInstance(GetWorld())))
{
if (UNakatomiSaveGame* Save = gameInstance->GetSaveGameObject())
{
//TODO: More loading here
GetHealthComponent()->SetCurrentHealth(Save->PlayerHealth);
}
}
} }
// Called every frame // Called every frame

View File

@ -71,7 +71,7 @@ UNakatomiSaveGame* UNakatomiGameInstance::CreateNewSaveGame(FString PlayerName)
if (UNakatomiSaveGame* Save = Cast<UNakatomiSaveGame>( if (UNakatomiSaveGame* Save = Cast<UNakatomiSaveGame>(
UGameplayStatics::CreateSaveGameObject(UNakatomiSaveGame::StaticClass()))) UGameplayStatics::CreateSaveGameObject(UNakatomiSaveGame::StaticClass())))
{ {
SaveGameObject->PlayerName = PlayerName; Save->PlayerName = PlayerName;
if (UGameplayStatics::SaveGameToSlot(Save, PlayerName, 0)) if (UGameplayStatics::SaveGameToSlot(Save, PlayerName, 0))
{ {

View File

@ -45,7 +45,7 @@ public:
UNakatomiSaveGame* LoadGameFromSlot(FString SaveSlotName); UNakatomiSaveGame* LoadGameFromSlot(FString SaveSlotName);
UFUNCTION(BlueprintCallable) UFUNCTION(BlueprintCallable)
bool SaveGame(bool ResetDefaults); bool SaveGame(bool ResetDefaults = false);
UFUNCTION(BlueprintCallable) UFUNCTION(BlueprintCallable)
UNakatomiSaveGame* GetSaveGameObject(); UNakatomiSaveGame* GetSaveGameObject();

View File

@ -3,6 +3,7 @@
#include "PauseUIWidget.h" #include "PauseUIWidget.h"
#include "NakatomiGameInstance.h"
#include "Blueprint/WidgetBlueprintLibrary.h" #include "Blueprint/WidgetBlueprintLibrary.h"
#include "Kismet/GameplayStatics.h" #include "Kismet/GameplayStatics.h"
@ -105,7 +106,12 @@ void UPauseUIWidget::OptionsButtonOnClicked()
void UPauseUIWidget::SaveButtonOnClicked() void UPauseUIWidget::SaveButtonOnClicked()
{ {
// TODO: Implement Functionality UNakatomiGameInstance* gameInstance = Cast<UNakatomiGameInstance>(UGameplayStatics::GetGameInstance(GetWorld()));
if (gameInstance->SaveGame())
{
PlayAnimation(SaveConfirmedAnimation, 0.0f, 1, EUMGSequencePlayMode::Forward, 1.0f);
}
} }
void UPauseUIWidget::QuitButtonOnClicked() void UPauseUIWidget::QuitButtonOnClicked()

View File

@ -36,6 +36,12 @@ public:
UPROPERTY(BlueprintReadWrite, meta = (BindWidget)) UPROPERTY(BlueprintReadWrite, meta = (BindWidget))
UTextBlock* SaveTextBlock; UTextBlock* SaveTextBlock;
UPROPERTY(BlueprintReadWrite, meta = (BindWidget))
UTextBlock* SaveConfirmedTextBlock;
UPROPERTY(Transient, meta = (BindWidgetAnim))
UWidgetAnimation* SaveConfirmedAnimation;
UPROPERTY(BlueprintReadWrite, meta = (BindWidget)) UPROPERTY(BlueprintReadWrite, meta = (BindWidget))
UButton* QuitButton; UButton* QuitButton;

View File

@ -3,6 +3,10 @@
#include "../UI/SaveGameEntryUserWidget.h" #include "../UI/SaveGameEntryUserWidget.h"
#include "Blueprint/WidgetBlueprintLibrary.h"
#include "Kismet/GameplayStatics.h"
#include "Nakatomi/NakatomiGameInstance.h"
void USaveGameEntryUserWidget::NativeConstruct() void USaveGameEntryUserWidget::NativeConstruct()
{ {
Super::NativeConstruct(); Super::NativeConstruct();
@ -30,7 +34,17 @@ void USaveGameEntryUserWidget::SetSaveInfo(FNakatomiSaveFileInfo SaveFile)
void USaveGameEntryUserWidget::LoadSaveButtonOnClicked() void USaveGameEntryUserWidget::LoadSaveButtonOnClicked()
{ {
// TODO: implement loading of stuff UNakatomiGameInstance* gameInstance = Cast<UNakatomiGameInstance>(UGameplayStatics::GetGameInstance(GetWorld()));
UNakatomiSaveGame* Save = gameInstance->LoadGameFromSlot(SaveFileInfo.PlayerName);
UGameplayStatics::OpenLevel(GetWorld(), FName(Save->LevelName));
if (APlayerController* PlayerController = UGameplayStatics::GetPlayerController(GetWorld(), 0))
{
PlayerController->bShowMouseCursor = false;
UWidgetBlueprintLibrary::SetInputMode_GameOnly(PlayerController);
}
SetIsFocusable(false);
} }
void USaveGameEntryUserWidget::LoadSaveButtonHoveredDelegate() void USaveGameEntryUserWidget::LoadSaveButtonHoveredDelegate()