Beispiel #1
0
 public void Update(GameTime gameTime, Mouse_handler ourCursor)
 {
     HandleMouse(ourCursor);
 }
Beispiel #2
0
        public void HandleMouse(Mouse_handler ourCursor)
        {
            MouseState aCurrentMouseState = Mouse.GetState();

            foreach (Bottle b in bottle_list)
            {
                if (ourCursor.ButtonClick(b))
                {
                    if ((aCurrentMouseState.LeftButton == ButtonState.Pressed) & (mPreviousMouseState.LeftButton == ButtonState.Released))
                    {
                        b.Selecting         = true;
                        b.position.X        = aCurrentMouseState.X;
                        b.position.Y        = aCurrentMouseState.Y;
                        mPreviousMouseState = aCurrentMouseState;
                    }
                    else if (aCurrentMouseState.LeftButton == ButtonState.Pressed & mPreviousMouseState.LeftButton == ButtonState.Pressed)
                    {
                        b.position.X        = aCurrentMouseState.X;
                        b.position.Y        = aCurrentMouseState.Y;
                        mPreviousMouseState = aCurrentMouseState;
                    }
                    else if (aCurrentMouseState.LeftButton == ButtonState.Released && mPreviousMouseState.LeftButton == ButtonState.Pressed)
                    {
                        b.Selecting         = false;
                        mPreviousMouseState = aCurrentMouseState;
                    }
                    else
                    {
                        b.Selecting = false;
                    }
                }

                if (no_of_bottles == 3)
                {
                    if ((b.bottle_rect.Intersects(yellow_trash_chk)) ||
                        (b.bottle_rect.Intersects(orange_trash_chk)) ||
                        (b.bottle_rect.Intersects(red_trash_chk)))
                    {
                        Trash_spread.trash_counter++;
                        Trash_spread.score = Trash_spread.score - 5;
                        draw_minus         = true;
                        b.position         = new Vector2(-500, 0);
                    }
                }

                if (no_of_bottles == 4)
                {
                    if ((b.bottle_rect.Intersects(red_trash_chk)))
                    {
                        Trash_spread.trash_counter++;
                        Trash_spread.score = Trash_spread.score - 5;
                        draw_minus         = true;
                        b.position         = new Vector2(-500, 0);
                    }
                }

                if (b.bottle_rect.Intersects(blue_trash_chk))
                {
                    Trash_spread.trash_counter++;
                    Trash_spread.score = Trash_spread.score + 10;
                    draw_add           = true;
                    b.position         = new Vector2(-500, 0);
                }
            }
        }