diff --git a/ProjectFish/Binaries/Win64/UnrealEditor-ProjectFish.dll b/ProjectFish/Binaries/Win64/UnrealEditor-ProjectFish.dll index c1506fa..ef58065 100644 Binary files a/ProjectFish/Binaries/Win64/UnrealEditor-ProjectFish.dll and b/ProjectFish/Binaries/Win64/UnrealEditor-ProjectFish.dll differ diff --git a/ProjectFish/Content/DataTable/DT_TutorialSteps.uasset b/ProjectFish/Content/DataTable/DT_TutorialSteps.uasset index 9db6a23..68b0e74 100644 Binary files a/ProjectFish/Content/DataTable/DT_TutorialSteps.uasset and b/ProjectFish/Content/DataTable/DT_TutorialSteps.uasset differ diff --git a/ProjectFish/Source/ProjectFish/Definations.h b/ProjectFish/Source/ProjectFish/Definations.h index 0fa4215..6d299b5 100644 --- a/ProjectFish/Source/ProjectFish/Definations.h +++ b/ProjectFish/Source/ProjectFish/Definations.h @@ -514,5 +514,8 @@ public: //引导task UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Tutorial Asset") TSubclassOf TutorialTaskClass; + + UPROPERTY() + UTutorialTask_Base* TutorialTaskObject; }; diff --git a/ProjectFish/Source/ProjectFish/Gameplay/Subsystem/TutorialManagerSubsystem.cpp b/ProjectFish/Source/ProjectFish/Gameplay/Subsystem/TutorialManagerSubsystem.cpp index 6e747ad..6221769 100644 --- a/ProjectFish/Source/ProjectFish/Gameplay/Subsystem/TutorialManagerSubsystem.cpp +++ b/ProjectFish/Source/ProjectFish/Gameplay/Subsystem/TutorialManagerSubsystem.cpp @@ -52,7 +52,8 @@ void UTutorialManagerSubsystem::ApplyCurrentTutorialStep() } if (IsValid(CurrentStep.TutorialTaskClass)) { - + TutorialTaskObject = NewObject< UTutorialTask_Base>(this); + TutorialTaskObject->Execute(GetWorld()->GetAuthGameMode()); } } else @@ -66,10 +67,15 @@ void UTutorialManagerSubsystem::CompleteTutorialStep() { if (bTutorialing) { - if (TutorialTask) + if (TutorialTaskObject) { - TutorialTask->ConditionalBeginDestroy(); - TutorialTask = nullptr; + TutorialTaskObject->ConditionalBeginDestroy(); + TutorialTaskObject = nullptr; + } + if (TutorialWidget) + { + TutorialWidget->RemoveFromViewport(); + TutorialWidget = nullptr; } UE_LOG(LogTemp, Warning, TEXT("教程进行下一步 currentstep = %d"), CurrentTutorialStep); OnStepComplete.Broadcast(CurrentTutorialStep); @@ -138,7 +144,7 @@ void UTutorialManagerSubsystem::AccepAndFollowQuest() void UTutorialManagerSubsystem::ShowTutorialUI() { FTutorialStep CurrentStep = TutorialSteps[CurrentTutorialStep]; - UUserWidget* TutorialWidget = CreateWidget(GetWorld(), CurrentStep.TutorialUI); + TutorialWidget = CreateWidget(GetWorld(), CurrentStep.TutorialUI); TutorialWidget->AddToViewport(99); } diff --git a/ProjectFish/Source/ProjectFish/Gameplay/Subsystem/TutorialManagerSubsystem.h b/ProjectFish/Source/ProjectFish/Gameplay/Subsystem/TutorialManagerSubsystem.h index 4a96fd7..d120c7e 100644 --- a/ProjectFish/Source/ProjectFish/Gameplay/Subsystem/TutorialManagerSubsystem.h +++ b/ProjectFish/Source/ProjectFish/Gameplay/Subsystem/TutorialManagerSubsystem.h @@ -59,7 +59,10 @@ private: FString DialogueUIPath; UPROPERTY() class UDialogueWidget_Base* DialogueWidget; - + UPROPERTY() - class UTutorialTask_Base* TutorialTask; + UUserWidget* TutorialWidget; + + UPROPERTY() + class UTutorialTask_Base* TutorialTaskObject; }; diff --git a/ProjectFish/Source/ProjectFish/Gameplay/TutorialSystem/TutorialTask_GamePause.cpp b/ProjectFish/Source/ProjectFish/Gameplay/TutorialSystem/TutorialTask_GamePause.cpp index 812ba0d..265ce4b 100644 --- a/ProjectFish/Source/ProjectFish/Gameplay/TutorialSystem/TutorialTask_GamePause.cpp +++ b/ProjectFish/Source/ProjectFish/Gameplay/TutorialSystem/TutorialTask_GamePause.cpp @@ -8,7 +8,11 @@ void UTutorialTask_GamePause::Execute_Implementation(class AGameModeBase* GameMode) { Super::Execute_Implementation(GameMode); - UGameplayStatics::SetGamePaused(this, true); + LevelLoadedDelegateHandle = FCoreUObjectDelegates::PostLoadMapWithWorld.AddUObject( + this, + &UTutorialTask_GamePause::OnLevelLoaded + ); + } void UTutorialTask_GamePause::BeforTutorialComplete_Implementation() @@ -16,3 +20,18 @@ void UTutorialTask_GamePause::BeforTutorialComplete_Implementation() Super::BeforTutorialComplete_Implementation(); UGameplayStatics::SetGamePaused(this, false); } + +void UTutorialTask_GamePause::OnLevelLoaded(UWorld* World) +{ + FCoreUObjectDelegates::PostLoadMapWithWorld.Remove(LevelLoadedDelegateHandle); + FTimerHandle LambdaTimerHandle; + GetWorld()->GetTimerManager().SetTimer( + LambdaTimerHandle, + [this]() + { + UGameplayStatics::SetGamePaused(this, true); + }, + 1.5f, + false + ); +} diff --git a/ProjectFish/Source/ProjectFish/Gameplay/TutorialSystem/TutorialTask_GamePause.h b/ProjectFish/Source/ProjectFish/Gameplay/TutorialSystem/TutorialTask_GamePause.h index 8d3bb2c..35a99c1 100644 --- a/ProjectFish/Source/ProjectFish/Gameplay/TutorialSystem/TutorialTask_GamePause.h +++ b/ProjectFish/Source/ProjectFish/Gameplay/TutorialSystem/TutorialTask_GamePause.h @@ -18,4 +18,8 @@ public: virtual void Execute_Implementation(class AGameModeBase* GameMode) override; virtual void BeforTutorialComplete_Implementation() override; + + void OnLevelLoaded(UWorld* World); +private: + FDelegateHandle LevelLoadedDelegateHandle; };