Compare commits

..

No commits in common. "0526f25058b4c5dc0b2f0be1786db3c87215d675" and "7929dfa4f2b17925c38bda5cea4391b6ca8761fb" have entirely different histories.

49 changed files with 30 additions and 109 deletions

View File

@ -84,8 +84,8 @@ TSet<int32> UContainerInfo::GetOverlapOtherItem(FContainerItem Item)
if (Item.IsSlotUsing(FIntPoint(x, y))) if (Item.IsSlotUsing(FIntPoint(x, y)))
{ {
if (ContainerShape->IsSlotActive(Item.ContainerStartPos.X + x, Item.ContainerStartPos.Y + y) && SlotItems.Contains(FIntPoint(x + Item.ContainerStartPos.X, y + Item.ContainerStartPos.Y)) if (ContainerShape->IsSlotActive(Item.ContainerStartPos.X + x, Item.ContainerStartPos.Y + y) &&
///SlotItems[FIntPoint(x + Item.ContainerStartPos.X, y + Item.ContainerStartPos.Y)] != -1 SlotItems[FIntPoint(x + Item.ContainerStartPos.X, y + Item.ContainerStartPos.Y)] != -1
) )
{ {
OverlapItems.Add(SlotItems[FIntPoint(x + Item.ContainerStartPos.X, y + Item.ContainerStartPos.Y)] ); OverlapItems.Add(SlotItems[FIntPoint(x + Item.ContainerStartPos.X, y + Item.ContainerStartPos.Y)] );

View File

@ -5,18 +5,12 @@
#include "ProjectFish/Gameplay/Subsystem/GameInfoManager.h" #include "ProjectFish/Gameplay/Subsystem/GameInfoManager.h"
void UPlayerInfoSaveGame::BeginDestroy()
{
Super::BeginDestroy();
}
void UPlayerInfoSaveGame::SetShipContainerItems(TArray<FContainerItemSaveData> NewItems) void UPlayerInfoSaveGame::SetShipContainerItems(TArray<FContainerItemSaveData> NewItems)
{ {
ShipContainerItems = NewItems; ShipContainerItems = NewItems;
if (GetWorld())
if (GetOuter())
{ {
GetOuter()->GetWorld()->GetGameInstance()->GetSubsystem<UGameInfoManager>()->SaveGameInfo(); GetWorld()->GetGameInstance()->GetSubsystem<UGameInfoManager>()->SaveGameInfo();
OnShipContainerUpdate.Broadcast(); OnShipContainerUpdate.Broadcast();
} }
} }

View File

@ -18,8 +18,6 @@ class PROJECTFISH_API UPlayerInfoSaveGame : public USaveGame
{ {
GENERATED_BODY() GENERATED_BODY()
public: public:
virtual void BeginDestroy() override;
UPROPERTY(SaveGame, BlueprintReadWrite, meta = (ToolTip = "开启教程模式")) UPROPERTY(SaveGame, BlueprintReadWrite, meta = (ToolTip = "开启教程模式"))
bool TutorialMode = true; bool TutorialMode = true;
@ -59,11 +57,10 @@ public:
UPROPERTY(SaveGame, BlueprintReadWrite, meta = (ToolTip = "被击败的鱼")) UPROPERTY(SaveGame, BlueprintReadWrite, meta = (ToolTip = "被击败的鱼"))
TArray<int32> Fish_defeated_IDS; TArray<int32> Fish_defeated_IDS;
public: protected:
UPROPERTY(BlueprintAssignable, Category = "PlayerInfoSaveGame") UPROPERTY(BlueprintAssignable, Category = "PlayerInfoSaveGame")
FOnShipContainerUpdate OnShipContainerUpdate; FOnShipContainerUpdate OnShipContainerUpdate;
protected:
UFUNCTION(BlueprintCallable, Category= "PlayerInfoSaveGame") UFUNCTION(BlueprintCallable, Category= "PlayerInfoSaveGame")
void SetShipContainerItems(TArray<FContainerItemSaveData> NewItems); void SetShipContainerItems(TArray<FContainerItemSaveData> NewItems);
}; };

View File

@ -514,8 +514,5 @@ public:
//引导task //引导task
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Tutorial Asset") UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Tutorial Asset")
TSubclassOf<class UTutorialTask_Base> TutorialTaskClass; TSubclassOf<class UTutorialTask_Base> TutorialTaskClass;
UPROPERTY()
UTutorialTask_Base* TutorialTaskObject;
}; };

View File

@ -24,10 +24,9 @@ void UGameInfoManager::NewSaveGame()
void UGameInfoManager::SaveGameInfo() void UGameInfoManager::SaveGameInfo()
{ {
if (!IsValid(PlayerInfo)) if (!IsValid(PlayerInfo.Get()))
{ {
PlayerInfo = NewObject<UPlayerInfoSaveGame>(this);
PlayerInfo = NewObject<UPlayerInfoSaveGame>(GetGameInstance());
} }
// 保存任务数据 // 保存任务数据
if (UQuestManager* QuestManager = GetGameInstance()->GetSubsystem<UQuestManager>()) if (UQuestManager* QuestManager = GetGameInstance()->GetSubsystem<UQuestManager>())
@ -35,7 +34,7 @@ void UGameInfoManager::SaveGameInfo()
PlayerInfo->QuestSaveData = QuestManager->GetQuestSaveData(); PlayerInfo->QuestSaveData = QuestManager->GetQuestSaveData();
} }
if (UGameplayStatics::SaveGameToSlot(PlayerInfo, SaveGameSlotName, 0)) if (UGameplayStatics::SaveGameToSlot(PlayerInfo.Get(), SaveGameSlotName, 0))
{ {
UE_LOG(LogTemp, Warning, TEXT("存档保存成功")); UE_LOG(LogTemp, Warning, TEXT("存档保存成功"));
} }
@ -50,7 +49,7 @@ bool UGameInfoManager::LoadGameInfo()
if (UGameplayStatics::DoesSaveGameExist(SaveGameSlotName, 0)) if (UGameplayStatics::DoesSaveGameExist(SaveGameSlotName, 0))
{ {
PlayerInfo = Cast<UPlayerInfoSaveGame>(UGameplayStatics::LoadGameFromSlot(SaveGameSlotName, 0)); PlayerInfo = Cast<UPlayerInfoSaveGame>(UGameplayStatics::LoadGameFromSlot(SaveGameSlotName, 0));
PlayerInfo->Rename(nullptr, this);
// 加载任务数据 // 加载任务数据
if (UQuestManager* QuestManager = GetGameInstance()->GetSubsystem<UQuestManager>()) if (UQuestManager* QuestManager = GetGameInstance()->GetSubsystem<UQuestManager>())
{ {
@ -75,8 +74,7 @@ bool UGameInfoManager::LoadGameInfo()
void UGameInfoManager::CreateGameInfo(UContainerInfo* ShipContainer, UContainerInfo* PlayerContainer) void UGameInfoManager::CreateGameInfo(UContainerInfo* ShipContainer, UContainerInfo* PlayerContainer)
{ {
if (!IsValid(PlayerInfo)) PlayerInfo = NewObject<UPlayerInfoSaveGame>(this);
PlayerInfo = NewObject<UPlayerInfoSaveGame>(GetGameInstance());
PlayerInfo->ShipContainerItems = ShipContainer->GetSaveData(); PlayerInfo->ShipContainerItems = ShipContainer->GetSaveData();
PlayerInfo->ShipContainerShapeID = ShipContainer->ContainerShape->GetPrimaryAssetId(); PlayerInfo->ShipContainerShapeID = ShipContainer->ContainerShape->GetPrimaryAssetId();
@ -95,7 +93,7 @@ void UGameInfoManager::CreateGameInfoAndSave(UShapeAsset* ShipContainerShape, US
PlayerContainer->InitContainerByShape(PlayerContainerShape); PlayerContainer->InitContainerByShape(PlayerContainerShape);
//创建要保存的额存档信息 //创建要保存的额存档信息
PlayerInfo = NewObject<UPlayerInfoSaveGame>(GetGameInstance()); PlayerInfo = NewObject<UPlayerInfoSaveGame>(this);
PlayerInfo->ShipContainerItems = ShipContainer->GetSaveData(); PlayerInfo->ShipContainerItems = ShipContainer->GetSaveData();
PlayerInfo->ShipContainerShapeID = ShipContainer->ContainerShape->GetPrimaryAssetId(); PlayerInfo->ShipContainerShapeID = ShipContainer->ContainerShape->GetPrimaryAssetId();
@ -121,7 +119,7 @@ void UGameInfoManager::SetTutorialMode(bool bTutorialMode)
{ {
if (!IsValid(PlayerInfo)) if (!IsValid(PlayerInfo))
{ {
PlayerInfo = NewObject<UPlayerInfoSaveGame>(GetGameInstance()); PlayerInfo = NewObject<UPlayerInfoSaveGame>(this);
} }
PlayerInfo->TutorialMode = bTutorialMode; PlayerInfo->TutorialMode = bTutorialMode;
} }
@ -139,7 +137,7 @@ void UGameInfoManager::AddDefeatedFish(int32 FishID)
{ {
if (!IsValid(PlayerInfo)) if (!IsValid(PlayerInfo))
{ {
PlayerInfo = NewObject<UPlayerInfoSaveGame>(GetGameInstance()); PlayerInfo = NewObject<UPlayerInfoSaveGame>(this);
} }
PlayerInfo->Fish_defeated_IDS.Add(FishID); PlayerInfo->Fish_defeated_IDS.Add(FishID);
SaveGameInfo(); SaveGameInfo();

View File

@ -3,7 +3,6 @@
#pragma once #pragma once
#include "CoreMinimal.h" #include "CoreMinimal.h"
#include "DialogueAsset.h"
#include "ProjectFish/Data/PlayerInfoSaveGame.h" #include "ProjectFish/Data/PlayerInfoSaveGame.h"
#include "Subsystems/GameInstanceSubsystem.h" #include "Subsystems/GameInstanceSubsystem.h"
#include "GameInfoManager.generated.h" #include "GameInfoManager.generated.h"
@ -42,11 +41,9 @@ public:
UFUNCTION(BlueprintCallable) UFUNCTION(BlueprintCallable)
void AddDefeatedFish(int32 FishID); void AddDefeatedFish(int32 FishID);
TObjectPtr<class UPlayerInfoSaveGame> GetPlayerInfo() {return PlayerInfo;}
protected: protected:
UPROPERTY(BlueprintReadWrite) UPROPERTY(BlueprintReadOnly)
class UPlayerInfoSaveGame* PlayerInfo; TObjectPtr<class UPlayerInfoSaveGame> PlayerInfo;
static FString SaveGameSlotName; static FString SaveGameSlotName;
}; };

View File

@ -32,7 +32,6 @@ void UTutorialManagerSubsystem::ApplyCurrentTutorialStep()
{ {
if (TutorialSteps.Num() > CurrentTutorialStep ) if (TutorialSteps.Num() > CurrentTutorialStep )
{ {
UE_LOG(LogTemp, Warning, TEXT("执行 CurrentTutorialStep = %d || name = %s "), CurrentTutorialStep, *GetCurrentTutorialStep().StepName.ToString() );
bTutorialing = true; bTutorialing = true;
FTutorialStep CurrentStep = TutorialSteps[CurrentTutorialStep]; FTutorialStep CurrentStep = TutorialSteps[CurrentTutorialStep];
if (IsValid(CurrentStep.Dialogue)) if (IsValid(CurrentStep.Dialogue))
@ -53,7 +52,7 @@ void UTutorialManagerSubsystem::ApplyCurrentTutorialStep()
} }
if (IsValid(CurrentStep.TutorialTaskClass)) if (IsValid(CurrentStep.TutorialTaskClass))
{ {
CreateTask();
} }
} }
else else
@ -67,18 +66,12 @@ void UTutorialManagerSubsystem::CompleteTutorialStep()
{ {
if (bTutorialing) if (bTutorialing)
{ {
if (TutorialTaskObject) if (TutorialTask)
{ {
TutorialTaskObject->BeforTutorialComplete(); TutorialTask->ConditionalBeginDestroy();
TutorialTaskObject->ConditionalBeginDestroy(); TutorialTask = nullptr;
TutorialTaskObject = nullptr;
} }
if (TutorialWidget) UE_LOG(LogTemp, Warning, TEXT("教程进行下一步 currentstep = %d"), CurrentTutorialStep);
{
TutorialWidget->RemoveFromViewport();
TutorialWidget = nullptr;
}
UE_LOG(LogTemp, Warning, TEXT(" 教程进行下一步"));
OnStepComplete.Broadcast(CurrentTutorialStep); OnStepComplete.Broadcast(CurrentTutorialStep);
CurrentTutorialStep++; CurrentTutorialStep++;
ApplyCurrentTutorialStep(); ApplyCurrentTutorialStep();
@ -145,7 +138,7 @@ void UTutorialManagerSubsystem::AccepAndFollowQuest()
void UTutorialManagerSubsystem::ShowTutorialUI() void UTutorialManagerSubsystem::ShowTutorialUI()
{ {
FTutorialStep CurrentStep = TutorialSteps[CurrentTutorialStep]; FTutorialStep CurrentStep = TutorialSteps[CurrentTutorialStep];
TutorialWidget = CreateWidget<UUserWidget>(GetWorld(), CurrentStep.TutorialUI); UUserWidget* TutorialWidget = CreateWidget<UUserWidget>(GetWorld(), CurrentStep.TutorialUI);
TutorialWidget->AddToViewport(99); TutorialWidget->AddToViewport(99);
} }
@ -168,7 +161,6 @@ void UTutorialManagerSubsystem::ControlUI()
void UTutorialManagerSubsystem::CreateTask() void UTutorialManagerSubsystem::CreateTask()
{ {
FTutorialStep CurrentStep = TutorialSteps[CurrentTutorialStep]; TutorialTask = NewObject<UTutorialTask_Base>(this);
TutorialTaskObject = NewObject<UTutorialTask_Base>(this, CurrentStep.TutorialTaskClass); TutorialTask->Execute(GetWorld()->GetAuthGameMode());
TutorialTaskObject->Execute(GetWorld()->GetAuthGameMode());
} }

View File

@ -12,7 +12,7 @@ DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FOnStepComplete, int32, CompleteInde
/** /**
* *
*/ */
UCLASS(BlueprintType) UCLASS()
class PROJECTFISH_API UTutorialManagerSubsystem : public UGameInstanceSubsystem class PROJECTFISH_API UTutorialManagerSubsystem : public UGameInstanceSubsystem
{ {
GENERATED_BODY() GENERATED_BODY()
@ -48,11 +48,10 @@ protected:
void ControlUI(); void ControlUI();
//创建task //创建task
void CreateTask(); void CreateTask();
protected: private:
FDelegateHandle LevelLoadedDelegateHandle; FDelegateHandle LevelLoadedDelegateHandle;
UPROPERTY(BlueprintAssignable) UPROPERTY(BlueprintAssignable)
FOnStepComplete OnStepComplete; FOnStepComplete OnStepComplete;
UPROPERTY(BlueprintReadOnly)
bool bTutorialing; bool bTutorialing;
TArray<FTutorialStep> TutorialSteps; TArray<FTutorialStep> TutorialSteps;
@ -62,8 +61,5 @@ protected:
class UDialogueWidget_Base* DialogueWidget; class UDialogueWidget_Base* DialogueWidget;
UPROPERTY() UPROPERTY()
UUserWidget* TutorialWidget; class UTutorialTask_Base* TutorialTask;
UPROPERTY()
class UTutorialTask_Base* TutorialTaskObject;
}; };

View File

@ -24,5 +24,4 @@ public:
UFUNCTION(BlueprintNativeEvent, Category= "TutorialTask") UFUNCTION(BlueprintNativeEvent, Category= "TutorialTask")
void BeforTutorialComplete(); void BeforTutorialComplete();
virtual void BeforTutorialComplete_Implementation(); virtual void BeforTutorialComplete_Implementation();
}; };

View File

@ -3,32 +3,13 @@
#include "TutorialTask_CheckShipContainer.h" #include "TutorialTask_CheckShipContainer.h"
#include "GameFramework/GameModeBase.h"
#include "ProjectFish/Gameplay/Subsystem/GameInfoManager.h"
#include "ProjectFish/Gameplay/Subsystem/TutorialManagerSubsystem.h"
void UTutorialTask_CheckShipContainer::Execute_Implementation(class AGameModeBase* GameMode) void UTutorialTask_CheckShipContainer::Execute_Implementation(class AGameModeBase* GameMode)
{ {
Super::Execute_Implementation(GameMode); Super::Execute_Implementation(GameMode);
if (GameMode)
{
GameMode->GetGameInstance()->GetSubsystem<UGameInfoManager>()->GetPlayerInfo()
->OnShipContainerUpdate.AddDynamic(this, &UTutorialTask_CheckShipContainer::OnShipContainerUpdate);
}
} }
void UTutorialTask_CheckShipContainer::BeforTutorialComplete_Implementation() void UTutorialTask_CheckShipContainer::BeforTutorialComplete_Implementation()
{ {
Super::BeforTutorialComplete_Implementation(); Super::BeforTutorialComplete_Implementation();
} }
void UTutorialTask_CheckShipContainer::OnShipContainerUpdate()
{
//只有3个物品时才完成当前的引导步骤
int CurrentItemCount = GetOuter()->GetWorld()->GetGameInstance()->GetSubsystem<UGameInfoManager>()->GetPlayerInfo()->ShipContainerItems.Num();
if (CurrentItemCount == ReqItemsCount)
{
Cast<UTutorialManagerSubsystem>(GetOuter())->CompleteTutorialStep();
}
}

View File

@ -13,14 +13,7 @@ UCLASS()
class PROJECTFISH_API UTutorialTask_CheckShipContainer : public UTutorialTask_Base class PROJECTFISH_API UTutorialTask_CheckShipContainer : public UTutorialTask_Base
{ {
GENERATED_BODY() GENERATED_BODY()
virtual void Execute_Implementation(class AGameModeBase* GameMode) override; virtual void Execute_Implementation(class AGameModeBase* GameMode) override;
virtual void BeforTutorialComplete_Implementation() override; virtual void BeforTutorialComplete_Implementation() override;
UFUNCTION()
void OnShipContainerUpdate();
protected:
UPROPERTY(BlueprintReadOnly, EditAnywhere, Category = "TutorialTask_CheckShipContainer")
int32 ReqItemsCount;
}; };

View File

@ -8,10 +8,6 @@
void UTutorialTask_GamePause::Execute_Implementation(class AGameModeBase* GameMode) void UTutorialTask_GamePause::Execute_Implementation(class AGameModeBase* GameMode)
{ {
Super::Execute_Implementation(GameMode); Super::Execute_Implementation(GameMode);
// LevelLoadedDelegateHandle = FCoreUObjectDelegates::PostLoadMapWithWorld.AddUObject(
// this,
// &UTutorialTask_GamePause::OnLevelLoaded
// );
UGameplayStatics::SetGamePaused(this, true); UGameplayStatics::SetGamePaused(this, true);
} }
@ -20,18 +16,3 @@ void UTutorialTask_GamePause::BeforTutorialComplete_Implementation()
Super::BeforTutorialComplete_Implementation(); Super::BeforTutorialComplete_Implementation();
UGameplayStatics::SetGamePaused(this, false); 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
// );
}

View File

@ -18,8 +18,4 @@ public:
virtual void Execute_Implementation(class AGameModeBase* GameMode) override; virtual void Execute_Implementation(class AGameModeBase* GameMode) override;
virtual void BeforTutorialComplete_Implementation() override; virtual void BeforTutorialComplete_Implementation() override;
void OnLevelLoaded(UWorld* World);
private:
FDelegateHandle LevelLoadedDelegateHandle;
}; };

View File

@ -23,7 +23,7 @@ void USkillManager::Tick(float DeltaTime)
bool USkillManager::IsTickable() const bool USkillManager::IsTickable() const
{ {
return !bGameEnd && IsValid(GameMode) && GameMode->GetBattleIsBegin() && !GameMode->IsPaused(); return !bGameEnd && IsValid(GameMode) && GameMode->GetBattleIsBegin();
} }
TStatId USkillManager::GetStatId() const TStatId USkillManager::GetStatId() const