Exemplo n.º 1
0
        private void nextWave()
        {
            wave++;
            invaderDirection = Direction.Right;
            if (wave < 7)
            {
                framesSkipped = 6 - wave;
            }
            else
            {
                framesSkipped = 0;
            }

            int currentInvaderYSpace = 0;

            for (int x = 0; x < 5; x++)
            {
                ShipType currentInvaderType = (ShipType)x;
                currentInvaderYSpace += INVADERYSPACING;

                int currentInavderXSpace = 0;
                for (int y = 0; y < 5; y++)
                {
                    currentInavderXSpace += INVADERXSPACING;
                    Point    newInvaderPoint = new Point(currentInavderXSpace, currentInvaderYSpace);
                    Invaders newInvader      = new Invaders(currentInvaderType, newInvaderPoint, 10);
                    invaders.Add(newInvader);
                }
            }
        }
Exemplo n.º 2
0
        private void returnFire()
        {
            if (invaderShots.Count == wave)
            {
                return;
            }
            if (random.Next(10) < (10 - wave))
            {
                return;
            }

            var invaderColumns = from invader in invaders
                                 group invader by invader.Location.X into columns
                                 select columns;

            int randomColumnNumber = random.Next(invaderColumns.Count());
            var randomColumn       = invaderColumns.ElementAt(randomColumnNumber);

            var invaderRow = from invader in randomColumn
                             orderby invader.Location.Y descending
                             select invader;
            Invaders shooter         = invaderRow.First();
            Point    newShotLocation = new Point(shooter.Location.X + (shooter.Area.Width / 2), shooter.Location.Y + shooter.Area.Height);

            Shot newShot = new Shot(newShotLocation, Direction.Down, formArea);

            invaderShots.Add(newShot);
        }