public void AddScoreboardEntry(int score, string name) { //Create scoreboard entry ScoreboardEntry scoreboardEntry = new ScoreboardEntry { score = score, name = name }; //Load saved highscores string jsonString = PlayerPrefs.GetString("highscores"); HighScores highscores = JsonUtility.FromJson <HighScores>(jsonString); //Add new entry to scores highscores.highscoreEntryList.Add(scoreboardEntry); //Save updated highscores string json = JsonUtility.ToJson(highscores); PlayerPrefs.SetString("highscores", json); PlayerPrefs.Save(); foreach (Transform scoreboardEntryTransform in scoreboardEntryTransformList) { GameObject.Destroy(scoreboardEntryTransform.gameObject); } LoadScores(); }
public bool AddScore(string username, string userPassword, string game, string gamePassword, int score) { if (!this.usersPasswords.ContainsKey(username) || this.usersPasswords[username] != userPassword) { // Invalid username / password return(false); } if (!this.gamesPasswords.ContainsKey(game) || this.gamesPasswords[game] != gamePassword) { // Invalid game / game password return(false); } var scoreboardEntry = new ScoreboardEntry() { Score = score, Username = username }; var currentGameScoreboard = this.scoreboardByGame[game]; currentGameScoreboard.Add(scoreboardEntry); if (currentGameScoreboard.Count > this.maxEntriesToKeep) { // Keep no more than maxEntriesToKeep entries (e.g. 10 entries) currentGameScoreboard.RemoveLast(); } return(true); }
public bool AddScore(string username, string userPassword, string game, string gamePassword, int score) { var userAndPass = new Tuple <string, string>(username, userPassword); if (!this.usersPasswords.Contains(userAndPass)) { return(false); } var gameAndPass = new Tuple <string, string>(game, gamePassword); if (!this.gamesPasswords.Contains(gameAndPass)) { return(false); } var scoreboardEntry = new ScoreboardEntry() { Score = score, Username = username, Game = game }; this.scoreboardEntries.Add(scoreboardEntry); return(true); }
public void OnPlayerAdded(string username) { if (playerScores == null) { playerScores = new Dictionary <string, ScoreboardEntry>(); } if (PlayerRowPrefab == null) { print("Player Row Prefab = null, should not = null!"); } if (ScoreBoardPanel == null) { print("ScoreBoardPanel = null, should not = null!"); } ScoreboardEntry tablerow = Instantiate(PlayerRowPrefab, ScoreBoardPanel.transform); playerScores.Add(username, tablerow); tablerow.PlayerName = username; tablerow.Score1 = 0; tablerow.Score2 = 0; tablerow.Score3 = 0; tablerow.updateFlag = true; //Scorebuffer buf = new Scorebuffer(); //buf.playertoadd = username; //buffer.Add(buf); }
private float getTeamAccuracy(SlotTeams team) { float totalAccuracy = 0; int playerCount = 0; List <ScoreboardEntryExtended> scores = player.ScoreEntries ?? PlayerVs.LastScoreEntries; int count = scores.Count; for (int i = 0; i < count; i++) { ScoreboardEntry se = scores[i]; if (se == null) { continue; } if (se.Team != team) { continue; } if (se.Score != null) { totalAccuracy += se.Score.Accuracy; } playerCount++; } return(totalAccuracy / playerCount); }
public void DisplayScoreboardEntries() { float entryDelta = scoreboardEntryPrefab.GetHeight() + entrySpacing; for (int i = 0; i < ScoreManager.scoreList.Count || i < activeScoreboardEntries.Count; i++) { if (i < ScoreManager.scoreList.Count) { if (i < activeScoreboardEntries.Count) { activeScoreboardEntries[i].SetValues(ScoreManager.scoreList[i]); activeScoreboardEntries[i].SetVerticalPosition(i * entryDelta); } else { ScoreboardEntry newEntry = Instantiate(scoreboardEntryPrefab, transform); newEntry.SetValues(ScoreManager.scoreList[i]); newEntry.SetVerticalPosition(i * entryDelta); activeScoreboardEntries.Add(newEntry); } } else { Destroy(activeScoreboardEntries[i].gameObject); activeScoreboardEntries.RemoveAt(i); i--; } } _rectTransform.sizeDelta = new Vector2(_rectTransform.sizeDelta.x, entryDelta * activeScoreboardEntries.Count); }
public void CreateScoreEntry(ExampleNetworkedEntity entity) { GameObject newEntry = Instantiate(scoreEntryPrefab, scoreRoot, false); ScoreboardEntry entry = newEntry.GetComponent <ScoreboardEntry>(); entry.Init(entity); spawnedEntries.Add(entry); }
private void spriteBackground_OnClick(object sender, EventArgs e) { ScoreboardEntry sbe = (ScoreboardEntry)((pSprite)sender).Tag; Player.scoreBoard.Reorder(true); sbe.MoveTo(sbe.spriteBackground.CurrentPosition - new Vector2(30, 0), true, false); LoadScore(sbe.name, sbe.Frame); }
private void Awake() { entryContainer = transform.Find("EntryContainer"); entryTemplate = entryContainer.Find("EntryTemplate"); entryTemplate.gameObject.SetActive(false); scoreboardEntryList = new List <ScoreboardEntry> { new ScoreboardEntry { time = 124234, name = "ABC" }, new ScoreboardEntry { time = 1234, name = "RTF" }, new ScoreboardEntry { time = 253462, name = "EWQ" }, new ScoreboardEntry { time = 345, name = "BHY" }, new ScoreboardEntry { time = 890678, name = "HUY" }, new ScoreboardEntry { time = 2245, name = "NMK" }, new ScoreboardEntry { time = 6666, name = "KIR" } }; //Sorting for (int i = 0; i < scoreboardEntryList.Count; i++) { for (int j = i + 1; j < scoreboardEntryList.Count; j++) { if (scoreboardEntryList[j].time < scoreboardEntryList[i].time) { //Swap ScoreboardEntry temp = scoreboardEntryList[i]; scoreboardEntryList[i] = scoreboardEntryList[j]; scoreboardEntryList[j] = temp; } } } scoreboardEntryTransformList = new List <Transform>(); foreach (ScoreboardEntry scoreboardEntry in scoreboardEntryList) { CreateScoreboardEntry(scoreboardEntry, entryContainer, scoreboardEntryTransformList); } PlayerPrefs.SetString("scoreboardTable", "100"); PlayerPrefs.Save(); PlayerPrefs.GetString("scoreboardTable"); }
/// <summary> /// Set GUI name and score to the provided entry. /// </summary> /// <param name="entry">score entry to add to gui</param> public void SetEntry(ScoreboardEntry entry) { if (entry == null) { return; } this.name.SetText(entry.PlayerName); this.score.SetText(entry.Score.ToString()); }
/// <summary> /// Creates an entry in the scoreboard. /// </summary> /// <param name="scoreboardEntry">The entry to be displayed. Uses the entry fields to show player name and score on screen</param> /// <param name="container">What container the score should be child of</param> /// <param name="transformList">The list of all the other scores</param> private void CreateScoreboardEntryTransform(ScoreboardEntry scoreboardEntry, Transform container, List <ScoreBoardEntryGUI> transformList) { var guiEntry = Instantiate(GUIScoreBoardEntry, container); guiEntry.SetEntry(scoreboardEntry); guiEntry.transform.SetParent(container); transformList.Add(guiEntry); }
public void AddScoreboardEntry(ClientConnectedPlayer player) { ScoreboardEntry scoreboardEntry = Instantiate(ScoreboardEntryPrefab, ScoreboardEntryPanel.transform).GetComponent <ScoreboardEntry>(); scoreboardEntry.Username = player.Username; player.PlayerPingUpdated += scoreboardEntry.OnConnectedPlayerPingUpdated; player.PlayerScoreUpdated += scoreboardEntry.OnConnectedPlayerScoreUpdated; player.PlayerDisconnected += scoreboardEntry.OnPlayerDisconnected; }
public void AddScoreboardEntry(Client client) { ScoreboardEntry scoreboardEntry = Instantiate(ScoreboardEntryPrefab, ScoreboardEntryPanel.transform).GetComponent <ScoreboardEntry>(); scoreboardEntry.Username = client.Username; client.PlayerLatencyUpdated += scoreboardEntry.OnClientLatencyUpdated; client.PlayerScoreUpdated += scoreboardEntry.OnClientScoreUpdated; client.PlayerDisconnected += scoreboardEntry.OnPlayerDisconnected; }
public void Set(ScoreboardEntry entry) { ID = entry.ID; Score = entry.Score; Kills = entry.Kills; Username = entry.Username; Deaths = entry.Deaths; ResetTexts(); }
public bool AddScore(string username, string userPassword, string gameName, string gamePassword, int score) { if (!this.Games.ContainsKey(gameName) || this.Games[gameName] != gamePassword || !this.Users.ContainsKey(username) || this.Users[username] != userPassword) { return(false); } ScoreboardEntry sbe = new ScoreboardEntry(score, username); GameResults[gameName].Add(sbe); return(true); }
public void AddEntry(int iD, string username, int kills, int deaths, int score) { GameObject entryToAdd = Instantiate(ScoreboardEntryPrefab, ScoreboardPanel.transform); ScoreboardEntry scoreboardEntry = entryToAdd.GetComponent <ScoreboardEntry>(); scoreboardEntry.Init(); scoreboardEntry.Set(iD, username, kills, deaths, score); ScoreboardEntriesDictionary.Add(iD, scoreboardEntry); ScoreboardEntriesPanels.Add(scoreboardEntry); ScoreboardChanged = true; }
private void CreateScoreboardEntryTransform(ScoreboardEntry entry, Transform container, List <Transform> transformList) { Transform entryTransform = Instantiate(entryTemplate, container); RectTransform entryRectTransform = entryTransform.GetComponent <RectTransform>(); entryRectTransform.anchoredPosition = new Vector2(0, -templateHeight * transformList.Count); entryTransform.gameObject.SetActive(true); entryTransform.GetComponent <ScoreboardEntryUI>().nameText.text = entry.name; entryTransform.GetComponent <ScoreboardEntryUI>().scoreText.text = entry.score.ToString(); transformList.Add(entryTransform); }
public void RemoveView(ExampleNetworkedEntity entity) { ScoreboardEntry entryForView = GetEntryByID(entity.id); if (entryForView != null) { spawnedEntries.Remove(entryForView); Destroy(entryForView.gameObject); } else { LSLog.LogError("Player left game but we do not have a scoreboard entry for them!"); } }
private ScoreboardEntry GetEntryByID(string entityID) { ScoreboardEntry entryForView = null; foreach (ScoreboardEntry score in spawnedEntries) { if (score.entityRef.id.Equals(entityID)) { entryForView = score; } } return(entryForView); }
private void RpcAddPlayer(string playerId) { // Make a new entry on the scoreboard GameObject scorePanel = Instantiate(m_playerScorePrefab) as GameObject; scorePanel.transform.SetParent(m_playerList.transform, false); ScoreboardEntry scoreboardEntry = scorePanel.GetComponent <ScoreboardEntry>(); // Try to add the player to the scoreboard, if it fails add it to the list of outdated players if (!AddPlayer(playerId, scoreboardEntry)) { m_outdatedPlayers.Add(playerId, scoreboardEntry); } }
void FormatScoreboard(string textStream) { string[] entries = textStream.Split(new char[] { '\n' }, System.StringSplitOptions.RemoveEmptyEntries); scoreboardList = new ScoreboardEntry[entries.Length]; Debug.Log("Entries Length:" + entries.Length); for (int i = 0; i < entries.Length; i++) { string[] entryInfo = entries[i].Split(new char[] { '|' }); string uname = entryInfo[0]; int time = int.Parse(entryInfo[1]); scoreboardList[i] = new ScoreboardEntry(uname, time); Debug.Log(scoreboardList[i].name + " " + scoreboardList[i].time); CreateScoreboardEntry(scoreboardList[i], entryContainer, i); } }
public void UpdateScore(ShootingGalleryScoreUpdateMessage updateMessage, int remainingTargets) { ScoreboardEntry entryForView = GetEntryByID(updateMessage.entityID); if (entryForView != null) { entryForView.UpdateScore(updateMessage.score); UpdateEntryOrder(); } else { LSLog.LogError("Tried to Update a score but couldn't find an entry!"); } SetTargetsText(remainingTargets); }
private void CreateScoreboardEntry(ScoreboardEntry scoreboardEntry, Transform container, int index) { float templateHeight = 30f; Transform entryTransform = Instantiate(entryTemplate, container); RectTransform entryRectTransform = entryTransform.GetComponent <RectTransform>(); //Debug.Log(transformList.Count); entryRectTransform.anchoredPosition = new Vector2(0, -templateHeight * index); entryTransform.gameObject.SetActive(true); int rank = index + 1; string rankString; switch (rank) { default: rankString = rank + "th"; break; case 1: rankString = "1st"; break; case 2: rankString = "2nd"; break; case 3: rankString = "3rd"; break; } entryTransform.Find("Position").GetComponent <Text>().text = rankString; float time = scoreboardEntry.time / 1000; GameObject timer = GameObject.Find("Timer"); entryTransform.Find("Time").GetComponent <Text>().text = timer.GetComponent <Timer>().DisplayTime(time); string name = scoreboardEntry.name; entryTransform.Find("Name").GetComponent <Text>().text = name; //transformList.Add(entryTransform); }
public override ScoreboardModel GetModel() { PopIfMessage("SCOREBOARD_OUT"); var scoreBoardList = new List <ScoreboardEntry>(); while (HaveContents()) { var entry = new ScoreboardEntry(PopString(), PopInt(), PopInt()); scoreBoardList.Add(entry); } scoreBoardList.Sort(); var model = new ScoreboardModel(scoreBoardList); return(model); }
public override void Replicate(NetworkObjectState state) { NetworkScoreBoardState networkScoreboardState = new NetworkScoreBoardState(); state.GetState <NetworkScoreBoardState>(networkScoreboardState); ScoreboardEntry scoreBoardEntry = new ScoreboardEntry(); for (int i = 0; i < networkScoreboardState.EntriesLength; i++) { networkScoreboardState.GetEntries(scoreBoardEntry, i); scoreBoardState.SetEntry(i, scoreBoardEntry.PlayerName, scoreBoardEntry.Score); } for (int i = networkScoreboardState.EntriesLength; i < scoreBoardState.maxScoreboardPlayers; i++) { scoreBoardState.SetEntry(i, "-", 0); } }
private bool AddPlayer(string playerId, ScoreboardEntry scoreboardEntry) { // Find the player, return false if nothing found GameObject player = GameObject.Find(playerId); if (player == null) { return(false); } Soldier playerScript = player.GetComponent <Soldier>(); Color scoreboardColor = playerScript.Color; scoreboardColor.a = 100f / 255f; // Set alpha to 100. Color.a works with a value between 0 and 1. scoreboardEntry.SetColor(scoreboardColor); scoreboardEntry.SetScore(playerScript.Score); scoreboardEntry.Score.OnScoreChange += RpcSortPlayerList; if (playerScript.isLocalPlayer) { scoreboardEntry.EnableOutline(); } return(true); }
public static void Main(string[] arguments) { string inputLine = string.Empty; char[,] boardArea = CreatePlayingField(); char[,] bombsArea = GenerateBombsBoard(); int openedCellsCount = 0; const int MaxEmptyCellsCount = 35; bool isGameOver = false; bool boardIsToBeRendered = true; bool isGameWon = false; List <ScoreboardEntry> scoreBoard = new List <ScoreboardEntry>(6); int inputRow = 0; int inputCol = 0; do { if (boardIsToBeRendered) { Console.WriteLine("Let's play Minesweeper. Try to find all the cells without mines." + " Command 'top' shows the Scoreboard, 'restart' starts a new game, 'exit' quits the game. Good luck!"); WriteBoardOnScreen(boardArea); boardIsToBeRendered = false; } Console.Write("Input row and column: "); inputLine = Console.ReadLine().Trim(); if (inputLine.Length >= 3) { if (int.TryParse(inputLine[0].ToString(), out inputRow) && int.TryParse(inputLine[2].ToString(), out inputCol) && inputRow <= boardArea.GetLength(0) && inputCol <= boardArea.GetLength(1)) { inputLine = "turn"; } } switch (inputLine) { case "top": WriteScoreboardOnScreen(scoreBoard); break; case "restart": boardArea = CreatePlayingField(); bombsArea = GenerateBombsBoard(); WriteBoardOnScreen(boardArea); isGameOver = false; boardIsToBeRendered = false; break; case "exit": Console.WriteLine("Bye, bye!"); break; case "turn": if (bombsArea[inputRow, inputCol] != '*') { if (bombsArea[inputRow, inputCol] == '-') { WriteNumberOfBombsInCell(boardArea, bombsArea, inputRow, inputCol); openedCellsCount++; } if (MaxEmptyCellsCount == openedCellsCount) { isGameWon = true; } else { WriteBoardOnScreen(boardArea); } } else { isGameOver = true; } break; default: Console.WriteLine("\nError: Invalid command\n"); break; } if (isGameOver) { WriteBoardOnScreen(bombsArea); Console.Write( "\nYou died with {0} points. " + "Please input your nickname: ", openedCellsCount); string nickname = Console.ReadLine(); ScoreboardEntry currentWinnerEntry = new ScoreboardEntry(nickname, openedCellsCount); if (scoreBoard.Count < 5) { scoreBoard.Add(currentWinnerEntry); } else { for (int i = 0; i < scoreBoard.Count; i++) { if (scoreBoard[i].Points < currentWinnerEntry.Points) { scoreBoard.Insert(i, currentWinnerEntry); scoreBoard.RemoveAt(scoreBoard.Count - 1); break; } } } scoreBoard.Sort((ScoreboardEntry firstEntry, ScoreboardEntry secondEntry) => secondEntry.Name.CompareTo(firstEntry.Name)); scoreBoard.Sort((ScoreboardEntry firstEntry, ScoreboardEntry secondEntry) => secondEntry.Points.CompareTo(firstEntry.Points)); WriteScoreboardOnScreen(scoreBoard); boardArea = CreatePlayingField(); bombsArea = GenerateBombsBoard(); openedCellsCount = 0; isGameOver = false; boardIsToBeRendered = true; } if (isGameWon) { Console.WriteLine("\nCongratulations! You opened 35 cells without getting hit."); WriteBoardOnScreen(bombsArea); Console.WriteLine("Please input nickname: "); string nickname = Console.ReadLine(); ScoreboardEntry winnerEntry = new ScoreboardEntry(nickname, openedCellsCount); scoreBoard.Add(winnerEntry); WriteScoreboardOnScreen(scoreBoard); boardArea = CreatePlayingField(); bombsArea = GenerateBombsBoard(); openedCellsCount = 0; isGameWon = false; boardIsToBeRendered = true; } }while (inputLine != "exit"); Console.WriteLine("Made in Bulgaria"); Console.WriteLine("Goodbye"); Console.Read(); }
public override void Initialize() { base.Initialize(); Player.ScoreBoard.spriteManager.WidescreenAutoOffset = true; Player.ScoreBoard.spriteManager.Alpha = 1; lock (StreamingManager.LockReplayScore) { InputManager.ReplayMode = false; InputManager.ReplayStreaming = false; InputManager.ReplayStartTime = 0; } pText text = null; SlotTeams winner = PlayerVs.TeamOverlay.winner; if (PlayerVs.TeamFailed(SlotTeams.Blue)) { text = new pText("Blue team failed!", 20, new Vector2(GameBase.WindowManager.WidthScaled / 2, 85), Vector2.Zero, 1, true, Color.Blue, false); } else if (PlayerVs.TeamFailed(SlotTeams.Red)) { text = new pText("Red team failed!", 20, new Vector2(GameBase.WindowManager.WidthScaled / 2, 85), Vector2.Zero, 1, true, Color.Red, false); } else { switch (winner) { case SlotTeams.Blue: text = new pText("Blue team wins!", 20, new Vector2(GameBase.WindowManager.WidthScaled / 2, 85), Vector2.Zero, 1, true, Color.Blue, false); break; case SlotTeams.Red: text = new pText("Red team wins!", 20, new Vector2(GameBase.WindowManager.WidthScaled / 2, 85), Vector2.Zero, 1, true, Color.Red, false); break; } } text.TextBold = true; text.Origin = Origins.Centre; spriteManagerWideScrolling.Add(text); int tabHeight = 113; //add team1Tabs = new pTabCollection(spriteManagerWideScrolling, 3, new Vector2(56, tabHeight), 0.8f, true, Color.BlueViolet, 40); team2Tabs = new pTabCollection(spriteManagerWideScrolling, 3, new Vector2(GameBase.WindowManager.WidthScaled - 224, tabHeight), 0.8f, true, Color.BlueViolet, 40); team1Tabs.Add("Total", 0); team2Tabs.Add("Total", 0); team1Tabs.SetSelected(0); team2Tabs.SetSelected(0); team1Tabs.OnTabChanged += delegate(object sender, EventArgs e) { loadScores(SlotTeams.Blue, (int)sender, false); }; team2Tabs.OnTabChanged += delegate(object sender, EventArgs e) { loadScores(SlotTeams.Red, (int)sender, false); }; int count = PlayerVs.LastScoreEntries.Count; for (int i = 0; i < count; i++) { ScoreboardEntry entry = PlayerVs.LastScoreEntries[i]; if (entry != null) { (entry.Team == SlotTeams.Blue ? team1Tabs : team2Tabs).Add(entry.name, i + 1); } } pSprite scoreBackground1 = new pSprite(TextureManager.Load(@"ranking-panel"), Fields.TopLeft, Origins.TopLeft, Clocks.Game, new Vector2(1, SkinManager.UseNewLayout ? 107 : 97), 0.79f, true, Color.White); scoreBackground1.Alpha = 1.0f; scoreBackground1.VectorScale = new Vector2(0.715f, 0.77f); pSprite scoreBackground2 = new pSprite(TextureManager.Load(@"ranking-panel"), Fields.TopLeft, Origins.TopLeft, Clocks.Game, new Vector2(GameBase.WindowManager.WidthScaled - 279, SkinManager.UseNewLayout ? 107 : 97), 0.79f, true, Color.White); scoreBackground2.Alpha = 1.0f; scoreBackground2.VectorScale = new Vector2(0.715f, 0.77f); spriteManagerWideScrolling.Add(scoreBackground1); spriteManagerWideScrolling.Add(scoreBackground2); initializeStatics(); //cache scores for more efficiency team1Score = getTeamScore(SlotTeams.Blue); team2Score = getTeamScore(SlotTeams.Red); loadScores(SlotTeams.Blue, 0, true); loadScores(SlotTeams.Red, 0, true); playMode = Player.Mode; }
private Score getTeamScore(SlotTeams teamId) { Score teamScore = ScoreFactory.Create(playMode, string.Empty, BeatmapManager.Current); int teamCount = 0; teamScore.HpGraph = new List <Vector2>(); //we need the combined hpgaphs to be sorted //because it's probably out of order due to latency SortedDictionary <float, float> timeHealth = new SortedDictionary <float, float>(); for (int i = 0; i < PlayerVs.LastScoreEntries.Count; i++) { ScoreboardEntry entry = PlayerVs.LastScoreEntries[i]; if (entry != null) { Score score = entry.Score; if (score != null) { if (entry.Team == teamId) { teamScore.MaxCombo += score.MaxCombo; teamScore.TotalScore += score.TotalScore; teamScore.Count300 += score.Count300; teamScore.CountGeki += score.CountGeki; teamScore.Count100 += score.Count100; teamScore.CountKatu += score.CountKatu; teamScore.Count50 += score.Count50; teamScore.CountMiss += score.CountMiss; if (score.HpGraph != null) { if (PlayerVs.Match.matchTeamType == MatchTeamTypes.TeamVs) { if (teamCount == 0) { teamScore.HpGraph.AddRange(score.HpGraph); } else // calculate average hpGraph { for (int j = Math.Min(teamScore.HpGraph.Count, score.HpGraph.Count) - 1; j >= 0; j--) { teamScore.HpGraph[j] = new Vector2(teamScore.HpGraph[j].X, (teamScore.HpGraph[j].Y * teamCount + score.HpGraph[j].Y) / (teamCount + 1)); } } } else { foreach (Vector2 TimeHealth in score.HpGraph) { // Will be sorted automaticlly if (!timeHealth.ContainsKey(TimeHealth.X)) { timeHealth.Add(TimeHealth.X, TimeHealth.Y); } } } } teamCount++; } } } } if (PlayerVs.Match.matchTeamType == MatchTeamTypes.TagTeamVs) { foreach (KeyValuePair <float, float> th in timeHealth) { teamScore.HpGraph.Add(new Vector2(th.Key, th.Value)); } } return(teamScore); }
public static void PrintValues(ScoreboardEntry entry) { Debug.Log($"ID: {entry.ID}, Name: {entry.Username}, Kills: {entry.Kills}, Deaths: {entry.Deaths}, Score: {entry.Score}"); }