feat: starting skills
This commit is contained in:
BIN
Content/Art/T_Start.uasset
(Stored with Git LFS)
Normal file
BIN
Content/Art/T_Start.uasset
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
Content/DT_SkillTree.uasset
(Stored with Git LFS)
BIN
Content/DT_SkillTree.uasset
(Stored with Git LFS)
Binary file not shown.
BIN
Content/UI/WBP_SkillNode.uasset
(Stored with Git LFS)
BIN
Content/UI/WBP_SkillNode.uasset
(Stored with Git LFS)
Binary file not shown.
BIN
Content/UI/WBP_SkillNodeTooltip.uasset
(Stored with Git LFS)
BIN
Content/UI/WBP_SkillNodeTooltip.uasset
(Stored with Git LFS)
Binary file not shown.
BIN
Content/UI/WBP_SkillTree.uasset
(Stored with Git LFS)
BIN
Content/UI/WBP_SkillTree.uasset
(Stored with Git LFS)
Binary file not shown.
@@ -19,6 +19,7 @@ void USkillTreeComponent::BeginPlay()
|
|||||||
void USkillTreeComponent::InitializeSkillTree()
|
void USkillTreeComponent::InitializeSkillTree()
|
||||||
{
|
{
|
||||||
AllSkills.Empty();
|
AllSkills.Empty();
|
||||||
|
PurchasedSkills.Empty();
|
||||||
|
|
||||||
if (!SkillDataTable)
|
if (!SkillDataTable)
|
||||||
{
|
{
|
||||||
@@ -44,10 +45,33 @@ void USkillTreeComponent::InitializeSkillTree()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Auto-purchase starting skills (these don't cost skill points)
|
||||||
|
for (auto& Pair : AllSkills)
|
||||||
|
{
|
||||||
|
const FName& SkillID = Pair.Key;
|
||||||
|
FSkillNodeRuntime& SkillNode = Pair.Value;
|
||||||
|
|
||||||
|
if (SkillNode.NodeData.bStartingSkill)
|
||||||
|
{
|
||||||
|
// Mark as purchased
|
||||||
|
SkillNode.CurrentState = ESkillNodeState::Purchased;
|
||||||
|
PurchasedSkills.Add(SkillID);
|
||||||
|
|
||||||
|
// Apply skill effects
|
||||||
|
ApplySkillEffects(SkillNode.NodeData);
|
||||||
|
|
||||||
|
// Broadcast purchase event
|
||||||
|
OnSkillPurchased.Broadcast(SkillID);
|
||||||
|
|
||||||
|
UE_LOG(LogTemp, Log, TEXT("SkillTreeComponent: Auto-purchased starting skill: %s"),
|
||||||
|
*SkillNode.NodeData.DisplayName.ToString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
UpdateSkillStates();
|
UpdateSkillStates();
|
||||||
|
|
||||||
UE_LOG(LogTemp, Log, TEXT("SkillTreeComponent: Initialized with %d skills"),
|
UE_LOG(LogTemp, Log, TEXT("SkillTreeComponent: Initialized with %d skills (%d starting)"),
|
||||||
AllSkills.Num());
|
AllSkills.Num(), PurchasedSkills.Num());
|
||||||
}
|
}
|
||||||
|
|
||||||
void USkillTreeComponent::AddSkillPoints(int32 Amount)
|
void USkillTreeComponent::AddSkillPoints(int32 Amount)
|
||||||
@@ -414,14 +438,20 @@ float USkillTreeComponent::GetTotalSpeedBonusPercent() const
|
|||||||
|
|
||||||
void USkillTreeComponent::ResetAllSkills()
|
void USkillTreeComponent::ResetAllSkills()
|
||||||
{
|
{
|
||||||
// Refund all skill points
|
// Refund skill points (but not for starting skills)
|
||||||
int32 RefundAmount = 0;
|
int32 RefundAmount = 0;
|
||||||
for (const FName& SkillID : PurchasedSkills)
|
for (const FName& SkillID : PurchasedSkills)
|
||||||
{
|
{
|
||||||
if (const FSkillNodeRuntime* SkillNode = AllSkills.Find(SkillID))
|
if (const FSkillNodeRuntime* SkillNode = AllSkills.Find(SkillID))
|
||||||
{
|
{
|
||||||
RefundAmount += SkillNode->NodeData.Cost;
|
// Remove skill effects for all purchased skills
|
||||||
RemoveSkillEffects(SkillNode->NodeData);
|
RemoveSkillEffects(SkillNode->NodeData);
|
||||||
|
|
||||||
|
// Only refund cost for non-starting skills
|
||||||
|
if (!SkillNode->NodeData.bStartingSkill)
|
||||||
|
{
|
||||||
|
RefundAmount += SkillNode->NodeData.Cost;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -437,13 +467,39 @@ void USkillTreeComponent::ResetAllSkills()
|
|||||||
CurrentSelectionCost = 0;
|
CurrentSelectionCost = 0;
|
||||||
|
|
||||||
// Add refunded points
|
// Add refunded points
|
||||||
AddSkillPoints(RefundAmount);
|
if (RefundAmount > 0)
|
||||||
|
{
|
||||||
|
AddSkillPoints(RefundAmount);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Re-purchase starting skills
|
||||||
|
for (auto& Pair : AllSkills)
|
||||||
|
{
|
||||||
|
const FName& SkillID = Pair.Key;
|
||||||
|
FSkillNodeRuntime& SkillNode = Pair.Value;
|
||||||
|
|
||||||
|
if (SkillNode.NodeData.bStartingSkill)
|
||||||
|
{
|
||||||
|
// Mark as purchased
|
||||||
|
SkillNode.CurrentState = ESkillNodeState::Purchased;
|
||||||
|
PurchasedSkills.Add(SkillID);
|
||||||
|
|
||||||
|
// Apply skill effects
|
||||||
|
ApplySkillEffects(SkillNode.NodeData);
|
||||||
|
|
||||||
|
// Broadcast purchase event
|
||||||
|
OnSkillPurchased.Broadcast(SkillID);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Update states
|
// Update states
|
||||||
UpdateSkillStates();
|
UpdateSkillStates();
|
||||||
|
|
||||||
// Broadcast events
|
// Broadcast events
|
||||||
OnSkillSelectionChanged.Broadcast(CurrentSelectionCost);
|
OnSkillSelectionChanged.Broadcast(CurrentSelectionCost);
|
||||||
|
|
||||||
|
UE_LOG(LogTemp, Log, TEXT("SkillTreeComponent: Reset all skills. Refunded %d points. Re-purchased %d starting skills."),
|
||||||
|
RefundAmount, PurchasedSkills.Num());
|
||||||
}
|
}
|
||||||
|
|
||||||
void USkillTreeComponent::UpdateSkillStates()
|
void USkillTreeComponent::UpdateSkillStates()
|
||||||
|
|||||||
@@ -50,6 +50,10 @@ struct FSkillNodeData : public FTableRowBase
|
|||||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Skill")
|
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Skill")
|
||||||
int32 PurchaseOrder;
|
int32 PurchaseOrder;
|
||||||
|
|
||||||
|
// Is this a starting skill? (automatically purchased at initialization)
|
||||||
|
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Skill")
|
||||||
|
bool bStartingSkill;
|
||||||
|
|
||||||
// Prerequisites - must have these skills first
|
// Prerequisites - must have these skills first
|
||||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Skill")
|
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Skill")
|
||||||
TArray<FName> Prerequisites;
|
TArray<FName> Prerequisites;
|
||||||
@@ -76,6 +80,7 @@ struct FSkillNodeData : public FTableRowBase
|
|||||||
Icon = nullptr;
|
Icon = nullptr;
|
||||||
Cost = 1;
|
Cost = 1;
|
||||||
PurchaseOrder = 0;
|
PurchaseOrder = 0;
|
||||||
|
bStartingSkill = false;
|
||||||
HealthBonus = 0.0f;
|
HealthBonus = 0.0f;
|
||||||
DamageBonus = 0.0f;
|
DamageBonus = 0.0f;
|
||||||
SpeedBonus = 0.0f;
|
SpeedBonus = 0.0f;
|
||||||
|
|||||||
Reference in New Issue
Block a user