Exemplo 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());
        }
Exemplo n.º 2
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());
 }