public virtual void Initiate(CardInfo_Base cardInfo, CardShowMode cardShowMode, ClientPlayer clientPlayer = null) { ClientPlayer = clientPlayer; CardInfo = cardInfo.Clone(); SetCardShowMode(cardShowMode); transform.rotation = Quaternion.Euler(0, 0, 0); transform.Rotate(Vector3.up, 180); Usable = false; if (DragComponent) { DragComponent.enabled = true; } BoxCollider.enabled = true; M_Metal = CardInfo.BaseInfo.Metal; M_Energy = CardInfo.BaseInfo.Energy; M_Coin = CardInfo.BaseInfo.Coin; string cur_Language = LanguageManager.Instance ? LanguageManager.Instance.GetCurrentLanguage() : "zh"; M_Name = CardInfo.BaseInfo.CardNames[cur_Language] + (CardInfo.BaseInfo.IsTemp ? "*" : ""); M_Desc = CardInfo.GetCardDescShow(); CardDescComponent.SetTempCard(false); ChangeCardPicture(CardInfo.BaseInfo.PictureID); CardDescComponent?.SetCardTypeText(CardInfo.GetCardTypeDesc()); SetBlockCountValue(0, true); SetBlockCountMaxValue(CardInfo.BaseInfo.LimitNum, true); SetBannerType(CardNoticeComponent.BannerTypes.None); SetArrowType(CardNoticeComponent.ArrowTypes.None); SetStarNumber(CardInfo.UpgradeInfo.CardLevel, CardInfo.UpgradeInfo.CardLevelMax); RefreshCardAllColors(); }
public static CardInfo_Base GetRandomCardInfoByLevelNum(int levelNum, HashSet <int> exceptCardIDs = null) { if (exceptCardIDs == null) { exceptCardIDs = new HashSet <int>(); } CardInfo_Base res = null; if (CardLevelDict.ContainsKey(levelNum)) { List <CardInfo_Base> levelCards = CloneVariantUtils.List(CardLevelDict[levelNum]); List <CardInfo_Base> removeLevelCards = new List <CardInfo_Base>(); foreach (CardInfo_Base cb in levelCards) { if (exceptCardIDs.Contains(cb.CardID)) { removeLevelCards.Add(cb); } } foreach (CardInfo_Base cb in removeLevelCards) { levelCards.Remove(cb); } if (levelCards.Count >= 1) { res = Utils.GetRandomFromList(levelCards, 1)[0]; } } return(res == null ? res : res.Clone()); }
public void Initiate(CardInfo_Base cardInfo, BattlePlayer battlePlayer) { BattlePlayer = battlePlayer; CardInfo = cardInfo.Clone(); Stars = CardInfo.UpgradeInfo.CardLevel; InitializeSideEffects(); Initiate(); isInitialized = true; BattlePlayer.GameManager.EventManager.RegisterEvent(CardInfo.SideEffectBundle); BattlePlayer.GameManager.EventManager.RegisterEvent(CardInfo.SideEffectBundle_BattleGroundAura); }
public virtual void Initiate(CardInfo_Base cardInfo, BattlePlayer battlePlayer, int cardInstanceId) { isInitialized = false; BattlePlayer = battlePlayer; CardInfo = cardInfo.Clone(); M_Metal = CardInfo.BaseInfo.Metal; M_Energy = CardInfo.BaseInfo.Energy; M_EffectFactor = CardInfo.BaseInfo.EffectFactor; M_CardInstanceId = cardInstanceId; Stars = CardInfo.UpgradeInfo.CardLevel; isInitialized = true; foreach (SideEffectExecute see in CardInfo.SideEffectBundle.SideEffectExecutes) { if (see.M_ExecuteSetting is ScriptExecuteSettingBase sesb) { sesb.Player = BattlePlayer; } see.M_ExecutorInfo = new ExecutorInfo(clientId: BattlePlayer.ClientId, sideEffectExecutorID: see.ID, cardId: CardInfo.CardID, cardInstanceId: M_CardInstanceId); foreach (SideEffectBase se in see.SideEffectBases) { se.Player = BattlePlayer; se.M_SideEffectExecute = see; if (se is AddPlayerBuff addPlayerBuff) { if (addPlayerBuff.AttachedBuffSEE.M_ExecuteSetting is ScriptExecuteSettingBase _sesb) { _sesb.Player = BattlePlayer; } foreach (SideEffectBase buff_se in addPlayerBuff.AttachedBuffSEE.SideEffectBases) { buff_se.Player = BattlePlayer; buff_se.M_SideEffectExecute = addPlayerBuff.AttachedBuffSEE; foreach (SideEffectBase sub_se in buff_se.Sub_SideEffect) { sub_se.Player = BattlePlayer; sub_se.M_SideEffectExecute = addPlayerBuff.AttachedBuffSEE; } } } } } BattlePlayer.GameManager.EventManager.RegisterEvent(CardInfo.SideEffectBundle); }
public static void RefreshCardXML(CardInfo_Base ci) { ci = ci.Clone(); if (CardDict.ContainsKey(ci.CardID)) { CardDict[ci.CardID] = ci; } else { CardDict.Add(ci.CardID, ci); } string text; using (StreamReader sr = new StreamReader(CardsXMLFile)) { text = sr.ReadToEnd(); } XmlDocument doc = new XmlDocument(); doc.LoadXml(text); XmlElement allCards = doc.DocumentElement; ci.ExportToXML(allCards); SortedDictionary <int, XmlElement> cardNodesDict = new SortedDictionary <int, XmlElement>(); foreach (XmlElement node in allCards.ChildNodes) { cardNodesDict.Add(int.Parse(node.Attributes["id"].Value), node); } allCards.RemoveAll(); foreach (KeyValuePair <int, XmlElement> kv in cardNodesDict) { allCards.AppendChild(kv.Value); } using (StreamWriter sw = new StreamWriter(CardsXMLFile)) { doc.Save(sw); } }