Exemplo n.º 1
0
        protected override void Draw(GameTime gameTime)
        {
            GraphicsDevice.Clear(Color.CornflowerBlue);

            // TODO: Add your drawing code here
            spriteBatch.Begin();
            gameField.Draw(spriteBatch);
            spriteBatch.Draw(mouseTexture, new Vector2(mousePosition.X, mousePosition.Y), Color.White);

            currentObjects.Clear();
            foreach (HitCircle circle in map.hitObjects)
            {
                int time = bassPosition();
                if (time >= circle.hitTime - map.getRealtimeAR() &&
                        time <= circle.hitTime + 50)
                {
                    currentObjects.Add(circle);
                    circle.Scale = map.circleSize;
                    circle.ApproachScale = circle.approachSize(time, map.getRealtimeAR());

                    circle.Draw(this.spriteBatch);
                }
            }

            int theTime = bassPosition();
            if ((mCurrentMouseState.LeftButton == ButtonState.Pressed && mPreviousMouseState.LeftButton == ButtonState.Released)
                    ||(mCurrentMouseState.RightButton == ButtonState.Pressed && mPreviousMouseState.RightButton == ButtonState.Released))
            {
                for (int i = 0; i < currentObjects.Count; i++)
                {
                    HitCircle hc = (HitCircle)currentObjects.ElementAt(i);
                    Rectangle rect = new Rectangle((int)hc.position.X, (int)hc.position.Y, hc.size.Width, hc.size.Height);
                    if (rect.Contains(mousePosition) && (theTime >= hc.hitTime - map.getRealtimeAR() &&
                            theTime <= hc.hitTime + 50))
                    {
                        int accuracy = checkHitTiming(hc, theTime);
                        ScoreObject scr = new ScoreObject(theTime, accuracy, this.Content);
                        if (!currentScoreObjects.Contains(scr))
                            currentScoreObjects.Add(scr);

                        foreach (ScoreObject so in currentScoreObjects)
                        {
                            so.LoadContent(this.Content);
                            so.Draw(spriteBatch, new Vector2(rect.X, rect.Y), theTime);
                        }
                        currentObjects.Remove(hc);
                    }
                }
            }

            spriteBatch.End();

            base.Draw(gameTime);
        }
Exemplo n.º 2
0
 public void onMouseClick(int theTime)
 {
     for(int i = 0; i < currentObjects.Count; i++)
     {
         HitCircle hc = (HitCircle)currentObjects.ElementAt(i);
         Rectangle rect = new Rectangle((int)hc.position.X, (int)hc.position.Y, hc.size.Width, hc.size.Height);
         if (rect.Contains(mousePosition) &&  (theTime >= hc.hitTime - map.getRealtimeAR() &&
                 theTime <= hc.hitTime + 50))
         {
             int accuracy = checkHitTiming(hc, theTime);
             ScoreObject so = new ScoreObject(theTime, accuracy, this.Content);
             so.LoadContent(this.Content);
             so.Draw(this.spriteBatch, new Vector2(rect.X, rect.Y), theTime);
             currentObjects.Remove(hc);
         }
     }
 }