Esempio n. 1
0
        public void Draw(SpriteBatch spriteBatch, ref MainPlayer player, GameTime gameTime)
        {
            foreach (Sprite obstacle in Obstacles)
            {
                obstacle.Draw(spriteBatch);
                Obstacle.Depth -= 0.00001f;
            }

            foreach (Pickup pickup in Enemies)
            {
                pickup.Draw(spriteBatch);
            }

            string score = "Score: " + Score.ToString();

            spriteBatch.DrawString(font, score, new Vector2(10, 10), Color.Black, 0f, Vector2.Zero, 1.5f, SpriteEffects.None, 0f);

            if (ComboCount > 1)
            {
                float   shakeCount = ComboTimer;
                string  comboUI    = "x" + ComboCount.ToString() + " COMBO!";
                Vector2 comboPos   = new Vector2(20, -60f);
                float   shake      = (float)((int)gameTime.TotalGameTime.TotalMilliseconds % 20);

                if (shake < 10)
                {
                    shake = 10 - shake % 10;
                }

                comboPos.Y += shake;

                spriteBatch.DrawString(font, comboUI, player.Position + comboPos, Color.Black, 0f, Vector2.Zero, 1.5f, SpriteEffects.None, 0f);
            }
        }
Esempio n. 2
0
        public void Update(GameTime gameTime, Rectangle playArea, ref MainPlayer player)
        {
            double deltaTime = gameTime.ElapsedGameTime.TotalSeconds;

            ComboTimer -= (float)deltaTime;
            if (ComboTimer <= 0)
            {
                ComboCount = 0;
            }
        }
Esempio n. 3
0
        public void Draw(SpriteBatch spriteBatch, ref MainPlayer player, GameTime gameTime)
        {
            if (ComboCount > 1)
            {
                float   shakeCount = ComboTimer;
                string  comboUI    = "x" + ComboCount.ToString() + " COMBO!";
                Vector2 comboPos   = new Vector2(20, -60f);
                float   shake      = (float)((int)gameTime.TotalGameTime.TotalMilliseconds % 20);

                if (shake < 10)
                {
                    shake = 10 - shake % 10;
                }

                comboPos.Y += shake;

                spriteBatch.DrawString(font, comboUI, player.Position + comboPos, Color.Black, 0f, Vector2.Zero, 1.5f, SpriteEffects.None, 0f);
            }
        }
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            // Create a new SpriteBatch, which can be used to draw textures.

            spriteBatch = new SpriteBatch(GraphicsDevice);

            int leftExit  = GraphicsDevice.Viewport.Width / 2;
            int rightExit = GraphicsDevice.Viewport.Width / 2;

            //Audio
            allSounds = new List <SoundEffect>();
            allSounds.Add(Content.Load <SoundEffect>("NunchuckSpin_Loopable"));
            allSounds.Add(Content.Load <SoundEffect>("Hit"));
            allSounds.Add(Content.Load <SoundEffect>("Hiyuh_louder"));
            allSounds.Add(Content.Load <SoundEffect>("Fail_state"));
            this.gameMusic = Content.Load <Song>("GameSong");
            MediaPlayer.Play(gameMusic);
            MediaPlayer.IsRepeating = true;
            MediaPlayer.Volume      = 0.5f;
            Texture2D mainTexture = this.Content.Load <Texture2D>("All Attacks_Fixed");

            arrowTexture = this.Content.Load <Texture2D>("arrow-pointer");
            baseTexture  = this.Content.Load <Texture2D>("base");
            Texture2D furyTexture  = Content.Load <Texture2D>("Fury-Indicator3");
            Texture2D angryTexture = Content.Load <Texture2D>("Anger-Brackets");

            gameOverTexture = this.Content.Load <Texture2D>("gameover");

            // Load the player resources
            mainChar = new MainPlayer(new Vector2(GraphicsDevice.Viewport.Width / 2 - mainTexture.Width / 2, GraphicsDevice.Viewport.Height / 2 - mainTexture.Height / 2), new Vector2(50), allSounds);


            Pickup.PickupTexture = Content.Load <Texture2D>("NinjaStar");
            Pickup.DeathTexture  = Content.Load <Texture2D>("EnemyDeath");
            Pickup.PickupScale   = 3f;
            mainChar.LoadTexture(mainTexture, arrowTexture, baseTexture, furyTexture, angryTexture);
            mainChar.Initialize();

            gameState.InitSounds(allSounds);
            gameState.SetObstaclesTexture(Content.Load <Texture2D>("Block1"));
            gameState.SetObstaclesTexture(Content.Load <Texture2D>("Block1_transparent"));

            // Set the game font
            gameState.SetFont(Content.Load <SpriteFont>("font"));

            float     boostScale            = 2.5f;
            Texture2D boostContainerTexture = Content.Load <Texture2D>("FuryBar2");

            boostMeter.Initialize(boostContainerTexture, Content.Load <Texture2D>("FuryBar3_Filler"), Content.Load <Texture2D>("FuryBar_Full"), boostScale, ref mainChar);

            //Title Screen
            titleTexture      = Content.Load <Texture2D>("TitleScreen");
            titleRightTexture = Content.Load <Texture2D>("TitleScreen_RipRight");
            titleLeftTexture  = Content.Load <Texture2D>("TitleScreen_RipLeft");
            startTexture      = Content.Load <Texture2D>("StartButton");

            //Environment

            Texture2D TopWall   = Content.Load <Texture2D>("TopWall");
            Texture2D Fence     = Content.Load <Texture2D>("Fence");
            Texture2D BotWall   = Content.Load <Texture2D>("BotWall");
            Texture2D SideWall  = Content.Load <Texture2D>("SideWall");
            Texture2D SideFence = Content.Load <Texture2D>("FenceSide");
            Texture2D FenceEnd  = Content.Load <Texture2D>("FenceSideN");
            Texture2D Decor     = Content.Load <Texture2D>("Decor");

            Wood.Intiliaze(Content.Load <Texture2D>("Background"), GraphicsDevice.Viewport);
            Wood.Blocks();
            //top
            topBorder.Intiliaze(TopWall, GraphicsDevice.Viewport);
            topBorder.walls(0, 0, 3f, true, GraphicsDevice.Viewport.Width);
            topFence.Intiliaze(Fence, GraphicsDevice.Viewport);
            topFence.fences(SideWall.Width * 2, TopWall.Height * 3 - Fence.Height * 2 + 8, 2f, true, GraphicsDevice.Viewport.Width - SideWall.Width * 2);
            //bottom
            botBorder.Intiliaze(BotWall, GraphicsDevice.Viewport);
            botBorder.walls(SideWall.Width * 2, GraphicsDevice.Viewport.Height - BotWall.Height, 1f, true, GraphicsDevice.Viewport.Width - SideWall.Width * 2);
            botFence.Intiliaze(Fence, GraphicsDevice.Viewport);
            botFence.fences(SideWall.Width * 2, GraphicsDevice.Viewport.Height - BotWall.Height - Fence.Height * 2, 2f, true, GraphicsDevice.Viewport.Width - SideWall.Width * 2);
            //leftSide
            leftBorder.Intiliaze(SideWall, GraphicsDevice.Viewport);
            leftBorder.walls(0, (int)(TopWall.Height * 3f - Fence.Height / 2), 2f, false, GraphicsDevice.Viewport.Height);
            leftFence.Intiliaze(SideFence, GraphicsDevice.Viewport);
            leftFence.fences(SideWall.Width * 2 - (SideFence.Width), (int)(TopWall.Height * 3f), 2f, false, GraphicsDevice.Viewport.Height - BotWall.Height - Fence.Height);
            //rightSide
            rightBorder.Intiliaze(SideWall, GraphicsDevice.Viewport);
            rightBorder.walls(GraphicsDevice.Viewport.Width - TopWall.Width * 2, (int)(TopWall.Height * 3f - Fence.Height / 2), 2f, false, GraphicsDevice.Viewport.Height);
            rightFence.Intiliaze(SideFence, GraphicsDevice.Viewport);
            rightFence.fences(GraphicsDevice.Viewport.Width - TopWall.Width * 2 - SideFence.Width, (int)(TopWall.Height * 3f), 2f, false, GraphicsDevice.Viewport.Height - BotWall.Height - Fence.Height);
            //left fence end
            DecorObj.Intiliaze(Decor, GraphicsDevice.Viewport);
            DecorObj1.Intiliaze(Decor, GraphicsDevice.Viewport);
            leftFenceAdj.Intiliaze(FenceEnd, GraphicsDevice.Viewport);
            leftFenceAdj2.Intiliaze(FenceEnd, GraphicsDevice.Viewport);
            rightFenceAdj.Intiliaze(FenceEnd, GraphicsDevice.Viewport);
            rightFenceAdj2.Intiliaze(FenceEnd, GraphicsDevice.Viewport);
        }
Esempio n. 5
0
        public void Update(GameTime gameTime, Rectangle playArea, ref MainPlayer player)
        {
            double deltaTime = gameTime.ElapsedGameTime.TotalSeconds;

            ComboTimer -= (float)deltaTime;
            if (ComboTimer <= 0)
            {
                ComboCount = 0;
            }

            Vector2 playerCenter = new Vector2(player.Position.X + player.Rectangle.Width / 2, player.Position.Y + player.Rectangle.Height / 2);

            TimeToSpawn -= deltaTime;
            if (TimeToSpawn <= 0 && Enemies.Count < 7)
            {
                float DifficultyModifier = 1f / (((float)EnemiesKilled * Difficulty) + 1f);
                TimeToSpawn = (float)random.Next(875, 4376) * DifficultyModifier / 1000;

                Pickup pickup;
                bool   isColliding = false;

                int spawnAttempts = 0;
                do
                {
                    // Find whether the object will be spawned from above, the right, below, or the left
                    int start = random.Next(0, 2 * Pickup.PickupWidth() + 2 * Pickup.PickupHeight() + 1);
                    int x, y;
                    if (start < Pickup.PickupWidth())
                    {
                        y = -(Pickup.PickupHeight());
                        x = random.Next(-(Pickup.PickupWidth()), playArea.Width);
                    }
                    else if (start < Pickup.PickupWidth() + Pickup.PickupHeight())
                    {
                        x = playArea.Width;
                        y = random.Next(-(Pickup.PickupHeight()), playArea.Height);
                    }
                    else if (start < Pickup.PickupWidth() * 2 + Pickup.PickupHeight())
                    {
                        y = playArea.Height;
                        x = random.Next(-(Pickup.PickupWidth()), playArea.Width);
                    }
                    else
                    {
                        x = -(Pickup.PickupWidth());
                        y = random.Next(-(Pickup.PickupHeight()), playArea.Height);
                    }

                    Vector2 position = new Vector2(x, y);
                    //Vector2 direction = new Vector2((playArea.Width / 2) - (x + Pickup.PickupWidth() / 2), (playArea.Height / 2) - (y + Pickup.PickupHeight() / 2));
                    Vector2 direction = playerCenter - position;
                    pickup = new FollowPickup(position, direction, pikcups_Speed);

                    spawnAttempts++;
                    if (spawnAttempts >= 10)
                    {
                        break;
                    }

                    foreach (Pickup other in Enemies)
                    {
                        isColliding = false;
                        if (pickup.IsColliding(other))
                        {
                            isColliding = true;
                            break;
                        }
                    }
                }while (isColliding);

                Enemies.Add(pickup);
            }

            // Check enemy collisions. This is done the naive O(n^2) way. If given more time, something like
            // an axis-aligned bounding box tree could be implemented.
            int count = 0;

            while (count < Enemies.Count)
            {
                // Delete enemies who are dead and have had their animation finish
                if (Enemies[count].NeedsDeletion())
                {
                    Enemies.RemoveAt(count);
                    continue;
                }

                // Update enemies
                Enemies[count].Update(deltaTime, playerCenter);
                Enemies[count].Update(gameTime);

                // Remove the object if it has left the screen
                if (Enemies[count].IsOutOfBounds(playArea))
                {
                    Enemies.RemoveAt(count);
                    continue;
                }

                // Make enemies somewhat bounce off one another
                for (int i = 0; i < Enemies.Count; i++)
                {
                    if (Enemies[count].IsColliding(Enemies[i]))
                    {
                        Pickup temp1 = Enemies[count];
                        Pickup temp2 = Enemies[i];

                        Pickup.Collide(ref temp1, ref temp2);

                        Enemies[count] = temp1;
                        Enemies[i]     = temp2;
                    }
                }

                // Kill the enemy or the player if the two collide
                if (player.IsColliding(Enemies[count]))
                {
                    if (player.Boosting)
                    {
                        HandleEnemyDestroyed(Enemies[count]);
                        Enemies[count].Kill();
                        EnemiesKilled++;

                        player.BoostMeter += 0.1f;
                        if (player.BoostMeter >= 1.2f)
                        {
                            player.BoostMeter = 1.2f;
                        }

                        player.allsounds[1].Play(volume: 0.3f, pitch: 0f, pan: 0f);
                    }
                    else
                    {
                        player.allsounds[3].Play(volume: 1f, pitch: 0f, pan: 0f);
                        IsGameOver = true;
                    }
                }

                // Kill the enemies if they hit any obstacles
                //for (int i = 0; i < Obstacles.Count; i++)
                //{
                //    if (Enemies[count].IsColliding(Obstacles[i]))
                //    {
                //        Enemies[count].Kill();
                //        break;
                //    }
                //}

                count++;
            }
        }
Esempio n. 6
0
        public void Initialize(Texture2D containerTexture, Texture2D barTexture, Texture2D fullFuryTexture, float scale, ref MainPlayer player)
        {
            MaxBoost     = player.BoostMeter;
            CurrentBoost = MaxBoost;
            base.Initialize(containerTexture);
            BarTexture      = barTexture;
            FullFuryTexture = fullFuryTexture;
            Scale           = scale;

            MaxSize = Scale * barTexture.Height;
        }