/// <summary> /// Test Method for saving the user score in App42 Cloud. /// </summary> public static void SaveUserScore() { /// Enter your Public Key and Private Key Here in Constructor. You can /// get it once you will create a app in app42 console. ServiceAPI sp = new ServiceAPI("<Your_API_Key>", "<Your_Secret_Key>"); String gameName = "PokerGame"; String userName = "******"; double gameScore = 3500; String description = "description"; /// Create Instance of ScoreBoard Service ScoreBoardService scoreBoardService = sp.BuildScoreBoardService(); GameService gameService = sp.BuildGameService(); try { Game saveScore = scoreBoardService.SaveUserScore(gameName,userName,gameScore); Console.WriteLine("gameName is " + saveScore.GetName()); for (int i = 0; i < saveScore.GetScoreList().Count; i++) { Console.WriteLine("userName is : " + saveScore.GetScoreList()[i].GetUserName()); Console.WriteLine("score is : " + saveScore.GetScoreList()[i].GetValue()); Console.WriteLine("scoreId is : " + saveScore.GetScoreList()[i].GetScoreId()); } } catch (App42Exception ex) { /// Exception Caught /// Do exception Handling of Score Board Service functions. if (ex.GetAppErrorCode() == 3002) { Game createGame = gameService.CreateGame(gameName, description); Console.WriteLine("gameName is " + createGame.GetName()); Game game = scoreBoardService.SaveUserScore(gameName, userName, gameScore); Console.WriteLine("gameName is " + game.GetName()); for (int i = 0; i < game.GetScoreList().Count; i++) { Console.WriteLine("userName is : " + game.GetScoreList()[i].GetUserName()); Console.WriteLine("score is : " + game.GetScoreList()[i].GetValue()); Console.WriteLine("scoreId is : " + game.GetScoreList()[i].GetScoreId()); } } else if (ex.GetAppErrorCode() == 1401) { Console.WriteLine("Please verify your API_KEY and SECRET_KEY From AppHq Console (Apphq.shephertz.com)."); } else { Console.WriteLine("Exception is : " + ex.ToString()); } } Console.ReadKey(); }
/// <summary> /// Test Method for saving the user score in App42 Cloud. /// </summary> public static void SaveUserScore() { /// Enter your Public Key and Private Key Here in Constructor. You can /// get it once you will create a app in app42 console. ServiceAPI sp = new ServiceAPI("<Your_API_Key>", "<Your_Secret_Key>"); String gameName = "PokerGame"; String userName = "******"; double gameScore = 3500; String description = "description"; /// Create Instance of ScoreBoard Service ScoreBoardService scoreBoardService = sp.BuildScoreBoardService(); GameService gameService = sp.BuildGameService(); try { Game saveScore = scoreBoardService.SaveUserScore(gameName, userName, gameScore); Console.WriteLine("gameName is " + saveScore.GetName()); for (int i = 0; i < saveScore.GetScoreList().Count; i++) { Console.WriteLine("userName is : " + saveScore.GetScoreList()[i].GetUserName()); Console.WriteLine("score is : " + saveScore.GetScoreList()[i].GetValue()); Console.WriteLine("scoreId is : " + saveScore.GetScoreList()[i].GetScoreId()); } } catch (App42Exception ex) { /// Exception Caught /// Do exception Handling of Score Board Service functions. if (ex.GetAppErrorCode() == 3002) { Game createGame = gameService.CreateGame(gameName, description); Console.WriteLine("gameName is " + createGame.GetName()); Game game = scoreBoardService.SaveUserScore(gameName, userName, gameScore); Console.WriteLine("gameName is " + game.GetName()); for (int i = 0; i < game.GetScoreList().Count; i++) { Console.WriteLine("userName is : " + game.GetScoreList()[i].GetUserName()); Console.WriteLine("score is : " + game.GetScoreList()[i].GetValue()); Console.WriteLine("scoreId is : " + game.GetScoreList()[i].GetScoreId()); } } else if (ex.GetAppErrorCode() == 1401) { Console.WriteLine("Please verify your API_KEY and SECRET_KEY From AppHq Console (Apphq.shephertz.com)."); } else { Console.WriteLine("Exception is : " + ex.ToString()); } } Console.ReadKey(); }
void OnGUI() { if (Time.time % 2 < 1) { success = callBack.getResult(); } // For Setting Up ResponseBox. GUI.TextArea(new Rect(10, 5, 1300, 175), success); //======================================{{{{************}}}}================================ if (GUI.Button(new Rect(470, 160, 200, 30), "CreateGame")) { App42Log.SetDebug(true); gameService = sp.BuildGameService(); // Initializing ScoreBoard Service. gameService.CreateGame(cons.gameName, cons.description, callBack); } //======================================{{{{************}}}}================================ if (GUI.Button(new Rect(50, 200, 200, 30), "SaveUserScore")) { App42Log.SetDebug(true); scoreBoardService = sp.BuildScoreBoardService(); // Initializing ScoreBoard Service. scoreBoardService.SaveUserScore(cons.gameName, cons.userName, userScore, callBack); } //======================================{{{{************}}}}================================= if (GUI.Button(new Rect(260, 200, 200, 30), "GetScoresByUser")) { scoreBoardService = sp.BuildScoreBoardService(); // Initializing ScoreBoard Service. scoreBoardService.GetScoresByUser(cons.gameName, cons.userName, callBack); } //======================================{{{{************}}}}========================================== if (GUI.Button(new Rect(470, 200, 200, 30), "GetHighestScoreByUser")) { scoreBoardService = sp.BuildScoreBoardService(); // Initializing ScoreBoard Service. scoreBoardService.GetHighestScoreByUser(cons.gameName, cons.userName, callBack); } //======================================{{{{************}}}}========================================== if (GUI.Button(new Rect(680, 200, 200, 30), "GetLowestScoreByUser")) { scoreBoardService = sp.BuildScoreBoardService(); // Initializing ScoreBoard Service. scoreBoardService.GetLowestScoreByUser(cons.gameName, cons.userName, callBack); } //======================================{{{{************}}}}========================================== if (GUI.Button(new Rect(890, 200, 200, 30), "GetTopRankings")) { scoreBoardService = sp.BuildScoreBoardService(); // Initializing ScoreBoard Service. scoreBoardService.GetTopRankings(cons.gameName, callBack); } //======================================{{{{************}}}}========================================== if (GUI.Button(new Rect(50, 250, 200, 30), "GetAverageScoreByUser")) { scoreBoardService = sp.BuildScoreBoardService(); // Initializing ScoreBoard Service. scoreBoardService.GetAverageScoreByUser(cons.gameName, cons.userName, callBack); } //======================================{{{{************}}}}========================================== if (GUI.Button(new Rect(260, 250, 200, 30), "GetLastScoreByUser")) { scoreBoardService = sp.BuildScoreBoardService(); // Initializing ScoreBoard Service. scoreBoardService.GetLastScoreByUser(cons.gameName, cons.userName, callBack); } //======================================{{{{************}}}}========================================== if (GUI.Button(new Rect(470, 250, 200, 30), "GetTopRankings")) { scoreBoardService = sp.BuildScoreBoardService(); // Initializing ScoreBoard Service. scoreBoardService.GetTopRankings(cons.gameName, callBack); } //======================================{{{{************}}}}========================================== if (GUI.Button(new Rect(680, 250, 200, 30), "GetTopNRankings")) { scoreBoardService = sp.BuildScoreBoardService(); // Initializing ScoreBoard Service. scoreBoardService.GetTopNRankings(cons.gameName, max, callBack); } //======================================{{{{************}}}}========================================== if (GUI.Button(new Rect(890, 250, 200, 30), "GetTopNRankers")) { scoreBoardService = sp.BuildScoreBoardService(); // Initializing ScoreBoard Service. scoreBoardService.GetTopNRankers(cons.gameName, max, callBack); } }