Exemple #1
0
        public BonusSpawner(LostSoulWorld world)
            : base(world.Game)
        {
            this.world = world;

            actionBehavior = new BonusSpawnerBehavior();
        }
        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 void ResetGame()
        {
            world = new LostSoulWorld(this);
            world.LoadContent();

            audio.ListenerPosition = new Vector2(world.PlayField.Center.X, world.PlayField.Center.Y);
            audio.PanDivisor       = world.PlayField.Width / 2;
        }
        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 setupGameOverInstructions(LostSoulWorld world)
        {
            var center   = new Vector2(world.PlayField.Center.X, world.PlayField.Center.Y);
            var label    = new HudElementText(world.Game, "Press RMB to restart or Escape to exit.");
            var position = center - label.RenderBehavior.Size / 2.0f;

            position.Y += label.RenderBehavior.Size.Y;
            label.BodyBehavior.Position = position;
            label.Color = gameOverTextColor;
            gameOverTextBackground.AddChild(label);
        }
        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();
        }
Exemple #7
0
        private void SpawnBonus(LostSoulWorld world)
        {
            var klass = BonusRandomFactory.PickRandomBonus();

            if (klass == null)
            {
                throw new InvalidOperationException("null bonus class returned");
            }
            var   entity     = new Bonus(world.Game, klass);
            var   spawnField = world.PlayField;
            float margin     = entity.BodyBehavior.Size.X;

            spawnField.Inflate((int)-margin, (int)-margin);
            entity.BodyBehavior.Position = new Vector2(
                (float)spawnField.Left + (float)random.NextDouble() * spawnField.Width,
                (float)spawnField.Top + (float)random.NextDouble() * spawnField.Height);
            world.AddActor(entity);
        }
        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);
        }
 public LostSoulWorldInputBehavior(LostSoulWorld world)
 {
     this.world = world;
 }
Exemple #10
0
 public override void Activate(LostSoulWorld world)
 {
     world.ModifyDifficultyByFactor(-0.25f);
     world.Game.Audio.PlaySound(world.Game.ContentLoader.BabySound);
 }
Exemple #11
0
 public override void Activate(LostSoulWorld world)
 {
     world.AddActor(new AtomBomb(world.Game));
 }
Exemple #12
0
 public override void Activate(LostSoulWorld world)
 {
     world.AddSpeedModifierActor(new FactorModifierActor(world.Game, 0.2f, 3.0f));
     world.Game.Audio.PlaySound(world.Game.ContentLoader.TurtleSound);
 }
Exemple #13
0
 public override void Activate(LostSoulWorld world)
 {
     world.Game.Audio.PlaySound(world.Game.ContentLoader.OneUpSound);
     world.AddLives(5);
 }
Exemple #14
0
 public abstract void Activate(LostSoulWorld world);