添加任务系统UI
This commit is contained in:
parent
10d2c7e354
commit
8917abed28
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.
BIN
ProjectFish/Content/UI/Quest/Widget/UMG_QuestInfo_Widget.uasset
Normal file
BIN
ProjectFish/Content/UI/Quest/Widget/UMG_QuestInfo_Widget.uasset
Normal file
Binary file not shown.
Binary file not shown.
BIN
ProjectFish/Content/UI/Quest/Window/UMG_QuestWindow.uasset
Normal file
BIN
ProjectFish/Content/UI/Quest/Window/UMG_QuestWindow.uasset
Normal file
Binary file not shown.
@ -33,8 +33,8 @@ public:
|
|||||||
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Quest|Basic", meta = (MultiLine = true))
|
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Quest|Basic", meta = (MultiLine = true))
|
||||||
FText QuestDescription;
|
FText QuestDescription;
|
||||||
|
|
||||||
/** 前置任务ID列表(完成这些任务后才能触发当前任务) */
|
/** 前置任务ID列表() */
|
||||||
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Quest|Trigger")
|
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Quest|Trigger", meta = (ToolTip = "完成这些任务后才能触发当前任务, 不填写默认激活接受"))
|
||||||
TArray<int32> PrerequisiteQuestIDs;
|
TArray<int32> PrerequisiteQuestIDs;
|
||||||
|
|
||||||
/** 任务触发条件(预留,可在蓝图中实现) */
|
/** 任务触发条件(预留,可在蓝图中实现) */
|
||||||
@ -52,8 +52,5 @@ public:
|
|||||||
/** 任务完成条件描述(预留,可在蓝图中实现) */
|
/** 任务完成条件描述(预留,可在蓝图中实现) */
|
||||||
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Quest|Completion")
|
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Quest|Completion")
|
||||||
FString CompletionCondition;
|
FString CompletionCondition;
|
||||||
|
|
||||||
/** 是否自动触发(游戏开始时自动接取) */
|
|
||||||
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Quest|Trigger")
|
|
||||||
bool bAutoTrigger = false;
|
|
||||||
};
|
};
|
||||||
|
|||||||
@ -44,6 +44,18 @@ void UQuestManager::LoadAllQuests()
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void UQuestManager::CheckAcceptableQuests()
|
||||||
|
{
|
||||||
|
for (auto QuestAsset : QuestAssets)
|
||||||
|
{
|
||||||
|
if (!ActiveQuestsMap.Find(QuestAsset->QuestID) && CompletedQuestIDs.Contains(QuestAsset->QuestID))
|
||||||
|
{
|
||||||
|
//任务不在当前已激活的任务 和 已完成的任务列表中
|
||||||
|
AcceptQuest(QuestAsset);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bool UQuestManager::AcceptQuest(UQuestAsset* QuestAsset)
|
bool UQuestManager::AcceptQuest(UQuestAsset* QuestAsset)
|
||||||
{
|
{
|
||||||
if (!QuestAsset)
|
if (!QuestAsset)
|
||||||
@ -70,7 +82,7 @@ bool UQuestManager::AcceptQuest(UQuestAsset* QuestAsset)
|
|||||||
|
|
||||||
// 触发事件
|
// 触发事件
|
||||||
OnQuestStateChanged.Broadcast(QuestAsset->QuestID);
|
OnQuestStateChanged.Broadcast(QuestAsset->QuestID);
|
||||||
|
UE_LOG(LogTemp, Warning, TEXT("Quest %s Accepted"), *QuestAsset->QuestName.ToString());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -97,10 +109,12 @@ bool UQuestManager::CompleteQuest(int32 QuestID)
|
|||||||
|
|
||||||
// 触发事件
|
// 触发事件
|
||||||
OnQuestStateChanged.Broadcast(QuestID);
|
OnQuestStateChanged.Broadcast(QuestID);
|
||||||
|
UE_LOG(LogTemp, Warning, TEXT("Quest id = %d Complete"), QuestID);
|
||||||
// 从活动任务中移除
|
// 从活动任务中移除
|
||||||
ActiveQuestsMap.Remove(QuestID);
|
ActiveQuestsMap.Remove(QuestID);
|
||||||
|
|
||||||
|
//检测是否有其他可接受的任务
|
||||||
|
CheckAcceptableQuests();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -307,6 +321,8 @@ void UQuestManager::LoadFromSaveData(const TArray<FQuestSaveData>& SaveData)
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CheckAcceptableQuests();
|
||||||
}
|
}
|
||||||
|
|
||||||
void UQuestManager::CheckQuestCompletion(int32 QuestID)
|
void UQuestManager::CheckQuestCompletion(int32 QuestID)
|
||||||
|
|||||||
@ -51,6 +51,10 @@ public:
|
|||||||
/** 加载本地所有任务 */
|
/** 加载本地所有任务 */
|
||||||
void LoadAllQuests();
|
void LoadAllQuests();
|
||||||
|
|
||||||
|
/** 检测所有可接收的任务 */
|
||||||
|
UFUNCTION(BlueprintCallable, Category = "Quest")
|
||||||
|
void CheckAcceptableQuests();
|
||||||
|
|
||||||
/** 接受任务 */
|
/** 接受任务 */
|
||||||
UFUNCTION(BlueprintCallable, Category = "Quest")
|
UFUNCTION(BlueprintCallable, Category = "Quest")
|
||||||
bool AcceptQuest(UQuestAsset* QuestAsset);
|
bool AcceptQuest(UQuestAsset* QuestAsset);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user