예제 #1
0
        /// <summary>
        /// Checks all collisions in Game1.COLLISIONS Dictionary.
        /// </summary>
        public static void checkCollisons()
        {
            if (Game1.baseState.Equals("main")) // if the title screen is in session
            {
                Button b  = (Button)Game1.COLLISIONS["playButton"];
                Button b2 = (Button)Game1.COLLISIONS["optionsButton"];
                if (!b.isSelected() &&
                    b.compareTo((CollisionObject)Game1.COLLISIONS["cursor"]).Equals("collision"))
                {
                    b.forceSelect();
                }
                else if (b.isSelected() &&
                         b.compareTo((CollisionObject)Game1.COLLISIONS["cursor"]).Equals("none"))
                {
                    b.unselect();
                }
                else if (b.isSelected() &&
                         Cursor.leftClicked)
                {
                    b.click();
                }


                if (!b2.isSelected() &&
                    b2.compareTo((CollisionObject)Game1.COLLISIONS["cursor"]).Equals("collision"))
                {
                    b2.forceSelect();
                }
                else if (b2.isSelected() &&
                         b2.compareTo((CollisionObject)Game1.COLLISIONS["cursor"]).Equals("none"))
                {
                    b2.unselect();
                }
                else if (b2.isSelected() &&
                         Cursor.leftClicked)
                {
                    b2.click();
                }
            }
            else if (Game1.baseState.Equals("game")) // if the game is in session
            {
                if (!GameState.isInitiated)
                {
                    return;
                }
                List <Pikmin> pikminList = (List <Pikmin>)Game1.COLLISIONS["pikminList"];
                for (int i = 0; i < pikminList.Count(); i++)
                {
                    for (int i2 = 0; i2 < pikminList.Count(); i2++)
                    {
                        if (i >= i2)
                        {
                            continue;
                        }
                        else if (pikminList[i].compareTo(pikminList[i2]).Equals("collision"))
                        {
                            if (!pikminList[i].getCollidable())
                            {
                                continue;
                            }
                            pikminList[i].collision("south");
                            pikminList[i2].collision("north");
                        }
                    }
                }
            }
            else if (Game1.baseState.Equals("options"))//if the option screen is displayed.
            {
                //Options collisions (Buttons and stuff)\\
            }
        }
예제 #2
0
        /// <summary>
        /// This is called when the game should draw itself.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Draw(GameTime gameTime)
        {
            GraphicsDevice.Clear(Color.White);

            spriteBatch.Begin();

            if (baseState.Equals("main")) //Frame is on the title screen
            {
                if (cursor.getStandingImage() != FOREGROUND_IMAGES["titleCursor"])
                {
                    cursor.setStand(FOREGROUND_IMAGES["titleCursor"]);
                }
                spriteBatch.Draw(TITLE_IMAGES["background"], new Vector2(0, 0), Color.White);
                spriteBatch.Draw(TITLE_IMAGES["title"], new Vector2(100, 25), Color.White);

                if (playButton.isSelected())
                {
                    spriteBatch.Draw(playButton.getStandingImage(), playButton.getPosition(), Color.LimeGreen);
                }
                else
                {
                    spriteBatch.Draw(playButton.getStandingImage(), playButton.getPosition(), Color.White);
                }

                if (optionButton.isSelected())
                {
                    spriteBatch.Draw(optionButton.getStandingImage(), optionButton.getPosition(), Color.LimeGreen);
                }
                else
                {
                    spriteBatch.Draw(optionButton.getStandingImage(), optionButton.getPosition(), Color.White);
                }

                cursor.draw(spriteBatch);
                if (playButton.isClicked())
                {
                    baseState = "game";
                }
            }
            else if (baseState.Equals("game")) //Frame is on the game screen
            {
                if (cursor.getStandingImage() != FOREGROUND_IMAGES["gameCursor"])
                {
                    GameState.initiate(cursor);
                    cursor.setStand(FOREGROUND_IMAGES["gameCursor"]);
                }
                cursor.draw(spriteBatch);
                GameState.draw(spriteBatch);
            }
            else if (baseState.Equals("options"))
            {
                if (cursor.getStandingImage() != FOREGROUND_IMAGES["titleCursor"])
                {
                    cursor.setStand(FOREGROUND_IMAGES["titleCursor"]);
                }
                cursor.draw(spriteBatch);
                OptionState.draw(spriteBatch);
            }

            spriteBatch.End();

            base.Draw(gameTime);
        }