public ContinuedTurnBasedMatch(JSONDict matchInfo)
        {
            GameData = matchInfo.SafeGetStringValue("gameData");

            object player = matchInfo.SafeGetValue("player");
            if (player != null && player.GetType() == typeof(JSONDict))
            {
                JSONDict playerData = (JSONDict)player;
                MyCurrentTotalScore = playerData.SafeGetDoubleValue("currentTotalScore");
            }
            else
            {
                MyCurrentTotalScore = null;
            }

            object opponent = matchInfo.SafeGetValue("opponent");
            if (opponent != null && opponent.GetType() == typeof(JSONDict))
            {
                JSONDict opponentData = (JSONDict)opponent;
                Opponent = new Player(opponentData);
                OpponentCurrentTotalScore = opponentData.SafeGetDoubleValue("currentTotalScore");
            }
            else
            {
                Opponent = new Player();
                OpponentCurrentTotalScore = null;
            }
        }
示例#2
0
    public static SkillzSDK.Player GetPlayer()
    {
        var playerNative = GetSkillz().CallStatic <AndroidJavaObject>("getPlayerDetails", GetCurrentActivity());

        Dictionary <string, object> map = new Dictionary <string, object> ();

        map.Add("userName", playerNative.Call <string>("getUserName"));
        map.Add("userId", Convert.ToUInt32(playerNative.Call <string>("getUserId"), 10));
        map.Add("avatarUrl", playerNative.Call <string>("getAvatarUrl"));
        map.Add("flagUrl", playerNative.Call <string>("getFlagUrl"));
        map.Add("playerMatchId", playerNative.Call <string>("getPlayerMatchId"));
        map.Add("isCurrentPlayer", playerNative.Call <bool>("isCurrentPlayer").ToString());

        SkillzSDK.Player playerObj = new SkillzSDK.Player(map);

        return(playerObj);
    }
        public Match(JSONDict jsonData)
        {
            Description = jsonData.SafeGetStringValue("matchDescription");
            EntryCash = jsonData.SafeGetIntValue("entryCash");
            EntryPoints = jsonData.SafeGetIntValue("entryPoints");
            ID = jsonData.SafeGetIntValue("id");
            TemplateID = jsonData.SafeGetIntValue("templateId");
            Name = jsonData.SafeGetStringValue("name");
            IsCash = jsonData.SafeGetBoolValue("isCash");

            object player = jsonData.SafeGetValue("player");
            if (player != null && player.GetType() == typeof(JSONDict))
            {
                JSONDict playerData = (JSONDict)player;
                Player = new Player(playerData);
            }
            else
            {
                Player = new Player();
            }

            GameParams = new Dictionary<string, string>();
            object parameters = jsonData.SafeGetValue("gameParameters");
            if (parameters != null && parameters.GetType() == typeof(JSONDict))
            {
                foreach (KeyValuePair<string, object> kvp in (JSONDict)parameters)
                {
                    if (kvp.Value == null)
                    {
                        continue;
                    }

                    string val = kvp.Value.ToString();
                    if (kvp.Key == "skillz_difficulty")
                    {
                        SkillzDifficulty = Helpers.SafeUintParse(val);
                    }
                    else
                    {
                        GameParams.Add(kvp.Key, val);
                    }
                }
            }
        }