Example #1
0
        private static void AddStartText()
        {
            nezFont = new NezSpriteFont(titleScene.content.Load <SpriteFont>("testFont"));

            Title = new TitleText("SPIDER STRIDER", nezFont, Color.Yellow);
            titleScene.addEntity(Title);

            Title.transform.scale = new Vector2(8, 8);
            Title.position        = new Vector2(GameManager.Width / 2, GameManager.Height / 8);
            Title.position       -= new Vector2(Title.text.width / 2, Title.text.height / 2);

            startText = new StartText("START", nezFont, Color.Red);
            titleScene.addEntity(startText);

            startText.transform.scale = new Vector2(3, 3);
            startText.position        = new Vector2(GameManager.Width / 2, GameManager.Height / 4);
            startText.position       -= new Vector2(startText.text.width / 2, startText.text.height / 2);


            titleScene.addEntity(GetHighScoreBoard(nezFont));

            NameField nameField = new NameField(nezFont, Color.Black);

            titleScene.addEntity(nameField);

            nameField.transform.scale = new Vector2(3, 3);
            nameField.position        = new Vector2(GameManager.Width / 2, GameManager.Height / 3f);
            nameField.position       -= new Vector2(nameField.text.width / 2, nameField.text.height / 2);
        }
Example #2
0
        public static TitleText GetHighScoreBoard(NezSpriteFont font)
        {
            string highscores = "Highscores\n";

            foreach (Highscore score in HighScoreManager.highscores)
            {
                highscores += $"{score.name}: {score.score}\n";
            }

            TitleText scores = new TitleText(highscores, font, Color.White);

            scores.position        = new Vector2(GameManager.Width / 2, GameManager.Height / 2.5f);
            scores.position       -= new Vector2(scores.text.width, 0);
            scores.transform.scale = new Vector2(2, 2);
            return(scores);
        }
Example #3
0
        public void GameFinish()
        {
            GameManager.gameScene.destroyAllEntities();
            active      = false;
            currentWave = waveList.Count + 1;
            MediaPlayer.Stop();

            var gameOverScene = Scene.createWithDefaultRenderer(Color.DarkGray);

            Core.scene = gameOverScene;

            var nezFont = new NezSpriteFont(gameOverScene.content.Load <SpriteFont>("testFont"));

            gameOverScene.content.Load <SoundEffect>("GameOverJingle").Play(0.4f, 0.0f, 0.0f);

            HighScoreManager.highscores.Add(new Highscore(GameManager.playerName, ScoreCounter.Points));
            HighScoreManager.highscores.Sort((a, b) => b.score.CompareTo(a.score));
            HighScoreManager.SaveFile();

            gameOverScene.addEntity(GameManager.GetHighScoreBoard(nezFont));

            GameOverText gameOverText = new GameOverText("GAME OVER", nezFont, Color.Red);
            TitleText    score        = new TitleText($"SCORE: {ScoreCounter.Points}", nezFont, Color.Yellow);

            gameOverScene.addEntity(gameOverText);

            gameOverText.transform.scale = new Vector2(8, 8);
            gameOverText.position        = new Vector2(GameManager.Width / 2, GameManager.Height / 5);
            gameOverText.position       -= new Vector2(gameOverText.text.width / 2, gameOverText.text.height / 2);

            gameOverScene.addEntity(score);

            score.transform.scale = new Vector2(3, 3);
            score.position        = new Vector2(GameManager.Width / 2, GameManager.Height / 3);
            score.position       -= new Vector2(score.text.width / 2, score.text.height / 2);
        }