// Create a Control to display one entry in a leaderboard. The content is broken out into a parameter // list so that we can easily create a control with fake data when running under the emulator. // // Note that for time leaderboards, this function interprets the time as a count in seconds. The // value posted is simply a long, so your leaderboard might actually measure time in ticks, milliseconds, // or microfortnights. If that is the case, adjust this function to display appropriately. protected Control CreateAccountingEntryControl(string wavestring, string scorestring, bool isCurrentHighScore) { Color textColor = isCurrentHighScore?Color.Yellow:Color.Green; var panel = new PanelControl(); // Wave panel.AddChild( new TextControl { Text = wavestring, Font = detailFont, Color = textColor, Position = new Vector2(30, 0) }); // Score panel.AddChild( new TextControl { Text = scorestring, Font = detailFont, Color = textColor, Position = new Vector2(175, 0) }); return panel; }
/* private void PopulateWithFakeData() { PanelControl newList = new PanelControl(); Random rng = new Random(); for (int i = 0; i < 10; i++) { long score = 10000 - i * 10; TimeSpan time = TimeSpan.FromSeconds(rng.Next(60, 3600)); newList.AddChild(CreateLeaderboardEntryControl("player" + i.ToString(), "$4,000,000,000", "Wave 2")); } newList.LayoutColumn(0, 0, 0); if (resultListControl != null) { RemoveChild(resultListControl); } resultListControl = newList; AddChild(resultListControl); LayoutColumn(0, 0, 0); } */ protected Control CreateHeaderControl() { PanelControl panel = new PanelControl(); panel.AddChild(new TextControl("Player", headerFont, Color.Red, new Vector2(0, 0))); panel.AddChild(new TextControl("Score", headerFont, Color.Red, new Vector2(155, 0))); panel.AddChild(new TextControl("Progress", headerFont, Color.Red, new Vector2(350, 0))); return panel; }
private void AddControls() { //get game data to inform the controls //WaveAccountingTable table = ((Game1)(ScreenManager.Game)).GetAccounting(); RootControl = new PanelControl(); RootControl.Position = panelOffset; row_control = new PanelControl[rows]; int createditems = 0; for (int i = 0; i < rows; i++) { row_control[i] = new PanelControl(); for (int k = 0; k < columns && createditems < totalitems; k++) { row_control[i].AddChild(new LevelSelectControl((highScores.GetHighestWave() >= createditems +1)?level_textures[createditems]:level_lock_texture, Vector2.Zero, createditems+1, this)); //TextControl tc = new TextControl((createditems + 1).ToString(), menufont, Color.LawnGreen); //tc.Size = new Vector2(64.0f, 64.0f); //row_control[i].AddChild(tc); createditems++; } row_control[i].LayoutRow(itemXmargin, itemYmargin, itemspacing); RootControl.AddChild(row_control[i]); } ((PanelControl)(RootControl)).LayoutColumn(itemXmargin, itemYmargin, itemspacing); RootControl.Visible = true; }
// Create a Control to display one entry in a leaderboard. The content is broken out into a parameter // list so that we can easily create a control with fake data when running under the emulator. // // Note that for time leaderboards, this function interprets the time as a count in seconds. The // value posted is simply a long, so your leaderboard might actually measure time in ticks, milliseconds, // or microfortnights. If that is the case, adjust this function to display appropriately. protected Control CreateLeaderboardEntryControl(string player, string scorestring, string wavestring, bool isCurrentHighScore) { Color textColor = isCurrentHighScore?Color.Yellow:Color.Red; var panel = new PanelControl(); // Player name panel.AddChild( new TextControl { Text = player, Font = detailFont, Color = textColor, Position = new Vector2(0, 0) }); // Score panel.AddChild( new TextControl { Text = scorestring, Font = detailFont, Color = textColor, Position = new Vector2(155, 0) }); // Time panel.AddChild( new TextControl { Text = wavestring, Font = detailFont, Color = textColor, Position = new Vector2(350, 0) }); return panel; }
private void PopulateScores(HighScoreTable scores) { List<HighScoreEntry> scorelist = scores.GetHighScores(); PanelControl newList = new PanelControl(); for(int i = 0; i < scorelist.Count; i++) { CurrencyStringer stringer = new CurrencyStringer(scorelist[i].score); newList.AddChild(CreateLeaderboardEntryControl(scorelist[i].name, stringer.outputstring.ToString(), "Wave " + scorelist[i].wave, i == scores.currentHighScoreIndex)); } newList.LayoutColumn(0, 0, 0); if (resultListControl != null) { RemoveChild(resultListControl); } resultListControl = newList; AddChild(resultListControl); LayoutColumn(0, 0, 0); }
private void PopulateTable(WaveAccountingTable table, int currentWave, UInt64 totalscore) { List<WaveAccountingEntry> entries = table.GetEntries(); PanelControl newList = new PanelControl(); for (int i = 0; i < entries.Count; i++) { CurrencyStringer stringer = new CurrencyStringer(entries[i].c_score); newList.AddChild(CreateAccountingEntryControl(entries[i].c_wave.ToString(), stringer.outputstring.ToString(), entries[i].c_wave == currentWave)); } newList.LayoutColumn(0, 0, 0); if (resultListControl != null) { RemoveChild(resultListControl); } resultListControl = newList; AddChild(resultListControl); LayoutColumn(0, 0, 0); AddChild(new ImageControl(separator, new Vector2(0, 610))); AddChild(new TextControl("Total: " + totalStringer.outputstring.ToString(), headerFont, Color.Green, new Vector2(50, 630))); }
/* private void PopulateWithFakeData() { PanelControl newList = new PanelControl(); Random rng = new Random(); for (int i = 0; i < 10; i++) { long score = 10000 - i * 10; TimeSpan time = TimeSpan.FromSeconds(rng.Next(60, 3600)); newList.AddChild(CreateLeaderboardEntryControl("player" + i.ToString(), "$4,000,000,000", "Wave 2")); } newList.LayoutColumn(0, 0, 0); if (resultListControl != null) { RemoveChild(resultListControl); } resultListControl = newList; AddChild(resultListControl); LayoutColumn(0, 0, 0); } */ protected Control CreateHeaderControl() { PanelControl panel = new PanelControl(); panel.AddChild(new TextControl("Wave", headerFont, Color.Green, new Vector2(30, 100))); panel.AddChild(new TextControl("Score", headerFont, Color.Green, new Vector2(175, 100))); return panel; }