Exemple #1
0
        public LevelEndHUD(GameEnvironment env)
            : base(env.Controller)
        {
            Environment = env;

            Sound.PlayCue("stage_clear");

            /////

            // Background color.
            m_background = new RectangleWidget(this, ScreenSize.X * 0.5f, ScreenSize.Y * 0.5f);
            m_background.PositionPercent = new Vector2(0.5f, 0.5f);
            m_background.Position = new Vector2(0.0f, 20.0f);
            m_background.VertexColor = Color.Black;
            m_background.Alpha = 0.5f;
            m_background.Zindex = 1.0f;
            AddChild(m_background);

            // Title.
            TextWidget winTitle = new TextWidget(this, "font", "You win!");
            winTitle.PositionPercent = new Vector2(0.5f, 0.5f);
            winTitle.Position = new Vector2(0.0f, -50.0f);
            winTitle.Zindex = 0.5f;
            AddChild(winTitle);

            // Score.
            TextWidget score = new TextWidget(this, "font", String.Format("Time: {0:0.00} seconds.", env.LevelTimeSpent));
            score.PositionPercent = new Vector2(0.5f, 0.5f);
            score.Position = new Vector2(0.0f, 0.0f);
            score.Zindex = 0.5f;
            AddChild(score);

            // Press key to exit.
            TextWidget exit = new TextWidget(this, "font", "Press SPACE for Main Menu");
            exit.PositionPercent = new Vector2(0.5f, 0.5f);
            exit.Position = new Vector2(0.0f, 50.0f);
            exit.Zindex = 0.5f;
            AddChild(exit);
        }
Exemple #2
0
        public HUD(GameEnvironment env)
            : base(env.Controller)
        {
            Environment = env;

            // Cursor.
            Cursor = new Widget(this);
            Cursor.LoadTexture(contentManager, "bullet_arrow");
            Cursor.Registration = new Vector2(Cursor.Texture.Width, Cursor.Texture.Height) * 0.5f;
            Cursor.Scale = 0.2f;
            AddChild(Cursor);

            // Arrow pointing towards boss.
            BossDirection = new Widget(this);
            BossDirection.LoadTexture(contentManager, "arrow");
            BossDirection.Registration = new Vector2(BossDirection.Texture.Width, BossDirection.Texture.Height) * 0.5f;
            BossDirection.PositionPercent = new Vector2(1.0f, 1.0f);
            BossDirection.Position = new Vector2(-75.0f, -75.0f);
            AddChild(BossDirection);

            /////

            // Boss health meter.
            BossHealth = new RectangleWidget(this, ScreenSize.X * 0.75f - 4.0f, 20.0f - 4.0f);
            BossHealth.PositionPercent = new Vector2(0.5f, 0.0f);
            BossHealth.Position = new Vector2(0.0f, 20.0f);
            BossHealth.VertexColor = Color.DarkRed;
            BossHealth.Zindex = 0.0f;
            AddChild(BossHealth);

            // Boss health background.
            BossHealthBG = new RectangleWidget(this, ScreenSize.X * 0.75f, 20.0f);
            BossHealthBG.PositionPercent = new Vector2(0.5f, 0.0f);
            BossHealthBG.Position = new Vector2(0.0f, 20.0f);
            BossHealthBG.VertexColor = Color.Black;
            BossHealthBG.Zindex = 1.0f;
            AddChild(BossHealthBG);

            /////

            // Ship health meter.
            ShipHealth = new RectangleWidget(this, ScreenSize.X * 0.25f - 4.0f, 20.0f - 4.0f);
            ShipHealth.PositionPercent = new Vector2(0.0f, 1.0f);
            ShipHealth.Position = new Vector2(10.0f + ScreenSize.X * 0.25f / 2, -20.0f);
            ShipHealth.VertexColor = Color.Green;
            ShipHealth.Zindex = 0.5f;
            ShipHealth.Alpha = 0.0f;
            AddChild(ShipHealth);

            // Ship health shield.
            ShipHealthShield = new RectangleWidget(this, ScreenSize.X * 0.25f - 4.0f, 20.0f - 4.0f);
            ShipHealthShield.PositionPercent = new Vector2(0.0f, 1.0f);
            ShipHealthShield.Position = new Vector2(10.0f + ScreenSize.X * 0.25f / 2, -20.0f);
            ShipHealthShield.VertexColor = Color.LightBlue;
            ShipHealthShield.Zindex = 0.0f;
            ShipHealthShield.Alpha = 0.0f;
            AddChild(ShipHealthShield);

            // Ship health background.
            ShipHealthBG = new RectangleWidget(this, ScreenSize.X * 0.25f, 20.0f);
            ShipHealthBG.PositionPercent = new Vector2(0.0f, 1.0f);
            ShipHealthBG.Position = new Vector2(10.0f + ScreenSize.X * 0.25f / 2, -20.0f);
            ShipHealthBG.VertexColor = Color.Black;
            ShipHealthBG.Zindex = 1.0f;
            ShipHealthBG.Alpha = 0.0f;
            AddChild(ShipHealthBG);

            /////

            // Sputnik time left.
            SputnikTimeLeft = new RectangleWidget(this, 100.0f - 4.0f, 10.0f - 4.0f);
            SputnikTimeLeft.VertexColor = Color.White;
            SputnikTimeLeft.Zindex = 0.0f;
            SputnikTimeLeft.Alpha = 0.0f;
            AddChild(SputnikTimeLeft);

            // Sputnik time left background.
            SputnikTimeLeftBG = new RectangleWidget(this, 100.0f, 10.0f);
            SputnikTimeLeftBG.VertexColor = Color.Black;
            SputnikTimeLeftBG.Zindex = 1.0f;
            SputnikTimeLeftBG.Alpha = 0.0f;
            AddChild(SputnikTimeLeftBG);
        }