Merge branch 'dev'
This commit is contained in:
commit
86c87dbe64
@ -21,38 +21,6 @@
|
||||
"BuildId": "37670630"
|
||||
},
|
||||
"BuildProducts": [
|
||||
{
|
||||
"Path": "$(ProjectDir)/Binaries/Win64/UnrealEditor-ProjectFish.dll",
|
||||
"Type": "DynamicLibrary"
|
||||
},
|
||||
{
|
||||
"Path": "$(ProjectDir)/Binaries/Win64/UnrealEditor-ProjectFish.pdb",
|
||||
"Type": "SymbolFile"
|
||||
},
|
||||
{
|
||||
"Path": "$(ProjectDir)/Binaries/Win64/UnrealEditor-ProjectFishEditor.dll",
|
||||
"Type": "DynamicLibrary"
|
||||
},
|
||||
{
|
||||
"Path": "$(ProjectDir)/Binaries/Win64/UnrealEditor-ProjectFishEditor.pdb",
|
||||
"Type": "SymbolFile"
|
||||
},
|
||||
{
|
||||
"Path": "$(ProjectDir)/Binaries/Win64/UnrealEditor.modules",
|
||||
"Type": "RequiredResource"
|
||||
},
|
||||
{
|
||||
"Path": "$(ProjectDir)/Plugins/DeskMode/Binaries/Win64/UnrealEditor-DeskMode.dll",
|
||||
"Type": "DynamicLibrary"
|
||||
},
|
||||
{
|
||||
"Path": "$(ProjectDir)/Plugins/DeskMode/Binaries/Win64/UnrealEditor-DeskMode.pdb",
|
||||
"Type": "SymbolFile"
|
||||
},
|
||||
{
|
||||
"Path": "$(ProjectDir)/Plugins/DeskMode/Binaries/Win64/UnrealEditor.modules",
|
||||
"Type": "RequiredResource"
|
||||
},
|
||||
{
|
||||
"Path": "$(EngineDir)/Binaries/ThirdParty/USD/UsdResources/Win64/plugins/ar/resources/plugInfo.json",
|
||||
"Type": "RequiredResource"
|
||||
@ -8040,17 +8008,41 @@
|
||||
{
|
||||
"Path": "$(EngineDir)/Plugins/XGEController/Binaries/Win64/UnrealEditor.modules",
|
||||
"Type": "RequiredResource"
|
||||
},
|
||||
{
|
||||
"Path": "$(ProjectDir)/Binaries/Win64/UnrealEditor-ProjectFish.dll",
|
||||
"Type": "DynamicLibrary"
|
||||
},
|
||||
{
|
||||
"Path": "$(ProjectDir)/Binaries/Win64/UnrealEditor-ProjectFish.pdb",
|
||||
"Type": "SymbolFile"
|
||||
},
|
||||
{
|
||||
"Path": "$(ProjectDir)/Binaries/Win64/UnrealEditor-ProjectFishEditor.dll",
|
||||
"Type": "DynamicLibrary"
|
||||
},
|
||||
{
|
||||
"Path": "$(ProjectDir)/Binaries/Win64/UnrealEditor-ProjectFishEditor.pdb",
|
||||
"Type": "SymbolFile"
|
||||
},
|
||||
{
|
||||
"Path": "$(ProjectDir)/Binaries/Win64/UnrealEditor.modules",
|
||||
"Type": "RequiredResource"
|
||||
},
|
||||
{
|
||||
"Path": "$(ProjectDir)/Plugins/DeskMode/Binaries/Win64/UnrealEditor-DeskMode.dll",
|
||||
"Type": "DynamicLibrary"
|
||||
},
|
||||
{
|
||||
"Path": "$(ProjectDir)/Plugins/DeskMode/Binaries/Win64/UnrealEditor-DeskMode.pdb",
|
||||
"Type": "SymbolFile"
|
||||
},
|
||||
{
|
||||
"Path": "$(ProjectDir)/Plugins/DeskMode/Binaries/Win64/UnrealEditor.modules",
|
||||
"Type": "RequiredResource"
|
||||
}
|
||||
],
|
||||
"RuntimeDependencies": [
|
||||
{
|
||||
"Path": "$(ProjectDir)/Plugins/DeskMode/DeskMode.uplugin",
|
||||
"Type": "UFS"
|
||||
},
|
||||
{
|
||||
"Path": "$(ProjectDir)/ProjectFish.uproject",
|
||||
"Type": "UFS"
|
||||
},
|
||||
{
|
||||
"Path": "$(EngineDir)/Binaries/ThirdParty/DbgHelp/dbghelp.dll",
|
||||
"Type": "NonUFS"
|
||||
@ -33778,6 +33770,14 @@
|
||||
{
|
||||
"Path": "$(EngineDir)/Plugins/XGEController/XGEController.uplugin",
|
||||
"Type": "UFS"
|
||||
},
|
||||
{
|
||||
"Path": "$(ProjectDir)/Plugins/DeskMode/DeskMode.uplugin",
|
||||
"Type": "UFS"
|
||||
},
|
||||
{
|
||||
"Path": "$(ProjectDir)/ProjectFish.uproject",
|
||||
"Type": "UFS"
|
||||
}
|
||||
],
|
||||
"BuildPlugins": [
|
||||
|
||||
Binary file not shown.
Binary file not shown.
@ -100,6 +100,9 @@ ManualIPAddress=
|
||||
+ClassRedirects=(OldName="/Script/ProjectFish.PlayerInventorySubsystem",NewName="/Script/ProjectFish.FishingRodConfigSubsystem")
|
||||
+ClassRedirects=(OldName="/Script/ProjectFish.SimpleMapSystem",NewName="/Script/ProjectFish.FishingMapSubSystem")
|
||||
+ClassRedirects=(OldName="/Script/ProjectFish.FishingMapSystem",NewName="/Script/ProjectFish.FishingMapSubSystem")
|
||||
+ClassRedirects=(OldName="/Script/ProjectFish.BagShapeAsset",NewName="/Script/ProjectFish.ShapeAsset")
|
||||
+ClassRedirects=(OldName="/Script/ProjectFishEditor.BagShapeFactory",NewName="/Script/ProjectFishEditor.ShapeFactory")
|
||||
+ClassRedirects=(OldName="/Script/ProjectFishEditor.BagShapeAssetThumbnailRenderer",NewName="/Script/ProjectFishEditor.ShapeAssetThumbnailRenderer")
|
||||
|
||||
[/Script/Engine.CollisionProfile]
|
||||
-Profiles=(Name="NoCollision",CollisionEnabled=NoCollision,ObjectTypeName="WorldStatic",CustomResponses=((Channel="Visibility",Response=ECR_Ignore),(Channel="Camera",Response=ECR_Ignore)),HelpMessage="No collision",bCanModify=False)
|
||||
|
||||
@ -5,3 +5,18 @@ ProjectName=Top Down Game Template
|
||||
[/Script/ProjectFish.ProjectFishCharacter]
|
||||
FixedCameraPitch=-45.0
|
||||
FixedCameraDistance=1500.0
|
||||
|
||||
[/Script/Engine.AssetManagerSettings]
|
||||
-PrimaryAssetTypesToScan=(PrimaryAssetType="Map",AssetBaseClass=/Script/Engine.World,bHasBlueprintClasses=False,bIsEditorOnly=True,Directories=((Path="/Game/Maps")),SpecificAssets=,Rules=(Priority=-1,ChunkId=-1,bApplyRecursively=True,CookRule=Unknown))
|
||||
-PrimaryAssetTypesToScan=(PrimaryAssetType="PrimaryAssetLabel",AssetBaseClass=/Script/Engine.PrimaryAssetLabel,bHasBlueprintClasses=False,bIsEditorOnly=True,Directories=((Path="/Game")),SpecificAssets=,Rules=(Priority=-1,ChunkId=-1,bApplyRecursively=True,CookRule=Unknown))
|
||||
+PrimaryAssetTypesToScan=(PrimaryAssetType="Map",AssetBaseClass="/Script/Engine.World",bHasBlueprintClasses=False,bIsEditorOnly=True,Directories=((Path="/Game/Maps")),SpecificAssets=,Rules=(Priority=-1,ChunkId=-1,bApplyRecursively=True,CookRule=Unknown))
|
||||
+PrimaryAssetTypesToScan=(PrimaryAssetType="PrimaryAssetLabel",AssetBaseClass="/Script/Engine.PrimaryAssetLabel",bHasBlueprintClasses=False,bIsEditorOnly=True,Directories=((Path="/Game")),SpecificAssets=,Rules=(Priority=-1,ChunkId=-1,bApplyRecursively=True,CookRule=Unknown))
|
||||
+PrimaryAssetTypesToScan=(PrimaryAssetType="FishingRewardDataAsset",AssetBaseClass="/Script/ProjectFish.FishingRewardDataAsset",bHasBlueprintClasses=False,bIsEditorOnly=False,Directories=((Path="/Game/DataAssets/FishReward")),SpecificAssets=,Rules=(Priority=-1,ChunkId=-1,bApplyRecursively=True,CookRule=AlwaysCook))
|
||||
+PrimaryAssetTypesToScan=(PrimaryAssetType="ShapeAsset",AssetBaseClass="/Script/ProjectFish.ShapeAsset",bHasBlueprintClasses=False,bIsEditorOnly=False,Directories=((Path="/Game/DataAssets")),SpecificAssets=,Rules=(Priority=-1,ChunkId=-1,bApplyRecursively=True,CookRule=AlwaysCook))
|
||||
bOnlyCookProductionAssets=False
|
||||
bShouldManagerDetermineTypeAndName=False
|
||||
bShouldGuessTypeAndNameInEditor=True
|
||||
bShouldAcquireMissingChunksOnLoad=False
|
||||
bShouldWarnAboutInvalidAssets=True
|
||||
MetaDataTagsForAssetRegistry=()
|
||||
|
||||
|
||||
BIN
ProjectFish/Content/DataAssets/Fish/Fish_Boss.uasset
Normal file
BIN
ProjectFish/Content/DataAssets/Fish/Fish_Boss.uasset
Normal file
Binary file not shown.
BIN
ProjectFish/Content/DataAssets/Fish/Fish_DeepInfo.uasset
Normal file
BIN
ProjectFish/Content/DataAssets/Fish/Fish_DeepInfo.uasset
Normal file
Binary file not shown.
BIN
ProjectFish/Content/DataAssets/FishReward/Fish1Reward.uasset
Normal file
BIN
ProjectFish/Content/DataAssets/FishReward/Fish1Reward.uasset
Normal file
Binary file not shown.
BIN
ProjectFish/Content/DataAssets/FishReward/Fish1Reward2.uasset
Normal file
BIN
ProjectFish/Content/DataAssets/FishReward/Fish1Reward2.uasset
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
ProjectFish/Content/DataAssets/Ship/ShipShapeAsset.uasset
Normal file
BIN
ProjectFish/Content/DataAssets/Ship/ShipShapeAsset.uasset
Normal file
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.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
ProjectFish/Content/Gameplay/Home/BP_HomeGameMode.uasset
Normal file
BIN
ProjectFish/Content/Gameplay/Home/BP_HomeGameMode.uasset
Normal file
Binary file not shown.
BIN
ProjectFish/Content/Gameplay/Home/BP_HomePlayerController.uasset
Normal file
BIN
ProjectFish/Content/Gameplay/Home/BP_HomePlayerController.uasset
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
ProjectFish/Content/Maps/Home.umap
Normal file
BIN
ProjectFish/Content/Maps/Home.umap
Normal file
Binary file not shown.
BIN
ProjectFish/Content/Maps/TestUI.umap
Normal file
BIN
ProjectFish/Content/Maps/TestUI.umap
Normal file
Binary file not shown.
BIN
ProjectFish/Content/Textures/FishingRewards/Reward1.uasset
Normal file
BIN
ProjectFish/Content/Textures/FishingRewards/Reward1.uasset
Normal file
Binary file not shown.
BIN
ProjectFish/Content/Textures/FishingRewards/Reward2.uasset
Normal file
BIN
ProjectFish/Content/Textures/FishingRewards/Reward2.uasset
Normal file
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.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
ProjectFish/Content/UI/Fishing/Windows/UMG_ReadyWIndow.uasset
Normal file
BIN
ProjectFish/Content/UI/Fishing/Windows/UMG_ReadyWIndow.uasset
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
ProjectFish/Content/UI/HomeUI/Windows/UMG_HomeWindow_Main.uasset
Normal file
BIN
ProjectFish/Content/UI/HomeUI/Windows/UMG_HomeWindow_Main.uasset
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -2,6 +2,6 @@
|
||||
"BuildId": "37670630",
|
||||
"Modules":
|
||||
{
|
||||
"DeskMode": "UnrealEditor-DeskMode-0003.dll"
|
||||
"DeskMode": "UnrealEditor-DeskMode.dll"
|
||||
}
|
||||
}
|
||||
@ -40,7 +40,9 @@
|
||||
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=72263A5F_002DD5F9_002D3915_002D8DA0_002DCD45C38A70E5_002Fdl_003ASource_003AF_0021_003FEpic_003FUE_005F5_002E5_003FEngine_003FSource_002Fd_003ARuntime_002Fd_003ACoreUObject_002Fd_003APublic_002Fd_003AUObject_002Ff_003AUnrealType_002Eh/@EntryIndexedValue">ForceIncluded</s:String>
|
||||
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=72263A5F_002DD5F9_002D3915_002D8DA0_002DCD45C38A70E5_002Fdl_003ASource_003AF_0021_003FEpic_003FUE_005F5_002E5_003FEngine_003FSource_002Fd_003ARuntime_002Fd_003ACoreUObject_002Fd_003APublic_002Fd_003AUObject_002Ff_003AUObjectArray_002Eh/@EntryIndexedValue">ForceIncluded</s:String>
|
||||
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=72263A5F_002DD5F9_002D3915_002D8DA0_002DCD45C38A70E5_002Fdl_003ASource_003AF_0021_003FEpic_003FUE_005F5_002E5_003FEngine_003FSource_002Fd_003ARuntime_002Fd_003ACoreUObject_002Fd_003APublic_002Fd_003AUObject_002Ff_003AUObjectBase_002Eh/@EntryIndexedValue">ForceIncluded</s:String>
|
||||
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=72263A5F_002DD5F9_002D3915_002D8DA0_002DCD45C38A70E5_002Fdl_003ASource_003AF_0021_003FEpic_003FUE_005F5_002E5_003FEngine_003FSource_002Fd_003ARuntime_002Fd_003ACore_002Fd_003APublic_002Fd_003ATemplates_002Ff_003ASharedPointer_002Eh/@EntryIndexedValue">ForceIncluded</s:String>
|
||||
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=72263A5F_002DD5F9_002D3915_002D8DA0_002DCD45C38A70E5_002Fdl_003ASource_003AF_0021_003FEpic_003FUE_005F5_002E5_003FEngine_003FSource_002Fd_003ARuntime_002Fd_003ACore_002Fd_003APublic_002Fd_003ATemplates_002Ff_003ATuple_002Eh/@EntryIndexedValue">ForceIncluded</s:String>
|
||||
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=72263A5F_002DD5F9_002D3915_002D8DA0_002DCD45C38A70E5_002Fdl_003ASource_003AF_0021_003FEpic_003FUE_005F5_002E5_003FEngine_003FSource_002Fd_003ARuntime_002Fd_003AEngine_002Fd_003AClasses_002Fd_003AEngine_002Ff_003AEngine_002Eh/@EntryIndexedValue">ForceIncluded</s:String>
|
||||
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=72263A5F_002DD5F9_002D3915_002D8DA0_002DCD45C38A70E5_002Fdl_003ASource_003AF_0021_003FEpic_003FUE_005F5_002E5_003FEngine_003FSource_002Fd_003ARuntime_002Fd_003AEngine_002Fd_003AClasses_002Fd_003AGameFramework_002Ff_003ACharacterMovementComponent_002Eh/@EntryIndexedValue">ForceIncluded</s:String>
|
||||
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=72263A5F_002DD5F9_002D3915_002D8DA0_002DCD45C38A70E5_002Fdl_003ASource_003AF_0021_003FEpic_003FUE_005F5_002E5_003FEngine_003FSource_002Fd_003ARuntime_002Fd_003AEngine_002Fd_003APrivate_002Fd_003AComponents_002Ff_003ACharacterMovementComponent_002Ecpp/@EntryIndexedValue">ForceIncluded</s:String>
|
||||
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=72263A5F_002DD5F9_002D3915_002D8DA0_002DCD45C38A70E5_002Fdl_003ASource_003AF_0021_003FEpic_003FUE_005F5_002E5_003FEngine_003FSource_002Fd_003ARuntime_002Fd_003AEngine_002Fd_003APrivate_002Ff_003AGameplayStatics_002Ecpp/@EntryIndexedValue">ForceIncluded</s:String>
|
||||
|
||||
167
ProjectFish/Source/ProjectFish/Data/ContainerInfo.cpp
Normal file
167
ProjectFish/Source/ProjectFish/Data/ContainerInfo.cpp
Normal file
@ -0,0 +1,167 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
|
||||
#include "ContainerInfo.h"
|
||||
|
||||
#include "PlayerInfoSaveGame.h"
|
||||
#include "Engine/AssetManager.h"
|
||||
#include "Engine/StreamableManager.h"
|
||||
|
||||
// void UContainerInfo::InitContainer(FPrimaryAssetId ContainerShapeId)
|
||||
// {
|
||||
// //加载形状资源
|
||||
// TSharedPtr<FStreamableHandle> LoadHandle = GEngine->AssetManager->LoadPrimaryAsset(ContainerShapeId);
|
||||
// if (LoadHandle.IsValid())
|
||||
// {
|
||||
// // 等待加载完成,这会阻塞线程
|
||||
// LoadHandle->WaitUntilComplete();
|
||||
//
|
||||
// // 加载完成后,通过句柄获取资源
|
||||
// UObject* LoadedObject = LoadHandle->GetLoadedAsset();
|
||||
// if (LoadedObject)
|
||||
// {
|
||||
// ContainerShape = Cast<UShapeAsset>(LoadedObject);
|
||||
// for (int x = 0; x < ContainerShape->GetShapeWidth(); x++)
|
||||
// {
|
||||
// for (int y = 0; y < ContainerShape->GetShapeHeight(); y++)
|
||||
// {
|
||||
// SlotInUsing.Add(FIntPoint(x, y), false);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// LoadHandle->ReleaseHandle();
|
||||
// }
|
||||
//
|
||||
// }
|
||||
|
||||
void UContainerInfo::InitContainerByShape(UShapeAsset* InContainerShape)
|
||||
{
|
||||
ContainerShape = InContainerShape;
|
||||
for (int x = 0; x < ContainerShape->GetShapeWidth(); x++)
|
||||
{
|
||||
for (int y = 0; y < ContainerShape->GetShapeHeight(); y++)
|
||||
{
|
||||
SlotInUsing.Add(FIntPoint(x, y), false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool UContainerInfo::AddContainerItem(FContainerItem Item, FIntPoint Position)
|
||||
{
|
||||
if (IsItemInContainerShape(Item, Position))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (IsItemOverlapOtherItem(Item, Position))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
Items.Add(Position, Item);
|
||||
//设置容器指定位置的占用状态
|
||||
for (int x = 0; x < Item.GetItemWIdth(); x++)
|
||||
{
|
||||
for (int y = 0; y < Item.GetItemHeight(); y++)
|
||||
{
|
||||
if (Item.IsSlotUsing(FIntPoint(x, y)))
|
||||
{
|
||||
SlotInUsing.Add(FIntPoint(x + Position.X, y + Position.Y), true);
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool UContainerInfo::IsItemOverlapOtherItem(FContainerItem NewItem, FIntPoint Position)
|
||||
{
|
||||
|
||||
for (int x = 0; x < NewItem.GetItemWIdth(); x++)
|
||||
{
|
||||
for (int y = 0; y < NewItem.GetItemHeight(); y++)
|
||||
{
|
||||
if (NewItem.IsSlotUsing(Position))
|
||||
{
|
||||
|
||||
if (!ContainerShape->IsSlotActive(Position.X + x, Position.Y + y) ||
|
||||
SlotInUsing[FIntPoint(x + Position.X, y + Position.Y)])
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool UContainerInfo::IsItemInContainerShape(FContainerItem NewItem, FIntPoint Position)
|
||||
{
|
||||
for (int x = 0; x < NewItem.GetItemWIdth(); x++)
|
||||
{
|
||||
for (int y = 0; y < NewItem.GetItemHeight(); y++)
|
||||
{
|
||||
if ( (x + Position.X) > 0 && (x + Position.X) < ContainerShape->GetShapeWidth() &&
|
||||
(y + Position.Y) > 0 && (y + Position.Y) < ContainerShape->GetShapeHeight()
|
||||
)
|
||||
{
|
||||
if (!ContainerShape->IsSlotActive(Position.X + x, Position.Y + y))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
TArray<FContainerItemSaveData> UContainerInfo::GetSaveData() const
|
||||
{
|
||||
TArray<FContainerItemSaveData> SaveDataArray;
|
||||
FPrimaryAssetId TestID = ContainerShape->GetPrimaryAssetId();
|
||||
for (const auto& ItemPair : Items)
|
||||
{
|
||||
FContainerItemSaveData SaveData;
|
||||
SaveData.PosX = ItemPair.Key.X;
|
||||
SaveData.PosY = ItemPair.Key.Y;
|
||||
SaveData.DegreeType = ItemPair.Value.DegreeType;
|
||||
|
||||
if (ItemPair.Value.RewardItem)
|
||||
{
|
||||
SaveData.RewardItemAssetId = ItemPair.Value.RewardItem->GetPrimaryAssetId();
|
||||
}
|
||||
|
||||
SaveDataArray.Add(SaveData);
|
||||
}
|
||||
|
||||
return SaveDataArray;
|
||||
}
|
||||
|
||||
void UContainerInfo::LoadFromSaveData(UPlayerInfoSaveGame* SaveGameData)
|
||||
{
|
||||
// 清空当前数据
|
||||
Items.Empty();
|
||||
SlotInUsing.Empty();
|
||||
//从存档中加载仓库形状
|
||||
if (IsValid(SaveGameData))
|
||||
{
|
||||
FSoftObjectPath ShipShapePath = UAssetManager::Get().GetPrimaryAssetPath(SaveGameData->ShipContainerShapeID);
|
||||
InitContainerByShape(Cast<UShapeAsset>(ShipShapePath.TryLoad()));
|
||||
;}
|
||||
// 获得仓库中的物品信息
|
||||
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);
|
||||
}
|
||||
}
|
||||
137
ProjectFish/Source/ProjectFish/Data/ContainerInfo.h
Normal file
137
ProjectFish/Source/ProjectFish/Data/ContainerInfo.h
Normal file
@ -0,0 +1,137 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "ProjectFish/DataAsset/FishingRewardDataAsset.h"
|
||||
#include "ProjectFish/DataAsset/ShapeAsset.h"
|
||||
#include "UObject/Object.h"
|
||||
#include "ContainerInfo.generated.h"
|
||||
|
||||
UENUM(BlueprintType)
|
||||
enum class EItemDegreeType: uint8
|
||||
{
|
||||
Zero,
|
||||
Ninety UMETA(DisplayName = "90度"),
|
||||
OneEighty UMETA(DisplayName = "180度"),
|
||||
TwentySeven UMETA(DisplayName = "270度"),
|
||||
};
|
||||
//仓库物品
|
||||
|
||||
class UShapeAsset;
|
||||
|
||||
// 可序列化的容器物品数据(仅用于存档)
|
||||
USTRUCT(BlueprintType)
|
||||
struct FContainerItemSaveData
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
UPROPERTY(SaveGame)
|
||||
int32 PosX;
|
||||
|
||||
UPROPERTY(SaveGame)
|
||||
int32 PosY;
|
||||
|
||||
UPROPERTY(SaveGame)
|
||||
EItemDegreeType DegreeType;
|
||||
|
||||
UPROPERTY(SaveGame)
|
||||
FPrimaryAssetId RewardItemAssetId;
|
||||
};
|
||||
|
||||
USTRUCT(BlueprintType)
|
||||
struct FContainerItem
|
||||
{
|
||||
GENERATED_BODY()
|
||||
public:
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite)
|
||||
EItemDegreeType DegreeType;
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite)
|
||||
UFishingRewardDataAsset* RewardItem;
|
||||
|
||||
//旋转后的水平宽度
|
||||
int32 GetItemWIdth()
|
||||
{
|
||||
return DegreeType == EItemDegreeType::Ninety || DegreeType == EItemDegreeType::TwentySeven? RewardItem->RewardShape->GetShapeHeight()
|
||||
: RewardItem->RewardShape->GetShapeWidth();
|
||||
}
|
||||
//旋转后的垂直高度
|
||||
int32 GetItemHeight()
|
||||
{
|
||||
return DegreeType == EItemDegreeType::Ninety || DegreeType == EItemDegreeType::TwentySeven? RewardItem->RewardShape->GetShapeWidth()
|
||||
: RewardItem->RewardShape->GetShapeHeight();
|
||||
}
|
||||
|
||||
bool IsSlotUsing(FIntPoint Position)
|
||||
{
|
||||
FIntPoint BeforeRotationPos;
|
||||
switch (DegreeType)
|
||||
{
|
||||
case EItemDegreeType::Zero:
|
||||
BeforeRotationPos = Position;
|
||||
break;
|
||||
case EItemDegreeType::Ninety:
|
||||
{
|
||||
BeforeRotationPos.X = Position.Y;
|
||||
BeforeRotationPos.Y = GetItemWIdth() - Position.X - 1;
|
||||
}
|
||||
break;
|
||||
case EItemDegreeType::OneEighty:
|
||||
{
|
||||
BeforeRotationPos.X = GetItemWIdth() - Position.X - 1;
|
||||
BeforeRotationPos.Y = GetItemHeight() - Position.Y- 1;
|
||||
}
|
||||
break;
|
||||
case EItemDegreeType::TwentySeven:
|
||||
{
|
||||
BeforeRotationPos.X = Position.X;
|
||||
BeforeRotationPos.Y = GetItemHeight() - Position.Y- 1;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
return RewardItem->RewardShape->IsSlotActive(BeforeRotationPos.X, BeforeRotationPos.Y);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* 仓库
|
||||
*/
|
||||
UCLASS(BlueprintType)
|
||||
class PROJECTFISH_API UContainerInfo : public UObject
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
|
||||
UFUNCTION(BlueprintCallable, Category = "ContainerInfo")
|
||||
void InitContainerByShape(UShapeAsset* InContainerShape);
|
||||
|
||||
UFUNCTION(BlueprintPure)
|
||||
bool AddContainerItem(FContainerItem Item, FIntPoint Position);
|
||||
|
||||
// 获取存档数据
|
||||
UFUNCTION(BlueprintCallable, Category = "ContainerInfo")
|
||||
TArray<FContainerItemSaveData> GetSaveData() const;
|
||||
|
||||
// 从存档数据加载
|
||||
UFUNCTION(BlueprintCallable, Category = "ContainerInfo")
|
||||
void LoadFromSaveData(UPlayerInfoSaveGame* SaveGameData);
|
||||
|
||||
private:
|
||||
//要添加的物品是否会覆盖其他物品
|
||||
bool IsItemOverlapOtherItem(FContainerItem Item, FIntPoint Position);
|
||||
//要添加的物品是否在容器范围内
|
||||
bool IsItemInContainerShape(FContainerItem Item, FIntPoint Position);
|
||||
|
||||
public:
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite)
|
||||
TMap<FIntPoint, FContainerItem> Items;
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite)
|
||||
UShapeAsset* ContainerShape;
|
||||
|
||||
private:
|
||||
TMap<FIntPoint, bool> SlotInUsing;
|
||||
};
|
||||
@ -0,0 +1,4 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
|
||||
#include "PlayerInfoSaveGame.h"
|
||||
46
ProjectFish/Source/ProjectFish/Data/PlayerInfoSaveGame.h
Normal file
46
ProjectFish/Source/ProjectFish/Data/PlayerInfoSaveGame.h
Normal file
@ -0,0 +1,46 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "ContainerInfo.h"
|
||||
#include "GameFramework/SaveGame.h"
|
||||
#include "ProjectFish/Definations.h"
|
||||
#include "PlayerInfoSaveGame.generated.h"
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
UCLASS()
|
||||
class PROJECTFISH_API UPlayerInfoSaveGame : public USaveGame
|
||||
{
|
||||
GENERATED_BODY()
|
||||
public:
|
||||
UPROPERTY(SaveGame, BlueprintReadWrite, meta = (ToolTip = "船只资源"))
|
||||
FPrimaryAssetId ShipAssetID;
|
||||
|
||||
UPROPERTY(SaveGame, BlueprintReadWrite, meta = (ToolTip = "船只等级"))
|
||||
int32 ShipLevel;
|
||||
|
||||
// 船舱容器形状资源ID
|
||||
UPROPERTY(SaveGame, BlueprintReadWrite, meta = (ToolTip = "船舱容器形状"))
|
||||
FPrimaryAssetId ShipContainerShapeID;
|
||||
|
||||
// 船舱物品存档数据
|
||||
UPROPERTY(SaveGame, BlueprintReadWrite, meta = (ToolTip = "船舱物品数据"))
|
||||
TArray<FContainerItemSaveData> ShipContainerItems;
|
||||
|
||||
UPROPERTY(SaveGame, BlueprintReadWrite, meta = (ToolTip = "仓库资源"))
|
||||
FPrimaryAssetId PlayerContainerAssetID;
|
||||
|
||||
UPROPERTY(SaveGame, BlueprintReadWrite, meta = (ToolTip = "仓库等级"))
|
||||
int32 PlayerContainerLevel;
|
||||
|
||||
// 玩家仓库容器形状资源ID
|
||||
UPROPERTY(SaveGame, BlueprintReadWrite, meta = (ToolTip = "玩家仓库容器形状"))
|
||||
FPrimaryAssetId PlayerContainerShapeID;
|
||||
|
||||
// 玩家仓库物品存档数据
|
||||
UPROPERTY(SaveGame, BlueprintReadWrite, meta = (ToolTip = "玩家仓库物品数据"))
|
||||
TArray<FContainerItemSaveData> PlayerContainerItems;
|
||||
};
|
||||
@ -3,7 +3,7 @@
|
||||
|
||||
#include "BagConfigAsset.h"
|
||||
|
||||
#include "BagShapeAsset.h"
|
||||
#include "ShapeAsset.h"
|
||||
|
||||
|
||||
bool UBagConfigAsset::AddSkill(USkillAsset* SkillObject, int32 PositionX, int32 PositionY)
|
||||
|
||||
@ -8,7 +8,7 @@
|
||||
#include "SkillAsset.h"
|
||||
#include "BagConfigAsset.generated.h"
|
||||
|
||||
class UBagShapeAsset;
|
||||
class UShapeAsset;
|
||||
|
||||
//背包中摆放的技能信息
|
||||
USTRUCT(BlueprintType)
|
||||
@ -66,7 +66,7 @@ class PROJECTFISH_API UBagConfigAsset : public UDataAsset
|
||||
public:
|
||||
// 背包形状资源引用
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "BagConfig")
|
||||
TObjectPtr<UBagShapeAsset> BagShapeAsset;
|
||||
TObjectPtr<UShapeAsset> BagShapeAsset;
|
||||
|
||||
// 背包中放置的技能列表
|
||||
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "BagConfig")
|
||||
|
||||
@ -1,56 +0,0 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
|
||||
#include "BagShapeAsset.h"
|
||||
|
||||
UBagShapeAsset::UBagShapeAsset()
|
||||
{
|
||||
|
||||
InitializeBagShape();
|
||||
}
|
||||
|
||||
void UBagShapeAsset::InitializeBagShape()
|
||||
{
|
||||
BagSlots.Empty();
|
||||
for (int x = 0; x < BagWidth; x++)
|
||||
{
|
||||
for (int y = 0; y < BagHeight; y++)
|
||||
{
|
||||
BagSlots.Add(FBagSlot(x, y, true));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool UBagShapeAsset::IsSlotActive(int32 X, int32 Y) const
|
||||
{
|
||||
if (X < 0 || X >= BagWidth || Y < 0 || Y >= BagHeight)
|
||||
return false;
|
||||
|
||||
for (auto BagSlot: BagSlots)
|
||||
{
|
||||
if (BagSlot.X == X && BagSlot.Y == Y)
|
||||
return BagSlot.bIsActive;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void UBagShapeAsset::SetSlotActive(int32 X, int32 Y, bool Active)
|
||||
{
|
||||
if (X < 0 || X >= BagWidth || Y < 0 || Y >= BagHeight)
|
||||
return;
|
||||
int SlotIndex = FIndSlotIndex(X, Y);
|
||||
if (SlotIndex != INDEX_NONE)
|
||||
{
|
||||
BagSlots[SlotIndex].bIsActive = Active;
|
||||
}
|
||||
}
|
||||
|
||||
int32 UBagShapeAsset::FIndSlotIndex(int32 X, int32 Y) const
|
||||
{
|
||||
for (int i = 0; i < BagSlots.Num(); i++)
|
||||
{
|
||||
if (BagSlots[i].X == X && BagSlots[i].Y == Y)
|
||||
return i;
|
||||
}
|
||||
return INDEX_NONE;
|
||||
}
|
||||
@ -1,63 +0,0 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "Engine/DataAsset.h"
|
||||
#include "BagShapeAsset.generated.h"
|
||||
|
||||
USTRUCT(BlueprintType)
|
||||
struct FBagSlot
|
||||
{
|
||||
GENERATED_BODY()
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite)
|
||||
int32 X;
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite)
|
||||
int32 Y;
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite)
|
||||
bool bIsActive;
|
||||
FBagSlot()
|
||||
{
|
||||
X = 0;
|
||||
Y = 0;
|
||||
bIsActive = false;
|
||||
}
|
||||
FBagSlot(int32 InX, int32 InY, bool InIsActive)
|
||||
{
|
||||
X = InX;
|
||||
Y = InY;
|
||||
bIsActive = InIsActive;
|
||||
}
|
||||
};
|
||||
/**
|
||||
*
|
||||
*/
|
||||
UCLASS(BlueprintType)
|
||||
class PROJECTFISH_API UBagShapeAsset : public UDataAsset
|
||||
{
|
||||
GENERATED_BODY()
|
||||
public:
|
||||
UBagShapeAsset();
|
||||
|
||||
UFUNCTION(BlueprintCallable, Category="BagShape")
|
||||
void InitializeBagShape();
|
||||
|
||||
UFUNCTION(Blueprintable, BlueprintPure, Category="BagShape")
|
||||
bool IsSlotActive(int32 X, int32 Y) const;
|
||||
|
||||
UFUNCTION(Blueprintable, Category="BagShape")
|
||||
void SetSlotActive(int32 X, int32 Y, bool Active);
|
||||
|
||||
private:
|
||||
int32 FIndSlotIndex(int32 X, int32 Y) const;
|
||||
public:
|
||||
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "BagShape", meta = (ClampMin = "1", ClampMax = "10"))
|
||||
int32 BagWidth;
|
||||
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "BagShape", meta = (ClampMin = "1", ClampMax = "10"))
|
||||
int32 BagHeight;
|
||||
|
||||
//存储格子状态
|
||||
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category="BagShape")
|
||||
TArray<FBagSlot> BagSlots;
|
||||
};
|
||||
@ -3,11 +3,12 @@
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "FishingRewardDataAsset.h"
|
||||
#include "Engine/DataAsset.h"
|
||||
#include "FishInfoConfigAsset.generated.h"
|
||||
|
||||
/**
|
||||
*
|
||||
* 敌人 鱼的信息配置
|
||||
*/
|
||||
UCLASS(BlueprintType)
|
||||
class PROJECTFISH_API UFishInfoConfigAsset : public UDataAsset
|
||||
@ -31,4 +32,7 @@ public:
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = fish, meta = (ToolTip = "韧性归零时的眩晕时长"))
|
||||
int32 StunTime;
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = fish, meta = (ToolTip = "击败后的鱼获配置", AllowedClasses = "FishingRewardDataAsset"))
|
||||
TArray<FPrimaryAssetId> Rewards;
|
||||
};
|
||||
|
||||
@ -0,0 +1,4 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
|
||||
#include "FishingRewardDataAsset.h"
|
||||
@ -0,0 +1,39 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "ShapeAsset.h"
|
||||
#include "Engine/DataAsset.h"
|
||||
#include "FishingRewardDataAsset.generated.h"
|
||||
|
||||
UENUM(BlueprintType)
|
||||
enum class ERewardRarityType: uint8
|
||||
{
|
||||
Common UMETA(DisplayName = "普通"),
|
||||
UnCommon UMETA(DisplayName = "精良"),
|
||||
Rare UMETA(DisplayName = "稀有"),
|
||||
};
|
||||
/**
|
||||
* 鱼获配置
|
||||
*/
|
||||
UCLASS()
|
||||
class PROJECTFISH_API UFishingRewardDataAsset : public UPrimaryDataAsset
|
||||
{
|
||||
GENERATED_BODY()
|
||||
public:
|
||||
UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "Fishing Reward Data" , meta = (ToolTip = "鱼获名称"))
|
||||
FText RewardName;
|
||||
|
||||
UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "Fishing Reward Data" , meta = (ToolTip = "鱼获图片") )
|
||||
UTexture2D* RewardTexture;
|
||||
|
||||
UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "Fishing Reward Data" , meta = (ToolTip = "鱼获重量"))
|
||||
float RewardWeight;
|
||||
|
||||
UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "Fishing Reward Data" , meta = (ToolTip = "鱼获形状"))
|
||||
class UShapeAsset* RewardShape;
|
||||
|
||||
UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "Fishing Reward Data" , meta = (ToolTip = "鱼获稀有度"))
|
||||
ERewardRarityType RewardRarityType;
|
||||
};
|
||||
61
ProjectFish/Source/ProjectFish/DataAsset/ShapeAsset.cpp
Normal file
61
ProjectFish/Source/ProjectFish/DataAsset/ShapeAsset.cpp
Normal file
@ -0,0 +1,61 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
|
||||
#include "ShapeAsset.h"
|
||||
|
||||
UShapeAsset::UShapeAsset()
|
||||
{
|
||||
|
||||
InitializeShape();
|
||||
}
|
||||
|
||||
FPrimaryAssetId UShapeAsset::GetPrimaryAssetId() const
|
||||
{
|
||||
return FPrimaryAssetId(TEXT("ShapeAsset"), GetFName());
|
||||
}
|
||||
|
||||
void UShapeAsset::InitializeShape()
|
||||
{
|
||||
Slots.Empty();
|
||||
for (int x = 0; x < ShapeWidth; x++)
|
||||
{
|
||||
for (int y = 0; y < ShapeHeight; y++)
|
||||
{
|
||||
Slots.Add(FShapeSlot(x, y, true));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool UShapeAsset::IsSlotActive(int32 X, int32 Y) const
|
||||
{
|
||||
if (X < 0 || X >= ShapeWidth || Y < 0 || Y >= ShapeHeight)
|
||||
return false;
|
||||
|
||||
for (auto BagSlot: Slots)
|
||||
{
|
||||
if (BagSlot.X == X && BagSlot.Y == Y)
|
||||
return BagSlot.bIsActive;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void UShapeAsset::SetSlotActive(int32 X, int32 Y, bool Active)
|
||||
{
|
||||
if (X < 0 || X >= ShapeWidth || Y < 0 || Y >= ShapeHeight)
|
||||
return;
|
||||
int SlotIndex = FIndSlotIndex(X, Y);
|
||||
if (SlotIndex != INDEX_NONE)
|
||||
{
|
||||
Slots[SlotIndex].bIsActive = Active;
|
||||
}
|
||||
}
|
||||
|
||||
int32 UShapeAsset::FIndSlotIndex(int32 X, int32 Y) const
|
||||
{
|
||||
for (int i = 0; i < Slots.Num(); i++)
|
||||
{
|
||||
if (Slots[i].X == X && Slots[i].Y == Y)
|
||||
return i;
|
||||
}
|
||||
return INDEX_NONE;
|
||||
}
|
||||
71
ProjectFish/Source/ProjectFish/DataAsset/ShapeAsset.h
Normal file
71
ProjectFish/Source/ProjectFish/DataAsset/ShapeAsset.h
Normal file
@ -0,0 +1,71 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "Engine/DataAsset.h"
|
||||
#include "ShapeAsset.generated.h"
|
||||
|
||||
USTRUCT(BlueprintType)
|
||||
struct FShapeSlot
|
||||
{
|
||||
GENERATED_BODY()
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite)
|
||||
int32 X;
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite)
|
||||
int32 Y;
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, meta = (ToolTip = "该槽位是否为激活状态"))
|
||||
bool bIsActive;
|
||||
FShapeSlot()
|
||||
{
|
||||
X = 0;
|
||||
Y = 0;
|
||||
bIsActive = false;
|
||||
}
|
||||
FShapeSlot(int32 InX, int32 InY, bool InIsActive)
|
||||
{
|
||||
X = InX;
|
||||
Y = InY;
|
||||
bIsActive = InIsActive;
|
||||
|
||||
}
|
||||
};
|
||||
/**
|
||||
*
|
||||
*/
|
||||
UCLASS(BlueprintType)
|
||||
class PROJECTFISH_API UShapeAsset : public UDataAsset
|
||||
{
|
||||
GENERATED_BODY()
|
||||
public:
|
||||
UShapeAsset();
|
||||
|
||||
virtual FPrimaryAssetId GetPrimaryAssetId() const override;
|
||||
UFUNCTION(BlueprintCallable, Category="Shape")
|
||||
void InitializeShape();
|
||||
|
||||
UFUNCTION(BlueprintPure, Category="Shape")
|
||||
int32 GetShapeWidth() { return ShapeWidth; }
|
||||
|
||||
UFUNCTION(BlueprintPure, Category="Shape")
|
||||
int32 GetShapeHeight() { return ShapeHeight; }
|
||||
|
||||
UFUNCTION(Blueprintable, BlueprintPure, Category="Shape")
|
||||
bool IsSlotActive(int32 X, int32 Y) const;
|
||||
|
||||
UFUNCTION(Blueprintable, Category="Shape")
|
||||
void SetSlotActive(int32 X, int32 Y, bool Active);
|
||||
|
||||
private:
|
||||
int32 FIndSlotIndex(int32 X, int32 Y) const;
|
||||
public:
|
||||
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Shape", meta = (ClampMin = "1", ClampMax = "10"))
|
||||
int32 ShapeWidth;
|
||||
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Shape", meta = (ClampMin = "1", ClampMax = "10"))
|
||||
int32 ShapeHeight;
|
||||
|
||||
//存储格子状态
|
||||
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category="Shape")
|
||||
TArray<FShapeSlot> Slots;
|
||||
};
|
||||
@ -0,0 +1,4 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
|
||||
#include "ShipConfigAsset.h"
|
||||
23
ProjectFish/Source/ProjectFish/DataAsset/ShipConfigAsset.h
Normal file
23
ProjectFish/Source/ProjectFish/DataAsset/ShipConfigAsset.h
Normal file
@ -0,0 +1,23 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "ShapeAsset.h"
|
||||
#include "Engine/DataAsset.h"
|
||||
#include "ShipConfigAsset.generated.h"
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
UCLASS()
|
||||
class PROJECTFISH_API UShipConfigAsset : public UPrimaryDataAsset
|
||||
{
|
||||
GENERATED_BODY()
|
||||
public:
|
||||
UPROPERTY(BlueprintReadWrite, EditAnywhere, Category= "Ship")
|
||||
FText ShipName;
|
||||
UPROPERTY(BlueprintReadWrite, EditAnywhere, Category= "Ship", meta=(ToolTip = "等级对应的船舱形状"))
|
||||
TArray<UShapeAsset*> Level_ShipShapes;
|
||||
|
||||
};
|
||||
@ -5,6 +5,7 @@
|
||||
#include "CoreMinimal.h"
|
||||
#include "GameplayTagContainer.h"
|
||||
#include "PawnWithSkill.h"
|
||||
#include "DataAsset/ShapeAsset.h"
|
||||
#include "UObject/Object.h"
|
||||
#include "Definations.generated.h"
|
||||
|
||||
@ -460,3 +461,7 @@ struct FSimpleConnection
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ -11,7 +11,7 @@
|
||||
#include "GameFramework/CharacterMovementComponent.h"
|
||||
#include "GameFramework/SpringArmComponent.h"
|
||||
#include "Kismet/KismetMathLibrary.h"
|
||||
#include "ProjectFish/Components/ShipSpringArmComponent.h"
|
||||
#include "ProjectFish/Gameplay/Components/ShipSpringArmComponent.h"
|
||||
#include "ProjectFish/Settings/GameConfigSettings.h"
|
||||
|
||||
|
||||
|
||||
@ -113,7 +113,7 @@ protected:
|
||||
class UBagConfigAsset* DefaultPlayerBag;
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = Inventory, meta = (AllowPrivateAccess = "true", ToolTip = "鱼竿装备槽形状"))
|
||||
class UBagShapeAsset* FishingRodShape;
|
||||
class UShapeAsset* FishingRodShape;
|
||||
|
||||
|
||||
private:
|
||||
|
||||
@ -4,9 +4,9 @@
|
||||
#include "FishingRodConfigSubsystem.h"
|
||||
|
||||
#include "ProjectFish/DataAsset/BagConfigAsset.h"
|
||||
#include "ProjectFish/DataAsset/BagShapeAsset.h"
|
||||
#include "ProjectFish/DataAsset/ShapeAsset.h"
|
||||
|
||||
void UFishingRodConfigSubsystem::CreateFishingRodInventory(class UBagShapeAsset* FishingRodShape, class UBagConfigAsset* PlayerBagConfig)
|
||||
void UFishingRodConfigSubsystem::CreateFishingRodInventory(class UShapeAsset* FishingRodShape, class UBagConfigAsset* PlayerBagConfig)
|
||||
{
|
||||
//鱼竿的技能配置资源
|
||||
fishingRodInventoryConfig = NewObject<UBagConfigAsset>(this);
|
||||
@ -36,8 +36,8 @@ bool UFishingRodConfigSubsystem::AddSkillByConfig(USkillAsset* SkillAsset, UBagC
|
||||
bool UFishingRodConfigSubsystem::AddSkillToPlayerInventory(USkillAsset* SkillAsset)
|
||||
{
|
||||
|
||||
int32 width = playerInventoryConfig->BagShapeAsset->BagWidth;
|
||||
int32 height = playerInventoryConfig->BagShapeAsset->BagHeight;
|
||||
int32 width = playerInventoryConfig->BagShapeAsset->ShapeWidth;
|
||||
int32 height = playerInventoryConfig->BagShapeAsset->ShapeHeight;
|
||||
for (int x = 0; x < width; x++)
|
||||
{
|
||||
for (int y = 0; y < height; y++)
|
||||
|
||||
@ -17,7 +17,7 @@ class PROJECTFISH_API UFishingRodConfigSubsystem : public UGameInstanceSubsystem
|
||||
|
||||
public:
|
||||
UFUNCTION(BlueprintCallable, Category = "PlayerInventorySubsystem")
|
||||
void CreateFishingRodInventory(class UBagShapeAsset* FishingRodShape, class UBagConfigAsset* PlayerBagConfig);
|
||||
void CreateFishingRodInventory(class UShapeAsset* FishingRodShape, class UBagConfigAsset* PlayerBagConfig);
|
||||
|
||||
UFUNCTION(BlueprintPure, Category = "PlayerInventorySubsystem")
|
||||
UBagConfigAsset* GetFishingRodInventory();
|
||||
|
||||
@ -0,0 +1,53 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
|
||||
#include "GameInfoManager.h"
|
||||
|
||||
#include "Kismet/GameplayStatics.h"
|
||||
|
||||
FString UGameInfoManager::SaveGameSlotName = TEXT("GameInfo");
|
||||
void UGameInfoManager::Initialize(FSubsystemCollectionBase& Collection)
|
||||
{
|
||||
Super::Initialize(Collection);
|
||||
if (!LoadGameInfo())
|
||||
{
|
||||
UE_LOG(LogTemp, Warning, TEXT("本地存档不存在加载失败"));
|
||||
}
|
||||
}
|
||||
|
||||
void UGameInfoManager::SaveGameInfo()
|
||||
{
|
||||
if (IsValid(PlayerInfo.Get()))
|
||||
{
|
||||
if (UGameplayStatics::SaveGameToSlot(PlayerInfo.Get(), SaveGameSlotName, 0))
|
||||
{
|
||||
UE_LOG(LogTemp, Warning, TEXT("存档保存成功"));
|
||||
}
|
||||
else
|
||||
{
|
||||
UE_LOG(LogTemp, Warning, TEXT("存档保存失败"));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
UE_LOG(LogTemp, Warning, TEXT("存档保存失败, PlayerInfo为空"));
|
||||
}
|
||||
}
|
||||
|
||||
bool UGameInfoManager::LoadGameInfo()
|
||||
{
|
||||
if (UGameplayStatics::DoesSaveGameExist(SaveGameSlotName, 0))
|
||||
{
|
||||
PlayerInfo = Cast<UPlayerInfoSaveGame>(UGameplayStatics::LoadGameFromSlot(SaveGameSlotName, 0));
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void UGameInfoManager::CreateGameInfo(UContainerInfo* ShipContainer)
|
||||
{
|
||||
PlayerInfo = NewObject<UPlayerInfoSaveGame>(this);
|
||||
PlayerInfo->ShipContainerItems = ShipContainer->GetSaveData();
|
||||
PlayerInfo->ShipContainerShapeID = ShipContainer->ContainerShape->GetPrimaryAssetId();
|
||||
SaveGameInfo();
|
||||
}
|
||||
@ -0,0 +1,31 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "ProjectFish/Data/PlayerInfoSaveGame.h"
|
||||
#include "Subsystems/GameInstanceSubsystem.h"
|
||||
#include "GameInfoManager.generated.h"
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
UCLASS()
|
||||
class PROJECTFISH_API UGameInfoManager : public UGameInstanceSubsystem
|
||||
{
|
||||
GENERATED_BODY()
|
||||
public:
|
||||
virtual void Initialize(FSubsystemCollectionBase& Collection) override;
|
||||
|
||||
protected:
|
||||
UFUNCTION(BlueprintCallable)
|
||||
void SaveGameInfo();
|
||||
UFUNCTION(BlueprintCallable)
|
||||
bool LoadGameInfo();
|
||||
UFUNCTION(BlueprintCallable)
|
||||
void CreateGameInfo(UContainerInfo* ShipContainer);
|
||||
protected:
|
||||
UPROPERTY(BlueprintReadOnly)
|
||||
TObjectPtr<class UPlayerInfoSaveGame> PlayerInfo;
|
||||
static FString SaveGameSlotName;
|
||||
};
|
||||
@ -3,7 +3,7 @@
|
||||
|
||||
#include "SkillEffect_EnhanceFishRod.h"
|
||||
|
||||
#include "ProjectFish/Components/FishingRodComponent.h"
|
||||
#include "ProjectFish/Gameplay/Components/FishingRodComponent.h"
|
||||
#include "ProjectFish/Skill/Skill.h"
|
||||
|
||||
void USkillEffect_EnhanceFishRod::Execute(const FSkillContext& context)
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
#include "Kismet/GameplayStatics.h"
|
||||
#include "ProjectFish/ProjectFishGameMode.h"
|
||||
#include "ProjectFish/DataAsset/BagConfigAsset.h"
|
||||
#include "ProjectFish/DataAsset/BagShapeAsset.h"
|
||||
#include "ProjectFish/DataAsset/ShapeAsset.h"
|
||||
|
||||
USkillManager::USkillManager()
|
||||
{
|
||||
|
||||
@ -4,6 +4,7 @@
|
||||
#include "FishFunctionLibrary.h"
|
||||
|
||||
#include "Kismet/GameplayStatics.h"
|
||||
#include "ProjectFish/Data/ContainerInfo.h"
|
||||
|
||||
void UFishFunctionLibrary::OpenLevelWithOptions(const UObject* WorldContextObject, FName LevelName, TMap<FString, FString> OptionsPaairs)
|
||||
{
|
||||
@ -14,3 +15,13 @@ void UFishFunctionLibrary::OpenLevelWithOptions(const UObject* WorldContextObjec
|
||||
}
|
||||
UGameplayStatics::OpenLevel(WorldContextObject, LevelName, true,OptionStr);
|
||||
}
|
||||
|
||||
int32 UFishFunctionLibrary::GetContainerItemWiidth(const UObject* WorldContextObject, FContainerItem ContainerItem)
|
||||
{
|
||||
return ContainerItem.GetItemWIdth();
|
||||
}
|
||||
|
||||
int32 UFishFunctionLibrary::GetContainerItemHeight(const UObject* WorldContextObject, FContainerItem ContainerItem)
|
||||
{
|
||||
return ContainerItem.GetItemHeight();
|
||||
}
|
||||
|
||||
@ -17,4 +17,10 @@ class PROJECTFISH_API UFishFunctionLibrary : public UBlueprintFunctionLibrary
|
||||
public:
|
||||
UFUNCTION(BlueprintCallable, Category = "FishFunctionLibrary", meta=(WorldContext="WorldContextObject"))
|
||||
static void OpenLevelWithOptions(const UObject* WorldContextObject, FName LevelName,TMap<FString, FString> OptionsPaairs);
|
||||
|
||||
UFUNCTION(BlueprintPure, Category = "FishFunctionLibrary", meta=(WorldContext="WorldContextObject"))
|
||||
static int32 GetContainerItemWiidth(const UObject* WorldContextObject, FContainerItem ContainerItem);
|
||||
|
||||
UFUNCTION(BlueprintPure, Category = "FishFunctionLibrary", meta=(WorldContext="WorldContextObject"))
|
||||
static int32 GetContainerItemHeight(const UObject* WorldContextObject, FContainerItem ContainerItem);
|
||||
};
|
||||
|
||||
@ -1,41 +0,0 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
|
||||
#include "AssetActions/BagShapeAssetTypeAction.h"
|
||||
|
||||
#include "AssetEditor/BagShapeAssetEditor.h"
|
||||
#include "ProjectFish/DataAsset/BagShapeAsset.h"
|
||||
|
||||
|
||||
UClass* FBagShapeAssetTypeAction::GetSupportedClass() const
|
||||
{
|
||||
return UBagShapeAsset::StaticClass();
|
||||
}
|
||||
|
||||
void FBagShapeAssetTypeAction::OpenAssetEditor(const TArray<UObject*>& InObjects,
|
||||
TSharedPtr<IToolkitHost> EditWithinLevelEditor)
|
||||
{
|
||||
EToolkitMode::Type Mode = EditWithinLevelEditor.IsValid() ? EToolkitMode::WorldCentric : EToolkitMode::Standalone;
|
||||
|
||||
for (auto ObjIt = InObjects.CreateConstIterator(); ObjIt; ++ObjIt)
|
||||
{
|
||||
if (UBagShapeAsset* BagShapeAsset = Cast<UBagShapeAsset>(*ObjIt))
|
||||
{
|
||||
TSharedRef<FBagShapeAssetEditor> EditorToolkit = MakeShareable(new FBagShapeAssetEditor());
|
||||
EditorToolkit->Initialize(Mode, EditWithinLevelEditor, BagShapeAsset);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
uint32 FBagShapeAssetTypeAction::GetCategories()
|
||||
{
|
||||
//系统原有
|
||||
//return EAssetTypeCategories::Gameplay;
|
||||
return MyAssetCategory;
|
||||
}
|
||||
|
||||
void FBagShapeAssetTypeAction::GetActions(const TArray<UObject*>& InObjects, struct FToolMenuSection& Section)
|
||||
{
|
||||
FAssetTypeActions_Base::GetActions(InObjects, Section);
|
||||
}
|
||||
@ -0,0 +1,41 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
|
||||
#include "AssetActions/ShapeAssetTypeAction.h"
|
||||
|
||||
#include "AssetEditor/ShapeAssetEditor.h"
|
||||
#include "ProjectFish/DataAsset/ShapeAsset.h"
|
||||
|
||||
|
||||
UClass* FShapeAssetTypeAction::GetSupportedClass() const
|
||||
{
|
||||
return UShapeAsset::StaticClass();
|
||||
}
|
||||
|
||||
void FShapeAssetTypeAction::OpenAssetEditor(const TArray<UObject*>& InObjects,
|
||||
TSharedPtr<IToolkitHost> EditWithinLevelEditor)
|
||||
{
|
||||
EToolkitMode::Type Mode = EditWithinLevelEditor.IsValid() ? EToolkitMode::WorldCentric : EToolkitMode::Standalone;
|
||||
|
||||
for (auto ObjIt = InObjects.CreateConstIterator(); ObjIt; ++ObjIt)
|
||||
{
|
||||
if (UShapeAsset* BagShapeAsset = Cast<UShapeAsset>(*ObjIt))
|
||||
{
|
||||
TSharedRef<FShapeAssetEditor> EditorToolkit = MakeShareable(new FShapeAssetEditor());
|
||||
EditorToolkit->Initialize(Mode, EditWithinLevelEditor, BagShapeAsset);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
uint32 FShapeAssetTypeAction::GetCategories()
|
||||
{
|
||||
//系统原有
|
||||
//return EAssetTypeCategories::Gameplay;
|
||||
return MyAssetCategory;
|
||||
}
|
||||
|
||||
void FShapeAssetTypeAction::GetActions(const TArray<UObject*>& InObjects, struct FToolMenuSection& Section)
|
||||
{
|
||||
FAssetTypeActions_Base::GetActions(InObjects, Section);
|
||||
}
|
||||
@ -1,74 +0,0 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
|
||||
#include "AssetEditor/BagShapeAssetEditor.h"
|
||||
#include "ProjectFish/DataAsset/BagShapeAsset.h"
|
||||
#include "Widgets/BagShapeEditorWidget.h"
|
||||
|
||||
const FName FBagShapeAssetEditor::BagShapeEditorTabId(TEXT("BagShapeEditor"));
|
||||
|
||||
void FBagShapeAssetEditor::Initialize(const EToolkitMode::Type Mode,
|
||||
const TSharedPtr<class IToolkitHost>& InitToolkitHost, UBagShapeAsset* InBagShapeAsset)
|
||||
{
|
||||
BagShapeAsset = InBagShapeAsset;
|
||||
|
||||
const TSharedRef<FTabManager::FLayout> StandaloneDefaultLayout = FTabManager::NewLayout("Standalone_BagShapeAssetEditor_Layout_v1")
|
||||
->AddArea
|
||||
(
|
||||
FTabManager::NewPrimaryArea()->SetOrientation(Orient_Vertical)
|
||||
->Split
|
||||
(
|
||||
FTabManager::NewStack()
|
||||
->SetSizeCoefficient(1.0f)
|
||||
->AddTab(BagShapeEditorTabId, ETabState::OpenedTab)
|
||||
)
|
||||
);
|
||||
|
||||
FAssetEditorToolkit::InitAssetEditor(Mode, InitToolkitHost, TEXT("BagShapeAssetEditorApp"), StandaloneDefaultLayout, true, true, InBagShapeAsset);
|
||||
|
||||
}
|
||||
|
||||
FName FBagShapeAssetEditor::GetToolkitFName() const
|
||||
{
|
||||
return FName("BagShapeEditor");
|
||||
}
|
||||
|
||||
FText FBagShapeAssetEditor::GetBaseToolkitName() const
|
||||
{
|
||||
return FText::FromString("Base BagShapeEditor");
|
||||
}
|
||||
|
||||
FString FBagShapeAssetEditor::GetWorldCentricTabPrefix() const
|
||||
{
|
||||
return TEXT("ShapeTab");
|
||||
}
|
||||
|
||||
FLinearColor FBagShapeAssetEditor::GetWorldCentricTabColorScale() const
|
||||
{
|
||||
//return FLinearColor::White;
|
||||
return FLinearColor(1.f, 0.8f, 0.45f, 0.5f);
|
||||
}
|
||||
|
||||
void FBagShapeAssetEditor::RegisterTabSpawners(const TSharedRef<FTabManager>& tabManager)
|
||||
{
|
||||
WorkspaceMenuCategory = tabManager->AddLocalWorkspaceMenuCategory( FText::FromString("BagShape"));
|
||||
|
||||
tabManager->RegisterTabSpawner(BagShapeEditorTabId, FOnSpawnTab::CreateSP(this, &FBagShapeAssetEditor::SpawnBagShapeEditorTab))
|
||||
.SetDisplayName( FText::FromString("BagShapeEditor"))
|
||||
.SetGroup(WorkspaceMenuCategory.ToSharedRef());
|
||||
}
|
||||
|
||||
void FBagShapeAssetEditor::UnregisterTabSpawners(const TSharedRef<FTabManager>& tabManager)
|
||||
{
|
||||
tabManager->UnregisterTabSpawner(BagShapeEditorTabId);
|
||||
}
|
||||
|
||||
TSharedRef<SDockTab> FBagShapeAssetEditor::SpawnBagShapeEditorTab(const FSpawnTabArgs& Args)
|
||||
{
|
||||
return SNew(SDockTab)
|
||||
.TabRole(ETabRole::PanelTab)
|
||||
[
|
||||
SNew(SBagShapeEditorWidget)
|
||||
.BagShapeAsset(BagShapeAsset)
|
||||
];
|
||||
}
|
||||
@ -0,0 +1,74 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
|
||||
#include "AssetEditor/ShapeAssetEditor.h"
|
||||
#include "ProjectFish/DataAsset/ShapeAsset.h"
|
||||
#include "Widgets/BagShapeEditorWidget.h"
|
||||
|
||||
const FName FShapeAssetEditor::ShapeEditorTabId(TEXT("BagShapeEditor"));
|
||||
|
||||
void FShapeAssetEditor::Initialize(const EToolkitMode::Type Mode,
|
||||
const TSharedPtr<class IToolkitHost>& InitToolkitHost, UShapeAsset* InBagShapeAsset)
|
||||
{
|
||||
ShapeAsset = InBagShapeAsset;
|
||||
|
||||
const TSharedRef<FTabManager::FLayout> StandaloneDefaultLayout = FTabManager::NewLayout("Standalone_BagShapeAssetEditor_Layout_v1")
|
||||
->AddArea
|
||||
(
|
||||
FTabManager::NewPrimaryArea()->SetOrientation(Orient_Vertical)
|
||||
->Split
|
||||
(
|
||||
FTabManager::NewStack()
|
||||
->SetSizeCoefficient(1.0f)
|
||||
->AddTab(ShapeEditorTabId, ETabState::OpenedTab)
|
||||
)
|
||||
);
|
||||
|
||||
FAssetEditorToolkit::InitAssetEditor(Mode, InitToolkitHost, TEXT("BagShapeAssetEditorApp"), StandaloneDefaultLayout, true, true, InBagShapeAsset);
|
||||
|
||||
}
|
||||
|
||||
FName FShapeAssetEditor::GetToolkitFName() const
|
||||
{
|
||||
return FName("ShapeEditor");
|
||||
}
|
||||
|
||||
FText FShapeAssetEditor::GetBaseToolkitName() const
|
||||
{
|
||||
return FText::FromString("Base ShapeEditor");
|
||||
}
|
||||
|
||||
FString FShapeAssetEditor::GetWorldCentricTabPrefix() const
|
||||
{
|
||||
return TEXT("ShapeTab");
|
||||
}
|
||||
|
||||
FLinearColor FShapeAssetEditor::GetWorldCentricTabColorScale() const
|
||||
{
|
||||
//return FLinearColor::White;
|
||||
return FLinearColor(1.f, 0.8f, 0.45f, 0.5f);
|
||||
}
|
||||
|
||||
void FShapeAssetEditor::RegisterTabSpawners(const TSharedRef<FTabManager>& tabManager)
|
||||
{
|
||||
WorkspaceMenuCategory = tabManager->AddLocalWorkspaceMenuCategory( FText::FromString("BagShape"));
|
||||
|
||||
tabManager->RegisterTabSpawner(ShapeEditorTabId, FOnSpawnTab::CreateSP(this, &FShapeAssetEditor::SpawnBagShapeEditorTab))
|
||||
.SetDisplayName( FText::FromString("BagShapeEditor"))
|
||||
.SetGroup(WorkspaceMenuCategory.ToSharedRef());
|
||||
}
|
||||
|
||||
void FShapeAssetEditor::UnregisterTabSpawners(const TSharedRef<FTabManager>& tabManager)
|
||||
{
|
||||
tabManager->UnregisterTabSpawner(ShapeEditorTabId);
|
||||
}
|
||||
|
||||
TSharedRef<SDockTab> FShapeAssetEditor::SpawnBagShapeEditorTab(const FSpawnTabArgs& Args)
|
||||
{
|
||||
return SNew(SDockTab)
|
||||
.TabRole(ETabRole::PanelTab)
|
||||
[
|
||||
SNew(SShapeEditorWidget)
|
||||
.BagShapeAsset(ShapeAsset)
|
||||
];
|
||||
}
|
||||
@ -1,30 +0,0 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
|
||||
#include "Factory/BagShapeFactory.h"
|
||||
|
||||
#include "ProjectFish/DataAsset/BagShapeAsset.h"
|
||||
|
||||
UBagShapeFactory::UBagShapeFactory()
|
||||
{
|
||||
SupportedClass = UBagShapeAsset::StaticClass();
|
||||
}
|
||||
|
||||
UObject* UBagShapeFactory::FactoryCreateNew(UClass* Class, UObject* InParent, FName Name, EObjectFlags Flags, UObject* Context, FFeedbackContext* Warn)
|
||||
{
|
||||
|
||||
|
||||
UBagShapeAsset* NewBagShapeAsset = NewObject<UBagShapeAsset>(InParent, Class, Name, Flags | RF_Transactional);
|
||||
if (NewBagShapeAsset)
|
||||
{
|
||||
NewBagShapeAsset->BagWidth = 5;
|
||||
NewBagShapeAsset->BagHeight = 5;
|
||||
NewBagShapeAsset->InitializeBagShape();
|
||||
}
|
||||
return NewBagShapeAsset;
|
||||
}
|
||||
|
||||
bool UBagShapeFactory::ShouldShowInNewMenu() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@ -0,0 +1,30 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
|
||||
#include "Factory/ShapeFactory.h"
|
||||
|
||||
#include "ProjectFish/DataAsset/ShapeAsset.h"
|
||||
|
||||
UShapeFactory::UShapeFactory()
|
||||
{
|
||||
SupportedClass = UShapeAsset::StaticClass();
|
||||
}
|
||||
|
||||
UObject* UShapeFactory::FactoryCreateNew(UClass* Class, UObject* InParent, FName Name, EObjectFlags Flags, UObject* Context, FFeedbackContext* Warn)
|
||||
{
|
||||
|
||||
|
||||
UShapeAsset* NewBagShapeAsset = NewObject<UShapeAsset>(InParent, Class, Name, Flags | RF_Transactional);
|
||||
if (NewBagShapeAsset)
|
||||
{
|
||||
NewBagShapeAsset->ShapeWidth = 5;
|
||||
NewBagShapeAsset->ShapeHeight = 5;
|
||||
NewBagShapeAsset->InitializeShape();
|
||||
}
|
||||
return NewBagShapeAsset;
|
||||
}
|
||||
|
||||
bool UShapeFactory::ShouldShowInNewMenu() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@ -3,10 +3,10 @@
|
||||
#include "AssetTypeActions_Base.h"
|
||||
#include "DataTableRowSelectorCustomization.h"
|
||||
#include "AssetActions/BagConfigAssetTypeAction.h"
|
||||
#include "AssetActions/BagShapeAssetTypeAction.h"
|
||||
#include "AssetActions/ShapeAssetTypeAction.h"
|
||||
#include "AssetRegistry/AssetRegistryModule.h"
|
||||
#include "ProjectFish/DataAsset/BagShapeAsset.h"
|
||||
#include "../Public/Thumbnail/BagShapeAssetThumbnailRenderer.h"
|
||||
#include "ProjectFish/DataAsset/ShapeAsset.h"
|
||||
#include "../Public/Thumbnail/ShapeAssetThumbnailRenderer.h"
|
||||
#include "../Public/Thumbnail/BagConfigThumbnailRenderer.h"
|
||||
#include "AssetActions/SkillAssetTypeAction.h"
|
||||
#include "ProjectFish/DataAsset/BagConfigAsset.h"
|
||||
@ -44,7 +44,7 @@ void FProjectFishEditorModule::RegisterAssetTypeActions()
|
||||
//注册背包形状的菜单
|
||||
EAssetTypeCategories::Type BogShapeAssetCategory = AssetTools.RegisterAdvancedAssetCategory(FName(TEXT("BagShape")), FText::FromString(TEXT("BagSystem")));
|
||||
//BagShape
|
||||
TSharedRef<FAssetTypeActions_Base> BagShapeAction = MakeShareable(new FBagShapeAssetTypeAction(BogShapeAssetCategory));
|
||||
TSharedRef<FAssetTypeActions_Base> BagShapeAction = MakeShareable(new FShapeAssetTypeAction(BogShapeAssetCategory));
|
||||
AssetTools.RegisterAssetTypeActions(BagShapeAction);
|
||||
CreatedAssetTypeActions.Add(BagShapeAction);
|
||||
|
||||
@ -77,7 +77,7 @@ void FProjectFishEditorModule::UnregisterAssetTypeActions()
|
||||
|
||||
void FProjectFishEditorModule::RegisterThumbnailRenderers()
|
||||
{
|
||||
UThumbnailManager::Get().RegisterCustomRenderer(UBagShapeAsset::StaticClass(), UBagShapeAssetThumbnailRenderer::StaticClass());
|
||||
UThumbnailManager::Get().RegisterCustomRenderer(UShapeAsset::StaticClass(), UShapeAssetThumbnailRenderer::StaticClass());
|
||||
UThumbnailManager::Get().RegisterCustomRenderer(UBagConfigAsset::StaticClass(), UBagConfigThumbnailRenderer::StaticClass());
|
||||
RefreshExistingAssetThumbnails();
|
||||
}
|
||||
@ -86,7 +86,7 @@ void FProjectFishEditorModule::UnregisterThumbnailRenderers()
|
||||
{
|
||||
if (UObjectInitialized())
|
||||
{
|
||||
UThumbnailManager::Get().UnregisterCustomRenderer(UBagShapeAsset::StaticClass());
|
||||
UThumbnailManager::Get().UnregisterCustomRenderer(UShapeAsset::StaticClass());
|
||||
UThumbnailManager::Get().UnregisterCustomRenderer(UBagConfigAsset::StaticClass());
|
||||
}
|
||||
}
|
||||
@ -103,7 +103,7 @@ void FProjectFishEditorModule::RefreshExistingAssetThumbnails()
|
||||
|
||||
// 查找所有BagShapeAsset资产
|
||||
TArray<FAssetData> BagShapeAssetList;
|
||||
AssetRegistry.GetAssetsByClass(UBagShapeAsset::StaticClass()->GetClassPathName(), BagShapeAssetList);
|
||||
AssetRegistry.GetAssetsByClass(UShapeAsset::StaticClass()->GetClassPathName(), BagShapeAssetList);
|
||||
|
||||
// 查找所有BagClass资产
|
||||
TArray<FAssetData> BagConfigAssetList;
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
#include "CanvasItem.h"
|
||||
#include "CanvasTypes.h"
|
||||
#include "ProjectFish/DataAsset/BagConfigAsset.h"
|
||||
#include "ProjectFish/DataAsset/BagShapeAsset.h"
|
||||
#include "ProjectFish/DataAsset/ShapeAsset.h"
|
||||
|
||||
bool UBagConfigThumbnailRenderer::CanVisualizeAsset(UObject* Object)
|
||||
{
|
||||
@ -43,7 +43,7 @@ void UBagConfigThumbnailRenderer::DrawBag(UBagConfigAsset* BagConfig, FCanvas* C
|
||||
return;
|
||||
}
|
||||
|
||||
UBagShapeAsset* BagShapeAsset = BagConfig->BagShapeAsset;
|
||||
UShapeAsset* BagShapeAsset = BagConfig->BagShapeAsset;
|
||||
|
||||
// Clear the background
|
||||
FCanvasBoxItem BackgroundBox(FVector2D(X, Y), FVector2D(Width, Height));
|
||||
@ -52,19 +52,19 @@ void UBagConfigThumbnailRenderer::DrawBag(UBagConfigAsset* BagConfig, FCanvas* C
|
||||
|
||||
// Calculate the best fit scale with spacing for separators
|
||||
float SeparatorWidth = 2.0f; // White separator width
|
||||
float Scale = GetBestFitScale(BagShapeAsset->BagWidth, BagShapeAsset->BagHeight, Width, Height);
|
||||
float Scale = GetBestFitScale(BagShapeAsset->ShapeWidth, BagShapeAsset->ShapeHeight, Width, Height);
|
||||
float CellSize = Scale - SeparatorWidth; // Reduce cell size to make room for separators
|
||||
|
||||
// Calculate starting position to center the grid (including separators)
|
||||
float GridWidth = BagShapeAsset->BagWidth * Scale - SeparatorWidth;
|
||||
float GridHeight = BagShapeAsset->BagHeight * Scale - SeparatorWidth;
|
||||
float GridWidth = BagShapeAsset->ShapeWidth * Scale - SeparatorWidth;
|
||||
float GridHeight = BagShapeAsset->ShapeHeight * Scale - SeparatorWidth;
|
||||
float StartX = X + (Width - GridWidth) * 0.5f;
|
||||
float StartY = Y + (Height - GridHeight) * 0.5f;
|
||||
|
||||
// Draw the bag slots (background) with separators
|
||||
for (int32 GridY = 0; GridY < BagShapeAsset->BagHeight; GridY++)
|
||||
for (int32 GridY = 0; GridY < BagShapeAsset->ShapeHeight; GridY++)
|
||||
{
|
||||
for (int32 GridX = 0; GridX < BagShapeAsset->BagWidth; GridX++)
|
||||
for (int32 GridX = 0; GridX < BagShapeAsset->ShapeWidth; GridX++)
|
||||
{
|
||||
float CellStartX = StartX + GridX * Scale;
|
||||
float CellStartY = StartY + GridY * Scale;
|
||||
@ -81,7 +81,7 @@ void UBagConfigThumbnailRenderer::DrawBag(UBagConfigAsset* BagConfig, FCanvas* C
|
||||
|
||||
// Draw white separators
|
||||
// Vertical separators
|
||||
for (int32 GridX = 1; GridX < BagShapeAsset->BagWidth; GridX++)
|
||||
for (int32 GridX = 1; GridX < BagShapeAsset->ShapeWidth; GridX++)
|
||||
{
|
||||
float SeparatorX = StartX + GridX * Scale - SeparatorWidth;
|
||||
FCanvasTileItem VerticalSeparator(FVector2D(SeparatorX, StartY), FVector2D(SeparatorWidth, GridHeight), FLinearColor::White);
|
||||
@ -90,7 +90,7 @@ void UBagConfigThumbnailRenderer::DrawBag(UBagConfigAsset* BagConfig, FCanvas* C
|
||||
}
|
||||
|
||||
// Horizontal separators
|
||||
for (int32 GridY = 1; GridY < BagShapeAsset->BagHeight; GridY++)
|
||||
for (int32 GridY = 1; GridY < BagShapeAsset->ShapeHeight; GridY++)
|
||||
{
|
||||
float SeparatorY = StartY + GridY * Scale - SeparatorWidth;
|
||||
FCanvasTileItem HorizontalSeparator(FVector2D(StartX, SeparatorY), FVector2D(GridWidth, SeparatorWidth), FLinearColor::White);
|
||||
@ -111,10 +111,10 @@ void UBagConfigThumbnailRenderer::DrawBag(UBagConfigAsset* BagConfig, FCanvas* C
|
||||
Canvas->DrawItem(OuterBorder);
|
||||
}
|
||||
|
||||
float UBagConfigThumbnailRenderer::GetBestFitScale(int32 BagWidth, int32 BagHeight, uint32 CanvasWidth,
|
||||
float UBagConfigThumbnailRenderer::GetBestFitScale(int32 ShapeWidth, int32 ShapeHeight, uint32 CanvasWidth,
|
||||
uint32 CanvasHeight) const
|
||||
{
|
||||
if (BagWidth == 0 || BagHeight == 0)
|
||||
if (ShapeWidth == 0 || ShapeHeight == 0)
|
||||
{
|
||||
return 1.0f;
|
||||
}
|
||||
@ -123,8 +123,8 @@ float UBagConfigThumbnailRenderer::GetBestFitScale(int32 BagWidth, int32 BagHeig
|
||||
float PaddedWidth = CanvasWidth * 0.85f;
|
||||
float PaddedHeight = CanvasHeight * 0.85f;
|
||||
|
||||
float ScaleX = PaddedWidth / BagWidth;
|
||||
float ScaleY = PaddedHeight / BagHeight;
|
||||
float ScaleX = PaddedWidth / ShapeWidth;
|
||||
float ScaleY = PaddedHeight / ShapeHeight;
|
||||
|
||||
// Use the smaller scale to ensure everything fits
|
||||
float Scale = FMath::Min(ScaleX, ScaleY);
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user