예제 #1
0
파일: Game1.cs 프로젝트: Xivid/RhythmHit
 // ----------------------- Feng ------------------------------------------------
 // check if the rocket runs into a hazard
 private void CheckCollision(Hazard theHazard)
 {
     // wrap the hazard and car with BoundingBox
     BoundingBox aHazardBox = new BoundingBox(new Vector3(theHazard.Position.X, theHazard.Position.Y, 0), new Vector3(theHazard.Position.X + (mHazard.Width * .5f), theHazard.Position.Y + ((mHazard.Height) * .5f), 0));
     BoundingBox aCarBox = new BoundingBox(new Vector3(mCarPosition.X, mCarPosition.Y, 0), new Vector3(mCarPosition.X + (mCar.Width * .8f), mCarPosition.Y + (mCar.Height * .8f), 0));
     BoundingBox aCarBoxPerfect = new BoundingBox(new Vector3(mCarPosition.X, mCarPosition.Y, 0), new Vector3(mCarPosition.X + (mCar.Width * .8f), mCarPosition.Y + (mCar.Height * .8f) * 0.05f, 0));
     BoundingBox aHazardBoxPerfect = new BoundingBox(new Vector3(theHazard.Position.X, theHazard.Position.Y + (mHazard.Height * .25f), 0), new Vector3(theHazard.Position.X + (mHazard.Width * .5f), theHazard.Position.Y + ((mHazard.Height) * .5f), 0));
     if (aHazardBox.Intersects(aCarBox) == true) // collided
     {
         if (aHazardBoxPerfect.Intersects(aCarBoxPerfect) == true)
         {
             mScore += 2;
             mHazardsPerfect++;
             theHazard.sign = Hazard.Sign.Perfect;
         }
         else
         {
             mScore++;
             mHazardsGood++;
             theHazard.sign = Hazard.Sign.Good;
         }
         mHazardsCombo++;
         hitSE.Play();
         theHazard.Visible = false;
         theHazard.SignDisplayTime = (double)mHazard.Height / mVelocityY; // show "Perfect" or "Good" in the game scene
     }
 }
예제 #2
0
파일: Game1.cs 프로젝트: Xivid/RhythmHit
 // ----------------------- Tian ---------------------
 private void MoveHazard(Hazard theHazard)
 {
     theHazard.Position.Y += (int)(mVelocityY * deltaTime);
     if (theHazard.Position.Y > graphics.GraphicsDevice.Viewport.Height && theHazard.Visible == true)
     {
         theHazard.Visible = false;
         mHazardsCombo = 0;
         ++mHazardsMiss;
         theHazard.sign = Hazard.Sign.Miss; // sign it with "miss" so that a "MISS" can be shown on the screen
         theHazard.Position.Y -= mHazard.Height;
         theHazard.SignDisplayTime = (double)mHazard.Height / mVelocityY; // set the duration it will be displayed
     }
 }
예제 #3
0
파일: Game1.cs 프로젝트: Xivid/RhythmHit
        private void AddHazard()
        {
            int aPosition = mLastHazardAtLeft ? 440 : 275; // make every hazard in the different column with the previous one

            bool aAddNewHazard = true;
            foreach (Hazard aHazard in mHazards)
            {
                if (aHazard.Visible == false && aHazard.sign == Hazard.Sign.Undecided) //reuse the isolated ones
                {
                    aAddNewHazard = false;
                    aHazard.Visible = true;
                    aHazard.Position = new Vector2(aPosition, -mHazard.Height);
                    break;
                }
            }

            if (aAddNewHazard == true) //no one can be reused
            {
                // Add a hazard to the different side to the previous one
                Hazard aHazard = new Hazard();
                aHazard.Position = new Vector2(aPosition, -mHazard.Height);
                mHazards.Add(aHazard);
            }
        }