diff --git a/ProjectFish/Binaries/Win64/UnrealEditor-ProjectFish.dll b/ProjectFish/Binaries/Win64/UnrealEditor-ProjectFish.dll index f4823c7..e9c44c6 100644 Binary files a/ProjectFish/Binaries/Win64/UnrealEditor-ProjectFish.dll and b/ProjectFish/Binaries/Win64/UnrealEditor-ProjectFish.dll differ diff --git a/ProjectFish/Content/Gameplay/Home/BP_HomePlayerController.uasset b/ProjectFish/Content/Gameplay/Home/BP_HomePlayerController.uasset index dc976b6..5815031 100644 Binary files a/ProjectFish/Content/Gameplay/Home/BP_HomePlayerController.uasset and b/ProjectFish/Content/Gameplay/Home/BP_HomePlayerController.uasset differ diff --git a/ProjectFish/Content/Maps/TestUI.umap b/ProjectFish/Content/Maps/TestUI.umap index ed3cec2..e81757b 100644 Binary files a/ProjectFish/Content/Maps/TestUI.umap and b/ProjectFish/Content/Maps/TestUI.umap differ diff --git a/ProjectFish/Content/UI/Common/Container/UMG_Container_Grid.uasset b/ProjectFish/Content/UI/Common/Container/UMG_Container_Grid.uasset new file mode 100644 index 0000000..0149550 Binary files /dev/null and b/ProjectFish/Content/UI/Common/Container/UMG_Container_Grid.uasset differ diff --git a/ProjectFish/Content/UI/Common/Container/UMG_Container_Item.uasset b/ProjectFish/Content/UI/Common/Container/UMG_Container_Item.uasset new file mode 100644 index 0000000..d9a3378 Binary files /dev/null and b/ProjectFish/Content/UI/Common/Container/UMG_Container_Item.uasset differ diff --git a/ProjectFish/Content/UI/Fishing/Widgets/ManagerRewards/BPI_ItemDragDrop.uasset b/ProjectFish/Content/UI/Fishing/Widgets/ManagerRewards/BPI_ItemDragDrop.uasset new file mode 100644 index 0000000..41b7c81 Binary files /dev/null and b/ProjectFish/Content/UI/Fishing/Widgets/ManagerRewards/BPI_ItemDragDrop.uasset differ diff --git a/ProjectFish/Content/UI/Fishing/Widgets/ManagerRewards/BP_RewardItem_DragOption.uasset b/ProjectFish/Content/UI/Fishing/Widgets/ManagerRewards/BP_RewardItem_DragOption.uasset index 8b20a4d..22ff753 100644 Binary files a/ProjectFish/Content/UI/Fishing/Widgets/ManagerRewards/BP_RewardItem_DragOption.uasset and b/ProjectFish/Content/UI/Fishing/Widgets/ManagerRewards/BP_RewardItem_DragOption.uasset differ diff --git a/ProjectFish/Content/UI/Fishing/Widgets/ManagerRewards/UMG_Grid_RewardsItem.uasset b/ProjectFish/Content/UI/Fishing/Widgets/ManagerRewards/UMG_Grid_RewardsItem.uasset index 3dad965..582146c 100644 Binary files a/ProjectFish/Content/UI/Fishing/Widgets/ManagerRewards/UMG_Grid_RewardsItem.uasset and b/ProjectFish/Content/UI/Fishing/Widgets/ManagerRewards/UMG_Grid_RewardsItem.uasset differ diff --git a/ProjectFish/Content/UI/Fishing/Widgets/ManagerRewards/UMG_RewardsGrid_Item.uasset b/ProjectFish/Content/UI/Fishing/Widgets/ManagerRewards/UMG_RewardsGrid_Item.uasset deleted file mode 100644 index 338603c..0000000 Binary files a/ProjectFish/Content/UI/Fishing/Widgets/ManagerRewards/UMG_RewardsGrid_Item.uasset and /dev/null differ diff --git a/ProjectFish/Content/UI/Fishing/Widgets/ManagerRewards/UMG_ShipContainer_Grid.uasset b/ProjectFish/Content/UI/Fishing/Widgets/ManagerRewards/UMG_ShipContainer_Grid.uasset deleted file mode 100644 index 42efc82..0000000 Binary files a/ProjectFish/Content/UI/Fishing/Widgets/ManagerRewards/UMG_ShipContainer_Grid.uasset and /dev/null differ diff --git a/ProjectFish/Content/UI/Fishing/Windows/UMG_ManagerFishingREward_Window.uasset b/ProjectFish/Content/UI/Fishing/Windows/UMG_ManagerFishingREward_Window.uasset index 703c02b..516888e 100644 Binary files a/ProjectFish/Content/UI/Fishing/Windows/UMG_ManagerFishingREward_Window.uasset and b/ProjectFish/Content/UI/Fishing/Windows/UMG_ManagerFishingREward_Window.uasset differ diff --git a/ProjectFish/Content/UI/HomeUI/Widgets/Market/UMG_Market_ContainerSwitcher.uasset b/ProjectFish/Content/UI/HomeUI/Widgets/Market/UMG_Market_ContainerSwitcher.uasset index 3a389fa..9e9113b 100644 Binary files a/ProjectFish/Content/UI/HomeUI/Widgets/Market/UMG_Market_ContainerSwitcher.uasset and b/ProjectFish/Content/UI/HomeUI/Widgets/Market/UMG_Market_ContainerSwitcher.uasset differ diff --git a/ProjectFish/Content/UI/HomeUI/Widgets/PlayerContainer/UMG_Container_Grid.uasset b/ProjectFish/Content/UI/HomeUI/Widgets/PlayerContainer/UMG_Container_Grid.uasset deleted file mode 100644 index 1ce3f3d..0000000 Binary files a/ProjectFish/Content/UI/HomeUI/Widgets/PlayerContainer/UMG_Container_Grid.uasset and /dev/null differ diff --git a/ProjectFish/Content/UI/HomeUI/Windows/UMG_HomeWindow_Market.uasset b/ProjectFish/Content/UI/HomeUI/Windows/UMG_HomeWindow_Market.uasset index c0db24a..18136d9 100644 Binary files a/ProjectFish/Content/UI/HomeUI/Windows/UMG_HomeWindow_Market.uasset and b/ProjectFish/Content/UI/HomeUI/Windows/UMG_HomeWindow_Market.uasset differ diff --git a/ProjectFish/Content/UI/HomeUI/Windows/UMG_HomeWindow_PlayerContainer.uasset b/ProjectFish/Content/UI/HomeUI/Windows/UMG_HomeWindow_PlayerContainer.uasset index f0188c8..5626a37 100644 Binary files a/ProjectFish/Content/UI/HomeUI/Windows/UMG_HomeWindow_PlayerContainer.uasset and b/ProjectFish/Content/UI/HomeUI/Windows/UMG_HomeWindow_PlayerContainer.uasset differ diff --git a/ProjectFish/Source/ProjectFish/Data/ContainerInfo.cpp b/ProjectFish/Source/ProjectFish/Data/ContainerInfo.cpp index 8d1db85..f295979 100644 --- a/ProjectFish/Source/ProjectFish/Data/ContainerInfo.cpp +++ b/ProjectFish/Source/ProjectFish/Data/ContainerInfo.cpp @@ -3,36 +3,12 @@ #include "ContainerInfo.h" +#include "IDetailTreeNode.h" #include "PlayerInfoSaveGame.h" +#include "Chaos/PBDRigidClusteringAlgo.h" #include "Engine/AssetManager.h" #include "Engine/StreamableManager.h" -// void UContainerInfo::InitContainer(FPrimaryAssetId ContainerShapeId) -// { -// //加载形状资源 -// TSharedPtr LoadHandle = GEngine->AssetManager->LoadPrimaryAsset(ContainerShapeId); -// if (LoadHandle.IsValid()) -// { -// // 等待加载完成,这会阻塞线程 -// LoadHandle->WaitUntilComplete(); -// -// // 加载完成后,通过句柄获取资源 -// UObject* LoadedObject = LoadHandle->GetLoadedAsset(); -// if (LoadedObject) -// { -// ContainerShape = Cast(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) { @@ -46,18 +22,19 @@ void UContainerInfo::InitContainerByShape(UShapeAsset* InContainerShape) } } -bool UContainerInfo::AddContainerItem(FContainerItem Item, FIntPoint Position) +bool UContainerInfo::AddContainerItem(FContainerItem Item, int32& ItemID) { - if (IsItemInContainerShape(Item, Position)) + if (IsItemInContainerShape(Item)) { return false; } - if (IsItemOverlapOtherItem(Item, Position)) + if (IsItemOverlapOtherItem(Item)) { return false; } - - Items.Add(Position, Item); + ItemID = NextItemID; + Items.Add(NextItemID, Item); + ++NextItemID; //设置容器指定位置的占用状态 for (int x = 0; x < Item.GetItemWIdth(); x++) { @@ -65,25 +42,46 @@ bool UContainerInfo::AddContainerItem(FContainerItem Item, FIntPoint Position) { if (Item.IsSlotUsing(FIntPoint(x, y))) { - SlotInUsing.Add(FIntPoint(x + Position.X, y + Position.Y), true); + SlotInUsing.Add(FIntPoint(x + Item.ContainerStartPos.X, y + Item.ContainerStartPos.Y), true); } } } return true; } -bool UContainerInfo::IsItemOverlapOtherItem(FContainerItem NewItem, FIntPoint Position) +bool UContainerInfo::RemoveContainerItem(const int32& ItemID) +{ + if (Items.Contains(ItemID)) + { + FContainerItem Item = Items[ItemID]; + for (int x = 0; x < Item.GetItemWIdth(); x++) + { + for (int y = 0; y < Item.GetItemHeight(); y++) + { + if (Item.IsSlotUsing(FIntPoint(x + Item.ContainerStartPos.X, y + Item.ContainerStartPos.Y))) + { + SlotInUsing[FIntPoint(x + Item.ContainerStartPos.X, y + Item.ContainerStartPos.Y)] = false; + } + } + } + Items.Remove(ItemID); + return true; + } + return false; +} + +bool UContainerInfo::IsItemOverlapOtherItem(FContainerItem NewItem) { for (int x = 0; x < NewItem.GetItemWIdth(); x++) { for (int y = 0; y < NewItem.GetItemHeight(); y++) { - if (NewItem.IsSlotUsing(Position)) + if (NewItem.IsSlotUsing(FIntPoint(x, y))) { - if (!ContainerShape->IsSlotActive(Position.X + x, Position.Y + y) || - SlotInUsing[FIntPoint(x + Position.X, y + Position.Y)]) + if (!ContainerShape->IsSlotActive(NewItem.ContainerStartPos.X + x, NewItem.ContainerStartPos.Y + y) || + SlotInUsing[FIntPoint(x + NewItem.ContainerStartPos.X, y + NewItem.ContainerStartPos.Y)]) { return true; } @@ -94,17 +92,17 @@ bool UContainerInfo::IsItemOverlapOtherItem(FContainerItem NewItem, FIntPoint Po return false; } -bool UContainerInfo::IsItemInContainerShape(FContainerItem NewItem, FIntPoint Position) +bool UContainerInfo::IsItemInContainerShape(FContainerItem NewItem) { 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 ( (x + NewItem.ContainerStartPos.X) > 0 && (x + NewItem.ContainerStartPos.X) < ContainerShape->GetShapeWidth() && + (y + NewItem.ContainerStartPos.Y) > 0 && (y + NewItem.ContainerStartPos.Y) < ContainerShape->GetShapeHeight() ) { - if (!ContainerShape->IsSlotActive(Position.X + x, Position.Y + y)) + if (!ContainerShape->IsSlotActive(NewItem.ContainerStartPos.X + x, NewItem.ContainerStartPos.Y + y)) { return false; } @@ -125,8 +123,8 @@ TArray UContainerInfo::GetSaveData() const for (const auto& ItemPair : Items) { FContainerItemSaveData SaveData; - SaveData.PosX = ItemPair.Key.X; - SaveData.PosY = ItemPair.Key.Y; + SaveData.PosX = ItemPair.Value.ContainerStartPos.X; + SaveData.PosY = ItemPair.Value.ContainerStartPos.Y; SaveData.DegreeType = ItemPair.Value.DegreeType; if (ItemPair.Value.RewardItem) @@ -158,13 +156,15 @@ bool UContainerInfo::LoadFromSaveData(FPrimaryAssetId ShapeID, const TArray(RewardItemPath.TryLoad()); //添加物品到容器中 FIntPoint Position(ItemData.PosX, ItemData.PosY); - AddContainerItem(NewItem, Position); + int32 ItemID; + AddContainerItem(NewItem, ItemID); } return true; diff --git a/ProjectFish/Source/ProjectFish/Data/ContainerInfo.h b/ProjectFish/Source/ProjectFish/Data/ContainerInfo.h index 1dc0c70..b1c46ba 100644 --- a/ProjectFish/Source/ProjectFish/Data/ContainerInfo.h +++ b/ProjectFish/Source/ProjectFish/Data/ContainerInfo.h @@ -44,6 +44,8 @@ struct FContainerItem { GENERATED_BODY() public: + UPROPERTY(EditAnywhere, BlueprintReadWrite) + FIntPoint ContainerStartPos; UPROPERTY(EditAnywhere, BlueprintReadWrite) EItemDegreeType DegreeType; UPROPERTY(EditAnywhere, BlueprintReadWrite) @@ -110,7 +112,9 @@ public: void InitContainerByShape(UShapeAsset* InContainerShape); UFUNCTION(BlueprintPure) - bool AddContainerItem(FContainerItem Item, FIntPoint Position); + bool AddContainerItem(FContainerItem Item, int32& ItemID); + UFUNCTION(BlueprintPure) + bool RemoveContainerItem(const int32& ItemID); // 获取存档数据 UFUNCTION(BlueprintCallable, Category = "ContainerInfo") @@ -125,16 +129,17 @@ public: private: //要添加的物品是否会覆盖其他物品 - bool IsItemOverlapOtherItem(FContainerItem Item, FIntPoint Position); + bool IsItemOverlapOtherItem(FContainerItem Item); //要添加的物品是否在容器范围内 - bool IsItemInContainerShape(FContainerItem Item, FIntPoint Position); + bool IsItemInContainerShape(FContainerItem Item); public: UPROPERTY(EditAnywhere, BlueprintReadWrite) - TMap Items; + TMap Items; UPROPERTY(EditAnywhere, BlueprintReadWrite) UShapeAsset* ContainerShape; private: + int32 NextItemID = 0; TMap SlotInUsing; };