Esempio n. 1
0
        /// <summary>
        /// Gets the encounter areas with <see cref="EncounterSlot"/> information from Generation 1 Grass/Water data.
        /// </summary>
        /// <param name="data">Input raw data.</param>
        /// <returns>Array of encounter areas.</returns>
        public static EncounterArea1[] GetArray1GrassWater(byte[] data)
        {
            // RBY Format
            var ptr   = new int[255];
            int count = 0;

            for (int i = 0; i < ptr.Length; i++)
            {
                ptr[i] = BitConverter.ToInt16(data, i * 2);
                if (ptr[i] != -1)
                {
                    continue;
                }

                count = i;
                break;
            }

            EncounterArea1[] areas = new EncounterArea1[count];
            for (int i = 0; i < areas.Length; i++)
            {
                var grass = GetSlots1GrassWater(data, ref ptr[i], SlotType.Grass);
                var water = GetSlots1GrassWater(data, ref ptr[i], SlotType.Surf);
                areas[i] = new EncounterArea1
                {
                    Location = i,
                    Slots    = grass.Concat(water).ToArray()
                };
            }
            return(areas.Where(area => area.Slots.Length != 0).ToArray());
        }
Esempio n. 2
0
        private static EncounterArea1[] GetAreas()
        {
            var red_gw   = EncounterArea1.GetArray1GrassWater(Util.GetBinaryResource("encounter_red.pkl"));
            var blu_gw   = EncounterArea1.GetArray1GrassWater(Util.GetBinaryResource("encounter_blue.pkl"));
            var ylw_gw   = EncounterArea1.GetArray1GrassWater(Util.GetBinaryResource("encounter_yellow.pkl"));
            var rb_fish  = EncounterArea1.GetArray1Fishing(Util.GetBinaryResource("encounter_rb_f.pkl"));
            var ylw_fish = EncounterArea1.GetArray1FishingYellow(Util.GetBinaryResource("encounter_yellow_f.pkl"));

            MarkEncountersVersion(red_gw, GameVersion.RD);
            MarkEncountersVersion(blu_gw, GameVersion.BU);
            MarkEncountersVersion(ylw_gw, GameVersion.YW);
            MarkEncountersVersion(rb_fish, GameVersion.RB);
            MarkEncountersVersion(ylw_fish, GameVersion.YW);

            var table = AddExtraTableSlots(red_gw, blu_gw, ylw_gw, rb_fish, ylw_fish);

            Array.Resize(ref table, table.Length + 1);
            table[table.Length - 1] = FishOldGood_RBY;

            foreach (var arr in table)
            {
                foreach (var slot in arr.Slots)
                {
                    slot.Area = arr;
                }
            }

            return(table);
        }
Esempio n. 3
0
        /// <summary>
        /// Gets the encounter areas with <see cref="EncounterSlot"/> information from Generation 1 Fishing data.
        /// </summary>
        /// <param name="data">Input raw data.</param>
        /// <returns>Array of encounter areas.</returns>
        public static EncounterArea1[] GetArray1Fishing(byte[] data)
        {
            var ptr   = new int[255];
            var map   = new int[255];
            int count = 0;

            for (int i = 0; i < ptr.Length; i++)
            {
                map[i] = data[(i * 3) + 0];
                if (map[i] == 0xFF)
                {
                    count = i;
                    break;
                }
                ptr[i] = BitConverter.ToInt16(data, (i * 3) + 1);
            }

            EncounterArea1[] areas = new EncounterArea1[count];
            for (int i = 0; i < areas.Length; i++)
            {
                areas[i] = new EncounterArea1
                {
                    Location = map[i],
                    Slots    = GetSlots1Fishing(data, ref ptr[i])
                };
            }
            return(areas);
        }
Esempio n. 4
0
        public static EncounterArea1[] GetAreas(byte[][] input, GameVersion game)
        {
            var result = new EncounterArea1[input.Length];

            for (int i = 0; i < input.Length; i++)
            {
                result[i] = new EncounterArea1(input[i], game);
            }
            return(result);
        }
Esempio n. 5
0
 /// <summary>
 /// Gets the encounter areas with <see cref="EncounterSlot"/> information from Generation 1 Fishing data.
 /// </summary>
 /// <param name="data">Input raw data.</param>
 /// <param name="count">Count of areas in the binary.</param>
 /// <returns>Array of encounter areas.</returns>
 public static EncounterArea1[] GetArray1Fishing(byte[] data, int count)
 {
     EncounterArea1[] areas = new EncounterArea1[count];
     for (int i = 0; i < areas.Length; i++)
     {
         int loc = data[(i * 3) + 0];
         int ptr = BitConverter.ToInt16(data, (i * 3) + 1);
         areas[i] = new EncounterArea1
         {
             Location = loc,
             Slots    = GetSlots1Fishing(data, ptr)
         };
     }
     return(areas);
 }
Esempio n. 6
0
 /// <summary>
 /// Gets the encounter areas with <see cref="EncounterSlot"/> information from Generation 1 Grass/Water data.
 /// </summary>
 /// <param name="data">Input raw data.</param>
 /// <param name="count">Count of areas in the binary.</param>
 /// <returns>Array of encounter areas.</returns>
 public static EncounterArea1[] GetArray1GrassWater(byte[] data, int count)
 {
     EncounterArea1[] areas = new EncounterArea1[count];
     for (int i = 0; i < areas.Length; i++)
     {
         int ptr   = BitConverter.ToInt16(data, i * 2);
         var grass = GetSlots1GrassWater(data, ref ptr, SlotType.Grass);
         var water = GetSlots1GrassWater(data, ref ptr, SlotType.Surf);
         areas[i] = new EncounterArea1
         {
             Location = i,
             Slots    = ArrayUtil.ConcatAll(grass, water),
         };
     }
     return(areas.Where(area => area.Slots.Length != 0).ToArray());
 }
Esempio n. 7
0
        /// <summary>
        /// Gets the encounter areas with <see cref="EncounterSlot"/> information from Pokémon Yellow (Generation 1) Fishing data.
        /// </summary>
        /// <param name="data">Input raw data.</param>
        /// <returns>Array of encounter areas.</returns>
        public static EncounterArea1[] GetArray1FishingYellow(byte[] data)
        {
            const int size  = 9;
            int       count = data.Length / size;

            EncounterArea1[] areas = new EncounterArea1[count];
            for (int i = 0; i < count; i++)
            {
                int ofs = (i * size) + 1;
                areas[i] = new EncounterArea1
                {
                    Location = data[(i * size) + 0],
                    Slots    = ReadSlots1FishingYellow(data, ref ofs, 4, SlotType.Super_Rod, -1)
                };
            }
            return(areas);
        }
Esempio n. 8
0
 private static EncounterArea1[] Get(string name, string ident, GameVersion game) =>
 EncounterArea1.GetAreas(BinLinker.Unpack(Util.GetBinaryResource($"encounter_{name}.pkl"), ident), game);