Beispiel #1
0
 public void PlayStartSound(Game1 game)
 {
     if (playsoundatstart && !game.isGameOver())
     {
         soundGong.Play(1.0f, 0.0f, 0.0f, false);
         playsoundatstart = false;
     }
 }
Beispiel #2
0
 public void PlayUmbrellaPickUp(Game1 game)
 {
     if (!game.isGameOver())
         soundUmbrella_PickUp.Play(1.0f, 0.0f, 0.0f, false);
 }
Beispiel #3
0
 public void PlayUmbrellaOpen(Game1 game)
 {
     if (!game.isGameOver())
         soundUmbrella_Open.Play(1.0f, 0.0f, 0.0f, false);
 }
Beispiel #4
0
 public void PlayGong(Game1 game)
 {
     if(!game.isGameOver())
         soundGong.Play(1.0f, 0.0f, 0.0f, false);
 }
Beispiel #5
0
 public void PlayFlowerPick(Game1 game)
 {
     if (!game.isGameOver())
         soundFlowerPick.Play(0.4f, 0.0f, 0.0f, false);
 }
Beispiel #6
0
 public void PlayAngryBuzz(Game1 game)
 {
     if (!game.isGameOver())
         soundAngryBuzz.Play(1.0f, 0.0f, 0.0f, false);
 }
Beispiel #7
0
 public void StartBuzzing(Game1 game)
 {
     if (!game.isGameOver())
     {
         if (soundBeesBuzzingInstance == null)
             soundBeesBuzzingInstance = soundBeesBuzzing.Play(0.2f, 0.0f, 0.0f, true);
         else
             soundBeesBuzzingInstance.Resume();
     }
 }
Beispiel #8
0
        public void Draw(Game1 game, GameTime gameTime, int max_X, int max_Y, Sound1 so, int LevelRefresh, PlayerObject pl)
        {
            string output;
            Vector2 FontOrigin;

            //greyscale_color = (float)Math.Abs(Math.Sin(MathHelper.ToRadians((float)(gameTime.TotalGameTime.TotalSeconds * 10))));

            // TODO: Add your drawing code here
            // Draw the sprite.
            spriteBatch.Begin(SpriteBlendMode.AlphaBlend);

            int xTiles = max_X / sprite4.Width;
            int yTiles = max_Y / sprite4.Height;

            // background image
            for (int i = 0; i <= xTiles; i++)
            {
                for (int j = 0; j <= yTiles; j++)
                {
                    //spriteBatch.Draw(sprite4, Vector2.Zero, null, Color.White, 0.0f, Vector2.Zero, new Vector2(graphics.GraphicsDevice.Viewport.Width / (float)sprite4.Width, graphics.GraphicsDevice.Viewport.Height / (float)sprite4.Height), SpriteEffects.None, 0);
                    //spriteBatch.Draw(sprite4, new Vector2(i * sprite4.Width, j * sprite4.Height), new Color(1.0f, 1.0f, 1.0f, MathHelper.Clamp(greyscale_color,0.2f,1.0f)));
                    spriteBatch.Draw(sprite4, new Vector2(i * sprite4.Width, j * sprite4.Height), new Color(1.0f, 1.0f, 1.0f));
                }
            }

            // tree
            DrawTree(max_Y);

            // flowers
            float half_w = sprite7.Width / 2;
            float half_h = sprite7.Height / 2;
            foreach (MovingObject a in SpriteList2)
            {
                Vector2 center;
            //                float new_scale = (game.CorrectX() + game.CorrectY())/2;
                center = new Vector2(half_w, half_h);
            //                center = new Vector2(sprite7.Width / 2 * game.CorrectX(), sprite7.Height / 2 * game.CorrectY());
                spriteBatch.Draw(sprite7, a.position, null, Color.White, a.rotation, center, 1.0f, SpriteEffects.None, 0.0f);
            //                spriteBatch.Draw(sprite7, new Vector2(a.position.X * game.CorrectX(), a.position.Y * game.CorrectY()), null, Color.White, a.rotation, center, new_scale, SpriteEffects.None, 0.0f);
            }

            // beehive
            spriteBatch.Draw(sprite6, new Vector2(max_X * 4 / 7, 2), Color.White);

            // bees
            if (!game.isGameOver())
            {
                Vector2 center;

                // umbrella
                if (umbrella != null)
                {
                    Rectangle r = new Rectangle(0, 0, sprite11.Width/2, sprite11.Height);
                    center = new Vector2(umb_width, umb_height);
                    spriteBatch.Draw(sprite11, umbrella.position, r, Color.White, 0.0f, center, 1.0f, SpriteEffects.None, 0.0f);
                }

                foreach (MovingObject a in SpriteList)
                {
                    switch (a.tex)
                    {
                        case 0:
                            center = new Vector2(sprite1.Width / 2, sprite1.Height / 2);
                            spriteBatch.Draw(sprite1, a.position, null, Color.White, a.rotation, center, 1.0f, SpriteEffects.None, 0.0f);
                            output = a.position.ToString();
                            FontOrigin = Font1.MeasureString(output) / 2;
                            FontPos = a.position;
                            //spriteBatch.DrawString(Font1, output, FontPos, Color.LightGreen, 0, FontOrigin, 1.0f, SpriteEffects.None, 0.5f);
                            break;
                        case 1:
                            center = new Vector2(sprite2.Width / 2, sprite2.Height / 2);
                            spriteBatch.Draw(sprite2, a.position, null, Color.White, a.rotation, center, 1.0f, SpriteEffects.None, 0.0f);
                            output = a.position.ToString();
                            FontOrigin = Font1.MeasureString(output) / 2;
                            FontPos = a.position;
                            //spriteBatch.DrawString(Font1, output, FontPos, Color.LightGreen, 0, FontOrigin, 1.0f, SpriteEffects.None, 0.5f);
                            break;
                        case 2:
                            center = new Vector2(sprite3.Width / 2, sprite3.Height / 2);
                            spriteBatch.Draw(sprite3, a.position, null, Color.White, a.rotation, center, 1.0f, SpriteEffects.None, 0.0f);
                            output = a.position.ToString();
                            FontOrigin = Font1.MeasureString(output) / 2;
                            FontPos = a.position;
                            //spriteBatch.DrawString(Font1, output, FontPos, Color.LightGreen, 0, FontOrigin, 1.0f, SpriteEffects.None, 0.5f);
                            break;
                        case 3:
                            center = new Vector2(sprite4.Width / 2, sprite4.Height / 2);
                            spriteBatch.Draw(sprite4, a.position, null, Color.White, a.rotation, center, 1.0f, SpriteEffects.None, 0.0f);
                            output = a.position.ToString();
                            FontOrigin = Font1.MeasureString(output) / 2;
                            FontPos = a.position;
                            //spriteBatch.DrawString(Font1, output, FontPos, Color.LightGreen, 0, FontOrigin, 1.0f, SpriteEffects.None, 0.5f);
                            break;
                        case 4:
                            center = new Vector2(sprite5.Width / 2, sprite5.Height / 2);
                            Color draw_color = Color.White;
                            Texture2D current_sprite = sprite5;

                            if (a.first)
                            {
                                current_sprite = sprite10;
                                if (old_position.X > a.position.X )
                                {
                                    SEVal = SpriteEffects.FlipHorizontally;
                                }
                                else
                                if (old_position.X < a.position.X )
                                {
                                    SEVal = SpriteEffects.None;
                                }

                                if (game.GetPlayerHit())
                                    draw_color = Color.Crimson;
                                else
                                    draw_color = Color.White;

                                spriteBatch.Draw(current_sprite, a.position, null, draw_color, a.rotation, center, 1.0f, SEVal, 0.0f);

                                if(pl.umbrella_active>0)
                                {
                                    Rectangle r=new Rectangle(sprite11.Width / 2, 0, sprite11.Width, sprite11.Height);;
                                    center = new Vector2(umb_width, umb_height);
                                    if(SEVal==SpriteEffects.None)
                                        spriteBatch.Draw(sprite11, new Vector2(a.position.X + 30,a.position.Y - 10), r, Color.White, 0.0f, center, 1.0f, SpriteEffects.None, 0.0f);
                                    else
                                        spriteBatch.Draw(sprite11, new Vector2(a.position.X - 30, a.position.Y - 10), r, Color.White, 0.0f, center, 1.0f, SpriteEffects.None, 0.0f);
                                }
                            }
                            else
                            if (a.speed.X < 0)
                                spriteBatch.Draw(current_sprite, a.position, null, draw_color, a.rotation, center, 1.0f, SpriteEffects.FlipHorizontally, 0.0f);
                            else
                                spriteBatch.Draw(current_sprite, a.position, null, draw_color, a.rotation, center, 1.0f, SpriteEffects.None, 0.0f);

                            /*output = a.speed.ToString();
                            FontOrigin = Font1.MeasureString(output) / 2;
                            FontPos = new Vector2(a.position.X,a.position.Y+70);
                            spriteBatch.DrawString(Font1, output, FontPos, Color.Black, 0, FontOrigin, 1.0f, SpriteEffects.None, 0.5f);
                            */
                            break;
                    }

                }
            }
            // Game Over
            else
            {
                float float_effect = 0.75f + MathHelper.Clamp((float)Math.Abs(Math.Sin((gameTime.TotalGameTime.TotalSeconds) * 4 * Math.PI / 180)), 0.0f, 1.0f);
                //float float_effect = 0.75f + (float)Math.Sin((gameTime.TotalGameTime.TotalSeconds)*180 * Math.PI / 180);
                spriteBatch.Draw(sprite9, new Vector2(max_X / 2, max_Y / 2), null, Color.White, 0.0f, new Vector2(sprite9.Width / 2, sprite9.Height / 2), float_effect, SpriteEffects.None, 1.0f);
                so.PlayGameOver(game);
            }

            if (LevelRefresh > 0)
            {
                int Count = LevelRefresh / 60 + 1;
                output = Count.ToString();

                FontOrigin = Font3.MeasureString(output) / 2;
                FontPos = new Vector2(max_X / 2, max_Y / 2);
                spriteBatch.DrawString(Font3, output, FontPos * 1.01f, Color.Black, 0, FontOrigin, 1.5f, SpriteEffects.None, 1.0f);
                spriteBatch.DrawString(Font3, output, FontPos, Color.Wheat, 0, FontOrigin, 1.5f, SpriteEffects.None, 1.0f);
            }

            if (draw_HUD)
            {
                // Draw Hello World
                double val = Math.Sin((gameTime.TotalGameTime.TotalSeconds * 180) * Math.PI / 180);
                double val2 = max_X / (float)sprite4.Height;
                FPS_Count += (double)gameTime.ElapsedGameTime.TotalSeconds;//MovingObject val3 = SpriteList.First();

                framecount++;

                // HUD background
                spriteBatch.Draw(sprite8, Vector2.Zero, Color.White);

                double FPS = framecount/FPS_Count;
                output = "FPS: " + FPS.ToString("F04");
                FontOrigin = Font1.MeasureString(output) / 2;
                FontPos = new Vector2(max_X-100, max_Y-50);
                spriteBatch.DrawString(Font1, output, FontPos * 1.002f, Color.Black, 0, FontOrigin, 1.0f, SpriteEffects.None, 1.0f);
                spriteBatch.DrawString(Font1, output, FontPos, Color.White, 0, FontOrigin, 1.0f, SpriteEffects.None, 1.0f);

                output = "LEVEL: " + game.GetLevel() + "     " + "BEES: " + SpriteList.Count();
                FontOrigin = Font1.MeasureString(output) / 2;
                FontPos = new Vector2(FontOrigin.X + 40, 30);
                spriteBatch.DrawString(Font1, output, new Vector2(FontPos.X * 1.02f, FontPos.Y *1.06f), Color.Black, 0, FontOrigin, 1.0f, SpriteEffects.None, 1.0f);
                spriteBatch.DrawString(Font1, output, FontPos, Color.White, 0, FontOrigin, 1.0f, SpriteEffects.None, 1.0f);

                output = "LIVES: " + game.GetLives();
                FontOrigin = Font1.MeasureString(output) / 2;
                FontPos = new Vector2(FontOrigin.X + 40, 60);
                spriteBatch.DrawString(Font1, output, FontPos * 1.04f, Color.Black, 0, FontOrigin, 1.0f, SpriteEffects.None, 1.0f);
                spriteBatch.DrawString(Font1, output, FontPos, Color.White, 0, FontOrigin, 1.0f, SpriteEffects.None, 1.0f);
                /*
                output = "SINE: " + val.ToString("F04");
                FontOrigin = Font1.MeasureString(output) / 2;
                FontPos = new Vector2(FontOrigin.X + 40, 30);
                spriteBatch.DrawString(Font1, output, FontPos * 1.04f, Color.Black, 0, FontOrigin, 1.0f, SpriteEffects.None, 1.0f);
                spriteBatch.DrawString(Font1, output, FontPos, Color.White, 0, FontOrigin, 1.0f, SpriteEffects.None, 1.0f);
                */
                output = "FLOWERS: " + game.GetFlowerCount();
                FontOrigin = Font1.MeasureString(output) / 2;
                FontPos = new Vector2(FontOrigin.X + 40, 90);
                spriteBatch.DrawString(Font1, output, FontPos * 1.03f, Color.Black, 0, FontOrigin, 1.0f, SpriteEffects.None, 1.0f);
                spriteBatch.DrawString(Font1, output, FontPos, Color.White, 0, FontOrigin, 1.0f, SpriteEffects.None, 1.0f);

                //output = "FPS: " + framecount / FPS_Count;
                output = "UMBRELLAS: " + pl.umbrella; // +" Timeleft: " + pl.umbrella_active;
                FontOrigin = Font1.MeasureString(output) / 2;
                FontPos = new Vector2(FontOrigin.X + 40, 120);
                spriteBatch.DrawString(Font1, output, FontPos * 1.02f, Color.Black, 0, FontOrigin, 1.0f, SpriteEffects.None, 1.0f);
                spriteBatch.DrawString(Font1, output, FontPos, Color.White, 0, FontOrigin, 1.0f, SpriteEffects.None, 1.0f);
            }
            spriteBatch.End();
        }
Beispiel #9
0
        public void UpdateSprite(Game1 game, GameTime gameTime, int max_X, int max_Y, Sound1 so)
        {
            List<MovingObject> cleanup = new List<MovingObject>();
            Vector2 old_position;

            if (!game.isGameOver())
            {
                foreach (MovingObject a in SpriteList)
                {
                    // Move the sprite by speed, scaled by elapsed time.
                    // First sprite is the player sprite
                    if (!a.first)
                    {
                        old_position = a.position;

                        a.position += a.speed * (float)gameTime.ElapsedGameTime.TotalSeconds;
                        if (a.immune > 0) a.immune--;

                        foreach (MovingObject b in SpriteList)
                        {
                            if (a != b)
                            {

                                if (Intersects(a, b))
                                {
                                    if (b.first)
                                    {
                                        if (a.immune == 0)
                                        {
                                            game.PlayerHit();
                                            a.speed = new Vector2(100 + (50.0f * (float)Math.Sin(MathHelper.ToRadians((float)(360 * RandGen.NextDouble())))), 100 + (50.0f * (float)Math.Sin(MathHelper.ToRadians((float)(360 * RandGen.NextDouble()))))); ;
                                            a.immune = 30;
                                        }
                                    }
                                    else
                                    {
                                        Vector2 tmp = a.speed;
                                        a.speed = b.speed;
                                        b.speed = tmp;
                                        a.position = old_position;
                                    }
                                }
                            }
                        }

                        int MaxX = max_X - sprite5.Width;
                        int MinX = 0;
                        int MaxY = max_Y - sprite5.Height;
                        int MinY = 0;

                        //a.rotation += a.rotation_speed;

                        // Check for bounce.
                        if ((a.position.X - sprite5.Width) > MaxX)
                        {
                            Vector2 dir;
                            dir = Vector2.Normalize(a.speed);
                            a.speed.X = 100 + ((float)RandGen.NextDouble() * 100.0f);
                            a.speed.X *= -dir.X;
                            a.position.X = MaxX + sprite5.Width;
                        }

                        else if (a.position.X < MinX)
                        {
                            Vector2 dir;
                            dir = Vector2.Normalize(a.speed);
                            a.speed.X = 100 + ((float)RandGen.NextDouble() * 100.0f);
                            a.speed.X *= -dir.X;
                            a.position.X = MinX;
                        }

                        if ((a.position.Y - sprite5.Height) > MaxY)
                        {
                            Vector2 dir;
                            dir = Vector2.Normalize(a.speed);
                            a.speed.Y = 100 + ((float)RandGen.NextDouble() * 100.0f);
                            a.speed.Y *= -dir.Y;
                            a.position.Y = MaxY + sprite5.Height;
                        }

                        else if (a.position.Y < MinY)
                        {
                            Vector2 dir;
                            dir = Vector2.Normalize(a.speed);
                            a.speed.Y = 100 + ((float)RandGen.NextDouble() * 100.0f);
                            a.speed.Y *= -dir.Y;
                            a.position.Y = MinY;
                        }
                    }
                }
            }

            foreach (MovingObject a in SpriteList2)
            {

                // Move the sprite by speed, scaled by elapsed time.
                a.position += a.speed * (float)gameTime.ElapsedGameTime.TotalSeconds;

                int MaxX = max_X - sprite7.Width;
                int MinX = 0;
                int MaxY = max_Y - sprite7.Height;
                int MinY = 0;

                a.rotation += 0.001f;

                // Check for bounce.
                if ((a.position.X - sprite7.Width) > MaxX)
                {
                    Vector2 dir;
                    dir = Vector2.Normalize(a.speed);
                    a.speed.X = 10 + ((float)RandGen.NextDouble() * 20.0f);
                    a.speed.X *= -dir.X;
                    a.position.X = MaxX + sprite7.Width;
                }

                else if (a.position.X < MinX)
                {
                    Vector2 dir;
                    dir = Vector2.Normalize(a.speed);
                    a.speed.X = 10 + ((float)RandGen.NextDouble() * 20.0f);
                    a.speed.X *= -dir.X;
                    a.position.X = MinX;
                }

                if ((a.position.Y - sprite7.Height) > MaxY)
                {
                    Vector2 dir;
                    dir = Vector2.Normalize(a.speed);
                    a.speed.Y = 10 + ((float)RandGen.NextDouble() * 20.0f);
                    a.speed.Y *= -dir.Y;
                    a.position.Y = MaxY + sprite7.Height;
                }

                else if (a.position.Y < MinY)
                {
                    Vector2 dir;
                    dir = Vector2.Normalize(a.speed);
                    a.speed.Y = 10 + ((float)RandGen.NextDouble() * 20.0f);
                    a.speed.Y *= -dir.Y;
                    a.position.Y = MinY;
                }

                if (!game.isGameOver() && Intersects(SpriteList.First(), a))
                {
                    if (!game.isPlayerImmune())
                    {
                        game.IncrementFlowerCount();
                        cleanup.Add(a);
                    }
                }
            }

            if (!game.isGameOver())
            {
                foreach (MovingObject a in cleanup)
                {
                    so.PlayFlowerPick(game);
                    SpriteList2.Remove(a);
                }
            }
        }