예제 #1
0
        public void Update(CanvasBitmap alienImage, CanvasBitmap shipImage, CanvasBitmap laserImage)//CanvasDrawingSession image)//
        {
            if (gameOver == false)
            {
                if (MoveShipLeft(ship.MoveLeft) == true || MoveShipRight(ship.MoveRight) == true)
                {
                    ship.Update();
                }

                alien.Update();

                drawables.Add(ship);
                for (int i = 0; i < 10; i++)
                {
                    drawables.Add(AlienList[i]);
                }
                if (Gamepad.Gamepads.Count > 0)
                {
                    controller = Gamepad.Gamepads.First();
                    var reading = controller.GetCurrentReading();
                    if (reading.Buttons.HasFlag(GamepadButtons.A))
                    {
                        lasers.ShootLaser(laserImage, ship);
                        lasers.Update(laserImage);
                        lasers = new Lasers(lasers.X, lasers.Y, laserImage);
                        drawables.Add(lasers);
                    }
                }
                Collide(lasers, AlienList);

                gameOver = HitAll(AlienList); //if gameOver turns true, should quit

                if (gameOver == false)
                {
                    int lastAlienToTouch = 0;
                    for (int index = 1; index <= 10; index++)
                    {
                        if (AlienList[index - 1].GotHit == false && AlienList[index - 1].Y == 400)
                        {
                            lastAlienToTouch = index - 1;

                            if (score.LivesLeft == 0)
                            {
                                gameOver = true;
                            }
                        }
                    }
                }
            }
        }