IEnumerator GetHighscoreFromServer(int level, string country, int roundScore = 0, string playername = "undefined", float time = 0f) { Debug.Log("GetHighscoreFromServer"); statusText.text = "Status: Getting highscores from server..."; string mode = levelDictionary[currentCountry][currentLevel].type; WWW www = new WWW(highscoreURL + level.ToString() + "/" + country + "/" + mode); yield return(www); Debug.Log(www.text); var json = JsonUtility.FromJson <HighscoreCollection>(www.text); highscores = json; scoreText.text = ""; if (roundScore > 0) { Array.Resize(ref highscores.highscoreentries, highscores.highscoreentries.Length); highscores.highscoreentries[highscores.highscoreentries.Length - 1] = new HighscoreEntry(level, roundScore, playername, "undefined", (float)time, currentCountry); } int count = 0; foreach (HighscoreEntry entry in highscores.highscoreentries) { scoreText.text += entry.playername + ": " + string.Format("{0:n0}", entry.highscore) + "\n"; if (count > 9) { yield break; } } statusText.text = ""; }
public TitleScene(GraphicsDevice graphicsDevice, IContentProvider content, IMouseEvents mouse, IGameStateFactory gameStateFactory, CImage img, CSound snd, WorldCollection worlds, HighscoreCollection highscores, BBXConfig config) { this.graphicsDevice = graphicsDevice; this.content = content; this.gameStateFactory = gameStateFactory; this.img = img; this.snd = snd; this.config = config; this.spriteBatch = new SpriteBatch(graphicsDevice); this.random = new Random(); this.worlds = worlds; this.highscores = highscores; this.worlds.LoadWorlds(content); this.mouse = mouse; mouse.MouseMove += Mouse_MouseMove; mouse.MouseUp += Mouse_MouseUp; keyboard = new KeyboardEvents(); keyboard.KeyDown += Keyboard_KeyDown; font = new Font(img.Fonts.Default); }
/// <summary> /// Allows the game to perform any initialization it needs to before starting to run. /// This is where it can query for any required services and load any non-graphic /// related content. Calling base.Initialize will enumerate through any components /// and initialize them as well. /// </summary> protected override void Initialize() { base.Initialize(); var container = InitializeContainer(); highscores = container.Resolve <HighscoreCollection>(); highscores.LoadHighscores(); Window.Title = "Ball: Buster X"; bbx = container.Resolve <BBX>(); bbx.NoMoreScenes += Exit; }
public NewHighscoreScene(GraphicsDevice graphics, CImage img, HighscoreCollection highscores) { this.graphics = graphics; this.img = img; this.highscores = highscores; this.spriteBatch = new SpriteBatch(graphics); this.keyboard = new KeyboardEvents(); keyboard.KeyPress += Keyboard_KeyPress; DrawBelow = false; UpdateBelow = false; font = new Font(img.Fonts.Default); }