Compare commits
8 Commits
3a6b9042f1
...
427bede723
| Author | SHA1 | Date | |
|---|---|---|---|
| 427bede723 | |||
| 905e881cab | |||
| 86c87dbe64 | |||
| 7aac1a1544 | |||
| 08e4076f22 | |||
| d902bb9255 | |||
| 2cd0504023 | |||
| 248bffdc34 |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
ProjectFish/Release/Windows/ProjectFish.exe
Normal file
BIN
ProjectFish/Release/Windows/ProjectFish.exe
Normal file
Binary file not shown.
Binary file not shown.
@ -140,20 +140,22 @@ TArray<FContainerItemSaveData> UContainerInfo::GetSaveData() const
|
||||
return SaveDataArray;
|
||||
}
|
||||
|
||||
void UContainerInfo::LoadFromSaveData(UPlayerInfoSaveGame* SaveGameData)
|
||||
bool UContainerInfo::LoadFromSaveData(FPrimaryAssetId ShapeID, const TArray<FContainerItemSaveData>& ContainerItems)
|
||||
{
|
||||
// 清空当前数据
|
||||
Items.Empty();
|
||||
SlotInUsing.Empty();
|
||||
//从存档中加载仓库形状
|
||||
if (IsValid(SaveGameData))
|
||||
FSoftObjectPath ShipShapePath = UAssetManager::Get().GetPrimaryAssetPath(ShapeID);
|
||||
UShapeAsset* ShapeAsset = Cast<UShapeAsset>(ShipShapePath.TryLoad());
|
||||
if (!IsValid(ShapeAsset))
|
||||
{
|
||||
FSoftObjectPath ShipShapePath = UAssetManager::Get().GetPrimaryAssetPath(SaveGameData->ShipContainerShapeID);
|
||||
InitContainerByShape(Cast<UShapeAsset>(ShipShapePath.TryLoad()));
|
||||
;}
|
||||
return false;
|
||||
}
|
||||
InitContainerByShape(ShapeAsset);
|
||||
// 获得仓库中的物品信息
|
||||
TArray<FPrimaryAssetId> AssetsToLoad;
|
||||
for (const FContainerItemSaveData& ItemData : SaveGameData->ShipContainerItems)
|
||||
for (const FContainerItemSaveData& ItemData : ContainerItems)
|
||||
{
|
||||
FContainerItem NewItem;
|
||||
NewItem.DegreeType = ItemData.DegreeType;
|
||||
@ -164,4 +166,43 @@ void UContainerInfo::LoadFromSaveData(UPlayerInfoSaveGame* SaveGameData)
|
||||
FIntPoint Position(ItemData.PosX, ItemData.PosY);
|
||||
AddContainerItem(NewItem, Position);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// bool UContainerInfo::LoadFromSaveData(UPlayerInfoSaveGame* SaveGameData)
|
||||
// {
|
||||
// // 清空当前数据
|
||||
// Items.Empty();
|
||||
// SlotInUsing.Empty();
|
||||
// //从存档中加载仓库形状
|
||||
// if (IsValid(SaveGameData))
|
||||
// {
|
||||
// FSoftObjectPath ShipShapePath = UAssetManager::Get().GetPrimaryAssetPath(SaveGameData->ShipContainerShapeID);
|
||||
// UShapeAsset* ShapeAsset = Cast<UShapeAsset>(ShipShapePath.TryLoad());
|
||||
// if (!IsValid(ShapeAsset))
|
||||
// {
|
||||
// return false;
|
||||
// }
|
||||
// InitContainerByShape(ShapeAsset);
|
||||
// // 获得仓库中的物品信息
|
||||
// TArray<FPrimaryAssetId> AssetsToLoad;
|
||||
// for (const FContainerItemSaveData& ItemData : SaveGameData->ShipContainerItems)
|
||||
// {
|
||||
// FContainerItem NewItem;
|
||||
// NewItem.DegreeType = ItemData.DegreeType;
|
||||
// //获得物品形状
|
||||
// FSoftObjectPath RewardItemPath = UAssetManager::Get().GetPrimaryAssetPath(ItemData.RewardItemAssetId);
|
||||
// NewItem.RewardItem = Cast<UFishingRewardDataAsset>(RewardItemPath.TryLoad());
|
||||
// //添加物品到容器中
|
||||
// FIntPoint Position(ItemData.PosX, ItemData.PosY);
|
||||
// AddContainerItem(NewItem, Position);
|
||||
// }
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// return false;
|
||||
// }
|
||||
//
|
||||
// return true;
|
||||
// }
|
||||
|
||||
@ -117,8 +117,11 @@ public:
|
||||
TArray<FContainerItemSaveData> GetSaveData() const;
|
||||
|
||||
// 从存档数据加载
|
||||
// UFUNCTION(BlueprintCallable, Category = "ContainerInfo")
|
||||
// bool LoadFromSaveData(UPlayerInfoSaveGame* SaveGameData);
|
||||
|
||||
UFUNCTION(BlueprintCallable, Category = "ContainerInfo")
|
||||
void LoadFromSaveData(UPlayerInfoSaveGame* SaveGameData);
|
||||
bool LoadFromSaveData(FPrimaryAssetId ShapeID, const TArray<FContainerItemSaveData>& ContainerItems);
|
||||
|
||||
private:
|
||||
//要添加的物品是否会覆盖其他物品
|
||||
|
||||
@ -44,10 +44,33 @@ bool UGameInfoManager::LoadGameInfo()
|
||||
return false;
|
||||
}
|
||||
|
||||
void UGameInfoManager::CreateGameInfo(UContainerInfo* ShipContainer)
|
||||
void UGameInfoManager::CreateGameInfo(UContainerInfo* ShipContainer, UContainerInfo* PlayerContainer)
|
||||
{
|
||||
PlayerInfo = NewObject<UPlayerInfoSaveGame>(this);
|
||||
PlayerInfo->ShipContainerItems = ShipContainer->GetSaveData();
|
||||
PlayerInfo->ShipContainerShapeID = ShipContainer->ContainerShape->GetPrimaryAssetId();
|
||||
|
||||
PlayerInfo->PlayerContainerItems = PlayerContainer->GetSaveData();
|
||||
PlayerInfo->PlayerContainerShapeID = PlayerContainer->ContainerShape->GetPrimaryAssetId();
|
||||
SaveGameInfo();
|
||||
}
|
||||
|
||||
void UGameInfoManager::CreateGameInfoAndSave(UShapeAsset* ShipContainerShape, UShapeAsset* PlayerContainerShape)
|
||||
{
|
||||
//创建仓库信息
|
||||
UContainerInfo* ShipContainer = NewObject<UContainerInfo>();
|
||||
ShipContainer->InitContainerByShape(ShipContainerShape);
|
||||
|
||||
UContainerInfo* PlayerContainer = NewObject<UContainerInfo>();
|
||||
PlayerContainer->InitContainerByShape(PlayerContainerShape);
|
||||
|
||||
//创建要保存的额存档信息
|
||||
PlayerInfo = NewObject<UPlayerInfoSaveGame>(this);
|
||||
PlayerInfo->ShipContainerItems = ShipContainer->GetSaveData();
|
||||
PlayerInfo->ShipContainerShapeID = ShipContainer->ContainerShape->GetPrimaryAssetId();
|
||||
|
||||
PlayerInfo->PlayerContainerItems = PlayerContainer->GetSaveData();
|
||||
PlayerInfo->PlayerContainerShapeID = PlayerContainer->ContainerShape->GetPrimaryAssetId();
|
||||
|
||||
SaveGameInfo();
|
||||
}
|
||||
|
||||
@ -23,7 +23,10 @@ protected:
|
||||
UFUNCTION(BlueprintCallable)
|
||||
bool LoadGameInfo();
|
||||
UFUNCTION(BlueprintCallable)
|
||||
void CreateGameInfo(UContainerInfo* ShipContainer);
|
||||
void CreateGameInfo(UContainerInfo* ShipContainer, UContainerInfo* PlayerContainer);
|
||||
|
||||
UFUNCTION(BlueprintCallable)
|
||||
void CreateGameInfoAndSave(UShapeAsset* ShipContainerShape, UShapeAsset* PlayerContainerShape);
|
||||
protected:
|
||||
UPROPERTY(BlueprintReadOnly)
|
||||
TObjectPtr<class UPlayerInfoSaveGame> PlayerInfo;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user