public SimpleFriendData[] GetRankerFive() { List <GameUser> rankersInGame = GAME_DATA.getFriendDistanceRankingWithoutMe(); SimpleFriendData[] returnValue = new SimpleFriendData[5]; for (int i = 0; i < returnValue.Length; i++) { returnValue[i] = new SimpleFriendData(); returnValue[i].distance = -1; } int totalAvailableNum = 0; for (int i = rankersInGame.Count - 1; i >= 0; i--) { if (rankersInGame[i].weekDistance > 0) { totalAvailableNum = i + 1; break; } } if (totalAvailableNum > 0) { if (totalAvailableNum < 5) { for (int i = 0; i < totalAvailableNum; i++) { returnValue[i].userId = rankersInGame[rankersInGame.Count - i - 1].userID; //returnValue[i].distance = rankersInGame[i].weekDistance*10; returnValue[i].distance = 20000 * (i + 1); returnValue[i].faceurl = rankersInGame[i].image_url; } } else { float dIndex = (float)totalAvailableNum / 5f; int i = 4; for (float tmpStartIndex = totalAvailableNum - 1; tmpStartIndex >= 0; tmpStartIndex -= dIndex) { returnValue[i].userId = rankersInGame[(int)tmpStartIndex].userID; returnValue[i].faceurl = rankersInGame[(int)tmpStartIndex].image_url; returnValue[i].distance = rankersInGame[(int)tmpStartIndex].weekDistance * 10; i--; } } } return(returnValue); }
public void LoadRankers() { rankers = GAME_DATA.getFriendRanking(); }