コード例 #1
0
 public void SetSlot(ClientPlayer clientPlayer, ModuleMech mech, MechInfo mechInfo)
 {
     for (int i = 0; i < Slots.Length; i++)
     {
         if (Slots[i] != null)
         {
             Slots[i].Initialize(clientPlayer, mech, mechInfo.Slots[i]);
         }
     }
 }
コード例 #2
0
 public CardInfo_Mech(int cardID, BaseInfo baseInfo, UpgradeInfo upgradeInfo, LifeInfo lifeInfo, BattleInfo battleInfo, MechInfo mechInfo, SideEffectBundle sideEffectBundle, SideEffectBundle sideEffectBundle_BattleGroundAura)
     : base(cardID: cardID,
            upgradeInfo: upgradeInfo,
            baseInfo: baseInfo,
            sideEffectBundle: sideEffectBundle,
            sideEffectBundle_BattleGroundAura: sideEffectBundle_BattleGroundAura)
 {
     LifeInfo   = lifeInfo;
     BattleInfo = battleInfo;
     MechInfo   = mechInfo;
     Pro_Initialize();
 }
コード例 #3
0
ファイル: AllCards.cs プロジェクト: tuita520/Mech-Storm
    public static void AddAllCards()
    {
        Reset();
        SortedDictionary <string, string> cardNameKeyDict = new SortedDictionary <string, string>();

        foreach (int v in Enum.GetValues(typeof(LanguageShorts)))
        {
            string strName = Enum.GetName(typeof(LanguageShorts), v);
            cardNameKeyDict[strName] = "cardName_" + strName;
        }

        string text;

        using (StreamReader sr = new StreamReader(CardsXMLFile))
        {
            text = sr.ReadToEnd();
        }

        XmlDocument doc = new XmlDocument();

        doc.LoadXml(text);
        XmlElement node_AllCards = doc.DocumentElement;

        for (int i = 0; i < node_AllCards.ChildNodes.Count; i++)
        {
            XmlNode node_Card = node_AllCards.ChildNodes.Item(i);
            int     cardID    = int.Parse(node_Card.Attributes["id"].Value);
            CardDict.Add(cardID, new CardInfo_Base());
        }

        for (int i = 0; i < node_AllCards.ChildNodes.Count; i++)
        {
            XmlNode node_Card = node_AllCards.ChildNodes.Item(i);

            int cardID = int.Parse(node_Card.Attributes["id"].Value);

            BaseInfo    baseInfo    = new BaseInfo();
            UpgradeInfo upgradeInfo = new UpgradeInfo();
            LifeInfo    lifeInfo    = new LifeInfo();
            BattleInfo  battleInfo  = new BattleInfo();
            MechInfo    mechInfo    = new MechInfo();
            EquipInfo   equipInfo   = new EquipInfo();
            WeaponInfo  weaponInfo  = new WeaponInfo();
            ShieldInfo  shieldInfo  = new ShieldInfo();
            PackInfo    packInfo    = new PackInfo();
            MAInfo      maInfo      = new MAInfo();

            SideEffectBundle sideEffectBundle = new SideEffectBundle();
            SideEffectBundle sideEffectBundle_BattleGroundAura = new SideEffectBundle();

            for (int j = 0; j < node_Card.ChildNodes.Count; j++)
            {
                XmlNode node_CardInfo = node_Card.ChildNodes[j];
                switch (node_CardInfo.Attributes["name"].Value)
                {
                case "baseInfo":
                    SortedDictionary <string, string> cardNameDict = new SortedDictionary <string, string>();
                    foreach (KeyValuePair <string, string> kv in cardNameKeyDict)
                    {
                        string cardName = node_CardInfo.Attributes[kv.Value].Value;
                        cardNameDict[kv.Key] = cardName;
                    }

                    baseInfo = new BaseInfo(
                        pictureID: int.Parse(node_CardInfo.Attributes["pictureID"].Value),
                        cardNames: cardNameDict,
                        isTemp: node_CardInfo.Attributes["isTemp"].Value == "True",
                        isHide: node_CardInfo.Attributes["isHide"].Value == "True",
                        metal: int.Parse(node_CardInfo.Attributes["metal"].Value),
                        energy: int.Parse(node_CardInfo.Attributes["energy"].Value),
                        coin: int.Parse(node_CardInfo.Attributes["coin"].Value),
                        effectFactor: 1,
                        limitNum: int.Parse(node_CardInfo.Attributes["limitNum"].Value),
                        cardRareLevel: int.Parse(node_CardInfo.Attributes["cardRareLevel"].Value),
                        shopPrice: int.Parse(node_CardInfo.Attributes["shopPrice"].Value),
                        cardType: (CardTypes)Enum.Parse(typeof(CardTypes), node_CardInfo.Attributes["cardType"].Value));
                    break;

                case "upgradeInfo":
                    int u_id = int.Parse(node_CardInfo.Attributes["upgradeCardID"].Value);
                    int d_id = int.Parse(node_CardInfo.Attributes["degradeCardID"].Value);
                    upgradeInfo = new UpgradeInfo(
                        upgradeCardID: u_id,
                        degradeCardID: d_id,
                        cardLevel: 1,
                        cardLevelMax: 1);
                    break;

                case "lifeInfo":
                    lifeInfo = new LifeInfo(
                        life: int.Parse(node_CardInfo.Attributes["life"].Value),
                        totalLife: int.Parse(node_CardInfo.Attributes["totalLife"].Value));
                    break;

                case "battleInfo":
                    battleInfo = new BattleInfo(
                        basicAttack: int.Parse(node_CardInfo.Attributes["basicAttack"].Value),
                        basicArmor: int.Parse(node_CardInfo.Attributes["basicArmor"].Value),
                        basicShield: int.Parse(node_CardInfo.Attributes["basicShield"].Value));
                    break;

                case "mechInfo":
                    mechInfo = new MechInfo(
                        isSoldier: node_CardInfo.Attributes["isSoldier"].Value == "True",
                        isDefense: node_CardInfo.Attributes["isDefense"].Value == "True",
                        isSniper: node_CardInfo.Attributes["isSniper"].Value == "True",
                        isCharger: node_CardInfo.Attributes["isCharger"].Value == "True",
                        isFrenzy: node_CardInfo.Attributes["isFrenzy"].Value == "True",
                        isSentry: node_CardInfo.Attributes["isSentry"].Value == "True",
                        slot1: (SlotTypes)Enum.Parse(typeof(SlotTypes), node_CardInfo.Attributes["slot1"].Value),
                        slot2: (SlotTypes)Enum.Parse(typeof(SlotTypes), node_CardInfo.Attributes["slot2"].Value),
                        slot3: (SlotTypes)Enum.Parse(typeof(SlotTypes), node_CardInfo.Attributes["slot3"].Value),
                        slot4: (SlotTypes)Enum.Parse(typeof(SlotTypes), node_CardInfo.Attributes["slot4"].Value));
                    break;

                case "weaponInfo":
                    weaponInfo = new WeaponInfo(
                        energy: int.Parse(node_CardInfo.Attributes["energy"].Value),
                        energyMax: int.Parse(node_CardInfo.Attributes["energyMax"].Value),
                        attack: int.Parse(node_CardInfo.Attributes["attack"].Value),
                        weaponType: (WeaponTypes)Enum.Parse(typeof(WeaponTypes), node_CardInfo.Attributes["weaponType"].Value),
                        isSentry: node_CardInfo.Attributes["isSentry"].Value == "True",
                        isFrenzy: node_CardInfo.Attributes["isFrenzy"].Value == "True");
                    equipInfo = new EquipInfo(SlotTypes.Weapon);
                    break;

                case "shieldInfo":
                    shieldInfo = new ShieldInfo(
                        armor: int.Parse(node_CardInfo.Attributes["armor"].Value),
                        shield: int.Parse(node_CardInfo.Attributes["shield"].Value),
                        shieldType: (ShieldTypes)Enum.Parse(typeof(ShieldTypes), node_CardInfo.Attributes["shieldType"].Value),
                        isDefense: node_CardInfo.Attributes["isDefense"].Value == "True");
                    equipInfo = new EquipInfo(SlotTypes.Shield);
                    break;

                case "packInfo":
                    packInfo = new PackInfo(
                        isFrenzy: node_CardInfo.Attributes["isFrenzy"].Value == "True",
                        isDefense: node_CardInfo.Attributes["isDefense"].Value == "True",
                        isSniper: node_CardInfo.Attributes["isSniper"].Value == "True"
                        );
                    equipInfo = new EquipInfo(SlotTypes.Pack);
                    break;

                case "maInfo":
                    maInfo = new MAInfo(
                        isFrenzy: node_CardInfo.Attributes["isFrenzy"].Value == "True",
                        isDefense: node_CardInfo.Attributes["isDefense"].Value == "True",
                        isSniper: node_CardInfo.Attributes["isSniper"].Value == "True"
                        );
                    equipInfo = new EquipInfo(SlotTypes.MA);
                    break;

                case "sideEffectsBundle":
                {
                    ExtractSideEffectBundle(baseInfo.CardType, node_CardInfo, sideEffectBundle);
                    break;
                }

                case "sideEffectsBundle_Aura":
                {
                    ExtractSideEffectBundle(baseInfo.CardType, node_CardInfo, sideEffectBundle_BattleGroundAura);
                    break;
                }
                }
            }

            switch (baseInfo.CardType)
            {
            case CardTypes.Mech:
                addCard(new CardInfo_Mech(
                            cardID: cardID,
                            baseInfo: baseInfo,
                            upgradeInfo: upgradeInfo,
                            lifeInfo: lifeInfo,
                            battleInfo: battleInfo,
                            mechInfo: mechInfo,
                            sideEffectBundle: sideEffectBundle,
                            sideEffectBundle_BattleGroundAura: sideEffectBundle_BattleGroundAura));
                break;

            case CardTypes.Equip:
                addCard(new CardInfo_Equip(
                            cardID: cardID,
                            baseInfo: baseInfo,
                            upgradeInfo: upgradeInfo,
                            equipInfo: equipInfo,
                            weaponInfo: weaponInfo,
                            shieldInfo: shieldInfo,
                            packInfo: packInfo,
                            maInfo: maInfo,
                            sideEffectBundle: sideEffectBundle,
                            sideEffectBundle_BattleGroundAura: sideEffectBundle_BattleGroundAura));
                break;

            case CardTypes.Spell:
                addCard(new CardInfo_Spell(
                            cardID: cardID,
                            baseInfo: baseInfo,
                            upgradeInfo: upgradeInfo,
                            sideEffectBundle: sideEffectBundle,
                            sideEffectBundle_BattleGroundAura: sideEffectBundle_BattleGroundAura));
                break;

            case CardTypes.Energy:
                addCard(new CardInfo_Spell(
                            cardID: cardID,
                            baseInfo: baseInfo,
                            upgradeInfo: upgradeInfo,
                            sideEffectBundle: sideEffectBundle,
                            sideEffectBundle_BattleGroundAura: sideEffectBundle_BattleGroundAura));
                break;
            }
        }

        // Check all upgradeID and degradeID valid in library
        foreach (KeyValuePair <int, CardInfo_Base> kv in CardDict)
        {
            int uid = kv.Value.UpgradeInfo.UpgradeCardID;
            int did = kv.Value.UpgradeInfo.DegradeCardID;

            if (uid != -1)
            {
                if (!CardDict.ContainsKey(uid))
                {
                    kv.Value.UpgradeInfo.UpgradeCardID = -1;
                    NeedReload = true;
                }
            }

            if (did != -1)
            {
                if (!CardDict.ContainsKey(did))
                {
                    kv.Value.UpgradeInfo.DegradeCardID = -1;
                    NeedReload = true;
                }
            }
        }

        //TODO  Check all id in SE

        // Make all upgradeID and degradeID linked
        foreach (KeyValuePair <int, CardInfo_Base> kv in CardDict)
        {
            int uid = kv.Value.UpgradeInfo.UpgradeCardID;
            int did = kv.Value.UpgradeInfo.DegradeCardID;

            if (uid != -1)
            {
                CardInfo_Base uCard = CardDict[uid];
                if (uCard.UpgradeInfo.DegradeCardID != kv.Key)
                {
                    if (uCard.UpgradeInfo.DegradeCardID == -1)
                    {
                        uCard.UpgradeInfo.DegradeCardID = kv.Key;
                    }
                    else
                    {
                        CardInfo_Base uCard_ori_dCard = CardDict[uCard.UpgradeInfo.DegradeCardID];
                        if (uCard_ori_dCard.UpgradeInfo.UpgradeCardID == uCard.CardID)
                        {
                            kv.Value.UpgradeInfo.UpgradeCardID = -1;
                        }
                        else
                        {
                            uCard.UpgradeInfo.DegradeCardID = kv.Key;
                        }
                    }

                    NeedReload = true;
                }
            }

            if (did != -1)
            {
                CardInfo_Base dCard = CardDict[did];
                if (dCard.UpgradeInfo.UpgradeCardID != kv.Key)
                {
                    if (dCard.UpgradeInfo.UpgradeCardID == -1)
                    {
                        dCard.UpgradeInfo.UpgradeCardID = kv.Key;
                    }
                    else
                    {
                        CardInfo_Base dCard_ori_uCard = CardDict[dCard.UpgradeInfo.UpgradeCardID];
                        if (dCard_ori_uCard.UpgradeInfo.DegradeCardID == dCard.CardID)
                        {
                            kv.Value.UpgradeInfo.DegradeCardID = -1;
                        }
                        else
                        {
                            dCard.UpgradeInfo.UpgradeCardID = kv.Key;
                        }
                    }

                    NeedReload = true;
                }
            }
        }

        // Check Series valid, no cycle
        foreach (KeyValuePair <int, CardInfo_Base> kv in CardDict)
        {
            List <int> cardSeries   = GetCardSeries(kv.Key);
            int        cardLevelMax = cardSeries.Count;
            kv.Value.UpgradeInfo.CardLevelMax = cardLevelMax;
            int cardLevel = 0;
            foreach (int cardID in cardSeries)
            {
                cardLevel++;
                if (cardID == kv.Key)
                {
                    break;
                }
            }

            kv.Value.UpgradeInfo.CardLevel = cardLevel;
        }

        //If any problem, refresh XML and reload
        if (NeedReload)
        {
            NeedReload = false;
            RefreshAllCardXML();
            ReloadCardXML();
        }
    }