Beispiel #1
0
 public void UpdateCredentials(string consumerKey, string consumerSecret, string accessToken, string accessTokenSecret)
 {
     Storage.SetValue(TwitterNewsSharerSettingsPage.TwitterConsumerKeyKey, consumerKey);
     Storage.SetValue(TwitterNewsSharerSettingsPage.TwitterConsumerSecretKey, consumerSecret);
     Storage.SetValue(TwitterNewsSharerSettingsPage.TwitterAccessTokenKey, accessToken);
     Storage.SetValue(TwitterNewsSharerSettingsPage.TwitterAccessTokenSecretKey, accessTokenSecret);
 }
        /**
         * Sets the balance of the given virtual item to be the given balance, and if notify is true
         * posts the change in the balance to the event bus.
         *
         * @param item the required virtual item
         * @param balance the new balance to be set
         * @param notify if notify is true post balance change event
         * @return the balance of the required virtual item
         */
        public int setBalance(VirtualItem item, int balance, bool notify)
        {
            SoomlaUtils.LogDebug(mTag, "setting balance " + balance + " to " + item.getName() + ".");

            int oldBalance = getBalance(item);

            if (oldBalance == balance)
            {
                return(balance);
            }

            String itemId = item.getItemId();

            String balanceStr = balance.ToString();
            String key        = keyBalance(itemId);

            KeyValueStorage.SetValue(key, balanceStr);

            if (notify)
            {
                postBalanceChangeEvent(item, balance, 0);
            }

            return(balance);
        }
        /// <summary>
        /// Sets the fastest (given) duration for the given <c>Level</c>.
        /// </summary>
        /// <param name="level"><c>Level</c> to set fastest duration.</param>
        /// <param name="duration">Duration to set.</param>
        protected virtual void _setFastestDurationMillis(Level level, long duration)
        {
            string key = keyFastestDuration(level.ID);
            string val = duration.ToString();

            KeyValueStorage.SetValue(key, val);
        }
        /** Unity-Editor Functions **/

        /// <summary>
        /// Increases the number of times the given <c>Mission</c> has been
        /// completed if the given <c>up</c> is <c>true</c>; otherwise decreases
        /// the number of times completed.
        /// </summary>
        /// <param name="mission"><c>Mission</c> to set as completed.</param>
        /// <param name="up">If set to <c>true</c> add 1 to the number of times
        /// completed, otherwise subtract 1.</param>
        /// <param name="notify">If set to <c>true</c> trigger the relevant
        /// event according to the value of <c>up</c>.</param>


        protected virtual void _setCompleted(Mission mission, bool up, bool notify)
        {
            int total = _getTimesCompleted(mission) + (up ? 1 : -1);

            if (total < 0)
            {
                total = 0;
            }

            string key = keyMissionTimesCompleted(mission.ID);

            KeyValueStorage.SetValue(key, total.ToString());

            if (notify)
            {
                if (up)
                {
                    LevelUpEvents.OnMissionCompleted(mission);
                }
                else
                {
                    LevelUpEvents.OnMissionCompletionRevoked(mission);
                }
            }
        }
Beispiel #5
0
        /** Protected Functions **/
        /** These protected virtual functions will only run when in editor **/

        virtual protected void _setStoreAssets(IStoreAssets storeAssets)
        {
#if UNITY_EDITOR
            string storeJSON = IStoreAssetsToJSON(storeAssets);

            KeyValueStorage.SetValue(keyMetaStoreInfo(), storeJSON);
#endif
        }
 /// <summary>
 /// Saves the orientation preference.
 ///     Orientation values (same as ScreenOrientation enum):
 ///         0       Unknown
 ///         1       Portrait
 ///         2       Portrait upside-down
 ///         3       Landscape left
 ///         4       Landscape right
 ///         5       Auto rotation
 /// </summary>
 private void SaveOrientationPref(int orientationIndex)
 {
     if (orientationIndex == (int)ScreenOrientation.Unknown)
     {
         return;
     }
     KeyValueStorage.SetValue(ORIENTATION_PREF_KEY, orientationIndex.ToString());
 }
Beispiel #7
0
        /** Unity-Editor Functions **/

        /// <summary>
        /// Sets the given <c>Score</c> to the given value.
        /// </summary>
        /// <param name="score"><c>Score</c> to set.</param>
        /// <param name="latest">The value to set for the <c>Score</c>.</param>
        protected virtual void _setLatestScore(Score score, double latest)
        {
            string key = keyLatestScore(score.ID);
            string val = latest.ToString();

            KeyValueStorage.SetValue(key, val);

            LevelUpEvents.OnLatestScoreChanged(score);
        }
Beispiel #8
0
        /// <summary>
        /// Sets the given record for the given <c>Score</c>.
        /// </summary>
        /// <param name="score"><c>Score</c> whose record is to change.</param>
        /// <param name="record">The new record.</param>
        protected virtual void _setRecordScore(Score score, double record)
        {
            string key = keyRecordScore(score.ID);
            string val = record.ToString();

            KeyValueStorage.SetValue(key, val);

            LevelUpEvents.OnScoreRecordChanged(score);
        }
Beispiel #9
0
        /**
         * Saves the store's metadata in the database as JSON.
         */
        public static void save()
        {
            String store_json = toJSONObject().ToString();

            SoomlaUtils.LogDebug(TAG, "saving StoreInfo to DB. json is: " + store_json);
            String key = keyMetaStoreInfo();

            KeyValueStorage.SetValue(key, store_json);
        }
Beispiel #10
0
        static void save()
        {
            string lu_json = toJSONObject().print();

            SoomlaUtils.LogDebug(TAG, "saving SoomlaLevelUp to DB. json is: " + lu_json);
            string key = DB_KEY_PREFIX + "model";

            KeyValueStorage.SetValue(key, lu_json);
        }
Beispiel #11
0
        /// <summary>
        /// Saves the store's metadata in the database as JSON.
        /// </summary>
        public static void Save()
        {
            string store_json = toJSONObject().print();

            SoomlaUtils.LogDebug(TAG, "saving StoreInfo to DB. json is: " + store_json);
            string key = keyMetaStoreInfo();

            KeyValueStorage.SetValue(key, store_json);

            instance.loadNativeFromDB();
        }
        /// <summary>   Adds the given non-consumable item to the storage. </summary>
        ///
        /// <param name="nonConsumableItem">    The non consumable item. </param>
        ///
        /// <returns>   true if it succeeds, false if it fails. </returns>
        public bool add(NonConsumableItem nonConsumableItem)
        {
            SoomlaUtils.LogDebug(TAG, "Adding " + nonConsumableItem.getItemId());

            String itemId = nonConsumableItem.getItemId();
            String key    = keyNonConsExists(itemId);

            KeyValueStorage.SetValue(key, "");

            return(true);
        }
        private static void setLoggedInForProvider(Provider provider, bool value)
        {
            string key = getLoggedInStorageKeyForProvider(provider);

            if (value)
            {
                KeyValueStorage.SetValue(key, "true");
            }
            else
            {
                KeyValueStorage.DeleteKeyValue(key);
            }
        }
        /// <summary>
        /// Decreases by 1 the number of times the given <c>Level</c> has been played.
        /// </summary>
        /// <returns>The number of times played after decreasing.</returns>
        /// <param name="level"><c>Level</c> to decrease its times played.</param>
        protected virtual int _decTimesCompleted(Level level)
        {
            int completed = _getTimesCompleted(level);

            if (completed <= 0)               /* can't be negative or zero */
            {
                return(0);
            }
            string completedStr = (completed - 1).ToString();
            string key          = keyTimesCompleted(level.ID);

            KeyValueStorage.SetValue(key, completedStr);

            return(completed - 1);
        }
Beispiel #15
0
        /// <summary>
        /// Assigns the reward with the given reward ID to the given <c>World</c>.
        /// </summary>
        /// <param name="world"><c>World</c> to assign a reward to.</param>
        /// <param name="rewardId">ID of reward to assign.</param>
        protected virtual void _setReward(World world, string rewardId)
        {
            string key = keyReward(world.ID);

            if (!string.IsNullOrEmpty(rewardId))
            {
                KeyValueStorage.SetValue(key, rewardId);
            }
            else
            {
                KeyValueStorage.DeleteKeyValue(key);
            }

            // Notify world was assigned a reward
            LevelUpEvents.OnWorldAssignedReward(world);
        }
Beispiel #16
0
        protected virtual void _setLastCompletedInnerWorld(World world, string innerWorldId)
        {
            string key = keyLastCompletedInnerWorld(world.ID);

            if (!string.IsNullOrEmpty(innerWorldId))
            {
                KeyValueStorage.SetValue(key, innerWorldId);
            }
            else
            {
                KeyValueStorage.DeleteKeyValue(key);
            }

            // Notify world had inner level complete
            LevelUpEvents.OnLastCompletedInnerWorldChanged(world, innerWorldId);
        }
Beispiel #17
0
        /// <summary>
        /// Sets the given <c>World</c> as completed if <c>completed</c> is <c>true</c>.
        /// </summary>
        /// <param name="world"><c>World</c> to set as completed.</param>
        /// <param name="completed">If set to <c>true</c> the <c>World</c> will be set
        /// as completed.</param>
        /// <param name="notify">If set to <c>true</c> trigger events.</param>
        protected virtual void _setCompleted(World world, bool completed, bool notify)
        {
            string key = keyWorldCompleted(world.ID);

            if (completed)
            {
                KeyValueStorage.SetValue(key, "yes");

                if (notify)
                {
                    LevelUpEvents.OnWorldCompleted(world);
                }
            }
            else
            {
                KeyValueStorage.DeleteKeyValue(key);
            }
        }
        /// <summary>
        /// Increases by 1 the number of times the given <c>Level</c> has been played.
        /// </summary>
        /// <returns>The number of times played after increasing.</returns>
        /// <param name="level"><c>Level</c> to increase its times played.</param>
        protected virtual int _incTimesPlayed(Level level)
        {
            int played = _getTimesPlayed(level);

            if (played < 0)               /* can't be negative */
            {
                played = 0;
            }
            string playedStr = (played + 1).ToString();
            string key       = keyTimesPlayed(level.ID);

            KeyValueStorage.SetValue(key, playedStr);

            // Notify level has ended
            LevelUpEvents.OnLevelEnded(level);

            return(played + 1);
        }
        /// <summary>
        /// Increases by 1 the number of times the given <c>Level</c> has been started.
        /// </summary>
        /// <returns>The number of times started after increasing.</returns>
        /// <param name="level"><c>Level</c> to increase its times started.</param>
        protected virtual int _incTimesStarted(Level level)
        {
            int started = _getTimesStarted(level);

            if (started < 0)               /* can't be negative */
            {
                started = 0;
            }
            string startedStr = (started + 1).ToString();
            string key        = keyTimesStarted(level.ID);

            KeyValueStorage.SetValue(key, startedStr);

            // Notify level has started
            LevelUpEvents.OnLevelStarted(level);

            return(started + 1);
        }
Beispiel #20
0
        public virtual void Save()
        {
            // Save to SettingsMappings

            foreach (SettingsMapping mapping in SettingsMappings)
            {
                if (!mapping.IsValid)
                {
                    MessageBox.Show($"\"{mapping.Serialize()}\" is invalid input:"
                                    + Environment.NewLine + mapping.ErrorMessage);
                    return;
                }
            }

            foreach (SettingsMapping mapping in SettingsMappings)
            {
                KeyValueStorage.SetValue(mapping.StorageKey, mapping.Serialize());
            }
        }
        /** Unity-Editor Functions **/

        /// <summary>
        /// Sets the given <c>Gate</c> as open if <c>open</c> is <c>true.</c>
        /// Otherwise sets as closed.
        /// </summary>
        /// <param name="gate">The <c>Gate</c> to open/close.</param>
        /// <param name="open">If set to <c>true</c> set the <c>Gate</c> to open;
        /// <param name="notify">If set to <c>true</c> trigger event.</param>
        protected virtual void _setOpen(Gate gate, bool open, bool notify)
        {
            string key = keyGateOpen(gate.ID);

            if (open)
            {
                KeyValueStorage.SetValue(key, "yes");


                if (notify)
                {
                    LevelUpEvents.OnGateOpened(gate);
                }
            }
            else
            {
                KeyValueStorage.DeleteKeyValue(key);
            }
        }
Beispiel #22
0
        /**
         * Assigns a specific upgrade to the given virtual good.
         *
         * @param good the VirtualGood to upgrade
         * @param upgradeVG the upgrade to assign
         * @param notify if true post event to bus
         */
        public void assignCurrentUpgrade(VirtualGood good, UpgradeVG upgradeVG, bool notify)
        {
            if (getCurrentUpgrade(good) != null && getCurrentUpgrade(good).getItemId() == upgradeVG.getItemId())
            {
                return;
            }

            SoomlaUtils.LogDebug(mTag, "Assigning upgrade " + upgradeVG.getName() + " to virtual good: "
                                 + good.getName());

            String itemId   = good.getItemId();
            String key      = keyGoodUpgrade(itemId);
            String upItemId = upgradeVG.getItemId();

            KeyValueStorage.SetValue(key, upItemId);

            if (notify)
            {
                BusProvider.Instance.Post(new GoodUpgradeEvent(good, upgradeVG));
            }
        }
        /**
         * Adds the given amount of items to the storage, and if notify is true
         * posts the change in the balance to the event bus.
         *
         * @param item the required virtual item
         * @param amount the amount of items to add
         * @param notify if true posts balance change event
         * @return new balance
         */
        public int add(VirtualItem item, int amount, bool notify)
        {
            SoomlaUtils.LogDebug(mTag, "adding " + amount + " " + item.getName());

            String itemId  = item.getItemId();
            int    balance = getBalance(item);

            if (balance < 0) /* in case the user "adds" a negative value */
            {
                balance = 0;
                amount  = 0;
            }
            String balanceStr = (balance + amount).ToString();
            String key        = keyBalance(itemId);

            KeyValueStorage.SetValue(key, balanceStr);

            if (notify)
            {
                postBalanceChangeEvent(item, balance + amount, amount);
            }

            return(balance + amount);
        }
        /**
         * Removes the given amount from the given virtual item's balance, and if notify is true
         * posts the change in the balance to the event bus.
         *
         * @param item is the virtual item to remove the given amount from
         * @param amount is the amount to remove
         * @param notify if notify is true post balance change event
         * @return new balance
         */
        public int remove(VirtualItem item, int amount, bool notify)
        {
            SoomlaUtils.LogDebug(mTag, "Removing " + amount + " " + item.getName() + ".");

            String itemId  = item.getItemId();
            int    balance = getBalance(item) - amount;

            if (balance < 0)
            {
                balance = 0;
                amount  = 0;
            }
            String balanceStr = balance.ToString();
            String key        = keyBalance(itemId);

            KeyValueStorage.SetValue(key, balanceStr);

            if (notify)
            {
                postBalanceChangeEvent(item, balance, -1 * amount);
            }

            return(balance);
        }
Beispiel #25
0
        /**
         * Helper function for <code>equip</code> and <code>unequip</code> functions.
         */
        private void equipPriv(EquippableVG good, bool equip, bool notify)
        {
            SoomlaUtils.LogDebug(mTag, (!equip ? "unequipping " : "equipping ") + good.getName() + ".");

            String itemId = good.getItemId();
            String key    = keyGoodEquipped(itemId);

            if (equip)
            {
                KeyValueStorage.SetValue(key, "");
                if (notify)
                {
                    BusProvider.Instance.Post(new GoodEquippedEvent(good));
                }
            }
            else
            {
                KeyValueStorage.DeleteKeyValue(key);
                if (notify)
                {
                    BusProvider.Instance.Post(new GoodUnEquippedEvent(good));
                }
            }
        }
Beispiel #26
0
 void SaveDomainRatings(KeyValueStorage kvs)
 {
     kvs.SetValue(DomainRatingNewsFilterSettingsPage.DomainRatingsKey,
                  _serializer.Serialize(_domainRatings));
 }
 /// <summary>
 /// Saves the lock state of the achievement.
 ///     Lock values:
 ///         1       Unlocked
 ///         0       Locked
 /// </summary>
 private void SaveAchievUnlocked_StraightLine00(bool unlocked)
 {
     KeyValueStorage.SetValue(ACHIEV_STRAIGHT_LINE_00_KEY, unlocked ? "1" : "0");
 }
 /// <summary>
 /// Saves whether the specified character has been used by the player.
 ///     Character used values:
 ///         1       Used
 ///         0       Unused
 /// </summary>
 private void SaveCharacterUsed(CharacterType character, bool isUsed)
 {
     string characterUsedKey = CHARACTER_USED_PREFIX + m_charResource.GetCharacterStruct(character).ItemID;
     KeyValueStorage.SetValue(characterUsedKey, isUsed ? "1" : "0");
 }
 /// <summary>
 /// Saves the lock state of the achievement.
 ///     Lock values:
 ///         1       Unlocked
 ///         0       Locked
 /// </summary>
 private void SaveAchievUnlocked_TrainTracks00(bool unlocked)
 {
     KeyValueStorage.SetValue(ACHIEV_TRAIN_TRACKS_00_KEY, unlocked ? "1" : "0");
 }
Beispiel #30
0
 public void Save(KeyValueStorage kvs)
 {
     kvs.SetValue(StorageKey, Serialize());
 }