private void setupGameHud(LostSoulWorld world)
        {
            gameHud = new HudElement(world.Game);
            root.AddChild(gameHud);

            scoreLabel       = new HudElementText(world.Game);
            scoreLabel.Color = textColor;
            gameHud.AddChild(scoreLabel);

            lostSoulsLabel       = new HudElementText(world.Game);
            lostSoulsLabel.Color = textColor;
            lostSoulsLabel.BodyBehavior.Position = new Vector2(200.0f, 0.0f);
            gameHud.AddChild(lostSoulsLabel);

            difficultyLabel       = new HudElementText(world.Game);
            difficultyLabel.Text  = "Difficulty: 100%";
            difficultyLabel.Color = textColor;
            difficultyLabel.BodyBehavior.Position = new Vector2(300.0f, 0.0f);
            gameHud.AddChild(difficultyLabel);

            helpLabel       = new HudElementText(world.Game);
            helpLabel.Text  = "F - Fullscreen";
            helpLabel.Color = textColor;
            helpLabel.BodyBehavior.Position = new Vector2(300.0f + difficultyLabel.BodyBehavior.Size.X + 15.0f, 0.0f);
            gameHud.AddChild(helpLabel);

            gameHud.RenderBehavior = new PrimitiveRectangleRenderBehavior(gameHud)
            {
                Color = new Color(0.0f, 0.0f, 0.0f, 0.4f)
            };
            gameHud.BodyBehavior.Position = Vector2.Zero;
            gameHud.BodyBehavior.Size     = helpLabel.BodyBehavior.Position + helpLabel.BodyBehavior.Size + new Vector2(5.0f, 2.0f);
        }
        public LostSoulWorldHud(LostSoulWorld world)
        {
            this.world             = world;
            world.GameOverChanged += OnGameOverChangedHandler;
            root = new HudElement(world.Game);
            root.BodyBehavior.Size = new Vector2(world.PlayField.Width, world.PlayField.Height);

            setupGameHud(world);
            setupGameOverHud(world);
        }
        private void setupGameOverHud(LostSoulWorld world)
        {
            gameOverHud                   = new HudElement(world.Game);
            gameOverHud.Visible           = false;
            gameOverHud.BodyBehavior.Size = root.BodyBehavior.Size;
            root.AddChild(gameOverHud);

            setupGameOverTextBackground(world);
            setupGameOverText(world);
            setupGameOverInstructions(world);
            adjustGameOverTextBackgroundSize();
        }
Esempio n. 4
0
 public void AddChild(HudElement element)
 {
     if (element == this)
     {
         throw new InvalidOperationException("HudElement cannot be its own child");
     }
     if (element.parent != null)
     {
         element.parent.RemoveChild(element);
     }
     element.parent = this;
     children.Add(element);
 }
        private void setupGameOverTextBackground(LostSoulWorld world)
        {
            gameOverTextBackground = new HudElement(world.Game);
            var center = gameOverHud.BodyBehavior.Size * 0.5f;
            var size   = new Vector2(200.0f, 200.0f);

            gameOverTextBackground.BodyBehavior.Size     = size;
            gameOverTextBackground.BodyBehavior.Position = new Vector2(
                center.X - size.X / 2.0f,
                center.Y - size.Y / 2.0f);
            var render = new PrimitiveRectangleRenderBehavior(gameOverTextBackground);

            var color = Color.Black;

            color.A      = (int)(255.0 * 0.8);
            render.Color = color;
            gameOverTextBackground.RenderBehavior = render;
            gameOverHud.AddChild(gameOverTextBackground);
        }
Esempio n. 6
0
 public void RemoveChild(HudElement element)
 {
     children.Remove(element);
 }