Exemplo n.º 1
0
        private EncounterArea2(byte[] data, GameVersion game) : base(game)
        {
            Location = data[0];
            Time     = (EncounterTime)data[1];
            var type = Type = (SlotType)data[2];
            var rate = data[3];

            if (type > SlotType.Surf) // Not Grass/Surf
            {
                const int size  = 5;
                int       count = (data.Length - 4) / size;

                var rates = new byte[count];
                for (int i = 0; i < rates.Length; i++)
                {
                    rates[i] = data[4 + i];
                }

                Rates = rates;
                Slots = ReadSlots(data, count, 4 + count);
            }
            else
            {
                Rate = rate;

                const int size  = 4;
                int       count = (data.Length - 4) / size;
                Rates = type == SlotType.BugContest ? BCC_SlotRates : (type == SlotType.Grass) ? RatesGrass : RatesSurf;
                Slots = ReadSlots(data, count, 4);
            }
        }
Exemplo n.º 2
0
        internal static int RandomValidTime(this EncounterTime t1)
        {
            int val = Util.Rand.Next(1, 4);

            if (t1 == EncounterTime.Any)
            {
                return(val);
            }
            while (!t1.Contains(val))
            {
                val = Util.Rand.Next(1, 4);
            }
            return(val);
        }
Exemplo n.º 3
0
        private static bool Contains(this EncounterTime t1, EncounterTime t2)
        {
            if (t1 == t2 || t1 == EncounterTime.Any || t2 == EncounterTime.Any)
            {
                return(true);
            }

            if (t1 == EncounterTime.MorningDay)
            {
                return(t2 == EncounterTime.Morning || t2 == EncounterTime.Day);
            }

            if (t2 == EncounterTime.MorningDay)
            {
                return(t1 == EncounterTime.Morning || t1 == EncounterTime.Day);
            }

            return(false);
        }
Exemplo n.º 4
0
        //---------------------------------------------------------------------
        //  Ctor
        //---------------------------------------------------------------------
        public RandomEncounter(
            XmlNode node,
            string facet,
            string regionType,
            string regionName,
            string probability,
            string shortest,
            string farthest,
            string landType,
            string time,
            string level,
            string levelType,
            string scaleUp
            )
        {
            m_XmlNode    = node;
            m_Facet      = facet;
            m_RegionType = regionType;
            m_RegionName = regionName;

            if (probability == "*")
            {
                m_Probability = -1;
                m_Inclusive   = true;
            }

            else
            {
                m_Probability = float.Parse(probability, RandomEncounterEngine.Language);
                m_Inclusive   = false;
            }

            m_Shortest      = int.Parse(shortest);
            m_Farthest      = int.Parse(farthest);
            m_LandType      = (LandType)Enum.Parse(typeof(LandType), landType);
            m_EncounterTime = (EncounterTime)Enum.Parse(typeof(EncounterTime), time);
            m_Level         = double.Parse(level);
            m_LevelType     = (LevelType)Enum.Parse(typeof(LevelType), levelType);
            m_ScaleUp       = bool.Parse(scaleUp);
            m_Elements      = new ArrayList();
        }
Exemplo n.º 5
0
        private static byte[] WriteTableOfTime(EncounterArea2 area, EncounterTime t)
        {
            using var ms = new MemoryStream();
            using var bw = new BinaryWriter(ms);

            var slots = area.Slots.Cast <EncounterSlot2>()
                        .Where(z => z.Time == EncounterTime.Any || z.Time == t).ToArray();

            bw.Write((byte)area.Location);
            bw.Write((byte)t);

            bw.Write((byte)area.Type);
            bw.Write((byte)0xFF);

            foreach (byte b in area.Rates)
            {
                bw.Write(b);
            }
            foreach (var s in slots)
            {
                WriteSlot(bw, s);
            }
            return(ms.ToArray());
        }
Exemplo n.º 6
0
        //--------------------------------------------------------------------- 
        //  Ctor
        //--------------------------------------------------------------------- 
        public RandomEncounter( 
            XmlNode node, 
            string facet, 
            string regionType, 
            string regionName, 
            string probability, 
            string shortest, 
            string farthest, 
            string landType,
            string time,
            string level,
            string levelType,
            string scaleUp
            )
        {
            m_XmlNode       = node;
            m_Facet         = facet;
            m_RegionType    = regionType;
            m_RegionName    = regionName;

            if( probability=="*" )
            { 
                m_Probability = -1; 
                m_Inclusive = true;
            }

            else
            { 
                m_Probability   = float.Parse( probability, RandomEncounterEngine.Language );
                m_Inclusive = false;
            }

            m_Shortest      = int.Parse( shortest );
            m_Farthest      = int.Parse( farthest );
            m_LandType      = (LandType) Enum.Parse( typeof( LandType ), landType );
            m_EncounterTime = (EncounterTime) Enum.Parse( typeof( EncounterTime ), time );
            m_Level         = double.Parse( level );
            m_LevelType     = (LevelType) Enum.Parse( typeof( LevelType ), levelType );
            m_ScaleUp       = bool.Parse( scaleUp );
            m_Elements      = new ArrayList();
        }
Exemplo n.º 7
0
 internal static bool Contains(this EncounterTime t1, int t2) => t1 == EncounterTime.Any || t1.HasFlag((EncounterTime)(1 << t2));
Exemplo n.º 8
0
 internal static bool Contains(this EncounterTime t1, int t2) => t1 == EncounterTime.Any || (t1 & (EncounterTime)(1 << t2)) != 0;
Exemplo n.º 9
0
 public static bool Contains(this EncounterTime t1, int t2) => t1.Contains((EncounterTime)t2);