/// <summary> /// 更新排行榜 /// </summary> /// <param name="data"></param> public void UpdateRankingList(BmobTab_RankingList data) { if (data == null || mPlayerInfoList == null) { return; } BmobTab_RankingList ss = mPlayerInfoList.Find(a => a.objectId == data.objectId); if (ss != null) { //更新 BmobManager.Instance.updateData <BmobTab_RankingList>(data, ss.objectId, BmobTab_RankingList.TABLENAME); ss = data; } else { BmobManager.Instance.InsertData <BmobTab_RankingList>(data, BmobTab_RankingList.TABLENAME); mPlayerInfoList.Add(data); } //判断是否多了 if (RankingModel.Instance.mPlayerInfoList.Count > Setting.RankingListMax) //删除最后一个 { int minScore = int.Parse(mPlayerInfoList[mPlayerInfoList.Count - 1].Money.ToString()); int curScore = int.Parse(data.Money.ToString()); if (minScore < curScore) { BmobTab_RankingList dd = mPlayerInfoList[mPlayerInfoList.Count - 1]; BmobManager.Instance.deleteData(dd.objectId, BmobTab_RankingList.TABLENAME); mPlayerInfoList.Remove(mPlayerInfoList.Find(a => a.Money == dd.Money)); } } ///更新界面显示 RankingListView.instance.UpdateView(); }
private int ScoreCompare(BmobTab_RankingList x, BmobTab_RankingList y) { int xMoney = int.Parse(x.Money.ToString()); int yMoney = int.Parse(y.Money.ToString()); if (xMoney > yMoney) { return(-1); } return(1); }