diff --git a/ProjectFish/Binaries/Win64/UnrealEditor-ProjectFish.dll b/ProjectFish/Binaries/Win64/UnrealEditor-ProjectFish.dll index 7577fe6..c119c7b 100644 Binary files a/ProjectFish/Binaries/Win64/UnrealEditor-ProjectFish.dll and b/ProjectFish/Binaries/Win64/UnrealEditor-ProjectFish.dll differ diff --git a/ProjectFish/Binaries/Win64/UnrealEditor-ProjectFishEditor.dll b/ProjectFish/Binaries/Win64/UnrealEditor-ProjectFishEditor.dll index c3554be..d0a1476 100644 Binary files a/ProjectFish/Binaries/Win64/UnrealEditor-ProjectFishEditor.dll and b/ProjectFish/Binaries/Win64/UnrealEditor-ProjectFishEditor.dll differ diff --git a/ProjectFish/Source/ProjectFish/Data/ContainerInfo.cpp b/ProjectFish/Source/ProjectFish/Data/ContainerInfo.cpp new file mode 100644 index 0000000..534ee1c --- /dev/null +++ b/ProjectFish/Source/ProjectFish/Data/ContainerInfo.cpp @@ -0,0 +1,104 @@ +// Fill out your copyright notice in the Description page of Project Settings. + + +#include "ContainerInfo.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(); + } + +} + +bool UContainerInfo::AddContainerItem(FContainerItem Item, FIntPoint Position) +{ + if (IsItemInContainerShape(Item, Position)) + { + return false; + } + if (!IsItemOverlapOtherItem(Item, Position)) + { + return false; + } + + //设置容器指定位置的占用状态 + 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.Find(FIntPoint(x + Position.X, y + Position.Y))) + { + return false; + } + + } + } + } + return true; +} + +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; +} diff --git a/ProjectFish/Source/ProjectFish/Data/ContainerInfo.h b/ProjectFish/Source/ProjectFish/Data/ContainerInfo.h new file mode 100644 index 0000000..f9131a4 --- /dev/null +++ b/ProjectFish/Source/ProjectFish/Data/ContainerInfo.h @@ -0,0 +1,106 @@ +// Fill out your copyright notice in the Description page of Project Settings. + +#pragma once + +#include "CoreMinimal.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 FContainerItem +{ + GENERATED_BODY() +public: + UPROPERTY(EditAnywhere, BlueprintReadWrite) + EItemDegreeType DegreeType; + UPROPERTY(EditAnywhere, BlueprintReadWrite) + UShapeAsset* ItemShape; + + //旋转后的水平宽度 + int32 GetItemWIdth() + { + return DegreeType == EItemDegreeType::Ninety || DegreeType == EItemDegreeType::TwentySeven? ItemShape->GetShapeHeight() + : ItemShape->GetShapeWidth(); + } + //旋转后的垂直高度 + int32 GetItemHeight() + { + return DegreeType == EItemDegreeType::Ninety || DegreeType == EItemDegreeType::TwentySeven? ItemShape->GetShapeWidth() + : ItemShape->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 ItemShape->IsSlotActive(BeforeRotationPos.X, BeforeRotationPos.Y); + } + +}; + + +/** + * 仓库 + */ +UCLASS() +class PROJECTFISH_API UContainerInfo : public UObject +{ + GENERATED_BODY() + +public: + void InitContainer(FPrimaryAssetId ContainerShapeId); + UFUNCTION(BlueprintPure) + bool AddContainerItem(FContainerItem Item, FIntPoint Position); + +private: + //要添加的物品是否会覆盖其他物品 + bool IsItemOverlapOtherItem(FContainerItem Item, FIntPoint Position); + //要添加的物品是否在容器范围内 + bool IsItemInContainerShape(FContainerItem Item, FIntPoint Position); + +public: + UPROPERTY(EditAnywhere, BlueprintReadWrite) + TMap Items; + UPROPERTY(EditAnywhere, BlueprintReadWrite) + UShapeAsset* ContainerShape; + +private: + TMap SlotInUsing; +}; diff --git a/ProjectFish/Source/ProjectFish/Data/PlayerInfoSaveGame.h b/ProjectFish/Source/ProjectFish/Data/PlayerInfoSaveGame.h index dee836c..ea7e008 100644 --- a/ProjectFish/Source/ProjectFish/Data/PlayerInfoSaveGame.h +++ b/ProjectFish/Source/ProjectFish/Data/PlayerInfoSaveGame.h @@ -20,13 +20,13 @@ public: UPROPERTY(BlueprintReadWrite, meta = (ToolTip = "船只等级")) int32 ShipLevel; UPROPERTY(BlueprintReadWrite, meta = (ToolTip = "船舱信息")) - FContainerInfo ShipContainer; + class UContainerInfo* ShipContainer; UPROPERTY(BlueprintReadWrite, meta = (ToolTip = "仓库资源")) FPrimaryAssetId PlayerContainerAssetID; UPROPERTY(BlueprintReadWrite, meta = (ToolTip = "仓库等级")) int32 PlayerContainerLevel; UPROPERTY(BlueprintReadWrite, meta = (ToolTip = "玩家仓库信息")) - FContainerInfo PlayerContainer; + class UContainerInfo* PlayerContainer; }; diff --git a/ProjectFish/Source/ProjectFish/DataAsset/FishInfoConfigAsset.h b/ProjectFish/Source/ProjectFish/DataAsset/FishInfoConfigAsset.h index fd5663e..3a20993 100644 --- a/ProjectFish/Source/ProjectFish/DataAsset/FishInfoConfigAsset.h +++ b/ProjectFish/Source/ProjectFish/DataAsset/FishInfoConfigAsset.h @@ -8,7 +8,7 @@ #include "FishInfoConfigAsset.generated.h" /** - * + * 敌人 鱼的信息配置 */ UCLASS(BlueprintType) class PROJECTFISH_API UFishInfoConfigAsset : public UDataAsset diff --git a/ProjectFish/Source/ProjectFish/DataAsset/FishingRewardDataAsset.h b/ProjectFish/Source/ProjectFish/DataAsset/FishingRewardDataAsset.h index a384f5e..20143fb 100644 --- a/ProjectFish/Source/ProjectFish/DataAsset/FishingRewardDataAsset.h +++ b/ProjectFish/Source/ProjectFish/DataAsset/FishingRewardDataAsset.h @@ -3,6 +3,7 @@ #pragma once #include "CoreMinimal.h" +#include "ShapeAsset.h" #include "Engine/DataAsset.h" #include "FishingRewardDataAsset.generated.h" @@ -14,7 +15,7 @@ enum class ERewardRarityType: uint8 Rare UMETA(DisplayName = "稀有"), }; /** - * + * 鱼获配置 */ UCLASS() class PROJECTFISH_API UFishingRewardDataAsset : public UPrimaryDataAsset @@ -30,6 +31,9 @@ public: 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; }; diff --git a/ProjectFish/Source/ProjectFish/DataAsset/ShapeAsset.h b/ProjectFish/Source/ProjectFish/DataAsset/ShapeAsset.h index d3feeac..5c148f6 100644 --- a/ProjectFish/Source/ProjectFish/DataAsset/ShapeAsset.h +++ b/ProjectFish/Source/ProjectFish/DataAsset/ShapeAsset.h @@ -14,8 +14,8 @@ struct FShapeSlot int32 X; UPROPERTY(EditAnywhere, BlueprintReadWrite) int32 Y; - - UPROPERTY(EditAnywhere, BlueprintReadWrite) + + UPROPERTY(EditAnywhere, BlueprintReadWrite, meta = (ToolTip = "该槽位是否为激活状态")) bool bIsActive; FShapeSlot() { @@ -28,6 +28,7 @@ struct FShapeSlot X = InX; Y = InY; bIsActive = InIsActive; + } }; /** diff --git a/ProjectFish/Source/ProjectFish/DataAsset/ShipConfigAsset.cpp b/ProjectFish/Source/ProjectFish/DataAsset/ShipConfigAsset.cpp new file mode 100644 index 0000000..da5c5f5 --- /dev/null +++ b/ProjectFish/Source/ProjectFish/DataAsset/ShipConfigAsset.cpp @@ -0,0 +1,4 @@ +// Fill out your copyright notice in the Description page of Project Settings. + + +#include "ShipConfigAsset.h" diff --git a/ProjectFish/Source/ProjectFish/DataAsset/ShipConfigAsset.h b/ProjectFish/Source/ProjectFish/DataAsset/ShipConfigAsset.h new file mode 100644 index 0000000..f4a06dc --- /dev/null +++ b/ProjectFish/Source/ProjectFish/DataAsset/ShipConfigAsset.h @@ -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 Level_ShipShapes; + +}; diff --git a/ProjectFish/Source/ProjectFish/Definations.h b/ProjectFish/Source/ProjectFish/Definations.h index 2c936f6..2b9d3a7 100644 --- a/ProjectFish/Source/ProjectFish/Definations.h +++ b/ProjectFish/Source/ProjectFish/Definations.h @@ -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" @@ -459,4 +460,8 @@ struct FSimpleConnection : FromNodeID(From), ToNodeID(To) { } -}; \ No newline at end of file +}; + + + + diff --git a/ProjectFish/Source/ProjectFish/Gameplay/Ship/Shipbase.cpp b/ProjectFish/Source/ProjectFish/Gameplay/Ship/Shipbase.cpp index f7bd52a..c897f1c 100644 --- a/ProjectFish/Source/ProjectFish/Gameplay/Ship/Shipbase.cpp +++ b/ProjectFish/Source/ProjectFish/Gameplay/Ship/Shipbase.cpp @@ -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" diff --git a/ProjectFish/Source/ProjectFish/Skill/SkillEffects/SkillEffect_EnhanceFishRod.cpp b/ProjectFish/Source/ProjectFish/Skill/SkillEffects/SkillEffect_EnhanceFishRod.cpp index 2c4cb8f..fac601e 100644 --- a/ProjectFish/Source/ProjectFish/Skill/SkillEffects/SkillEffect_EnhanceFishRod.cpp +++ b/ProjectFish/Source/ProjectFish/Skill/SkillEffects/SkillEffect_EnhanceFishRod.cpp @@ -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)