예제 #1
0
        public static int RandomInt(int min, int max, State2 state = null)
        {
            if (state == null && App.State != null)
            {
                state = App.State.Ext;
            }
            if (state == null)
            {
                return(UnityEngine.Random.Range(min, max));
            }
            if (state.RandomValues.Count == 0)
            {
                state.RandomizeNumbers();
            }
            while (state.RandomValues[0] > 1f)
            {
                state.RandomValues[0] = state.RandomValues[0] / 10f;
            }
            int num  = max - min;
            int num2 = (int)((float)num * state.RandomValues[0]);

            state.RandomValues.RemoveAt(0);
            state.RandomValues.Add(UnityEngine.Random.Range(0f, 0.9999f));
            return(num2 + min);
        }
예제 #2
0
        internal static State2 Deserialize(string base64String)
        {
            if (string.IsNullOrEmpty(base64String))
            {
                Log.Error("State2.FromString with empty value!");
                return(new State2());
            }
            string[] parts           = Conv.StringPartsFromBase64(base64String, "State2");
            State2   state           = new State2();
            string   stringFromParts = Conv.getStringFromParts(parts, "b");

            string[] array = stringFromParts.Split(new char[]
            {
                '&'
            });
            string[] array2 = array;
            for (int i = 0; i < array2.Length; i++)
            {
                string text = array2[i];
                if (!string.IsNullOrEmpty(text))
                {
                    state.AllPets.Add(Pet.Deserialize(text));
                }
            }
            Pet.CheckIfAllAdded(ref state.AllPets);
            state.PunyFood      = Conv.getCDoubleFromParts(parts, "c", false);
            state.StrongFood    = Conv.getCDoubleFromParts(parts, "d", false);
            state.MightyFood    = Conv.getCDoubleFromParts(parts, "e", false);
            state.PetIdInAvatar = Conv.getIntFromParts(parts, "f");
            stringFromParts     = Conv.getStringFromParts(parts, "g");
            array = stringFromParts.Split(new char[]
            {
                '&'
            });
            string[] array3 = array;
            for (int j = 0; j < array3.Length; j++)
            {
                string value = array3[j];
                if (!string.IsNullOrEmpty(value))
                {
                    state.RandomValues.Add(Conv.StringToFloat(value));
                }
            }
            if (state.RandomValues == null || state.RandomValues.Count == 0)
            {
                state.RandomizeNumbers();
            }
            state.CurrentRandomNumber = Conv.getIntFromParts(parts, "h");
            state.FacebookClicked     = Conv.getStringFromParts(parts, "i").ToLower().Equals("true");
            state.TwitterClicked      = Conv.getStringFromParts(parts, "j").ToLower().Equals("true");
            state.Lucky = LuckyDraw.Deserialize(Conv.getStringFromParts(parts, "k"));
            state.ImportedSaveFromKongToSteam = Conv.getStringFromParts(parts, "l").ToLower().Equals("true");
            state.SteamCurrency   = (Currency)Conv.getIntFromParts(parts, "m");
            state.SteamCountry    = Conv.getStringFromParts(parts, "n");
            state.KongConvertId   = Conv.getIntFromParts(parts, "o");
            state.TimeSinceSteam  = Conv.getLongFromParts(parts, "p");
            state.AdPoints        = Conv.getCDoubleFromParts(parts, "q", false);
            state.AdsWatched      = Conv.getIntFromParts(parts, "r");
            state.TotalAdsWatched = Conv.getIntFromParts(parts, "s");
            state.AfkGame         = AfkyGame.FromString(Conv.getStringFromParts(parts, "t"));
            state.RateDialogShown = Conv.getStringFromParts(parts, "u").ToLower().Equals("true");
            state.Chocolate       = Conv.getCDoubleFromParts(parts, "v", false);
            state.Factory         = CrystalFactory.Deserialize(Conv.getStringFromParts(parts, "w"));
            stringFromParts       = Conv.getStringFromParts(parts, "x");
            array = stringFromParts.Split(new char[]
            {
                '&'
            });
            string[] array4 = array;
            for (int k = 0; k < array4.Length; k++)
            {
                string text2 = array4[k];
                if (!string.IsNullOrEmpty(text2))
                {
                    state.AllCampaigns.Add(PetCampaign.Deserialize(text2));
                }
            }
            if (state.AllCampaigns.Count == 0)
            {
                state.AllCampaigns = PetCampaign.Initial;
            }
            state.PetStones      = Conv.getCDoubleFromParts(parts, "y", false);
            state.PetStonesSpent = Conv.getCDoubleFromParts(parts, "z", false);
            if (state.RandomValues == null || state.RandomValues.Count == 0)
            {
                state.RandomizeNumbers();
            }
            if (state.TimeSinceSteam < 5184000000L)
            {
                state.TimeSinceSteam = 5184000000L;
            }
            state.PetPowerMultiGods      = Conv.getCDoubleFromParts(parts, "A", false);
            state.PetPowerMultiCampaigns = Conv.getCDoubleFromParts(parts, "B", false);
            return(state);
        }