Ejemplo n.º 1
0
 public static void SetResources(uint hearts = 0, uint coins = 0, uint jewels = 0, int[] items = null, int[] enhancements = null)
 {
     if (items == null)
     {
         items = new int[ShuffleItems.ILength];
     }
     if (enhancements == null)
     {
         enhancements = new int[ShuffleItems.ELength];
     }
     Array.Copy(BitConverter.GetBytes((BitConverter.ToUInt32(savedata, Coins.Ofset()) & 0xF0000007) | (Math.Min(0x1FFFF, coins) << Coins.Shift()) | (Math.Min(0xFF, jewels) << Jewels.Shift())), 0, savedata, Coins.Ofset(), 4);
     Array.Copy(BitConverter.GetBytes((BitConverter.ToUInt16(savedata, Hearts.Ofset()) & (uint)0xC07F) | (Math.Min(0x7F, hearts) << Hearts.Shift())), 0, savedata, Hearts.Ofset(), 2);
     for (int i = 0; i < ShuffleItems.ILength; i++) //Items (battle)
     {
         ushort val = BitConverter.ToUInt16(savedata, Items.Ofset(i));
         val &= 0x7F;
         val |= (ushort)(Math.Min(0x7F, items[i]) << Items.Shift());
         Array.Copy(BitConverter.GetBytes(val), 0, savedata, Items.Ofset(i), 2);
     }
     for (int i = 0; i < ShuffleItems.ELength; i++) //Enhancements (pokemon)
     {
         savedata[Enhancements.Ofset(i)] = (byte)(((Math.Min(0x7F, enhancements[i]) << Enhancements.Shift()) & 0xFE) | (savedata[Enhancements.Ofset(i)] & Enhancements.Shift()));
     }
 }