diff --git a/ProjectFish/Source/ProjectFish/Gameplay/Subsystem/TutorialManagerSubsystem.cpp b/ProjectFish/Source/ProjectFish/Gameplay/Subsystem/TutorialManagerSubsystem.cpp index eb76c5e..3affcdb 100644 --- a/ProjectFish/Source/ProjectFish/Gameplay/Subsystem/TutorialManagerSubsystem.cpp +++ b/ProjectFish/Source/ProjectFish/Gameplay/Subsystem/TutorialManagerSubsystem.cpp @@ -11,6 +11,7 @@ #include "Engine/StreamableManager.h" #include "Kismet/GameplayStatics.h" #include "ProjectFish/DataAsset/QuestAsset.h" +#include "ProjectFish/Gameplay/TutorialSystem/TutorialTask_Base.h" #include "ProjectFish/Widget/DialogueWidget_Base.h" #include "ProjectFish/Widget/TutorialControlWidget_Base.h" @@ -49,6 +50,10 @@ void UTutorialManagerSubsystem::ApplyCurrentTutorialStep() { ControlUI(); } + if (IsValid(CurrentStep.TutorialTaskClass)) + { + + } } else { @@ -61,6 +66,11 @@ void UTutorialManagerSubsystem::CompleteTutorialStep() { if (bTutorialing) { + if (TutorialTask) + { + TutorialTask->ConditionalBeginDestroy(); + TutorialTask = nullptr; + } UE_LOG(LogTemp, Warning, TEXT("教程进行下一步 currentstep = %d"), CurrentTutorialStep); OnStepComplete.Broadcast(CurrentTutorialStep); CurrentTutorialStep++; @@ -147,3 +157,9 @@ void UTutorialManagerSubsystem::ControlUI() } } + +void UTutorialManagerSubsystem::CreateTask() +{ + TutorialTask = NewObject(this); + TutorialTask->Execute(GetWorld()->GetAuthGameMode()); +} diff --git a/ProjectFish/Source/ProjectFish/Gameplay/Subsystem/TutorialManagerSubsystem.h b/ProjectFish/Source/ProjectFish/Gameplay/Subsystem/TutorialManagerSubsystem.h index eba23dd..4a96fd7 100644 --- a/ProjectFish/Source/ProjectFish/Gameplay/Subsystem/TutorialManagerSubsystem.h +++ b/ProjectFish/Source/ProjectFish/Gameplay/Subsystem/TutorialManagerSubsystem.h @@ -46,6 +46,8 @@ protected: void ShowTutorialUI(); //控制指定UI void ControlUI(); + //创建task + void CreateTask(); private: FDelegateHandle LevelLoadedDelegateHandle; UPROPERTY(BlueprintAssignable) @@ -57,4 +59,7 @@ private: FString DialogueUIPath; UPROPERTY() class UDialogueWidget_Base* DialogueWidget; + + UPROPERTY() + class UTutorialTask_Base* TutorialTask; }; diff --git a/ProjectFish/Source/ProjectFish/Gameplay/TutorialSystem/TutorialTask_Base.cpp b/ProjectFish/Source/ProjectFish/Gameplay/TutorialSystem/TutorialTask_Base.cpp new file mode 100644 index 0000000..a334d51 --- /dev/null +++ b/ProjectFish/Source/ProjectFish/Gameplay/TutorialSystem/TutorialTask_Base.cpp @@ -0,0 +1,21 @@ +// Fill out your copyright notice in the Description page of Project Settings. + + +#include "TutorialTask_Base.h" + +#include "ProjectFish/Gameplay/Subsystem/TutorialManagerSubsystem.h" + +// void UTutorialTask_Base::BeginDestroy() +// { +// UObject::BeginDestroy(); +// //task 删除的时候,自动完成该引导step +// if (GetWorld()) +// GetWorld()->GetGameInstance()->GetSubsystem()->CompleteTutorialStep(); +// } +void UTutorialTask_Base::Execute_Implementation(class AGameModeBase* GameMode) +{ +} + +void UTutorialTask_Base::BeforTutorialComplete_Implementation() +{ +} diff --git a/ProjectFish/Source/ProjectFish/Gameplay/TutorialSystem/TutorialTask_Base.h b/ProjectFish/Source/ProjectFish/Gameplay/TutorialSystem/TutorialTask_Base.h new file mode 100644 index 0000000..0e25542 --- /dev/null +++ b/ProjectFish/Source/ProjectFish/Gameplay/TutorialSystem/TutorialTask_Base.h @@ -0,0 +1,27 @@ +// Fill out your copyright notice in the Description page of Project Settings. + +#pragma once + +#include "CoreMinimal.h" +#include "UObject/Object.h" +#include "TutorialTask_Base.generated.h" + +/** + * + */ +UCLASS(Blueprintable) +class PROJECTFISH_API UTutorialTask_Base : public UObject +{ + GENERATED_BODY() +public: + /** UObject */ + //virtual void BeginDestroy() override; + + UFUNCTION(BlueprintNativeEvent, Category= "TutorialTask") + void Execute(class AGameModeBase* GameMode); + virtual void Execute_Implementation(class AGameModeBase* GameMode); + + UFUNCTION(BlueprintNativeEvent, Category= "TutorialTask") + void BeforTutorialComplete(); + virtual void BeforTutorialComplete_Implementation(); +}; diff --git a/ProjectFish/Source/ProjectFish/Gameplay/TutorialSystem/TutorialTask_GamePause.cpp b/ProjectFish/Source/ProjectFish/Gameplay/TutorialSystem/TutorialTask_GamePause.cpp new file mode 100644 index 0000000..812ba0d --- /dev/null +++ b/ProjectFish/Source/ProjectFish/Gameplay/TutorialSystem/TutorialTask_GamePause.cpp @@ -0,0 +1,18 @@ +// Fill out your copyright notice in the Description page of Project Settings. + + +#include "TutorialTask_GamePause.h" + +#include "Kismet/GameplayStatics.h" + +void UTutorialTask_GamePause::Execute_Implementation(class AGameModeBase* GameMode) +{ + Super::Execute_Implementation(GameMode); + UGameplayStatics::SetGamePaused(this, true); +} + +void UTutorialTask_GamePause::BeforTutorialComplete_Implementation() +{ + Super::BeforTutorialComplete_Implementation(); + UGameplayStatics::SetGamePaused(this, false); +} diff --git a/ProjectFish/Source/ProjectFish/Gameplay/TutorialSystem/TutorialTask_GamePause.h b/ProjectFish/Source/ProjectFish/Gameplay/TutorialSystem/TutorialTask_GamePause.h new file mode 100644 index 0000000..8d3bb2c --- /dev/null +++ b/ProjectFish/Source/ProjectFish/Gameplay/TutorialSystem/TutorialTask_GamePause.h @@ -0,0 +1,21 @@ +// Fill out your copyright notice in the Description page of Project Settings. + +#pragma once + +#include "CoreMinimal.h" +#include "TutorialTask_Base.h" +#include "TutorialTask_GamePause.generated.h" + +/** + * + */ +UCLASS() +class PROJECTFISH_API UTutorialTask_GamePause : public UTutorialTask_Base +{ + GENERATED_BODY() +public: + + virtual void Execute_Implementation(class AGameModeBase* GameMode) override; + + virtual void BeforTutorialComplete_Implementation() override; +};