Compare commits
2 Commits
111f68fa10
...
4821d206c0
| Author | SHA1 | Date | |
|---|---|---|---|
| 4821d206c0 | |||
| 0f942b0b77 |
Binary file not shown.
Binary file not shown.
@ -10,5 +10,8 @@ InvalidTagCharacters="\"\',"
|
||||
+GameplayTagRedirects=(OldTagName="Skill.PoserPull",NewTagName="Skill.PowerPull")
|
||||
NumBitsForContainerSize=6
|
||||
NetIndexFirstBitSegment=16
|
||||
+GameplayTagList=(Tag="FishReward",DevComment="鱼获")
|
||||
+GameplayTagList=(Tag="FishReward.Fish1",DevComment="")
|
||||
+GameplayTagList=(Tag="FishReward.Fish2",DevComment="")
|
||||
+GameplayTagList=(Tag="Skill.PowerPull",DevComment="")
|
||||
|
||||
|
||||
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.
@ -5,6 +5,7 @@
|
||||
#include "CoreMinimal.h"
|
||||
#include "ShapeAsset.h"
|
||||
#include "Engine/DataAsset.h"
|
||||
#include "ProjectFish/Quest/QuestTypes.h"
|
||||
#include "FishingRewardDataAsset.generated.h"
|
||||
|
||||
UENUM(BlueprintType)
|
||||
@ -36,4 +37,7 @@ public:
|
||||
|
||||
UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "Fishing Reward Data" , meta = (ToolTip = "鱼获稀有度"))
|
||||
ERewardRarityType RewardRarityType;
|
||||
|
||||
UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "Fishing Reward Data" , meta = (ToolTip = "鱼获对应的任务信息"))
|
||||
FQuestTargetInfo QuestTargetInfo;
|
||||
};
|
||||
|
||||
@ -54,5 +54,35 @@ void UQuestAsset::PostEditChangeProperty(FPropertyChangedEvent& PropertyChangedE
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void UQuestAsset::PostDuplicate(bool bDuplicateForPIE)
|
||||
{
|
||||
Super::PostDuplicate(bDuplicateForPIE);
|
||||
if (!bDuplicateForPIE)
|
||||
{
|
||||
int32 MaxQuestID = 0;
|
||||
|
||||
// 获取资产注册表模块
|
||||
FAssetRegistryModule& AssetRegistryModule = FModuleManager::LoadModuleChecked<FAssetRegistryModule>("AssetRegistry");
|
||||
IAssetRegistry& AssetRegistry = AssetRegistryModule.Get();
|
||||
|
||||
// 查找所有 QuestAsset 资产
|
||||
TArray<FAssetData> AssetDataList;
|
||||
AssetRegistry.GetAssetsByClass(UQuestAsset::StaticClass()->GetClassPathName(), AssetDataList, true);
|
||||
|
||||
// 遍历所有已存在的任务资产,找到最大的 QuestID
|
||||
for (const FAssetData& AssetData : AssetDataList)
|
||||
{
|
||||
if (UQuestAsset* QuestAsset = Cast<UQuestAsset>(AssetData.GetAsset()))
|
||||
{
|
||||
if (QuestAsset->QuestID > MaxQuestID)
|
||||
{
|
||||
MaxQuestID = QuestAsset->QuestID;
|
||||
}
|
||||
}
|
||||
}
|
||||
QuestID += 1;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
@ -20,6 +20,8 @@ public:
|
||||
#if WITH_EDITOR
|
||||
// 编辑器中属性修改后的回调
|
||||
virtual void PostEditChangeProperty(FPropertyChangedEvent& PropertyChangedEvent) override;
|
||||
|
||||
virtual void PostDuplicate(bool bDuplicateForPIE) override;
|
||||
#endif
|
||||
/** 任务编号ID */
|
||||
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Quest|Basic")
|
||||
|
||||
@ -140,13 +140,12 @@ bool UQuestManager::CompleteQuest(int32 QuestID)
|
||||
// 触发事件
|
||||
OnQuestStateChanged.Broadcast(QuestID);
|
||||
UE_LOG(LogTemp, Warning, TEXT("Quest id = %d Complete"), QuestID);
|
||||
// 从活动任务中移除
|
||||
ActiveQuestsMap.Remove(QuestID);
|
||||
// // 从活动任务中移除
|
||||
// ActiveQuestsMap.Remove(QuestID);
|
||||
//更新存档数据
|
||||
GetGameInstance()->GetSubsystem<UGameInfoManager>()->SaveGameInfo();
|
||||
|
||||
//检测是否有其他可接受的任务
|
||||
CheckAcceptableQuests();
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -198,7 +197,7 @@ void UQuestManager::UpdateObjectiveProgress(int32 QuestID, int32 ObjectiveIndex,
|
||||
CheckQuestCompletion(QuestID);
|
||||
}
|
||||
|
||||
void UQuestManager::UpdateObjectiveByTargetID(FName TargetID, int32 ProgressDelta)
|
||||
void UQuestManager::UpdateObjectiveByTargetID(FGameplayTag TargetTag, int32 ProgressDelta)
|
||||
{
|
||||
// 遍历所有活动任务,查找匹配的目标
|
||||
for (TPair<int32, FQuestRuntimeData>& Pair : ActiveQuestsMap)
|
||||
@ -213,7 +212,7 @@ void UQuestManager::UpdateObjectiveByTargetID(FName TargetID, int32 ProgressDelt
|
||||
for (int32 i = 0; i < RuntimeData.QuestAsset->Objectives.Num(); ++i)
|
||||
{
|
||||
const FQuestObjective& Objective = RuntimeData.QuestAsset->Objectives[i];
|
||||
if (Objective.TargetID == TargetID)
|
||||
if (Objective.TargetID.TargetTag == TargetTag)
|
||||
{
|
||||
// 增加进度
|
||||
int32 NewProgress = RuntimeData.ObjectiveProgress[i].CurrentProgress + ProgressDelta;
|
||||
@ -221,6 +220,9 @@ void UQuestManager::UpdateObjectiveByTargetID(FName TargetID, int32 ProgressDelt
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//检测是否有其他可接受的任务
|
||||
CheckAcceptableQuests();
|
||||
}
|
||||
|
||||
EQuestState UQuestManager::GetQuestState(int32 QuestID) const
|
||||
@ -352,6 +354,7 @@ TArray<FQuestSaveData> UQuestManager::GetQuestSaveData() const
|
||||
SaveDataArray.Add(SaveData);
|
||||
}
|
||||
|
||||
|
||||
return SaveDataArray;
|
||||
}
|
||||
|
||||
|
||||
@ -79,7 +79,7 @@ public:
|
||||
|
||||
/** 通过目标ID更新进度(自动查找对应目标) */
|
||||
UFUNCTION(BlueprintCallable, Category = "Quest")
|
||||
void UpdateObjectiveByTargetID(FName TargetID, int32 ProgressDelta = 1);
|
||||
void UpdateObjectiveByTargetID(FGameplayTag TargetTag, int32 ProgressDelta = 1);
|
||||
|
||||
// ========== 任务查询 ==========
|
||||
|
||||
|
||||
@ -3,6 +3,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "GameplayTagContainer.h"
|
||||
#include "QuestTypes.generated.h"
|
||||
|
||||
/**
|
||||
@ -49,6 +50,24 @@ struct FQuestReward
|
||||
int32 GoldAmount = 0;
|
||||
};
|
||||
|
||||
/**
|
||||
* 任务目标数据
|
||||
*/
|
||||
USTRUCT(BlueprintType)
|
||||
struct FQuestTargetInfo
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
/** 目标名称*/
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Quest")
|
||||
FText QuestTargetName;
|
||||
|
||||
/** 目标ID */
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Quest")
|
||||
FGameplayTag TargetTag;
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
* 任务目标数据
|
||||
*/
|
||||
@ -67,7 +86,7 @@ struct FQuestObjective
|
||||
|
||||
/** 目标ID(物品ID、敌人ID、地点Tag等) */
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Quest")
|
||||
FName TargetID;
|
||||
FQuestTargetInfo TargetID;
|
||||
|
||||
/** 需要完成的数量 */
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Quest")
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user