2025-10-23 00:49:44 -04:00
|
|
|
|
using System;
|
2025-10-03 00:02:43 -04:00
|
|
|
|
using System.Collections.Generic;
|
2025-10-23 00:49:44 -04:00
|
|
|
|
using NaughtyAttributes;
|
|
|
|
|
|
using SLSFramework.General;
|
2025-10-03 00:02:43 -04:00
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
|
|
|
|
|
|
namespace Continentis.MainGame.Card
|
|
|
|
|
|
{
|
2025-10-23 00:49:44 -04:00
|
|
|
|
[Serializable]
|
2025-10-03 00:02:43 -04:00
|
|
|
|
public class CardUpgradeNode
|
|
|
|
|
|
{
|
|
|
|
|
|
[ReadOnly]
|
|
|
|
|
|
[Tooltip("来源卡牌")]
|
|
|
|
|
|
public CardData sourceCard;
|
|
|
|
|
|
|
|
|
|
|
|
public bool isTerminalNode;
|
|
|
|
|
|
|
|
|
|
|
|
[ShowIf("isTerminalNode")]
|
|
|
|
|
|
public bool isInfiniteUpgrade;
|
|
|
|
|
|
|
|
|
|
|
|
[HideIf("isInfiniteUpgrade")]
|
|
|
|
|
|
public int maxUpgradeLevel;
|
|
|
|
|
|
|
|
|
|
|
|
[HideIf("isTerminalNode")]
|
|
|
|
|
|
[Tooltip("可升级到的卡牌列表")]
|
|
|
|
|
|
public List<CardData> upgradeCards;
|
|
|
|
|
|
|
|
|
|
|
|
[ShowIf("isTerminalNode")]
|
|
|
|
|
|
[Tooltip("默认每次升级时增加的属性,第一栏是属性名,第二栏是增加的数值")]
|
|
|
|
|
|
public Dictionary<string, float> defaultUpgradeAttributes;
|
|
|
|
|
|
|
|
|
|
|
|
[ShowIf("isTerminalNode")]
|
|
|
|
|
|
[Tooltip("设计师设定的卡牌等级,升级时增加的属性,第一栏是属性名,第二栏是增加的数值,index=0为第一次升级,以此类推,优先使用此列表中的属性增量")]
|
|
|
|
|
|
public List<Dictionary<string, float>> customUpgradeAttributes;
|
|
|
|
|
|
|
|
|
|
|
|
[ShowIf("isTerminalNode")]
|
|
|
|
|
|
[Tooltip("设计师设定的卡牌等级,升级时替换的描述,index=0为第一次升级,以此类推,优先使用此列表中的描述,如果没有则使用原卡牌的描述")]
|
|
|
|
|
|
public List<string> customDescriptions;
|
|
|
|
|
|
|
|
|
|
|
|
public CardUpgradeNode(CardData sourceCard)
|
|
|
|
|
|
{
|
|
|
|
|
|
this.sourceCard = sourceCard;
|
|
|
|
|
|
this.isTerminalNode = true;
|
|
|
|
|
|
this.maxUpgradeLevel = 1;
|
|
|
|
|
|
this.isInfiniteUpgrade = false;
|
|
|
|
|
|
this.upgradeCards = new List<CardData>();
|
|
|
|
|
|
this.defaultUpgradeAttributes = new Dictionary<string, float>();
|
|
|
|
|
|
this.customUpgradeAttributes = new List<Dictionary<string, float>>();
|
|
|
|
|
|
this.customDescriptions = new List<string>();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public Dictionary<string, float> GetUpgradeAttributes(int upgradeLevel)
|
|
|
|
|
|
{
|
|
|
|
|
|
Dictionary<string, float> upgradeAttributes = new Dictionary<string, float>();
|
|
|
|
|
|
|
|
|
|
|
|
if (isTerminalNode)
|
|
|
|
|
|
{
|
|
|
|
|
|
int levelCountInCustom = Mathf.Min(customUpgradeAttributes.Count, upgradeLevel);
|
|
|
|
|
|
|
|
|
|
|
|
for (int level = 0; level < levelCountInCustom; level++)
|
|
|
|
|
|
{
|
|
|
|
|
|
Dictionary<string, float> thisLevel = customUpgradeAttributes[level];
|
|
|
|
|
|
foreach (KeyValuePair<string, float> attribute in thisLevel)
|
|
|
|
|
|
{
|
|
|
|
|
|
upgradeAttributes.ModifyOrAdd(attribute.Key, attribute.Value);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (upgradeLevel > customUpgradeAttributes.Count)
|
|
|
|
|
|
{
|
|
|
|
|
|
int defaultLevelCount = upgradeLevel - customUpgradeAttributes.Count;
|
|
|
|
|
|
|
|
|
|
|
|
foreach (KeyValuePair<string, float> attribute in defaultUpgradeAttributes)
|
|
|
|
|
|
{
|
|
|
|
|
|
upgradeAttributes.ModifyOrAdd(attribute.Key, attribute.Value * defaultLevelCount);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
2025-10-24 09:11:22 -04:00
|
|
|
|
Debug.LogError($"[CardUpgradeNode] Attempted to get upgrade attributes for a non-terminal node card {sourceCard.className}.");
|
2025-10-03 00:02:43 -04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return upgradeAttributes;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|