Ejemplo n.º 1
0
        /// <summary>
        /// Called to initialize the game
        /// Note: must be added to Game.FirstScene before calling
        /// </summary>
        public void Initialize()
        {
            OnBegin = delegate
            {
                Enemy.Initialize();
                Barricade.Initialize();
                MainScene scene = Program.game.GetScene <MainScene>();

                Ufo = new UFO();

                Program.game.GetScene <MainScene>().Add(Ufo);

                // Create player and add to scene
                player = new Player();
                Add(player);
                // Gametext for the entire game pretty much
                #region gameText

                var background = new Image("Assets/background.png");
                background.Alpha = 0.4f;
                scene.AddGraphic(background);

                //Setting a default config file for the RichText to use
                var txtConfig = new RichTextConfig()
                {
                    TextAlign = TextAlign.Center,
                    CharColor = Color.Green,
                    FontSize  = 18,
                    SineAmpX  = 1,
                    SineAmpY  = 2,
                    SineRateX = 1,
                    Font      = new Font("Assets/VCR_OSD_MONO.ttf"),
                };
                // Writing the text graphics and setting position
                var livesLeftTxtLabel = new RichText("Lives", txtConfig);
                livesLeftTxtLabel.SetPosition(50, 16);

                scene.livesLeftTxt      = new RichText(scene.player.playerLives.ToString(), txtConfig);
                scene.livesLeftTxt.Name = "livesLeftTxt";
                scene.livesLeftTxt.SetPosition(70, 32);

                var highScoreTxtLabel = new RichText("Highscore", txtConfig);
                highScoreTxtLabel.SetPosition(350, 15);

                highScoreTxt      = new RichText(ReadXML.MainScreenXML(), txtConfig);
                highScoreTxt.Name = "highScoreTxt";
                highScoreTxt.SetPosition(380, 30);

                var curScoreTxtLabel = new RichText("Score", txtConfig);
                curScoreTxtLabel.SetPosition(650, 15);

                scene.curScoreTxt      = new RichText(scene.player.ScoreAmount.ToString(), txtConfig);
                scene.curScoreTxt.Name = "curScoreTxt";
                scene.curScoreTxt.SetPosition(670, 32);
                // Adds Graphic to Scene
                scene.AddGraphic(livesLeftTxtLabel);
                scene.AddGraphic(highScoreTxtLabel);
                scene.AddGraphic(curScoreTxtLabel);

                scene.AddGraphic(scene.livesLeftTxt);
                scene.AddGraphic(scene.highScoreTxt);
                scene.AddGraphic(scene.curScoreTxt);

                #endregion gameText
            };
        }