コード例 #1
0
        public byte[] GetBytes(bool bigEndian)
        {
            byte[] o = new byte[0x180];
            using (DataWriter writer = new DataWriter())
            {
                writer.BigEndian = bigEndian;

                writer.WriteInt((TrainerID) | ((IsUsed ? 0x0100 : 0) << 16));

                if (TrainerName == "")
                {
                    writer.WriteInt(0x50000000);
                    writer.WriteInt(0);
                    writer.WriteInt(0);
                }
                else
                {
                    var en = GBStringEncoding.EncodeString(TrainerName);
                    writer.WriteInt(en[0]);
                    writer.WriteInt(en[1]);
                    writer.WriteInt(en[2]);
                }

                for (int i = 0; i < Pokemon.Length; i++)
                {
                    writer.Write(Pokemon[i].GetBytes(bigEndian));
                }

                writer.WriteInt(0x00005033);

                var sum = writer.CheckSum(0, 0x180 - 4) + 0x76 + 0x30;

                writer.WriteInt((0x7630 << 16) | (ushort)sum);

                o = writer.GetData();
            }

            return(o);
        }