예제 #1
0
 public GameView(SpriteBatch batch, Camera camera, Level lvl, Player a_player, GraphicsDevice a_graphicsDevice)
 {
     player = a_player;
     level = lvl;
     fadeTime = maxFadeTime;
     m_camera = camera;
     m_graphicsDevice = a_graphicsDevice;
     spriteBatch = batch;
 }
예제 #2
0
        internal Level(Player a_player, Camera a_camera)
        {
            camera = a_camera;
            allLevels.Add("Level 1 - Where is the disco?");
            allLevels.Add("Level 2 - Dance baby, dance!");
            allLevels.Add("Level 3 - What was that?!");
            player = a_player;

            currentLevelName = allLevels.ElementAt(currentLevelNr - 1);
            LoadTiles("Content/Levels/level_" + currentLevelNr + ".txt");
        }
예제 #3
0
        /*************************************
         * Draw player
         *************************************/
        private void DrawPlayerAt(Microsoft.Xna.Framework.Vector2 a_viewBottomCenterPosition, float a_scale, Player a_player)
        {
            int textureIndex = a_player.getCurrentFrame().X;
            int textureRowIndex = a_player.getCurrentFrame().Y;

            if (player.mustBoogie())
            {
                player.setCurrentState(Player.State.Dancing);
                String boogieText = "I feel a sudden urge to... dance!";
                spriteBatch.Draw(dummyTexture, new Rectangle(((int)a_viewBottomCenterPosition.X + playerTexture.Width / 8) - 5, (int)a_viewBottomCenterPosition.Y - playerTexture.Height - 5, (int)inGameFont.MeasureString(boogieText).X + 8, (int)inGameFont.MeasureString(boogieText).Y + 8), Color.Black);
                spriteBatch.DrawString(inGameFont, boogieText, new Vector2(a_viewBottomCenterPosition.X + playerTexture.Width / 8, a_viewBottomCenterPosition.Y - playerTexture.Height), Color.White);
            }

            if (player.getBlinkingState() == Player.State.Blinking)
            {
                String boogieText = "Ouch!";
                spriteBatch.Draw(dummyTexture, new Rectangle(((int)a_viewBottomCenterPosition.X + playerTexture.Width / 8) - 5, (int)a_viewBottomCenterPosition.Y - playerTexture.Height - 5, (int)inGameFont.MeasureString(boogieText).X + 8, (int)inGameFont.MeasureString(boogieText).Y + 8), Color.Black);
                spriteBatch.DrawString(inGameFont, boogieText, new Vector2(a_viewBottomCenterPosition.X + playerTexture.Width / 8, a_viewBottomCenterPosition.Y - playerTexture.Height), Color.White);
            }

            //Get the source rectangle (pixels on the texture) for the tile type
            Rectangle sourceRectangle = new Rectangle(28 * textureIndex, 45 * textureRowIndex, 28, 44);

            //Create rectangle and draw it, note the transformation of the position
            Rectangle destRect = new Rectangle((int)(a_viewBottomCenterPosition.X - a_scale / 2.0f), (int)(a_viewBottomCenterPosition.Y - a_scale), (int)a_scale, (int)a_scale);

            spriteBatch.Draw(playerTexture, destRect, sourceRectangle, player.getPlayerColor());
        }