Exemplo n.º 1
0
        /// <summary>
        /// Load graphics content.
        /// </summary>
        protected override void LoadContent()
        {
            marbleCursorTexture =
                MarbletsGame.Content.Load <Texture2D>("Textures/marble_cursor");
            Marble.LoadContent();

            base.LoadContent();
        }
Exemplo n.º 2
0
        /// <summary>
        /// Create a new game board
        /// </summary>
        /// <param name="game"></param>
        public GameBoard(Game game)
            : base(game)
        {
            Marble.Initialize();
#if MOUSE
            MouseState mouse = Mouse.GetState();
            lastMouseX = mouse.X;
            lastMouseY = mouse.Y;
#endif
        }
Exemplo n.º 3
0
        /// <summary>
        /// Initializes the board
        /// </summary>
        public void NewGame()
        {
            gameOver = false;

            //Fill board
            for (int x = 0; x < Width; x++)
            {
                for (int y = 0; y < Height; y++)
                {
                    Marbles[x, y]          = new Marble();
                    Marbles[x, y].Position = BoardToScreen(x, y);
                }
            }

            cursorX = 0;
            cursorY = 0;

            //The cursor might be on a matching color set
            FindSelectedMarbles();
        }
Exemplo n.º 4
0
        /// <summary>
        /// Initializes the board
        /// </summary>
        public void NewGame()
        {
            // Added functionality to account for the screen orientation.
            switch (MarbletsGame.screenOrientation)
            {
            case MarbletsGame.ScreenOrientation.LandscapeRight:
                scoreOffset = new Vector2(-Marble.Height * 1.5f, 0);
                break;

            case MarbletsGame.ScreenOrientation.LandscapeLeft:
                scoreOffset = new Vector2(Marble.Height * 1.5f, 0);
                break;

            default:
                break;
            }

            gameOver = false;

            //Fill board
            for (int x = 0; x < Width; x++)
            {
                for (int y = 0; y < Height; y++)
                {
                    Marbles[x, y] = new Marble();
                    Marbles[x, y].boardLocation.X = x;
                    Marbles[x, y].boardLocation.Y = y;
                    Marbles[x, y].Position        = BoardToScreen(x, y);
                }
            }

            // Remember, cursor position is 0 based.
            cursorX = 2;
            cursorY = 2;

            //The cursor might be on a matching color set
            FindSelectedMarbles();
        }
Exemplo n.º 5
0
		private void AttemptDrop()
		{
			//Drop a marble into every column that isn't full
			bool createdMarble = false;

			for (int x = 0; x < Width; x++)
			{
				for (int y = Height - 1; y >= 0; y--)
				{
					if (Marbles[x, y] == null)
					{
						Marbles[x, y] = new Marble();
						Marbles[x, y].Position = BoardToScreen(x, y);
						createdMarble = true;
						break;
					}
				}
			}

			if (createdMarble)
			{
				Sound.Play(SoundEntry.LandMarbles);
			}
		}
Exemplo n.º 6
0
        private void AttemptDrop()
        {
            //Drop a marble into every column that isn't full
            bool createdMarble = false;

            for (int x = 0; x < Width; x++)
            {
                for (int y = Height - 1; y >= 0; y--)
                {
                    if (Marbles[x, y] == null)
                    {
                        Marbles[x, y]          = new Marble();
                        Marbles[x, y].Position = BoardToScreen(x, y);
                        createdMarble          = true;
                        break;
                    }
                }
            }

            if (createdMarble)
            {
                // TODO Sound.Play(SoundEntry.LandMarbles);
            }
        }
Exemplo n.º 7
0
        private void FallAndSlide()
        {
            //Fall
            for (int x = 0; x < Width; x++)
            {
                int moveDistance = 0;
                for (int y = Height - 1; y >= 0; y--)
                {
                    //Remember the current marble
                    Marble currentMarble = Marbles[x, y];

                    if (moveDistance > 0)
                    {
                        Marbles[x, y + moveDistance] = Marbles[x, y];
                        Marbles[x, y] = null;
                        if (Marbles[x, y + moveDistance] != null)
                        {
                            Marbles[x, y + moveDistance].Position =
                                BoardToScreen(x, y + moveDistance);
                        }
                    }

                    if (currentMarble != null && currentMarble.Selected)
                    {
                        moveDistance++;
                    }
                }

                //Tidy up any marbles that didn't have anything above them
                for (int y = 0; y < moveDistance; y++)
                {
                    Marbles[x, y] = null;
                }
            }

            //Slide
            for (int y = 0; y < Height; y++)
            {
                int moveDistance = 0;
                for (int x = Width - 1; x >= 0; x--)
                {
                    //Remember the current marble
                    Marble currentMarble = Marbles[x, y];

                    if (moveDistance > 0)
                    {
                        Marbles[x + moveDistance, y] = Marbles[x, y];
                        Marbles[x, y] = null;
                        if (Marbles[x + moveDistance, y] != null)
                        {
                            Marbles[x + moveDistance, y].Position =
                                BoardToScreen(x + moveDistance, y);
                        }
                    }

                    if (currentMarble == null)
                    {
                        moveDistance++;
                    }
                }

                //Tidy up any marbles that didn't have anything to their left
                for (int x = 0; x < moveDistance; x++)
                {
                    Marbles[x, y] = null;
                }
            }
        }
Exemplo n.º 8
0
        /// <summary>
        /// Called when the GameComponent needs to be updated.
        /// Game Board update performs animation on the marbles, checks for cursor
        /// movement. Most of the game logic is here or called from here
        /// </summary>
        /// <param name="gameTime">Current game time</param>
        public override void Update(GameTime gameTime)
        {
            if (gameTime == null)
            {
                return;
            }

            base.Update(gameTime);

            if (!GameOver)
            {
                Marble.UpdateStatic(gameTime);

                foreach (Marble marble in Marbles)
                {
                    if (marble != null)
                    {
                        marble.Update(gameTime);
                    }
                }

                switch (AnimationState)
                {
                case Animation.Breaking:
                {
                    //Fade the score
                    scoreFadeFactor = (float)((gameTime.TotalGameTime -
                                               scoreFadeStart.TotalGameTime).TotalSeconds /
                                              Marble.BreakTime);

                    //Wait until all marbles are broken.
                    bool stillBreaking = false;
                    foreach (Marble marble in Marbles)
                    {
                        if (marble != null)
                        {
                            if (marble.Animation == Animation.Breaking)
                            {
                                stillBreaking = true;
                                break;
                            }
                        }
                    }

                    //Done breaking - do the 'fall' and 'slide'
                    if (!stillBreaking)
                    {
                        FallAndSlide();
                        totalSelected = 0;
                        FindCursorPosition();
                        FindSelectedMarbles();
                        // TODO Sound.Play(SoundEntry.LandMarbles);
                        AnimationState = Animation.None;
                    }
                    break;
                }

                case Animation.None:
                {
                    moveCursor();
                    BreakMarbles(gameTime);
                    break;
                }
                }
            }
        }
Exemplo n.º 9
0
        /// <summary>
        /// Initializes the board
        /// </summary>
        public void NewGame()
        {
            // Added functionality to account for the screen orientation.
            switch (MarbletsGame.screenOrientation)
            {
                case MarbletsGame.ScreenOrientation.LandscapeRight:
                    scoreOffset = new Vector2(-Marble.Height * 1.5f, 0);
                    break;

                case MarbletsGame.ScreenOrientation.LandscapeLeft:
                    scoreOffset = new Vector2(Marble.Height * 1.5f, 0);
                    break;

                default:
                    break;
            }

            gameOver = false;

            //Fill board
            for (int x = 0; x < Width; x++)
            {
                for (int y = 0; y < Height; y++)
                {
                    Marbles[x, y] = new Marble();
                    Marbles[x, y].boardLocation.X = x;
                    Marbles[x, y].boardLocation.Y = y;
                    Marbles[x, y].Position = BoardToScreen(x, y);
                }
            }

            // Remember, cursor position is 0 based.
            cursorX = 2;
            cursorY = 2;

            //The cursor might be on a matching color set
            FindSelectedMarbles();
        }
Exemplo n.º 10
0
		/// <summary>
		/// Initializes the board
		/// </summary>
		public void NewGame()
		{
			gameOver = false;

			//Fill board
			for (int x = 0; x < Width; x++)
			{
				for (int y = 0; y < Height; y++)
				{
					Marbles[x, y] = new Marble();
					Marbles[x, y].Position = BoardToScreen(x, y);
				}
			}

			cursorX = 0;
			cursorY = 0;

			//The cursor might be on a matching color set
			FindSelectedMarbles();
		}
Exemplo n.º 11
0
 /// <summary>
 /// Create a new game board
 /// </summary>
 /// <param name="game"></param>
 public GameBoard(Game game)
     : base(game)
 {
     Marble.Initialize();
 }