更新背包接收地图生成的技能
This commit is contained in:
parent
33a7fb06f1
commit
5ddb1b45f9
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -2,7 +2,7 @@
|
|||||||
"BuildId": "37670630",
|
"BuildId": "37670630",
|
||||||
"Modules":
|
"Modules":
|
||||||
{
|
{
|
||||||
"ProjectFish": "UnrealEditor-ProjectFish-0001.dll",
|
"ProjectFish": "UnrealEditor-ProjectFish.dll",
|
||||||
"ProjectFishEditor": "UnrealEditor-ProjectFishEditor-0001.dll"
|
"ProjectFishEditor": "UnrealEditor-ProjectFishEditor.dll"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Binary file not shown.
Binary file not shown.
@ -31,4 +31,11 @@ public:
|
|||||||
|
|
||||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category= MapConfig, meta = (ToolTip = "战斗节点名称"))
|
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category= MapConfig, meta = (ToolTip = "战斗节点名称"))
|
||||||
FName BattleMapName = FName(TEXT("Dabaza"));
|
FName BattleMapName = FName(TEXT("Dabaza"));
|
||||||
|
|
||||||
|
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category= MapConfig, meta = (ToolTip = "道具节点提供的技能"))
|
||||||
|
TArray<class USkillAsset*> RandomSkills;
|
||||||
|
// UPROPERTY(EditAnywhere, BlueprintReadWrite, Category= MapConfig, meta = (AllowedClasses = "SkillAsset", ToolTip = "道具节点提供的技能"))
|
||||||
|
// TArray<FSoftObjectPath> RandomSkills;
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|||||||
@ -1,4 +1,6 @@
|
|||||||
#include "FishingMapSubSystem.h"
|
#include "FishingMapSubSystem.h"
|
||||||
|
|
||||||
|
#include "FishingRodConfigSubsystem.h"
|
||||||
#include "Engine/Engine.h"
|
#include "Engine/Engine.h"
|
||||||
#include "Kismet/GameplayStatics.h"
|
#include "Kismet/GameplayStatics.h"
|
||||||
#include "ProjectFish/DataAsset/MapConfigAsset.h"
|
#include "ProjectFish/DataAsset/MapConfigAsset.h"
|
||||||
@ -100,6 +102,17 @@ void UFishingMapSubSystem::MoveToNode(FGuid NodeID)
|
|||||||
UGameplayStatics::OpenLevel(this, MapConfig->BattleMapName);
|
UGameplayStatics::OpenLevel(this, MapConfig->BattleMapName);
|
||||||
break;
|
break;
|
||||||
case EMapNodeType::Skill:
|
case EMapNodeType::Skill:
|
||||||
|
//添加技能到背包系统中
|
||||||
|
if (UGameInstance* GameInstance = GetGameInstance())
|
||||||
|
{
|
||||||
|
|
||||||
|
//USkillAsset* RandomSkill =LoadObject<USkillAsset>(this, * MapConfig->RandomSkills[FMath::RandRange(0, MapConfig->RandomSkills.Num() - 1)].ToString());
|
||||||
|
USkillAsset* RandomSkill = DuplicateObject<USkillAsset>(MapConfig->RandomSkills[FMath::RandRange(0, MapConfig->RandomSkills.Num() - 1)], this);
|
||||||
|
if (!GameInstance->GetSubsystem<UFishingRodConfigSubsystem>()->AddSkillToPlayerInventory(RandomSkill))
|
||||||
|
{
|
||||||
|
UE_LOG(LogTemp, Error, TEXT("道具节点添加道具失败,背包没有多余位置"));
|
||||||
|
}
|
||||||
|
}
|
||||||
break;;
|
break;;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -4,6 +4,7 @@
|
|||||||
#include "FishingRodConfigSubsystem.h"
|
#include "FishingRodConfigSubsystem.h"
|
||||||
|
|
||||||
#include "ProjectFish/DataAsset/BagConfigAsset.h"
|
#include "ProjectFish/DataAsset/BagConfigAsset.h"
|
||||||
|
#include "ProjectFish/DataAsset/BagShapeAsset.h"
|
||||||
|
|
||||||
void UFishingRodConfigSubsystem::CreateFishingRodInventory(class UBagShapeAsset* FishingRodShape, class UBagShapeAsset* PlayerBagShape)
|
void UFishingRodConfigSubsystem::CreateFishingRodInventory(class UBagShapeAsset* FishingRodShape, class UBagShapeAsset* PlayerBagShape)
|
||||||
{
|
{
|
||||||
@ -24,3 +25,27 @@ UBagConfigAsset* UFishingRodConfigSubsystem::GetPlayerInventory()
|
|||||||
{
|
{
|
||||||
return playerInventoryConfig;
|
return playerInventoryConfig;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool UFishingRodConfigSubsystem::AddSkillByConfig(USkillAsset* SkillAsset, UBagConfigAsset* InventoryConfig,
|
||||||
|
FIntPoint Position)
|
||||||
|
{
|
||||||
|
return InventoryConfig->AddSkill(SkillAsset, Position.X, Position.Y);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool UFishingRodConfigSubsystem::AddSkillToPlayerInventory(USkillAsset* SkillAsset)
|
||||||
|
{
|
||||||
|
|
||||||
|
int32 width = playerInventoryConfig->BagShapeAsset->BagWidth;
|
||||||
|
int32 height = playerInventoryConfig->BagShapeAsset->BagHeight;
|
||||||
|
for (int x = 0; x < width; x++)
|
||||||
|
{
|
||||||
|
for (int y = 0; y < height; y++)
|
||||||
|
{
|
||||||
|
if (playerInventoryConfig->AddSkill(SkillAsset, x, y))
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|||||||
@ -3,6 +3,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "CoreMinimal.h"
|
#include "CoreMinimal.h"
|
||||||
|
#include "ProjectFish/DataAsset/SkillAsset.h"
|
||||||
#include "Subsystems/GameInstanceSubsystem.h"
|
#include "Subsystems/GameInstanceSubsystem.h"
|
||||||
#include "FishingRodConfigSubsystem.generated.h"
|
#include "FishingRodConfigSubsystem.generated.h"
|
||||||
|
|
||||||
@ -22,6 +23,13 @@ public:
|
|||||||
UBagConfigAsset* GetFishingRodInventory();
|
UBagConfigAsset* GetFishingRodInventory();
|
||||||
UFUNCTION(BlueprintPure, Category = "PlayerInventorySubsystem")
|
UFUNCTION(BlueprintPure, Category = "PlayerInventorySubsystem")
|
||||||
UBagConfigAsset* GetPlayerInventory();
|
UBagConfigAsset* GetPlayerInventory();
|
||||||
|
|
||||||
|
UFUNCTION(BlueprintPure, Category = "PlayerInventorySubsystem")
|
||||||
|
bool AddSkillByConfig(USkillAsset* SkillAsset, UBagConfigAsset* InventoryConfig, FIntPoint Position);
|
||||||
|
|
||||||
|
UFUNCTION(BlueprintPure, Category = "PlayerInventorySubsystem")
|
||||||
|
bool AddSkillToPlayerInventory(USkillAsset* SkillAsset);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
UPROPERTY()
|
UPROPERTY()
|
||||||
class UBagConfigAsset* fishingRodInventoryConfig = nullptr;
|
class UBagConfigAsset* fishingRodInventoryConfig = nullptr;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user