Пример #1
0
        public void Draw(SpriteBatch spriteBatch)
        {
            for (int i = 0; i < backgrounds.Count; i++)
            {
                Background targBg = (Background)backgrounds[i];
                spriteBatch.Draw(targBg.texture, new Vector2(targBg.x, targBg.y), Color.White);
            }

            for (int i = 0; i < coins.Count; i++)
            {
                Coin targCoin = (Coin)coins[i];
                spriteBatch.Draw(Game1.coinTexture, new Vector2(targCoin.x, targCoin.y), Color.White);
            }

            for (int i = 0; i < blades.Count; i++)
            {
                Blade targBlade = (Blade)blades[i];
                spriteBatch.Draw(Game1.bladeTexture, new Vector2(targBlade.x, targBlade.y), Color.White);
            }

            for (int i = 0; i < spikes.Count; i++)
            {
                Spikes targSpikes = (Spikes)spikes[i];
                spriteBatch.Draw(Game1.spikesTexture, new Vector2(targSpikes.x, targSpikes.y), Color.White);
            }

            for (int i = 0; i < spikes2.Count; i++)
            {
                Spikes2 targSpikes2 = (Spikes2)spikes2[i];
                spriteBatch.Draw(Game1.spikesTexture2, new Vector2(targSpikes2.x, targSpikes2.y), Color.White);
            }

            for (int i = 0; i < harpoons.Count; i++)
            {
                Harpoon targHarpoon = (Harpoon)harpoons[i];
                spriteBatch.Draw(Game1.harpoonHead, new Vector2(targHarpoon.x, targHarpoon.y), Color.White);

                for (int i2 = 0; i2 < targHarpoon.chains.Count; i2++)
                {
                    Chain targChain = (Chain)targHarpoon.chains[i2];
                    spriteBatch.Draw(Game1.harpoonChain, new Vector2(targChain.x, targChain.y), Color.White);
                }
            }
        }
Пример #2
0
        public void Update(Platform platform, Level level)
        {
            x += xVel;
            y += yVel;

            if (xVel > deccel)
            {
                xVel -= deccel;
            }
            else if (xVel < -deccel)
            {
                xVel += deccel;
            }
            else
            {
                xVel = 0;
            }

            if (y + Game1.playerTexture.Height >= platform.y - 2 && y <= platform.y + (float)Game1.platformTexture.Height / 2 && x >= platform.x - (float)Game1.playerTexture.Width && x <= platform.x + Game1.platformTexture.Width)
            {
                if (!grounded)
                {
                    dust.Add(new Dust(x, y + 8));
                }
                y        = platform.y - Game1.playerTexture.Height;
                yVel     = 0;
                grounded = true;
            }
            else
            {
                yVel    += gravity;
                grounded = false;
            }

            if (y > Game1.screenHeight)
            {
                delay = 0;
                Death(2);
            }

            for (int i = 0; i < level.blades.Count; i++)
            {
                Blade targBlade = (Blade)level.blades[i];
                if (x + Game1.playerTexture.Width > targBlade.x && x < targBlade.x + Game1.bladeTexture.Width && y + Game1.playerTexture.Height > targBlade.y && y < targBlade.y + Game1.bladeTexture.Height)
                {
                    Death(1);
                }
                if (y + Game1.playerTexture.Height < targBlade.y && platform.y > targBlade.y && x + Game1.playerTexture.Width <= targBlade.x + Game1.bladeTexture.Width && x >= targBlade.x)
                {
                    Game1.bonusSound.Play();
                    score += 50 * scoreMult;
                    Game1.scoreTextSize += 0.1f;
                }
            }

            for (int i = 0; i < level.spikes.Count; i++)
            {
                Spikes targSpikes = (Spikes)level.spikes[i];
                if (x + Game1.playerTexture.Width > targSpikes.x && x < targSpikes.x + Game1.spikesTexture.Width && y + Game1.playerTexture.Height > targSpikes.y && y < targSpikes.y + Game1.spikesTexture.Height)
                {
                    Death(1);
                }
                if (y + Game1.playerTexture.Height < targSpikes.y && platform.y > targSpikes.y && x + Game1.playerTexture.Width <= targSpikes.x + Game1.spikesTexture.Width && x >= targSpikes.x)
                {
                    Game1.bonusSound.Play();
                    score += 100 * scoreMult;
                    Game1.scoreTextSize += 0.1f;
                }
            }

            for (int i = 0; i < level.spikes2.Count; i++)
            {
                Spikes2 targSpikes2 = (Spikes2)level.spikes2[i];
                if (x + Game1.playerTexture.Width > targSpikes2.x && x < targSpikes2.x + Game1.spikesTexture2.Width && y + Game1.playerTexture.Height > targSpikes2.y && y < targSpikes2.y + Game1.spikesTexture2.Height)
                {
                    Death(1);
                }
                if (y + Game1.playerTexture.Height < targSpikes2.y && platform.y > targSpikes2.y && x + Game1.playerTexture.Width <= targSpikes2.x + Game1.spikesTexture2.Width && x >= targSpikes2.x)
                {
                    Game1.bonusSound.Play();
                    score += 150 * scoreMult;
                    Game1.scoreTextSize += 0.1f;
                }
            }

            for (int i = 0; i < level.harpoons.Count; i++)
            {
                Harpoon targHarpoon = (Harpoon)level.harpoons[i];
                if (x + Game1.playerTexture.Width > targHarpoon.x && x < targHarpoon.x + Game1.harpoonHead.Width && y + Game1.playerTexture.Height > targHarpoon.y && y < targHarpoon.y + Game1.harpoonHead.Height)
                {
                    Death(1);
                }
                if (y + Game1.playerTexture.Height < targHarpoon.y && platform.y > targHarpoon.y && x + Game1.playerTexture.Width <= targHarpoon.x + Game1.harpoonHead.Width && x >= targHarpoon.x)
                {
                    Game1.bonusSound.Play();
                    score += 100 * scoreMult;
                    Game1.scoreTextSize += 0.1f;
                }
            }

            for (int i = 0; i < level.coins.Count; i++)
            {
                Coin targCoin = (Coin)level.coins[i];
                if (x + Game1.playerTexture.Width > targCoin.x && x < targCoin.x + Game1.coinTexture.Width && y + Game1.playerTexture.Height > targCoin.y && y < targCoin.y + Game1.coinTexture.Height)
                {
                    Game1.coinSound.Play();
                    score += coinScore * scoreMult;
                    Game1.scoreTextSize += 0.5f;
                    level.Remove(targCoin, ObjectType.coin);
                }
            }

            if (yVel < -8)
            {
                dust.Add(new Dust(x, y));
            }

            for (int i = 0; i < dust.Count; i++)
            {
                Dust targDust = (Dust)dust[i];
                targDust.Update();
            }

            if (delay > 0)
            {
                delay--;
            }

            score += 1 * scoreMult;
        }
Пример #3
0
        public void Update()
        {
            if (Game1.gameLevel == 2)
            {
                Control();
            }

            //Blades
            bladeCounter++;
            if (bladeCounter >= bladeCount)
            {
                bladeCounter = 0;
                bladeCount   = bladeCountMin + random.Next(bladeCountMax);
                blades.Add(new Blade(this));
            }

            for (int i = 0; i < blades.Count; i++)
            {
                Blade targBlade = (Blade)blades[i];
                targBlade.Update();
            }

            //Coins
            coinCounter++;
            if (coinCounter >= coinCount)
            {
                coinCounter = 0;
                coins.Add(new Coin(this));
            }

            for (int i = 0; i < coins.Count; i++)
            {
                Coin targCoin = (Coin)coins[i];
                targCoin.Update();
            }

            //Spikes
            if (Game1.timer > 3750 || Game1.gameLevel == 2)
            {
                spikesCounter++;
                if (spikesCounter >= spikesCount)
                {
                    spikesCounter = 0;
                    spikes.Add(new Spikes(this));
                }

                for (int i = 0; i < spikes.Count; i++)
                {
                    Spikes targSpikes = (Spikes)spikes[i];
                    targSpikes.Update();
                }
            }

            //Spikes2
            if (Game1.gameLevel != 1)
            {
                spikes2Counter++;
                if (spikes2Counter >= spikes2Count)
                {
                    spikes2Counter = 0;
                    spikes2.Add(new Spikes2(this));
                }

                for (int i = 0; i < spikes2.Count; i++)
                {
                    Spikes2 targSpikes2 = (Spikes2)spikes2[i];
                    targSpikes2.Update();
                }
            }

            //Harpoons
            if (Game1.gameLevel == 1 || Game1.gameLevel == 2)
            {
                harpoonCounter++;
                if (harpoonCounter >= harpoonCount)
                {
                    harpoonCounter = 0;
                    harpoons.Add(new Harpoon(this));
                }

                for (int i = 0; i < harpoons.Count; i++)
                {
                    Harpoon targHarpoon = (Harpoon)harpoons[i];
                    targHarpoon.Update();
                }
            }

            //Backgrounds
            bgCounter++;
            if (bgCounter >= bgCount && Game1.gameLevel != 2)
            {
                int       num     = random.Next(3);
                Texture2D texture = Game1.hellSpike1;
                switch (Game1.gameLevel)
                {
                case 0:
                    switch (num)
                    {
                    case 0:
                        texture = Game1.hellSpike1;
                        break;

                    case 1:
                        texture = Game1.hellSpike2;
                        break;

                    case 2:
                        texture = Game1.hellSpike3;
                        break;
                    }
                    break;

                case 1:
                    switch (num)
                    {
                    case 0:
                        texture = Game1.cloud1;
                        break;

                    case 1:
                        texture = Game1.cloud2;
                        break;

                    case 2:
                        texture = Game1.cloud3;
                        break;
                    }
                    break;
                }
                bgCounter = 0;
                bgCount   = bgCountMin + random.Next(60);
                backgrounds.Add(new Background(texture, false));
            }

            for (int i = 0; i < backgrounds.Count; i++)
            {
                Background targBg = (Background)backgrounds[i];
                targBg.Update(this);
            }

            scoreTracker++;

            if (scoreTracker >= levelUp)
            {
                scoreTracker = 0;
                if (bladeCountMin > bladeCountMinMin)
                {
                    bladeCountMin--;
                }
                if (bladeCountMax > bladeCountMaxMin)
                {
                    bladeCountMax--;
                }
                scrollSpeed += 0.5f;
            }
        }