添加船舱UI
This commit is contained in:
parent
df2e59ac80
commit
a8f426c2fc
BIN
ProjectFish/Binaries/Win64/UnrealEditor-ProjectFish-0001.dll
Normal file
BIN
ProjectFish/Binaries/Win64/UnrealEditor-ProjectFish-0001.dll
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -2,7 +2,7 @@
|
||||
"BuildId": "37670630",
|
||||
"Modules":
|
||||
{
|
||||
"ProjectFish": "UnrealEditor-ProjectFish.dll",
|
||||
"ProjectFishEditor": "UnrealEditor-ProjectFishEditor.dll"
|
||||
"ProjectFish": "UnrealEditor-ProjectFish-0001.dll",
|
||||
"ProjectFishEditor": "UnrealEditor-ProjectFishEditor-0001.dll"
|
||||
}
|
||||
}
|
||||
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.
@ -2,6 +2,6 @@
|
||||
"BuildId": "37670630",
|
||||
"Modules":
|
||||
{
|
||||
"DeskMode": "UnrealEditor-DeskMode.dll"
|
||||
"DeskMode": "UnrealEditor-DeskMode-0001.dll"
|
||||
}
|
||||
}
|
||||
@ -6,31 +6,43 @@
|
||||
#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();
|
||||
// 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();
|
||||
// }
|
||||
//
|
||||
// }
|
||||
|
||||
// 加载完成后,通过句柄获取资源
|
||||
UObject* LoadedObject = LoadHandle->GetLoadedAsset();
|
||||
if (LoadedObject)
|
||||
void UContainerInfo::InitContainerByShape(UShapeAsset* InContainerShape)
|
||||
{
|
||||
ContainerShape = InContainerShape;
|
||||
for (int x = 0; x < ContainerShape->GetShapeWidth(); x++)
|
||||
{
|
||||
for (int y = 0; y < ContainerShape->GetShapeHeight(); y++)
|
||||
{
|
||||
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);
|
||||
}
|
||||
}
|
||||
SlotInUsing.Add(FIntPoint(x, y), false);
|
||||
}
|
||||
LoadHandle->ReleaseHandle();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
bool UContainerInfo::AddContainerItem(FContainerItem Item, FIntPoint Position)
|
||||
@ -39,11 +51,12 @@ bool UContainerInfo::AddContainerItem(FContainerItem Item, FIntPoint Position)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (!IsItemOverlapOtherItem(Item, Position))
|
||||
if (IsItemOverlapOtherItem(Item, Position))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
Items.Add(Position, Item);
|
||||
//设置容器指定位置的占用状态
|
||||
for (int x = 0; x < Item.GetItemWIdth(); x++)
|
||||
{
|
||||
|
||||
@ -3,6 +3,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "ProjectFish/DataAsset/FishingRewardDataAsset.h"
|
||||
#include "ProjectFish/DataAsset/ShapeAsset.h"
|
||||
#include "UObject/Object.h"
|
||||
#include "ContainerInfo.generated.h"
|
||||
@ -27,19 +28,19 @@ public:
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite)
|
||||
EItemDegreeType DegreeType;
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite)
|
||||
UShapeAsset* ItemShape;
|
||||
UFishingRewardDataAsset* RewardItem;
|
||||
|
||||
//旋转后的水平宽度
|
||||
int32 GetItemWIdth()
|
||||
{
|
||||
return DegreeType == EItemDegreeType::Ninety || DegreeType == EItemDegreeType::TwentySeven? ItemShape->GetShapeHeight()
|
||||
: ItemShape->GetShapeWidth();
|
||||
return DegreeType == EItemDegreeType::Ninety || DegreeType == EItemDegreeType::TwentySeven? RewardItem->RewardShape->GetShapeHeight()
|
||||
: RewardItem->RewardShape->GetShapeWidth();
|
||||
}
|
||||
//旋转后的垂直高度
|
||||
int32 GetItemHeight()
|
||||
{
|
||||
return DegreeType == EItemDegreeType::Ninety || DegreeType == EItemDegreeType::TwentySeven? ItemShape->GetShapeWidth()
|
||||
: ItemShape->GetShapeHeight();
|
||||
return DegreeType == EItemDegreeType::Ninety || DegreeType == EItemDegreeType::TwentySeven? RewardItem->RewardShape->GetShapeWidth()
|
||||
: RewardItem->RewardShape->GetShapeHeight();
|
||||
}
|
||||
|
||||
bool IsSlotUsing(FIntPoint Position)
|
||||
@ -70,7 +71,7 @@ public:
|
||||
break;
|
||||
}
|
||||
|
||||
return ItemShape->IsSlotActive(BeforeRotationPos.X, BeforeRotationPos.Y);
|
||||
return RewardItem->RewardShape->IsSlotActive(BeforeRotationPos.X, BeforeRotationPos.Y);
|
||||
}
|
||||
|
||||
};
|
||||
@ -79,13 +80,18 @@ public:
|
||||
/**
|
||||
* 仓库
|
||||
*/
|
||||
UCLASS()
|
||||
UCLASS(BlueprintType)
|
||||
class PROJECTFISH_API UContainerInfo : public UObject
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
void InitContainer(FPrimaryAssetId ContainerShapeId);
|
||||
// UFUNCTION(BlueprintCallable, Category = "ContainerInfo")
|
||||
// void InitContainer(FPrimaryAssetId ContainerShapeId);
|
||||
|
||||
UFUNCTION(BlueprintCallable, Category = "ContainerInfo")
|
||||
void InitContainerByShape(UShapeAsset* InContainerShape);
|
||||
|
||||
UFUNCTION(BlueprintPure)
|
||||
bool AddContainerItem(FContainerItem Item, FIntPoint Position);
|
||||
|
||||
@ -97,7 +103,7 @@ private:
|
||||
|
||||
public:
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite)
|
||||
TMap<int32, FContainerItem> Items;
|
||||
TMap<FIntPoint, FContainerItem> Items;
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite)
|
||||
UShapeAsset* ContainerShape;
|
||||
|
||||
|
||||
@ -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.GetItemWIdth();
|
||||
}
|
||||
|
||||
@ -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);
|
||||
};
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user