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