private void SaveResult() { Leaderboard.Add(playground.p1.Points - (playground.p1.Steps - 56) * 5 - (TimeControl.Current - 15) * 5, user.Nickname); Connection.ExecNonQuery($"INSERT INTO [{user.Nickname}] VALUES ('{playground.p1.Points - (playground.p1.Steps - 56) * 5 - (TimeControl.Current - 15) * 5}')"); Leaderboard.Print(); winPanel.Visible = false; LeaderboardPanel.Visible = true; }
void InstantiateScore(Player player) { PlayerScore newScore = InstantiateScore(); newScore.SetPlayer(player); Leaderboard.Add(newScore); }
private void PushButton_Click(object sender, RoutedEventArgs e) { Leaderboard lb = new Leaderboard(); lb.Add(NameTextBox.Text, Points); lb.Sort(); lb.Cut(); lb.Serialize(); Close(); }
/// <summary> /// Inject Player to leaderboard /// </summary> /// <param name="Token"></param> /// <param name="Detail"> /// 1:TokenLeaderboard /// 2:Data /// 3:Studio /// </param> /// <returns></returns> public async Task Add(string Token, string Studio, string TokenPlayer, string NameLeaderboard, string Value) { if (await LeaderboardModel.Add(Token, Studio, TokenPlayer, NameLeaderboard, Value)) { Response.StatusCode = Ok().StatusCode; } else { Response.StatusCode = BadRequest().StatusCode; } }
private void LoadLeaderboard() { var data = _dataStorage.StarredMessages; _leaderboard = new Dictionary <MalUser, List <StarredForumMessage> >(); foreach (var user in data.Keys.OrderByDescending(s => data[s].Count)) { Leaderboard.Add(data[user][0].Poster, data[user]); } RaisePropertyChanged(() => Leaderboard); RaisePropertyChanged(() => EmptyNoticeVisibility); }
public async Task Leaderboard() { IEnumerable <UserRank> userRanks = await Db.GetRanksAsync(); ILeaderboard leaderboard = new Leaderboard(); foreach (UserRank userRank in userRanks) { IUser user = Context.Guild is null ? null : await Context.Guild.GetUserAsync(userRank.User.Id); leaderboard.Add(user?.Username ?? userRank.User.Username, userRank.User.SubmissionCount); } await ReplyLeaderboardAsync(leaderboard); }
protected internal override void Deserialize(BinaryReader br) { CarId = br.ReadByte(); LapTime = br.ReadUInt32(); Cuts = br.ReadByte(); var leaderboardCount = br.ReadByte(); Leaderboard.Clear(); for (int i = 0; i < leaderboardCount; i++) { Leaderboard.Add(MsgLapCompletedLeaderboardEnty.FromBinaryReader(br)); } GripLevel = br.ReadSingle(); }
public void Can_serialize_leaderboard_objects() { var target = new Leaderboard(); target .Add("Abdul-Jabbar", 38387, 1560, 24.6m) .Add("Karl Malone", 36928, 1476, 25.0m) .Add("Michael Jordan", 32292, 1072, 30.1m) .Add("W. Chamberlain", 31419, 1045, 30.1m) .Add("Kobe Bryant", 29484, 1161, 25.4m) .Add("Shaq O Neal", 28596, 1207, 23.7m) .Add("Moses Malone", 27409, 1329, 20.6m) .Add("Elvis Hayes", 28313, 1303, 21.0m) .Add("H. Olajuwon", 26946, 1238, 21.8m); string result = Serializer.Serialize(target); result.Should().NotBeNullOrEmpty(); }
public void PopulateLeaderBoard() { FirebaseDatabase.DefaultInstance .GetReference("Leaders").OrderByChild("score") .GetValueAsync().ContinueWith(task => { if (task.IsFaulted) { // Handle the error... } else if (task.IsCompleted) { DataSnapshot snapshot = task.Result; if (snapshot != null && snapshot.ChildrenCount > 0) { foreach (var childSnapshot in snapshot.Children) { if (childSnapshot.Child("score") == null || childSnapshot.Child("score").Value == null) { Debug.LogError("Bad data in sample. Did you forget to call SetEditorDatabaseUrl with your project id?"); break; } else { Dictionary <string, object> scoreMap = new Dictionary <string, object>(); scoreMap["name"] = childSnapshot.Child("name").Value; scoreMap["score"] = childSnapshot.Child("score").Value; scoreMap["email"] = childSnapshot.Child("email").Value; Debug.Log("Retrieved Score for " + scoreMap["name"] + " " + scoreMap["score"]); GameObject leaderEntry = Instantiate(LeaderboardEntry); LeaderboardEntry entry = new LeaderboardEntry(leaderEntry, scoreMap["name"].ToString(), scoreMap["score"].ToString()); scoreMap["entry"] = entry; //Add to list of LeaderboardEntries (accessible between all screens) Leaders.Add(entry); Leaderboard.Add(scoreMap); } } DisplayLoaderboard(); } } }); }
private void SpawnCars() { _carSpawners = GameObject.FindGameObjectsWithTag("CarSpawner"); var total = _players.Sum(player => player.Value.IsPlayer ? 1 : 0); foreach (var player in _players) { var id = player.Key; var spawner = _carSpawners[player.Key]; var car = Instantiate(player.Value.IsPlayer ? carPrefab : botCarPrefab); car.transform.position = spawner.transform.position; car.layer = LayerMask.NameToLayer("Player" + (id + 1) + "_Car"); var carComp = car.GetComponent <Car>(); var waypoints = SpawnWaypoints(); carComp.Init(player.Value, waypoints); carComp.SetName(id + 1); var entry = Instantiate(leaderboardPlayerPrefab); var component = entry.GetComponent <LeaderboardPlayer>(); component.SetData(player.Key + 1, player.Key + 1, !player.Value.IsPlayer); _leaderboard.Add(component); carComp.SetLeaderboardEntry(component); Cars.Add(carComp); if (player.Value.IsPlayer) { var localCar = car.GetComponent <LocalCar>(); switch (id) { case 0: localCar.mainCamera.cullingMask = layerMaskPlayer1; break; case 1: localCar.mainCamera.cullingMask = layerMaskPlayer2; break; case 2: localCar.mainCamera.cullingMask = layerMaskPlayer3; break; case 3: localCar.mainCamera.cullingMask = layerMaskPlayer4; break; } switch (total) { case 2: SetCamera(localCar.mainCamera, sizesTwoPlayers[id]); break; case 3: SetCamera(localCar.mainCamera, sizesThreePlayers[id]); break; case 4: SetCamera(localCar.mainCamera, sizesFourPlayers[id]); break; } } foreach (var waypoint in waypoints) { waypoint.layer = LayerMask.NameToLayer("Player" + (id + 1)); } } }