예제 #1
0
        private static void LoadCardNamesAndDescriptions(Localized_Text.Language language, IList <Card_Info> cards,
                                                         IReadOnlyDictionary <Localized_Text.Language, byte[]> indxByLanguage,
                                                         IReadOnlyDictionary <Localized_Text.Language, byte[]> namesByLanguage,
                                                         IReadOnlyDictionary <Localized_Text.Language, byte[]> descriptionsByLanguage)
        {
            if (language == Localized_Text.Language.Unknown)
            {
                return;
            }

            var indx         = indxByLanguage[language];
            var names        = namesByLanguage[language];
            var descriptions = descriptionsByLanguage[language];

            using (var indxReader = new BinaryReader(new MemoryStream(indx)))
                using (var namesReader = new BinaryReader(new MemoryStream(names)))
                    using (var descriptionsReader = new BinaryReader(new MemoryStream(descriptions)))
                    {
                        var namesByOffset        = ReadStrings(namesReader);
                        var descriptionsByOffset = ReadStrings(descriptionsReader);

                        var index = 0;
                        while (true)
                        {
                            var nameOffset        = indxReader.ReadUInt32();
                            var descriptionOffset = indxReader.ReadUInt32();

                            if (indxReader.BaseStream.Position >= indxReader.BaseStream.Length)
                            {
                                break;
                            }

                            Card_Info card = null;
                            if (cards.Count > index)
                            {
                                card = cards[index];
                            }
                            else
                            {
                                cards.Add(card = new Card_Info(index));
                            }

                            card.Name.SetText(language, namesByOffset[nameOffset]);
                            card.Description.SetText(language, descriptionsByOffset[descriptionOffset]);

                            index++;
                        }
                    }
        }
예제 #2
0
        private static void LoadCardProp(Card_Info card, IDictionary <short, Card_Info> CardsById, uint A1, uint A2)
        {
            var First = (A1 << 18) | (((A1 & 0x7FC000) | (A1 >> 18)) >> 5);

            var Second = (((A2 & 1u) | (A2 << 21)) & 0x80000001) |
                         (((A2 & 0x7800) | (((A2 & 0x780) | ((A2 & 0x7E) << 10)) << 8)) << 6) |
                         (((A2 & 0x38000) |
                           (((A2 & 0x7C0000) | (((A2 & 0x7800000) | ((A2 >> 8) & 0x780000)) >> 9)) >> 8)) >> 1);

            var CardId         = (short)((First >> 18) & 0x3FFF);
            var Atk            = (First >> 9) & 0x1FF;
            var Def            = First & 0x1FF;
            var CardType       = (CardType)((Second >> 25) & 0x3F);
            var Attribute      = (CardAttribute)((Second >> 21) & 0xF);
            var Level          = (Second >> 17) & 0xF;
            var SpellType      = (SpellType)((Second >> 14) & 7);
            var MonsterType    = (MonsterType)((Second >> 9) & 0x1F);
            var PendulumScale1 = (Second >> 1) & 0xF;
            var PendulumScale2 = (Second >> 5) & 0xF;

            card.CardId         = CardId;
            card.Atk            = (int)(Atk * 10);
            card.Def            = (int)(Def * 10);
            card.Level          = (byte)Level;
            card.Attribute      = Attribute;
            card.CardType       = CardType;
            card.SpellType      = SpellType;
            card.MonsterType    = MonsterType;
            card.PendulumScale1 = (byte)PendulumScale1;
            card.PendulumScale2 = (byte)PendulumScale2;

            CardsById.Add(CardId, card);

            Debug.Assert(CardId < Constants.MaxCardId + 1);

            if (!Enum.IsDefined(typeof(MonsterType), MonsterType) || !Enum.IsDefined(typeof(SpellType), SpellType) ||
                !Enum.IsDefined(typeof(CardType), CardType) || !Enum.IsDefined(typeof(CardAttribute), Attribute))
            {
                Debug.Assert(false);
            }
        }