示例#1
0
        public async Task <LeaderboardRecord> SaveAsync(LeaderboardRecord record)
        {
            await table.CreateIfNotExistsAsync();

            var result = await table.ExecuteAsync(TableOperation.InsertOrMerge(new LeaderboardRecordEntity(record)));

            var entity = result.Result as LeaderboardRecordEntity;

            return(entity.ToRecord());
        }
示例#2
0
 public void Set(LeaderboardRecord other)
 {
     if (other != null)
     {
         m_ApiVersion    = LeaderboardsInterface.LeaderboardrecordApiLatest;
         UserId          = other.UserId;
         Rank            = other.Rank;
         Score           = other.Score;
         UserDisplayName = other.UserDisplayName;
     }
 }
示例#3
0
 public LeaderboardRecordEntity(LeaderboardRecord record)
 {
     PartitionKey    = record.EventId.ToString("N");
     RowKey          = Guid.NewGuid().ToString("N");
     EventId         = record.EventId;
     PlayerName      = record.PlayerName;
     LeaderboardName = record.LeaderboardName;
     SubIndex        = record.SubIndex;
     Score           = record.Score;
     ScoreDisplay    = record.ScoreDisplay;
 }
示例#4
0
        public ActionResult CreateRecord(int leaderBoardId, LeaderboardRecord leaderBoardRecord)
        {
            leaderBoardRecord.LeaderboardId = leaderBoardId;
            leaderBoardRecord.RecordCreated = DateTime.Now;
            leaderBoardRecord.RecordHolder  = GetCurrentUserDetail();

            if (ModelState.IsValid)
            {
                db.LeaderboardRecords.Add(leaderBoardRecord);
                db.SaveChanges();
                return(RedirectToAction("Details", new { id = leaderBoardId }));
            }

            return(View(leaderBoardRecord));
        }
示例#5
0
 internal NLeaderboardRecord(LeaderboardRecord message)
 {
     LeaderboardId = message.LeaderboardId;
     OwnerId       = message.OwnerId;
     Handle        = message.Handle;
     Lang          = message.Lang;
     Location      = message.Location;
     Timezone      = message.Timezone;
     Rank          = message.Rank;
     Score         = message.Score;
     NumScore      = message.NumScore;
     Metadata      = message.Metadata;
     RankedAt      = message.RankedAt;
     UpdatedAt     = message.UpdatedAt;
     ExpiresAt     = message.ExpiresAt;
 }
    void DisplayLeaderBoard(LeaderboardRecord[] lead)
    {
        //calculate the width and height of each child item.
        float width = LeaderBoardRectView.rect.width / columnCount;
        float ratio = width / LeaderBoardPrefabRect.rect.width;
        float height = LeaderBoardPrefabRect.rect.height * ratio;
        int rowCount = lead.Length / columnCount;
        if (rowCount > 0)
        {
            if (lead.Length % rowCount > 0)
                rowCount++;
        }

        //adjust the height of the container so that it will just barely fit all its children
        float scrollHeight = height * rowCount;
        LeaderBoardRectView.offsetMin = new Vector2(LeaderBoardRectView.offsetMin.x, -scrollHeight / 2);
        LeaderBoardRectView.offsetMax = new Vector2(LeaderBoardRectView.offsetMax.x, scrollHeight / 2);

        int j = 0;
        for (int i = 0; i < lead.Length; i++)
        {
            //this is used instead of a double for loop because itemCount may not fit perfectly into the rows/columns
            if (i % columnCount == 0)
                j++;

            //create a new item, name it, and set the parent
            GameObject newItem = Instantiate(leaderPrefab) as GameObject;
            newItem.transform.SetParent(LeaderboardRectViewParent.transform, false);
            Debug.Log(newItem);
            leader.Add(newItem);
            //move and size the new item
            RectTransform rectTransform = newItem.GetComponent<RectTransform>();

            float x = -LeaderBoardRectView.rect.width / 2 + width * (i % columnCount);
            float y = LeaderBoardRectView.rect.height / 2 - height * j;
            rectTransform.offsetMin = new Vector2(x, y);

            x = rectTransform.offsetMin.x + width;
            y = rectTransform.offsetMin.y + height;
            rectTransform.offsetMax = new Vector2(x, y);

            string url = "http://5.9.251.204/api/user/" + lead[i];
            WWW www = new WWW(url);
            StartCoroutine(GetUserInfo(www, newItem, i));

        }
    }
示例#7
0
    // Parses the jsonObject and returns a list of LeaderBoardRecords
    private List <LeaderboardRecord> LeaderboardRecordListFromJSON(JSONObject jsonObject)
    {
        List <LeaderboardRecord> leaderboard = new List <LeaderboardRecord>();

        if (jsonObject.type == JSONObject.Type.ARRAY)
        {
            foreach (JSONObject j in jsonObject.list)
            {
                LeaderboardRecord record = new LeaderboardRecord();
                for (int i = 0; i < j.list.Count; i++)
                {
                    string     key = (string)j.keys[i];
                    JSONObject val = (JSONObject)j.list[i];
                    switch (key)
                    {
                    case "position":
                        record.position = (int)val.n;
                        break;

                    case "uid":
                        record.uid = val.str;
                        break;

                    case "isMine":
                        record.isMine = ((int)val.n) == 1;
                        break;

                    case "score":
                        record.score = (int)val.n;
                        break;

                    case "name":
                        record.name = val.str;
                        break;

                    default:
                        break;
                    }
                }
                leaderboard.Add(record);
            }
        }
        return(leaderboard);
    }
        public ActionResult Create(LeaderboardRecord leaderBoardRecord)
        {
            var username = User.Identity.Name;
            var id       = User.Identity.GetUserId();
            //if(id != null)
            //    post.CreatedById = id;

            string currentUserId = User.Identity.GetUserId();
            var    UserDetail    = db.UserDetails.FirstOrDefault(x => x.ApplicationIdentityId == currentUserId);

            leaderBoardRecord.RecordCreated = DateTime.Now;
            leaderBoardRecord.RecordHolder  = UserDetail;

            if (ModelState.IsValid)
            {
                db.LeaderboardRecords.Add(leaderBoardRecord);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(leaderBoardRecord));
        }
示例#9
0
        /// <summary>
        /// Fetches a leaderboard record from a given user ID.
        /// <seealso cref="Release" />
        /// </summary>
        /// <param name="options">Structure containing the user ID being accessed.</param>
        /// <param name="outLeaderboardRecord">The leaderboard record for the given user ID, if it exists and is valid, use <see cref="Release" /> when finished.</param>
        /// <returns>
        /// <see cref="Result.Success" /> if the leaderboard record is available and passed out in OutLeaderboardRecord
        /// <see cref="Result.InvalidParameters" /> if you pass a null pointer for the out parameter
        /// <see cref="Result.NotFound" /> if the leaderboard data is not found
        /// </returns>
        public Result CopyLeaderboardRecordByUserId(CopyLeaderboardRecordByUserIdOptions options, out LeaderboardRecord outLeaderboardRecord)
        {
            System.IntPtr optionsAddress = new System.IntPtr();
            Helper.TryMarshalSet <CopyLeaderboardRecordByUserIdOptionsInternal, CopyLeaderboardRecordByUserIdOptions>(ref optionsAddress, options);

            var outLeaderboardRecordAddress = System.IntPtr.Zero;

            var funcResult = EOS_Leaderboards_CopyLeaderboardRecordByUserId(InnerHandle, optionsAddress, ref outLeaderboardRecordAddress);

            Helper.TryMarshalDispose(ref optionsAddress);

            if (Helper.TryMarshalGet <LeaderboardRecordInternal, LeaderboardRecord>(outLeaderboardRecordAddress, out outLeaderboardRecord))
            {
                EOS_Leaderboards_LeaderboardRecord_Release(outLeaderboardRecordAddress);
            }

            return(funcResult);
        }