示例#1
0
 private void MoveApple(Apple theApple)
 {
     theApple.Position.Y += mVelocityY;
     if (theApple.Position.Y > graphics.GraphicsDevice.Viewport.Height && theApple.Visible == true)
     {
         theApple.Visible = false;
         theApple.isEated = true;
         existApple       = false;
         if (score >= 1000)  //第二种通关的可能就是score超过1000
         {
             MediaPlayer.Pause();
             cheer.Play();
             mCurrentState  = State.Success;
             mExitCountDown = 10;
         }
     }
 }
示例#2
0
        private int CheckAppleCollision(Apple theApple)
        {
            // 分别计算并使用封闭(包裹)盒给障碍物和车
            BoundingBox aAppleBox = new BoundingBox(new Vector3(theApple.Position.X, theApple.Position.Y, 0), new Vector3(theApple.Position.X + (mApple.Width * .4f), theApple.Position.Y + ((mApple.Height - 50) * .4f), 0));
            BoundingBox aCarBox = new BoundingBox(new Vector3(mCarPosition.X, mCarPosition.Y, 0), new Vector3(mCarPosition.X + (mCar.Width * .2f), mCarPosition.Y + (mCar.Height * .2f), 0));

            if (aAppleBox.Intersects(aCarBox) == true && theApple.isEated == false)
            {
                get.Play();
                MoveApple(theApple);
                theApple.Visible = false;
                theApple.isEated = true;
                existApple = false;
                score += 15;
                if(CarSelect == 1)if (mVelocityY >= 14) mVelocityY--;
                if (CarSelect == 2) if (mVelocityY >= 9) mVelocityY--;
                return 1;
            }
            return 0;
        }
示例#3
0
 private void MoveApple(Apple theApple)
 {
     theApple.Position.Y += mVelocityY;
     if (theApple.Position.Y > graphics.GraphicsDevice.Viewport.Height && theApple.Visible == true)
     {
         theApple.Visible = false;
         theApple.isEated = true;
         existApple = false;
         if (score >= 1000)  //第二种通关的可能就是score超过1000
         {
             MediaPlayer.Pause();
             cheer.Play();
             mCurrentState = State.Success;
             mExitCountDown = 10;
         }
     }
 }
示例#4
0
        private void AddApple()
        {
            int aRoadPosition = mRandom.Next(1, 8);
            int aPosition = 85 - mRandom.Next(1, 11); ;
            if (aRoadPosition == 2)
            {
                aPosition = 120+mRandom.Next(1,11);
            }
            else if (aRoadPosition == 3)
            {
                aPosition = 240 - mRandom.Next(1, 11);
            }
            else if (aRoadPosition == 4)
            {
                aPosition = 280 + mRandom.Next(1, 11);
            }
            else if (aRoadPosition == 5)
            {
                aPosition = 410 - mRandom.Next(1, 11);
            }
            else if (aRoadPosition == 6)
            {
                aPosition = 450 + mRandom.Next(1, 11);
            }
            else if (aRoadPosition == 7)
            {
                aPosition = 560 - mRandom.Next(1, 11);
            }
            bool aAddNewApple = true;
            foreach (Apple aApple in mApples)
            {
                if (aApple.Visible == false)
                {
                    aAddNewApple = false;
                    aApple.Visible = true;
                    aApple.isEated = false;
                    aApple.Position = new Vector2(aPosition, -mApple.Height);
                    break;
                }
            }
            if (aAddNewApple == true)
            {
                //Add a Apple to the left side of the Road
                Apple aApple = new Apple();
                aApple.Position = new Vector2(aPosition, -mApple.Height);

                mApples.Add(aApple);
            }
        }