Esempio n. 1
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;
            }
        }