コード例 #1
0
ファイル: FuelSDK.cs プロジェクト: unstablesun/FuelGroove
    /// <summary>
    /// Sets the language code for the Propeller SDK online content. Must be compliant to ISO 639-1.
    /// If the language code is not supported, then the content will default to English (en)
    /// </summary>
    /// <param name="languageCode">
    /// Two character string language code to set the Fuel SDK online content to.
    /// </param>
    public static void SetLanguageCode(string languageCode)
    {
        if (languageCode == null)
        {
            FuelSDKCommon.Log(FuelSDKCommon.LogLevel.WARN, "setting an undefined language code");
        }
        else
        {
            FuelSDKCommon.Log(FuelSDKCommon.LogLevel.DEBUG, "setting language code: " + languageCode);
        }

        if (!Application.isEditor)
        {
            GetFuelSDKPlatform().SetLanguageCode(languageCode);
        }
    }
コード例 #2
0
ファイル: FuelSDK.cs プロジェクト: unstablesun/FuelGroove
    /// <summary>
    /// Begins an asynchronous operation to indicate login info is complete.
    /// </summary>
    /// <param name="loginInfo">Login info.</param>
    public static void SdkSocialLoginCompleted(Dictionary <string, string> loginInfo)
    {
        if (loginInfo == null)
        {
            FuelSDKCommon.Log(FuelSDKCommon.LogLevel.DEBUG, "social login completed unsuccessfully");
        }
        else
        {
            FuelSDKCommon.Log(FuelSDKCommon.LogLevel.DEBUG, "social login completed with login info: " + FuelSDKCommon.Serialize(loginInfo));
        }

        if (!Application.isEditor)
        {
            GetFuelSDKPlatform().SdkSocialLoginCompleted(loginInfo);
        }
    }
コード例 #3
0
ファイル: FuelSDK.cs プロジェクト: unstablesun/FuelGroove
    public static void SetNotificationToken(string notificationToken)
    {
        if (notificationToken == null)
        {
            FuelSDKCommon.Log(FuelSDKCommon.LogLevel.WARN, "setting an undefined notification token");
        }
        else
        {
            FuelSDKCommon.Log(FuelSDKCommon.LogLevel.DEBUG, "setting notification token: " + notificationToken);
        }

        if (!Application.isEditor)
        {
            GetFuelSDKPlatform().SetNotificationToken(notificationToken);
        }
    }
コード例 #4
0
    public void OnUserValues(Dictionary <string, string> conditions, Dictionary <string, string> variables)
    {
        if (conditions == null)
        {
            Debug.Log("OnUserValues - undefined conditions");
            return;
        }

        if (conditions.Count == 0)
        {
            Debug.Log("OnUserValues - empty conditions");
        }

        string conditionsString = FuelSDKCommon.Serialize(conditions);

        if (conditionsString == null)
        {
            Debug.Log("OnUserValues - unable to serialize conditions");
            return;
        }

        Debug.Log("OnUserValues - conditions: " + conditionsString);

        if (variables == null)
        {
            Debug.Log("OnUserValues - undefined variables");
            return;
        }

        if (variables.Count == 0)
        {
            Debug.Log("OnUserValues - empty variables");
        }

        string variablesString = FuelSDKCommon.Serialize(variables);

        if (variablesString == null)
        {
            Debug.Log("OnUserValues - unable to serialize variables");
            return;
        }

        Debug.Log("OnUserValues - variables: " + variablesString);

        // update game experience depending on the user values (variables) received
    }
コード例 #5
0
    void onFuelSDKVirtualGoodConsumeSuccess(Dictionary <string, object> data)
    {
        object transactionIDObject;
        bool   keyExists = data.TryGetValue("transactionID", out transactionIDObject);

        if (transactionIDObject == null || keyExists == false)
        {
            FuelSDKCommon.Log(FuelSDKCommon.LogLevel.ERROR, "missing expected transaction ID");
            return;
        }

        if (!(transactionIDObject is string))
        {
            FuelSDKCommon.Log(FuelSDKCommon.LogLevel.ERROR, "invalid transaction ID data type: " + transactionIDObject.GetType().Name);
            return;
        }
    }
コード例 #6
0
ファイル: FuelSDK.cs プロジェクト: unstablesun/FuelGroove
    private bool validateDataReceived(DataReceiverAction action, Dictionary <string, object> data)
    {
        if (data == null)
        {
            FuelSDKCommon.Log(FuelSDKCommon.LogLevel.ERROR, action.ToString() + " - undefined data");
            return(false);
        }

        object successObject;
        bool   keyExists = data.TryGetValue("success", out successObject);

        if (successObject == null || keyExists == false)
        {
            FuelSDKCommon.Log(FuelSDKCommon.LogLevel.ERROR, action.ToString() + " - missing expected 'success' field");
            return(false);
        }

        if (!(successObject is bool))
        {
            FuelSDKCommon.Log(FuelSDKCommon.LogLevel.ERROR, action.ToString() + " - invalid success result data type: " + successObject.GetType().Name);
            return(false);
        }

        bool success = (bool)successObject;

        if (!success)
        {
            object reasonObject;
            keyExists = data.TryGetValue("reason", out reasonObject);

            if (reasonObject == null || keyExists == false)
            {
                reasonObject = "undefined failure reason";
            }

            if (!(reasonObject is string))
            {
                reasonObject = "invalid failure reason data type: " + reasonObject.GetType().Name;
            }

            FuelSDKCommon.Log(FuelSDKCommon.LogLevel.ERROR, action.ToString() + " - " + reasonObject.ToString());
        }

        return(success);
    }
コード例 #7
0
    void onFuelSDKIgniteEvents(Dictionary <string, object> data)
    {
        FuelSDKCommon.Log(FuelSDKCommon.LogLevel.DEBUG, "FuelIgnite : onFuelSDKIgniteEvents");

        mIgniteEventsDictionary = new Dictionary <string, IgniteEvent> ();

        object eventsObject;
        bool   keyExists = data.TryGetValue("events", out eventsObject);

        if (eventsObject == null || keyExists == false)
        {
            FuelSDKCommon.Log(FuelSDKCommon.LogLevel.ERROR, "missing expected event list");
            return;
        }

        List <object> eventList = null;

        try{
            eventList = eventsObject as List <object>;

            if (eventList == null)
            {
                FuelSDKCommon.Log(FuelSDKCommon.LogLevel.ERROR, "invalid event list data type: " + eventsObject.GetType().Name);
                return;
            }
        }catch (Exception e) {
            FuelSDKCommon.Log(FuelSDKCommon.LogLevel.ERROR, "invalid event list data type: " + eventsObject.GetType().Name + " error message : " + e.Message);
            return;
        }



        foreach (object eventObj in eventList)
        {
            IgniteEvent igniteEvent = new IgniteEvent();
            igniteEvent.Create(eventObj as Dictionary <string, object>);

            mIgniteEventsDictionary [igniteEvent.Id] = igniteEvent;
        }

        mIgniteEventsRecieved = true;
    }
コード例 #8
0
ファイル: FuelSDK.cs プロジェクト: unstablesun/FuelGroove
    /// <summary>
    /// Gets the quest.
    /// </summary>
    /// <returns><c>true</c>, if quest was gotten, <c>false</c> otherwise.</returns>
    /// <param name="questID">Quest I.</param>
    public static bool GetQuest(string questID)
    {
        if (questID == null)
        {
            FuelSDKCommon.Log(FuelSDKCommon.LogLevel.WARN, "getting quest with undefined quest ID");
        }
        else
        {
            FuelSDKCommon.Log(FuelSDKCommon.LogLevel.DEBUG, "getting quest with quest ID: " + questID);
        }

        bool succeeded = false;

        if (!Application.isEditor)
        {
            succeeded = GetFuelSDKPlatform().GetQuest(questID);
        }

        return(succeeded);
    }
コード例 #9
0
ファイル: FuelSDK.cs プロジェクト: unstablesun/FuelGroove
    /// <summary>
    /// Gets the leader board.
    /// </summary>
    /// <returns><c>true</c>, if leader board was gotten, <c>false</c> otherwise.</returns>
    /// <param name="boardID">Board I.</param>
    public static bool GetLeaderBoard(string boardID)
    {
        if (boardID == null)
        {
            FuelSDKCommon.Log(FuelSDKCommon.LogLevel.WARN, "getting leaderboard with undefined leaderboard ID");
        }
        else
        {
            FuelSDKCommon.Log(FuelSDKCommon.LogLevel.DEBUG, "getting leaderboard with leaderboard ID: " + boardID);
        }

        bool succeeded = false;

        if (!Application.isEditor)
        {
            succeeded = GetFuelSDKPlatform().GetLeaderBoard(boardID);
        }

        return(succeeded);
    }
コード例 #10
0
ファイル: FuelSDK.cs プロジェクト: unstablesun/FuelGroove
    /// <summary>
    /// Joins an event.
    /// </summary>
    /// <returns><c>true</c>, if join request was sent through, <c>false</c> otherwise.</returns>
    /// <param name="eventID">Event ID.</param>
    public static bool JoinEvent(string eventID)
    {
        if (eventID == null)
        {
            FuelSDKCommon.Log(FuelSDKCommon.LogLevel.WARN, "joining with undefined event ID");
        }
        else
        {
            FuelSDKCommon.Log(FuelSDKCommon.LogLevel.DEBUG, "joining with event ID: " + eventID);
        }

        bool succeeded = false;

        if (!Application.isEditor)
        {
            succeeded = GetFuelSDKPlatform().JoinEvent(eventID);
        }

        return(succeeded);
    }
コード例 #11
0
ファイル: FuelSDK.cs プロジェクト: unstablesun/FuelGroove
    /// <summary>
    /// Gets the mission.
    /// </summary>
    /// <returns><c>true</c>, if mission was gotten, <c>false</c> otherwise.</returns>
    /// <param name="missionID">Mission I.</param>
    public static bool GetMission(string missionID)
    {
        if (missionID == null)
        {
            FuelSDKCommon.Log(FuelSDKCommon.LogLevel.WARN, "getting mission with undefined mission ID");
        }
        else
        {
            FuelSDKCommon.Log(FuelSDKCommon.LogLevel.DEBUG, "getting mission with mission ID: " + missionID);
        }

        bool succeeded = false;

        if (!Application.isEditor)
        {
            succeeded = GetFuelSDKPlatform().GetMission(missionID);
        }

        return(succeeded);
    }
コード例 #12
0
ファイル: FuelSDK.cs プロジェクト: unstablesun/FuelGroove
    /// <summary>
    /// FUEL DYNAMICS - SetUserConditions
    ///
    /// </summary>
    /// <returns>
    /// True if the call to the SDK succeeded.
    /// </returns>
    /// <param name="conditions">
    /// A dictionary filled with values the SDK needs to use to properly pass the result to the Propeller servers. Examples: score, tournamentID, matchID, etc.
    /// </param>
    public static bool SetUserConditions(Dictionary <string, object> conditions)
    {
        string userConditions = FuelSDKCommon.Serialize(conditions);

        if (conditions == null)
        {
            FuelSDKCommon.Log(FuelSDKCommon.LogLevel.WARN, "setting undefined user conditions");
        }
        else
        {
            FuelSDKCommon.Log(FuelSDKCommon.LogLevel.DEBUG, "setting user conditions: " + userConditions);
        }

        bool succeeded = false;

        if (!Application.isEditor)
        {
            succeeded = GetFuelSDKPlatform().SetUserConditions(userConditions);
        }

        return(succeeded);
    }
コード例 #13
0
ファイル: FuelSDK.cs プロジェクト: unstablesun/FuelGroove
    /// <summary>
    /// Gets the events.
    /// </summary>
    /// <returns><c>true</c>, if events was gotten, <c>false</c> otherwise.</returns>
    public static bool GetEvents(List <object> eventTags)
    {
        string eventTagsString = FuelSDKCommon.Serialize(eventTags);

        if (eventTags == null)
        {
            FuelSDKCommon.Log(FuelSDKCommon.LogLevel.DEBUG, "getting events with undefined tags");
        }
        else
        {
            FuelSDKCommon.Log(FuelSDKCommon.LogLevel.DEBUG, "getting events with tags: " + eventTagsString);
        }

        bool succeeded = false;

        if (!Application.isEditor)
        {
            succeeded = GetFuelSDKPlatform().GetEvents(eventTagsString);
        }

        return(succeeded);
    }
コード例 #14
0
ファイル: FuelSDK.cs プロジェクト: unstablesun/FuelGroove
    public static bool IsNotificationEnabled(NotificationType notificationType)
    {
        FuelSDKCommon.Log(FuelSDKCommon.LogLevel.DEBUG, "validating if notification type '" + notificationType.ToString() + "' is enabled");

        bool succeed = false;

        if (!Application.isEditor)
        {
            succeed = GetFuelSDKPlatform().IsNotificationEnabled(notificationType);
        }

        if (succeed)
        {
            FuelSDKCommon.Log(FuelSDKCommon.LogLevel.DEBUG, "notification type '" + notificationType.ToString() + "' is enabled");
        }
        else
        {
            FuelSDKCommon.Log(FuelSDKCommon.LogLevel.DEBUG, "notification type '" + notificationType.ToString() + "' is disabled");
        }

        return(succeed);
    }
コード例 #15
0
ファイル: FuelSDK.cs プロジェクト: unstablesun/FuelGroove
    /// <summary>
    /// Submits the results of the match. You must stuff the match result into a dictionary that will be parsed and passed to the SDK API servers..
    /// Current parameters:
    ///     matchID
    ///     tournamentID
    ///     score
    /// </summary>
    /// <returns>
    /// True if the match results were submitted.
    /// </returns>
    /// <param name="matchResult">
    /// A dictionary filled with values the SDK needs to use to properly pass the result to the API servers. Examples: score, tournamentID, matchID, etc.
    /// </param>
    public static bool SubmitMatchResult(Dictionary <string, object> matchResult)
    {
        if (matchResult == null)
        {
            FuelSDKCommon.Log(FuelSDKCommon.LogLevel.WARN, "submitting undefined match result");
        }
        else
        {
            FuelSDKCommon.Log(FuelSDKCommon.LogLevel.DEBUG, "submitting match result: " + FuelSDKCommon.Serialize(matchResult));
        }

        bool succeeded = false;

        if (!Application.isEditor)
        {
            JSONClass matchResultJSON = FuelSDKCommon.toJSONClass(matchResult);

            if (matchResultJSON == null)
            {
                FuelSDKCommon.Log(FuelSDKCommon.LogLevel.ERROR, "unable to coerce match result dictionary into a JSON class");
            }
            else
            {
                succeeded = GetFuelSDKPlatform().SubmitMatchResult(matchResultJSON.ToString());
            }
        }

        if (succeeded)
        {
            FuelSDKCommon.Log(FuelSDKCommon.LogLevel.DEBUG, "match result was submitted");
        }
        else
        {
            FuelSDKCommon.Log(FuelSDKCommon.LogLevel.DEBUG, "match result was not submitted");
        }

        return(succeeded);
    }
コード例 #16
0
    void onFuelSDKIgniteMission(Dictionary <string, object> data)
    {
        FuelSDKCommon.Log(FuelSDKCommon.LogLevel.DEBUG, "FuelIgnite : onFuelSDKIgniteMission");

        object missionObject;
        bool   keyExists = data.TryGetValue("mission", out missionObject);

        if (missionObject == null || keyExists == false)
        {
            FuelSDKCommon.Log(FuelSDKCommon.LogLevel.ERROR, "missing expected mission data");
            return;
        }

        Dictionary <string, object> missionDictionary = null;

        try{
            missionDictionary = missionObject as Dictionary <string, object>;

            if (missionDictionary == null)
            {
                FuelSDKCommon.Log(FuelSDKCommon.LogLevel.ERROR, "invalid mission data type: " + missionObject.GetType().Name);
                return;
            }
        }catch (Exception e) {
            FuelSDKCommon.Log(FuelSDKCommon.LogLevel.ERROR, "invalid mission data type: " + missionObject.GetType().Name + " error message : " + e.Message);
            return;
        }

        IgniteEvent igniteEvent = mIgniteEventsDictionary[missionDictionary["id"].ToString()];

        if (igniteEvent != null)
        {
            igniteEvent.LoadActivityData(missionDictionary);
        }
        else
        {
        }
    }
コード例 #17
0
ファイル: FuelSDK.cs プロジェクト: unstablesun/FuelGroove
    /// <summary>
    /// Begins an asynchronous operation to acknowledge the received virtual goods from Fuel.
    /// </summary>
    /// <param name="transactionId">
    /// The transaction ID being acknowledged
    /// </param>
    /// <param name="consumed">
    /// Flags whether or not the virutal good were consumed
    /// </param>
    public static void AcknowledgeVirtualGoods(string transactionId, bool consumed)
    {
        if (transactionId == null)
        {
            FuelSDKCommon.Log(FuelSDKCommon.LogLevel.WARN, "acknowledging virtual goods with an undefined transaction ID");
        }
        else
        {
            if (consumed)
            {
                FuelSDKCommon.Log(FuelSDKCommon.LogLevel.DEBUG, "acknowledging virtual goods for transaction '" + transactionId + "' as consumed");
            }
            else
            {
                FuelSDKCommon.Log(FuelSDKCommon.LogLevel.DEBUG, "acknowledging virtual goods for transaction '" + transactionId + "' as not consumed");
            }
        }

        if (!Application.isEditor)
        {
            GetFuelSDKPlatform().AcknowledgeVirtualGoods(transactionId, consumed);
        }
    }
コード例 #18
0
        /// <summary>
        /// Localize the specified keyCode.
        /// </summary>
        /// <param name="keyCode">Key code.</param>
        public string LocalizeText(string keyCode)
        {
            if (languageDict == null)
            {
                FuelSDKCommon.Log(FuelSDKCommon.LogLevel.DEBUG, "there is no localization data loaded");
                return(keyCode);
            }
            if (languageDict.Count == 0)
            {
                FuelSDKCommon.Log(FuelSDKCommon.LogLevel.DEBUG, "there is no localization data loaded");
                return(keyCode);
            }
            if (keyCode == null)
            {
                FuelSDKCommon.Log(FuelSDKCommon.LogLevel.DEBUG, "Localization key is null");
                return(keyCode);
            }
            string language = GetSystemLanguage();

            try
            {
                cultureInfo = new CultureInfo(language);
            }
            catch (System.ArgumentException)
            {
                cultureInfo = CultureInfo.CurrentCulture;
            }

            object objectValue = null;

            languageDict.TryGetValue(keyCode, out objectValue);

            if (objectValue == null)
            {
                return(keyCode);
            }
            else
            {
                object localizedText = null;
                Dictionary <string, object> dicValue = new Dictionary <string, object>();

                try{
                    dicValue = (Dictionary <string, object>)objectValue;
                }catch (Exception e) {
                    FuelSDKCommon.Log(FuelSDKCommon.LogLevel.ERROR, "Localization file doesn't have the format excepted " + e.Message);
                    return(keyCode);
                }

                dicValue.TryGetValue(language, out localizedText);

                if (localizedText == null)
                {
                    FuelSDKCommon.Log(FuelSDKCommon.LogLevel.ERROR, "There is not " + language + " localization for " + keyCode);
                    return(keyCode);
                }
                else
                {
                    return(string.Format(cultureInfo, localizedText.ToString()));
                }
            }
        }
コード例 #19
0
ファイル: FuelSDK.cs プロジェクト: unstablesun/FuelGroove
    /// <summary>
    /// Initializes ignite.
    /// </summary>
    public static void InitializeIgnite()
    {
        FuelSDKCommon.Log(FuelSDKCommon.LogLevel.DEBUG, "initializing the ignite product");

        GetFuelSDKPlatform().InitializeIgnite();
    }
コード例 #20
0
    public void OnCompeteUICompletedWithMatch(Dictionary <string, object> matchInfo)
    {
        if (matchInfo == null)
        {
            Debug.Log("OnCompeteUICompletedWithMatch - undefined match info");
            return;
        }

        if (matchInfo.Count == 0)
        {
            Debug.Log("OnCompeteUICompletedWithMatch - empty match info");
            return;
        }

        string matchInfoString = FuelSDKCommon.Serialize(matchInfo);

        if (matchInfoString == null)
        {
            Debug.Log("OnCompeteUICompletedWithMatch - unable to serialize match info");
            return;
        }

        Debug.Log("OnCompeteUICompletedWithMatch - match info: " + matchInfoString);

        object tournamentIDObject = matchInfo["tournamentID"];

        if (tournamentIDObject == null)
        {
            Debug.Log("OnCompeteUICompletedWithMatch - missing expected tournament ID");
            return;
        }

        if (!(tournamentIDObject is string))
        {
            Debug.Log("OnCompeteUICompletedWithMatch - invalid tournament ID data type: " + tournamentIDObject.GetType().Name);
            return;
        }

        string tournamentID = (string)tournamentIDObject;

        object matchIDObject = matchInfo["matchID"];

        if (matchIDObject == null)
        {
            Debug.Log("OnCompeteUICompletedWithMatch - missing expected match ID");
            return;
        }

        if (!(matchIDObject is string))
        {
            Debug.Log("OnCompeteUICompletedWithMatch - invalid match ID data type: " + matchIDObject.GetType().Name);
            return;
        }

        string matchID = (string)matchIDObject;

        // Caching match information for later
        m_tournamentID = tournamentID;
        m_matchID      = matchID;

        // fake playing a match
        StartCoroutine(PerformMatch(matchInfo));
    }
コード例 #21
0
    public void OnVirtualGoodList(string transactionID, List <object> virtualGoods)
    {
        if (transactionID == null)
        {
            Debug.Log("OnVirtualGoodList - transaction ID: <undefined>");
            return;
        }

        Debug.Log("OnVirtualGoodList - transaction ID: " + transactionID);

        m_transactionID = transactionID;

        if (virtualGoods == null)
        {
            Debug.Log("OnVirtualGoodList - virtual good: <undefined_list>");
            return;
        }

        m_consumedVirtualGoodIDs.Clear();

        if (virtualGoods.Count == 0)
        {
            Debug.Log("OnVirtualGoodList - virtual good: <empty_list>");
            return;
        }

        string virtualGoodsString = FuelSDKCommon.Serialize(virtualGoods);

        if (virtualGoodsString == null)
        {
            Debug.Log("OnVirtualGoodList - unable to serialize the virtual good list");
            return;
        }

        Debug.Log("OnVirtualGoodList - virtual goods: " + virtualGoodsString);

        bool consumed = true;

        foreach (object virtualGoodObject in virtualGoods)
        {
            Dictionary <string, object> virtualGood = virtualGoodObject as Dictionary <string, object>;

            if (virtualGood == null)
            {
                Debug.Log("OnVirtualGoodList - invalid virtual good data type: " + virtualGoodObject.GetType().Name);
                consumed = false;
                break;
            }

            object goodIDObject = virtualGood["goodId"];

            if (goodIDObject == null)
            {
                Debug.Log("OnVirtualGoodList - missing expected virtual good ID");
                consumed = false;
                break;
            }

            if (!(goodIDObject is string))
            {
                Debug.Log("OnVirtualGoodList - invalid virtual good ID data type: " + goodIDObject.GetType().Name);
                consumed = false;
                break;
            }

            string goodID = (string)goodIDObject;

            // based on the virtual good ID, update the player
            // inventory with the received virtual good

            m_consumedVirtualGoodIDs.Add(goodID);
        }

        if (!consumed)
        {
            foreach (string goodID in m_consumedVirtualGoodIDs)
            {
                // revert the currently awarded virtual goods for
                // this transaction from the player inventory
                Debug.Log("OnVirtualGoodList - reverting consumed virtual good ID: " + goodID);
            }

            m_consumedVirtualGoodIDs.Clear();
        }

        FuelSDK.AcknowledgeVirtualGoods(transactionID, consumed);
    }
コード例 #22
0
    public void OnUserAvatars(Dictionary <string, object> avatars)
    {
        string dataString = FuelSDKCommon.Serialize(avatars);

        Debug.Log("OnUserAvatars - avatars: " + dataString);
    }
コード例 #23
0
    public void OnUpdatedUserInfo(Dictionary <string, object> data)
    {
        string dataString = FuelSDKCommon.Serialize(data);

        Debug.Log("OnUpdatedUserInfo - data: " + dataString);
    }
コード例 #24
0
    public void OnIgniteLeaderBoard(Dictionary <string, object> leaderBoard)
    {
        if (leaderBoard == null)
        {
            Debug.Log("OnIgniteLeaderBoard - undefined leaderboard");
            return;
        }

        if (leaderBoard.Count == 0)
        {
            Debug.Log("OnIgniteLeaderBoard - empty leaderboard");
            return;
        }

        string leaderBoardString = FuelSDKCommon.Serialize(leaderBoard);

        if (leaderBoardString == null)
        {
            Debug.Log("OnIgniteLeaderBoard - unable to serialize the leaderboard");
            return;
        }

        Debug.Log("OnIgniteLeaderBoard - leaderboard: " + leaderBoardString);



        // START PROCESSING - process the leaderboard information
        if (leaderBoard.ContainsKey("id"))
        {
            string Id = Convert.ToString(leaderBoard["id"]);
        }
        if (leaderBoard.ContainsKey("progress"))
        {
            int Progress = Convert.ToInt32(leaderBoard["progress"]);
        }
        if (leaderBoard.ContainsKey("currentUserId"))
        {
            string CurrentUserId = Convert.ToString(leaderBoard["currentUserId"]);
        }

        if (leaderBoard.ContainsKey("rule"))
        {
            Dictionary <string, object> leaderBoardRuleDict = leaderBoard["rule"] as Dictionary <string, object>;

            if (leaderBoardRuleDict.ContainsKey("id"))
            {
                string Id = Convert.ToString(leaderBoardRuleDict["id"]);
            }
            if (leaderBoardRuleDict.ContainsKey("variable"))
            {
                string Variable = Convert.ToString(leaderBoardRuleDict["variable"]);
            }
            if (leaderBoardRuleDict.ContainsKey("kind"))
            {
                int Kind = Convert.ToInt32(leaderBoardRuleDict["kind"]);
            }
            if (leaderBoardRuleDict.ContainsKey("score"))
            {
                int Score = Convert.ToInt32(leaderBoardRuleDict["score"]);
            }
        }

        if (leaderBoard.ContainsKey("leaderList"))
        {
            Dictionary <string, object> leaderListDict = leaderBoard["leaderList"] as Dictionary <string, object>;
            if (leaderListDict.ContainsKey("leaders"))
            {
                List <object> leaderList = leaderListDict["leaders"] as List <object>;

                foreach (object leaderObject in leaderList)
                {
                    Dictionary <string, object> leaderDict = leaderObject as Dictionary <string, object>;

                    if (leaderDict.ContainsKey("id"))
                    {
                        string Id = Convert.ToString(leaderDict["id"]);
                    }
                    if (leaderDict.ContainsKey("name"))
                    {
                        string Name = Convert.ToString(leaderDict["name"]);
                    }
                    if (leaderDict.ContainsKey("score"))
                    {
                        int Score = Convert.ToInt32(leaderDict["score"]);
                    }
                    if (leaderDict.ContainsKey("rank"))
                    {
                        int Rank = Convert.ToInt32(leaderDict["rank"]);
                    }
                }
            }
        }
    }
コード例 #25
0
ファイル: FuelSDK.cs プロジェクト: unstablesun/FuelGroove
    /// <summary>
    /// Data Receiver
    /// </summary>
    /// <param name="message">data</param>
    private void DataReceiver(string message)
    {
        if (m_listener == null)
        {
            FuelSDKCommon.Log(FuelSDKCommon.LogLevel.ERROR, "Fuel SDK listener has not been set");
            return;
        }

        if (message == null)
        {
            FuelSDKCommon.Log(FuelSDKCommon.LogLevel.ERROR, "received undefined message");
            return;
        }

        object messageObject = FuelSDKCommon.Deserialize(message);

        if (messageObject == null)
        {
            FuelSDKCommon.Log(FuelSDKCommon.LogLevel.ERROR, "message could not be deserialized");
            return;
        }

        Dictionary <string, object> messageDictionary = null;

        try{
            messageDictionary = messageObject as Dictionary <string, object>;

            if (messageDictionary == null)
            {
                FuelSDKCommon.Log(FuelSDKCommon.LogLevel.ERROR, " message data type: " + messageObject.GetType().Name);
                return;
            }
        }catch (Exception e) {
            FuelSDKCommon.Log(FuelSDKCommon.LogLevel.ERROR, " message data type: " + messageObject.GetType().Name + " error message : " + e.Message);
            return;
        }

        object actionObject;
        bool   keyExists = messageDictionary.TryGetValue("action", out actionObject);

        if (actionObject == null || keyExists == false)
        {
            FuelSDKCommon.Log(FuelSDKCommon.LogLevel.ERROR, "received undefined action for message: " + message);
            return;
        }

        if (!(actionObject is string))
        {
            FuelSDKCommon.Log(FuelSDKCommon.LogLevel.ERROR, "invalid action data type: " + actionObject.GetType().Name);
            return;
        }

        string             action             = (string)actionObject;
        DataReceiverAction dataReceiverAction = DataReceiverAction.none;

        if (!FuelSDKCommon.TryParseEnum <DataReceiverAction> (action, out dataReceiverAction))
        {
            FuelSDKCommon.Log(FuelSDKCommon.LogLevel.ERROR, "unsupported action: " + action);
            return;
        }

        object dataObject;

        keyExists = messageDictionary.TryGetValue("data", out dataObject);

        if (dataObject == null || keyExists == false)
        {
            FuelSDKCommon.Log(FuelSDKCommon.LogLevel.ERROR, "no specific data in the response object for action: " + action);
            return;
        }

        Dictionary <string, object> data = null;

        try{
            data = dataObject as Dictionary <string, object>;

            if (data == null)
            {
                FuelSDKCommon.Log(FuelSDKCommon.LogLevel.ERROR, "invalid data data type" + dataObject.GetType().Name);
                return;
            }
        }catch (Exception e) {
            FuelSDKCommon.Log(FuelSDKCommon.LogLevel.ERROR, "invalid data data type" + dataObject.GetType().Name + " error message : " + e.Message);
            return;
        }

        string dataString = FuelSDKCommon.Serialize(data);

        if (dataString == null)
        {
            FuelSDKCommon.Log(FuelSDKCommon.LogLevel.ERROR, "data could not be serialized");
            return;
        }

        FuelSDKCommon.Log(FuelSDKCommon.LogLevel.DEBUG, "received '" + action + "': " + dataString);

        switch (dataReceiverAction)
        {
        case DataReceiverAction.none:
        {
            // noop
            break;
        }

        case DataReceiverAction.fuelSDKVirtualGoodList:
        {
            object transactionIDObject;
            keyExists = data.TryGetValue("transactionID", out transactionIDObject);

            if (transactionIDObject == null || keyExists == false)
            {
                FuelSDKCommon.Log(FuelSDKCommon.LogLevel.ERROR, "missing expected transaction ID");
                break;
            }

            if (!(transactionIDObject is string))
            {
                FuelSDKCommon.Log(FuelSDKCommon.LogLevel.ERROR, "invalid transaction ID data type: " + transactionIDObject.GetType().Name);
                break;
            }

            string transactionID = (string)transactionIDObject;


            object virtualGoodsObject;
            keyExists = data.TryGetValue("virtualGoods", out virtualGoodsObject);

            if (virtualGoodsObject == null || keyExists == false)
            {
                FuelSDKCommon.Log(FuelSDKCommon.LogLevel.ERROR, "missing expected virtual goods list");
                break;
            }

            List <object> virtualGoods = null;

            try{
                virtualGoods = virtualGoodsObject as List <object>;

                if (virtualGoods == null)
                {
                    FuelSDKCommon.Log(FuelSDKCommon.LogLevel.ERROR, "invalid virtual goods list data type: " + virtualGoodsObject.GetType().Name);
                    break;
                }
            }catch (Exception e) {
                FuelSDKCommon.Log(FuelSDKCommon.LogLevel.ERROR, "invalid virtual goods list data type: " + virtualGoodsObject.GetType().Name + " error message : " + e.Message);
                break;
            }

            m_listener.OnVirtualGoodList(transactionID, virtualGoods);
            break;
        }

        case DataReceiverAction.fuelSDKVirtualGoodRollback:
        {
            object transactionIDObject;
            keyExists = data.TryGetValue("transactionID", out transactionIDObject);

            if (transactionIDObject == null || keyExists == false)
            {
                FuelSDKCommon.Log(FuelSDKCommon.LogLevel.ERROR, "missing expected transaction ID");
                break;
            }

            if (!(transactionIDObject is string))
            {
                FuelSDKCommon.Log(FuelSDKCommon.LogLevel.ERROR, "invalid transaction ID data type: " + transactionIDObject.GetType().Name);
                break;
            }

            m_listener.OnVirtualGoodRollback((string)transactionIDObject);
            break;
        }

        case DataReceiverAction.fuelSDKNotificationEnabled:
        {
            object notificationTypeObject;
            keyExists = data.TryGetValue("notificationType", out notificationTypeObject);

            if (notificationTypeObject == null || keyExists == false)
            {
                FuelSDKCommon.Log(FuelSDKCommon.LogLevel.ERROR, "missing expected notification type");
                break;
            }

            if (!(notificationTypeObject is long))
            {
                FuelSDKCommon.Log(FuelSDKCommon.LogLevel.ERROR, "invalid notification type data type: " + notificationTypeObject.GetType().Name);
                break;
            }

            int notificationTypeValue = (int)((long)notificationTypeObject);

            if (!Enum.IsDefined(typeof(NotificationType), notificationTypeValue))
            {
                FuelSDKCommon.Log(FuelSDKCommon.LogLevel.ERROR, "unsuppported notification type value: " + notificationTypeValue.ToString());
                break;
            }

            m_listener.OnNotificationEnabled((NotificationType)notificationTypeValue);
            break;
        }

        case DataReceiverAction.fuelSDKNotificationDisabled:
        {
            object notificationTypeObject;
            keyExists = data.TryGetValue("notificationType", out notificationTypeObject);

            if (notificationTypeObject == null || keyExists == false)
            {
                FuelSDKCommon.Log(FuelSDKCommon.LogLevel.ERROR, "missing expected notification type");
                break;
            }

            if (!(notificationTypeObject is long))
            {
                FuelSDKCommon.Log(FuelSDKCommon.LogLevel.ERROR, "invalid notification type data type: " + notificationTypeObject.GetType().Name);
                break;
            }

            int notificationTypeValue = (int)((long)notificationTypeObject);

            if (!Enum.IsDefined(typeof(NotificationType), notificationTypeValue))
            {
                FuelSDKCommon.Log(FuelSDKCommon.LogLevel.ERROR, "unsuppported notification type value: " + notificationTypeValue.ToString());
                break;
            }

            m_listener.OnNotificationDisabled((NotificationType)notificationTypeValue);
            break;
        }

        case DataReceiverAction.fuelSDKSocialLoginRequest:
        {
            object allowCacheObject;
            keyExists = data.TryGetValue("allowCache", out allowCacheObject);

            if (allowCacheObject == null || keyExists == false)
            {
                FuelSDKCommon.Log(FuelSDKCommon.LogLevel.ERROR, "missing expected allow cache flag");
                break;
            }

            if (!(allowCacheObject is bool))
            {
                FuelSDKCommon.Log(FuelSDKCommon.LogLevel.ERROR, "invalid allow cache data type: " + allowCacheObject.GetType().Name);
                break;
            }

            bool allowCache = (bool)allowCacheObject;

            m_listener.OnSocialLogin(allowCache);
            break;
        }

        case DataReceiverAction.fuelSDKSocialInviteRequest:
        {
            m_listener.OnSocialInvite(FuelSDKCommon.ToStringDictionary <string, object> (data));
            break;
        }

        case DataReceiverAction.fuelSDKSocialShareRequest:
        {
            m_listener.OnSocialShare(FuelSDKCommon.ToStringDictionary <string, object> (data));
            break;
        }

        case DataReceiverAction.fuelSDKImplicitLaunchRequest:
        {
            object applicationStateObject;
            keyExists = data.TryGetValue("applicationState", out applicationStateObject);

            if (applicationStateObject == null)
            {
                FuelSDKCommon.Log(FuelSDKCommon.LogLevel.ERROR, "missing expected application state");
                break;
            }

            if (!(applicationStateObject is string))
            {
                FuelSDKCommon.Log(FuelSDKCommon.LogLevel.ERROR, "invalid application state data type: " + applicationStateObject.GetType().Name);
                break;
            }

            string applicationStateString = (string)applicationStateObject;

            ApplicationState applicationState = ApplicationState.none;

            if (!FuelSDKCommon.TryParseEnum <ApplicationState> (applicationStateString, out applicationState))
            {
                FuelSDKCommon.Log(FuelSDKCommon.LogLevel.ERROR, "unsupported application state: " + applicationStateString);
                return;
            }

            m_listener.OnImplicitLaunch(applicationState);
            break;
        }

        case DataReceiverAction.fuelSDKUserValues:
        {
            object conditionsObject;
            keyExists = data.TryGetValue("dynamicConditions", out conditionsObject);

            if (conditionsObject == null || keyExists == false)
            {
                FuelSDKCommon.Log(FuelSDKCommon.LogLevel.ERROR, "missing expected dynamic conditions");
                break;
            }

            Dictionary <string, object> conditions = null;

            try{
                conditions = conditionsObject as Dictionary <string, object>;

                if (conditions == null)
                {
                    FuelSDKCommon.Log(FuelSDKCommon.LogLevel.ERROR, "invalid conditions data type: " + conditionsObject.GetType().Name);
                    break;
                }
            }catch (Exception e) {
                FuelSDKCommon.Log(FuelSDKCommon.LogLevel.ERROR, "invalid conditions data type: " + conditionsObject.GetType().Name + " error message : " + e.Message);
                break;
            }

            object variablesObject;
            keyExists = data.TryGetValue("variables", out variablesObject);

            if (variablesObject == null || keyExists == false)
            {
                FuelSDKCommon.Log(FuelSDKCommon.LogLevel.ERROR, "missing expected dynamic variables");
                break;
            }

            Dictionary <string, object> variables = null;

            try{
                variables = variablesObject as Dictionary <string, object>;

                if (variables == null)
                {
                    FuelSDKCommon.Log(FuelSDKCommon.LogLevel.ERROR, "invalid variables data type: " + variablesObject.GetType().Name);
                    break;
                }
            }catch (Exception e) {
                FuelSDKCommon.Log(FuelSDKCommon.LogLevel.ERROR, "invalid variables data type: " + variablesObject.GetType().Name + " error message : " + e.Message);
                break;
            }

            m_listener.OnUserValues(FuelSDKCommon.ToStringDictionary <string, object> (conditions), FuelSDKCommon.ToStringDictionary <string, object> (variables));
            break;
        }

        case DataReceiverAction.fuelSDKCompeteChallengeCount:
        {
            object countObject;
            keyExists = data.TryGetValue("count", out countObject);

            if (countObject == null || keyExists == false)
            {
                FuelSDKCommon.Log(FuelSDKCommon.LogLevel.ERROR, "missing expected challenge count");
                break;
            }

            if (!(countObject is long))
            {
                FuelSDKCommon.Log(FuelSDKCommon.LogLevel.ERROR, "invalid challenge count data type: " + countObject.GetType().Name);
                break;
            }

            int count = (int)((long)countObject);

            m_listener.OnCompeteChallengeCount(count);
            break;
        }

        case DataReceiverAction.fuelSDKCompeteTournamentInfo:
        {
            m_listener.OnCompeteTournamentInfo(FuelSDKCommon.ToStringDictionary <string, object> (data));
            break;
        }

        case DataReceiverAction.fuelSDKCompeteUICompletedExit:
        {
            m_listener.OnCompeteUICompletedWithExit();
            break;
        }

        case DataReceiverAction.fuelSDKCompeteUICompletedMatch:
        {
            m_listener.OnCompeteUICompletedWithMatch(data);
            break;
        }

        case DataReceiverAction.fuelSDKCompeteUICompletedFail:
        {
            object reasonObject;
            keyExists = data.TryGetValue("message", out reasonObject);

            if (reasonObject == null || keyExists == false)
            {
                FuelSDKCommon.Log(FuelSDKCommon.LogLevel.ERROR, "missing expected failure reason");
                break;
            }

            if (!(reasonObject is string))
            {
                FuelSDKCommon.Log(FuelSDKCommon.LogLevel.ERROR, "invalid failure reason data type: " + reasonObject.GetType().Name);
                break;
            }

            string reason = (string)reasonObject;

            m_listener.OnCompeteUIFailed(reason);
            break;
        }

        case DataReceiverAction.fuelSDKIgniteEvents:
        {
            if (!validateDataReceived(dataReceiverAction, data))
            {
                break;
            }

            object eventsObject;
            keyExists = data.TryGetValue("events", out eventsObject);

            if (eventsObject == null || keyExists == false)
            {
                FuelSDKCommon.Log(FuelSDKCommon.LogLevel.ERROR, "missing expected event list");
                break;
            }

            List <object> events = null;

            try{
                events = eventsObject as List <object>;

                if (events == null)
                {
                    FuelSDKCommon.Log(FuelSDKCommon.LogLevel.ERROR, "invalid event list data type: " + eventsObject.GetType().Name);
                    break;
                }
            }catch (Exception e) {
                FuelSDKCommon.Log(FuelSDKCommon.LogLevel.ERROR, "invalid event list data type: " + eventsObject.GetType().Name + " error message : " + e.Message);
                break;
            }

            m_listener.OnIgniteEvents(events);
            break;
        }

        case DataReceiverAction.fuelSDKIgniteLeaderBoard:
        {
            if (!validateDataReceived(dataReceiverAction, data))
            {
                break;
            }

            object leaderBoardObject;
            keyExists = data.TryGetValue("leaderBoard", out leaderBoardObject);

            if (leaderBoardObject == null || keyExists == false)
            {
                FuelSDKCommon.Log(FuelSDKCommon.LogLevel.ERROR, "missing expected leaderboard data");
                break;
            }

            Dictionary <string, object> leaderBoard = null;

            try{
                leaderBoard = leaderBoardObject as Dictionary <string, object>;

                if (leaderBoard == null)
                {
                    FuelSDKCommon.Log(FuelSDKCommon.LogLevel.ERROR, "invalid leaderboard data type: " + leaderBoardObject.GetType().Name);
                    break;
                }
            }catch (Exception e) {
                FuelSDKCommon.Log(FuelSDKCommon.LogLevel.ERROR, "invalid leaderboard data type: " + leaderBoardObject.GetType().Name + " error message : " + e.Message);
                break;
            }

            m_listener.OnIgniteLeaderBoard(leaderBoard);
            break;
        }

        case DataReceiverAction.fuelSDKIgniteMission:
        {
            if (!validateDataReceived(dataReceiverAction, data))
            {
                break;
            }

            object missionObject;
            keyExists = data.TryGetValue("mission", out missionObject);

            if (missionObject == null || keyExists == false)
            {
                FuelSDKCommon.Log(FuelSDKCommon.LogLevel.ERROR, "missing expected mission data");
                break;
            }

            Dictionary <string, object> mission = null;

            try{
                mission = missionObject as Dictionary <string, object>;

                if (mission == null)
                {
                    FuelSDKCommon.Log(FuelSDKCommon.LogLevel.ERROR, "invalid mission data type: " + missionObject.GetType().Name);
                    break;
                }
            }catch (Exception e) {
                FuelSDKCommon.Log(FuelSDKCommon.LogLevel.ERROR, "invalid mission data type: " + missionObject.GetType().Name + " error message : " + e.Message);
                break;
            }

            m_listener.OnIgniteMission(mission);
            break;
        }

        case DataReceiverAction.fuelSDKIgniteQuest:
        {
            if (!validateDataReceived(dataReceiverAction, data))
            {
                break;
            }

            object questObject;
            keyExists = data.TryGetValue("quest", out questObject);

            if (questObject == null || keyExists == false)
            {
                FuelSDKCommon.Log(FuelSDKCommon.LogLevel.ERROR, "missing expected quest data");
                break;
            }

            Dictionary <string, object> quest = null;

            try{
                quest = questObject as Dictionary <string, object>;

                if (quest == null)
                {
                    FuelSDKCommon.Log(FuelSDKCommon.LogLevel.ERROR, "invalid quest data type: " + questObject.GetType().Name);
                    break;
                }
            }catch (Exception e) {
                FuelSDKCommon.Log(FuelSDKCommon.LogLevel.ERROR, "invalid quest data type: " + questObject.GetType().Name + " error message : " + e.Message);
                break;
            }

            m_listener.OnIgniteQuest(quest);
            break;
        }

        case DataReceiverAction.fuelSDKIgniteJoinEvent:
        {
            if (!validateDataReceived(dataReceiverAction, data))
            {
                break;
            }

            object eventIDObject;
            keyExists = data.TryGetValue("eventID", out eventIDObject);

            if (eventIDObject == null || keyExists == false)
            {
                FuelSDKCommon.Log(FuelSDKCommon.LogLevel.ERROR, "missing expected event ID");
                break;
            }

            if (!(eventIDObject is string))
            {
                FuelSDKCommon.Log(FuelSDKCommon.LogLevel.ERROR, "invalid event ID data type: " + eventIDObject.GetType().Name);
                break;
            }

            string eventID = (string)eventIDObject;

            object joinStatusObject;
            keyExists = data.TryGetValue("joinStatus", out joinStatusObject);

            if (joinStatusObject == null || keyExists == false)
            {
                FuelSDKCommon.Log(FuelSDKCommon.LogLevel.ERROR, "missing expected join status");
                break;
            }

            if (!(joinStatusObject is bool))
            {
                FuelSDKCommon.Log(FuelSDKCommon.LogLevel.ERROR, "invalid join status data type: " + joinStatusObject.GetType().Name);
                break;
            }

            bool joinStatus = (bool)joinStatusObject;

            m_listener.OnIgniteJoinEvent(eventID, joinStatus);
            break;
        }

        default:
        {
            FuelSDKCommon.Log(FuelSDKCommon.LogLevel.WARN, "unsupported action: " + action);
            break;
        }
        }
    }