• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java LeaderboardScore类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.google.android.gms.games.leaderboard.LeaderboardScore的典型用法代码示例。如果您正苦于以下问题:Java LeaderboardScore类的具体用法?Java LeaderboardScore怎么用?Java LeaderboardScore使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



LeaderboardScore类属于com.google.android.gms.games.leaderboard包,在下文中一共展示了LeaderboardScore类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: scoresToJsonString

import com.google.android.gms.games.leaderboard.LeaderboardScore; //导入依赖的package包/类
private String scoresToJsonString( LeaderboardScoreBuffer scores ) {

        int scoresNb = scores.getCount();
        JSONArray jsonScores = new JSONArray();
        for ( int i = 0; i < scoresNb; ++i ) {
            LeaderboardScore score = scores.get(i);
            JSONObject jsonScore = new JSONObject();
            try {
                jsonScore.put("value", score.getRawScore());
                jsonScore.put("rank", score.getRank());

                Player player = score.getScoreHolder();
                JSONObject jsonPlayer = new JSONObject();
                jsonPlayer.put("id", player.getPlayerId());
                jsonPlayer.put("displayName", player.getDisplayName());
                jsonPlayer.put("picture", player.getIconImageUri());

                jsonScore.put("player", jsonPlayer);

                jsonScores.put( jsonScore );

            } catch( JSONException e ) {}
        }
        return jsonScores.toString();

    }
 
开发者ID:freshplanet,项目名称:ANE-Google-Play-Game-Services,代码行数:27,代码来源:ExtensionContext.java


示例2: getLeaderboardValue

import com.google.android.gms.games.leaderboard.LeaderboardScore; //导入依赖的package包/类
public void getLeaderboardValue(final String id) {
     if (googleApiClient == null || !googleApiClient.isConnected()) return;
     activity.runOnUiThread(new Runnable() {
	@Override
         public void run() {
             Games.Leaderboards.loadCurrentPlayerLeaderboardScore(googleApiClient, id, LeaderboardVariant.TIME_SPAN_ALL_TIME, LeaderboardVariant.COLLECTION_PUBLIC).setResultCallback(new ResultCallback<LoadPlayerScoreResult>() {
                 @Override
                 public void onResult(LoadPlayerScoreResult result) {
                     Status status = result.getStatus();
                     if (status.getStatusCode() == GamesStatusCodes.STATUS_OK) {
                         LeaderboardScore score = result.getScore();
                         if (score != null) {
                             int scoreValue = (int) score.getRawScore();
                             Log.d(TAG, "GPGS: Leaderboard values is " + score.getDisplayScore());
                             GodotLib.calldeferred(instance_id, "_on_leaderboard_get_value", new Object[]{ scoreValue, id });
                         } else {
                             Log.d(TAG, "GPGS: getLeaderboardValue STATUS_OK but is NULL -> Request again...");
                             getLeaderboardValue(id);
                         }
                     } else if (status.getStatusCode() == GamesStatusCodes.STATUS_CLIENT_RECONNECT_REQUIRED) {
                         Log.d(TAG, "GPGS: getLeaderboardValue reconnect required -> reconnecting...");
                         googleApiClient.reconnect();
                     } else {
                         Log.d(TAG, "GPGS: getLeaderboardValue connection error -> " + status.getStatusMessage());
                         GodotLib.calldeferred(instance_id, "_on_leaderboard_get_value_error", new Object[]{ id });
                     }
                 }
             });
             Log.d(TAG, "GPGS: getLeaderboardValue '" + id + "'.");
	}
});
 }
 
开发者ID:kloder-games,项目名称:godot-gpgs,代码行数:33,代码来源:Leaderboards.java


示例3: processLoadScoreResult

import com.google.android.gms.games.leaderboard.LeaderboardScore; //导入依赖的package包/类
private void processLoadScoreResult(LoadPlayerScoreResult result, String leaderboardId, int by, final Future<Boolean> future) {
    if (result.getStatus().isSuccess()) {
        LeaderboardScore score = result.getScore();
        long current = score == null ? 0 : score.getRawScore();
        Games.Leaderboards
            .submitScoreImmediate(
                helper.getApiClient(),
                leaderboardId,
                current + by
            )
            .setResultCallback(new ResultCallback<Leaderboards.SubmitScoreResult>() {
                @Override public void onResult(Leaderboards.SubmitScoreResult submitResult) {
                    final boolean success = submitResult.getStatus().isSuccess();
                    Gdx.app.postRunnable(new Runnable() {
                        @Override public void run() {
                            future.happen(success);
                        }
                    });
                }
            });
    } else {
        Gdx.app.postRunnable(new Runnable() {
            @Override public void run() {
                future.happen(false);
            }
        });
    }
}
 
开发者ID:ratrecommends,项目名称:dice-heroes,代码行数:29,代码来源:GameServicesHelper.java


示例4: getPlayerRecord

import com.google.android.gms.games.leaderboard.LeaderboardScore; //导入依赖的package包/类
@Override
public int getPlayerRecord() {
  final AtomicBoolean found = new AtomicBoolean();
  Games.Leaderboards.loadPlayerCenteredScores(aHelper.getApiClient(), Leaderboard.MOST_POINTS, 1,
          1,
          25).setResultCallback(new ResultCallback<Leaderboards.LoadScoresResult>() {

    @Override
    public void onResult(Leaderboards.LoadScoresResult arg0) {
      found.set(true);
    }
  });
  while (!found.get()) {

  }
  found.set(false);
  final AtomicLong score = new AtomicLong(0);
  Games.Leaderboards.loadCurrentPlayerLeaderboardScore(aHelper.getApiClient(), Leaderboard.MOST_POINTS, LeaderboardVariant.TIME_SPAN_ALL_TIME, LeaderboardVariant.COLLECTION_PUBLIC).setResultCallback(new ResultCallback<Leaderboards.LoadPlayerScoreResult>() {

    @Override
    public void onResult(Leaderboards.LoadPlayerScoreResult result) {
      if (result != null && result.getScore() != null) {
        LeaderboardScore lbScore = result.getScore();
        score.set(lbScore.getRawScore());
      }
      found.set(true);
    }
  });
  while (!found.get()) {

  }
  return Math.round(score.get());
}
 
开发者ID:bitbrain,项目名称:clouboy,代码行数:34,代码来源:AndroidLauncher.java


示例5: y

import com.google.android.gms.games.leaderboard.LeaderboardScore; //导入依赖的package包/类
public Leaderboards.LoadPlayerScoreResult y(final Status paramStatus)
{
  return new Leaderboards.LoadPlayerScoreResult()
  {
    public LeaderboardScore getScore()
    {
      return null;
    }

    public Status getStatus()
    {
      return paramStatus;
    }
  };
}
 
开发者ID:mmmsplay10,项目名称:QuizUpWinner,代码行数:16,代码来源:fw.java


示例6: incrementScore

import com.google.android.gms.games.leaderboard.LeaderboardScore; //导入依赖的package包/类
/**
 * Increments current score to leaderboard
 * @param pLeaderboard
 * @param pScore
 */
public void incrementScore(final String pLeaderboard, final long pScore){
	if(isSignedIn() == false)
		return;
	final String playerId = getGamesClient().getCurrentPlayer().getPlayerId();
	//Toast.makeText(this, "increment " + playerId, Toast.LENGTH_LONG).show();
	getGamesClient().loadPlayerCenteredScores(new OnLeaderboardScoresLoadedListener() {
		@Override
		public void onLeaderboardScoresLoaded(int arg0, LeaderboardBuffer arg1, LeaderboardScoreBuffer arg2) {
			Iterator <LeaderboardScore> it =arg2.iterator();
			//Toast.makeText(ActivityBaseGameLeaderboard.this, "on score loaded", Toast.LENGTH_LONG).show();
			if(it.hasNext() == false){
				//Toast.makeText(ActivityBaseGameLeaderboard.this, "first submit", Toast.LENGTH_LONG).show();
				submitScore(pLeaderboard, pScore);
				return;
			}
			while(it.hasNext()){
				LeaderboardScore lbScore = it.next();
				long score = lbScore.getRawScore();
				//Toast.makeText(ActivityBaseGameLeaderboard.this, score + " " + lbScore.getScoreHolder().getPlayerId(), Toast.LENGTH_LONG).show();
				if(lbScore.getScoreHolder().getPlayerId().equals(playerId)){
					submitScore(pLeaderboard, pScore + score);
				}
			}
		}
	}, pLeaderboard, LeaderboardVariant.TIME_SPAN_ALL_TIME, LeaderboardVariant.COLLECTION_PUBLIC, 1);
}
 
开发者ID:laurion,项目名称:wabbit-client,代码行数:32,代码来源:GameHelper.java


示例7: fetchLeaderboardEntriesSync

import com.google.android.gms.games.leaderboard.LeaderboardScore; //导入依赖的package包/类
private boolean fetchLeaderboardEntriesSync(String leaderBoardId, int limit, boolean relatedToPlayer,
                                            IFetchLeaderBoardEntriesResponseListener callback) {
    if (!isSessionActive())
        return false;

    if (gpgsLeaderboardIdMapper != null)
        leaderBoardId = gpgsLeaderboardIdMapper.mapToGsId(leaderBoardId);

    Leaderboards.LoadScoresResult scoresResult =
            (relatedToPlayer ?
                    Games.Leaderboards.loadTopScores(mGoogleApiClient, leaderBoardId,
                            LeaderboardVariant.TIME_SPAN_ALL_TIME, LeaderboardVariant.COLLECTION_PUBLIC,
                            MathUtils.clamp(limit, 1, 25), forceRefresh).await()
                    :
                    Games.Leaderboards.loadPlayerCenteredScores(mGoogleApiClient, leaderBoardId,
                            LeaderboardVariant.TIME_SPAN_ALL_TIME, LeaderboardVariant.COLLECTION_PUBLIC,
                            MathUtils.clamp(limit, 1, 25), forceRefresh).await());

    if (!scoresResult.getStatus().isSuccess()) {
        Gdx.app.log(GAMESERVICE_ID, "Failed to fetch leaderboard entries:" +
                scoresResult.getStatus().getStatusMessage());
        callback.onLeaderBoardResponse(null);
        return false;
    }

    LeaderboardScoreBuffer scores = scoresResult.getScores();

    Array<ILeaderBoardEntry> gpgsLbEs = new Array<ILeaderBoardEntry>(scores.getCount());
    String playerDisplayName = getPlayerDisplayName();

    for (LeaderboardScore score : scores) {
        GpgsLeaderBoardEntry gpgsLbE = new GpgsLeaderBoardEntry();

        gpgsLbE.userDisplayName = score.getScoreHolderDisplayName();
        gpgsLbE.currentPlayer = gpgsLbE.userDisplayName.equalsIgnoreCase(playerDisplayName);
        gpgsLbE.formattedValue = score.getDisplayScore();
        gpgsLbE.scoreRank = score.getDisplayRank();
        gpgsLbE.userId = score.getScoreHolder().getPlayerId();
        gpgsLbE.sortValue = score.getRawScore();
        gpgsLbE.scoreTag = score.getScoreTag();

        gpgsLbEs.add(gpgsLbE);
    }

    scores.release();

    callback.onLeaderBoardResponse(gpgsLbEs);

    return true;
}
 
开发者ID:MrStahlfelge,项目名称:gdx-gamesvcs,代码行数:51,代码来源:GpgsClient.java


示例8: getScore

import com.google.android.gms.games.leaderboard.LeaderboardScore; //导入依赖的package包/类
public final LeaderboardScore getScore()
{
  return this.uq;
}
 
开发者ID:mmmsplay10,项目名称:QuizUpWinner,代码行数:5,代码来源:fl.java


示例9: onLeaderboardScoresLoaded

import com.google.android.gms.games.leaderboard.LeaderboardScore; //导入依赖的package包/类
public void onLeaderboardScoresLoaded(int statusCode,
		LeaderboardBuffer leaderboard, LeaderboardScoreBuffer scores) {
	boolean found = false;
	if (statusCode == GamesClient.STATUS_OK && mGLView != null && mGLView.mRenderer != null) {
		String mId = mGamesClient.getCurrentPlayerId();
		Log.i(TAG, "onLeaderboardScoresLoaded: ");
		for (int i = 0; i < scores.getCount(); ++i) {
			LeaderboardScore score = scores.get(i);
			LeaderboardScore fScore = score.freeze();
			if (fScore.getScoreHolder().getPlayerId().equals(mId)) {
				found = true;
				Log.i(TAG, "Found me at position " + i);
				mGLView.mRenderer.setMyStats(fScore.getDisplayRank(), fScore.getDisplayScore(), (int)fScore.getRawScore());
				if (i > 0) {
					Log.i(TAG, "Found prev ");
					LeaderboardScore prevScore = scores.get(i-1).freeze();
					mGLView.mRenderer.setPrevPlayer(prevScore.getDisplayRank(), prevScore.getDisplayScore());
				}
				else {
					mGLView.mRenderer.setPrevPlayer("", "");
				}
				if (i < scores.getCount()-1) {
					Log.i(TAG, "Found next ");
					LeaderboardScore nextScore = scores.get(i+1).freeze();
					mGLView.mRenderer.setNextPlayer(nextScore.getDisplayRank(), nextScore.getDisplayScore());
				}
				else {
					mGLView.mRenderer.setNextPlayer("", "");
				}
				break;
			}
		}
		if (!found) {
			mGLView.mRenderer.setMyStats("", "", -1);
		}
	}
	else {
		Toast.makeText(this, "Error retrieving scores " + statusCode, Toast.LENGTH_SHORT).show();
	}
	leaderboard.close();
	scores.close();

}
 
开发者ID:d3alek,项目名称:TheHunt---Interactive-graphical-platform-for-AI-Experiments,代码行数:44,代码来源:TheHunt.java



注:本文中的com.google.android.gms.games.leaderboard.LeaderboardScore类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java OFFeaturesRequest类代码示例发布时间:2022-05-22
下一篇:
Java NoFilepatternException类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap