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 (ContainerShape->IsSlotActive(Item.ContainerStartPos.X + x, Item.ContainerStartPos.Y + y) && SlotItems.Contains(FIntPoint(x + Item.ContainerStartPos.X, y + Item.ContainerStartPos.Y))
///SlotItems[FIntPoint(x + Item.ContainerStartPos.X, y + Item.ContainerStartPos.Y)] != -1
if (ContainerShape->IsSlotActive(Item.ContainerStartPos.X + x, Item.ContainerStartPos.Y + y) &&
SlotItems[FIntPoint(x + Item.ContainerStartPos.X, y + Item.ContainerStartPos.Y)] != -1
)
{
OverlapItems.Add(SlotItems[FIntPoint(x + Item.ContainerStartPos.X, y + Item.ContainerStartPos.Y)] );

View File

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

View File

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

View File

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

View File

@ -16,7 +16,7 @@ class PROJECTFISH_API UFishGameInstance : public UGameInstance
public:
/** GameInstace */
virtual void OnStart() override;
UFUNCTION(BlueprintImplementableEvent)
void InitTutorialSteps();
};

View File

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

View File

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

View File

@ -32,7 +32,6 @@ void UTutorialManagerSubsystem::ApplyCurrentTutorialStep()
{
if (TutorialSteps.Num() > CurrentTutorialStep )
{
UE_LOG(LogTemp, Warning, TEXT("执行 CurrentTutorialStep = %d || name = %s "), CurrentTutorialStep, *GetCurrentTutorialStep().StepName.ToString() );
bTutorialing = true;
FTutorialStep CurrentStep = TutorialSteps[CurrentTutorialStep];
if (IsValid(CurrentStep.Dialogue))
@ -53,7 +52,7 @@ void UTutorialManagerSubsystem::ApplyCurrentTutorialStep()
}
if (IsValid(CurrentStep.TutorialTaskClass))
{
CreateTask();
}
}
else
@ -67,18 +66,12 @@ void UTutorialManagerSubsystem::CompleteTutorialStep()
{
if (bTutorialing)
{
if (TutorialTaskObject)
if (TutorialTask)
{
TutorialTaskObject->BeforTutorialComplete();
TutorialTaskObject->ConditionalBeginDestroy();
TutorialTaskObject = nullptr;
TutorialTask->ConditionalBeginDestroy();
TutorialTask = nullptr;
}
if (TutorialWidget)
{
TutorialWidget->RemoveFromViewport();
TutorialWidget = nullptr;
}
UE_LOG(LogTemp, Warning, TEXT(" 教程进行下一步"));
UE_LOG(LogTemp, Warning, TEXT("教程进行下一步 currentstep = %d"), CurrentTutorialStep);
OnStepComplete.Broadcast(CurrentTutorialStep);
CurrentTutorialStep++;
ApplyCurrentTutorialStep();
@ -145,7 +138,7 @@ void UTutorialManagerSubsystem::AccepAndFollowQuest()
void UTutorialManagerSubsystem::ShowTutorialUI()
{
FTutorialStep CurrentStep = TutorialSteps[CurrentTutorialStep];
TutorialWidget = CreateWidget<UUserWidget>(GetWorld(), CurrentStep.TutorialUI);
UUserWidget* TutorialWidget = CreateWidget<UUserWidget>(GetWorld(), CurrentStep.TutorialUI);
TutorialWidget->AddToViewport(99);
}
@ -168,7 +161,6 @@ void UTutorialManagerSubsystem::ControlUI()
void UTutorialManagerSubsystem::CreateTask()
{
FTutorialStep CurrentStep = TutorialSteps[CurrentTutorialStep];
TutorialTaskObject = NewObject<UTutorialTask_Base>(this, CurrentStep.TutorialTaskClass);
TutorialTaskObject->Execute(GetWorld()->GetAuthGameMode());
TutorialTask = NewObject<UTutorialTask_Base>(this);
TutorialTask->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
{
GENERATED_BODY()
@ -48,11 +48,10 @@ protected:
void ControlUI();
//创建task
void CreateTask();
protected:
private:
FDelegateHandle LevelLoadedDelegateHandle;
UPROPERTY(BlueprintAssignable)
FOnStepComplete OnStepComplete;
UPROPERTY(BlueprintReadOnly)
bool bTutorialing;
TArray<FTutorialStep> TutorialSteps;
@ -60,10 +59,7 @@ protected:
FString DialogueUIPath;
UPROPERTY()
class UDialogueWidget_Base* DialogueWidget;
UPROPERTY()
UUserWidget* TutorialWidget;
UPROPERTY()
class UTutorialTask_Base* TutorialTaskObject;
class UTutorialTask_Base* TutorialTask;
};

View File

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

View File

@ -3,32 +3,13 @@
#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)
{
Super::Execute_Implementation(GameMode);
if (GameMode)
{
GameMode->GetGameInstance()->GetSubsystem<UGameInfoManager>()->GetPlayerInfo()
->OnShipContainerUpdate.AddDynamic(this, &UTutorialTask_CheckShipContainer::OnShipContainerUpdate);
}
}
void UTutorialTask_CheckShipContainer::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
{
GENERATED_BODY()
virtual void Execute_Implementation(class AGameModeBase* GameMode) 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)
{
Super::Execute_Implementation(GameMode);
// LevelLoadedDelegateHandle = FCoreUObjectDelegates::PostLoadMapWithWorld.AddUObject(
// this,
// &UTutorialTask_GamePause::OnLevelLoaded
// );
UGameplayStatics::SetGamePaused(this, true);
}
@ -20,18 +16,3 @@ 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
// );
}

View File

@ -18,8 +18,4 @@ public:
virtual void Execute_Implementation(class AGameModeBase* GameMode) 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
{
return !bGameEnd && IsValid(GameMode) && GameMode->GetBattleIsBegin() && !GameMode->IsPaused();
return !bGameEnd && IsValid(GameMode) && GameMode->GetBattleIsBegin();
}
TStatId USkillManager::GetStatId() const