Esempio n. 1
0
        private void Split()
        {
            //todo use the ObjectInitializer to create these instead.
            var miniBallOne = new Ball()
            {
                IsActive   = true,
                IsMainBall = false,
                Speed      = this.Speed,
                Sprite     = new Sprite()
                {
                    DrawMap = new List <Pixel>()
                },
                CurrentDirection = this.CurrentDirection != Direction.UpRight ? Direction.UpRight : Direction.DownRight
            };

            var miniBallTwo = new Ball()
            {
                IsActive   = true,
                IsMainBall = false,
                Speed      = this.Speed,
                Sprite     = new Sprite()
                {
                    DrawMap = new List <Pixel>()
                },
                CurrentDirection = this.CurrentDirection != Direction.UpLeft ? Direction.UpLeft : Direction.DownLeft
            };

            foreach (var pixel in this.Sprite.DrawMap)
            {
                miniBallOne.Sprite.DrawMap.Add(Pixel.From(pixel, color: ConsoleColor.Red));
                miniBallTwo.Sprite.DrawMap.Add(Pixel.From(pixel, color: ConsoleColor.Red));
            }
            GameObjectCollection.Inject(miniBallOne);
            GameObjectCollection.Inject(miniBallTwo);
        }
Esempio n. 2
0
        private void ShootGun()
        {
            var bullet = hasMegaGuns ?
                         CurrentGame.GameObjectInitializer.GetMegaBullet(Sprite.Left.Point.X, Sprite.Right.Point.X, Sprite.Top.Point.Y) :
                         CurrentGame.GameObjectInitializer.GetBullet(Sprite.Left.Point.X, Sprite.Right.Point.X, Sprite.Top.Point.Y);

            GameObjectCollection.Inject(bullet);
        }
Esempio n. 3
0
        private void CollisionLogic()
        {
            if (BrickLevel > 0)
            {
                //update the break color.
                for (int i = 0; i < Sprite.DrawMap.Count; i++)
                {
                    Sprite.DrawMap[i] = Pixel.From(Sprite.DrawMap[i], color: BrickColorMap[BrickLevel]);
                }
            }
            //todo we should assign each power up its own chance to happen.
            //at the moment evey power up has the same chance to fire.
            var createPowerUp = CurrentGame.Randomizer.ByPercentage(25);

            if (createPowerUp)
            {
                var powerUpX = this.Sprite.Left.Point.X + this.Sprite.Width / 2;
                var powerUpY = this.Sprite.Bottom.Point.Y;

                var power = CurrentGame.GameObjectInitializer.GetRandomPowerUp(powerUpX, powerUpY);
                GameObjectCollection.Inject(power);
            }
        }