Пример #1
0
        public override void Initialize()
        {
            screenWidth  = ScreenManager.GraphicsDevice.Viewport.Width;
            screenHeight = ScreenManager.GraphicsDevice.Viewport.Height;

            colorDataList = new List <byte[]>();
            player        = new Player();
            generator     = new ItemsGenerator();
            current       = generator.GenerateMore();
            bgLayer1      = new ParallaxingBackground();
            bgLayer2      = new ParallaxingBackground();
            bgLayer3      = new ParallaxingBackground();
            bar           = new Bar(100, 20, 15, 270, 30);
            score         = new Score(870, 10, Color.Peru);
            currentSprite = new List <Sprite>();
            items         = new List <Texture2D>();
            songs         = new Song[2];
            soundEffects  = new SoundEffect[10];

            updateImmunityCounter = 0;
            alertTimer            = 0;
            playQueue             = 1;
            displayAlert          = false;
            enablePause           = true;



            Constants.ResetFlags();
            player.Initialize();
            base.Initialize();
        }
Пример #2
0
        /// <summary>
        /// Adds the newly generated items to the list of items to be displayed.
        /// </summary>
        private void NewItems()
        {
            current = generator.GenerateMore();

            Texture2D texture = items[18];

            for (int i = 0; i <= 9; i++)
            {
                int  height = 0, length = 50;
                bool transparent = false;

                switch (current[i, 1])
                {
                case "0": height = 499; break;

                case "1": height = 399; break;

                case "2": height = 299; break;
                }

                switch (current[i, 0])
                {
                case "tomato": texture = items[0]; break;

                case "carrot": texture = items[1]; break;

                case "strawberry": texture = items[2]; break;

                case "orange": texture = items[3]; break;

                case "pineapple": texture = items[4]; break;

                case "broccoli": texture = items[5]; break;

                case "fries": texture = items[6]; break;

                case "hamburger": texture = items[7]; break;

                case "pizza": texture = items[8]; break;

                case "donut": texture = items[9]; break;

                case "muffin": texture = items[10]; break;

                case "hotdog": texture = items[11]; break;

                case "level1": texture = items[12]; break;

                case "level2": texture = items[13]; break;

                case "level3": texture = items[14]; break;

                case "sheild": texture = items[15]; break;

                case "sword": texture = items[16]; break;

                case "gym": texture = items[17]; length = 200; height = 349; break;

                case "Empty": transparent = true; break;

                default: break;
                }

                if (current[i, 0].Contains("boss"))
                {
                    texture = items[19];
                    length  = 200;
                    height  = 349;
                }

                if (!transparent)
                {
                    Sprite sprite = new Sprite(texture, new Rectangle(1280, height, length, length), Content);
                    sprite.EnterName(current[i, 0]);
                    currentSprite.Add(sprite);
                }
            }
        }