Пример #1
0
        /// <summary>
        /// Loads graphics content for this screen. 
        /// </summary>
        public override void LoadContent()
        {
            if (_content == null)
                _content = new ContentManager(ScreenManager.Game.Services, "Content");

            Viewport viewport = ScreenManager.GraphicsDevice.Viewport;
            var fullscreen = new Rectangle(0, 0, viewport.Width, viewport.Height);

            _shipTexture = _content.Load<Texture2D>("spaceship");
            _starTexture = _content.Load<Texture2D>("star1");
            _content.Load<SoundEffect>("Sounds/laser");

            _game = new GameLogic.Game(_pilot);

            var rnd = new Random();
            for (int i = 0; i < 100; ++i)
                _stars.Add(new Vector2(rnd.Next(0, 125)/100f, rnd.Next(0, 100)/100f));
            _game.Start();

            _shipScale = 1;
            _shipScaleUp = true;

            _bgMusicList = new List<string> {"Sounds/01"};
            _bgMusicIndex = 0;

            /*
            _musicTimer = new Timer(state =>
            {
                                                _bgMusicIndex = (_bgMusicIndex + 1) % _bgMusicList.Count;
                                                _content.Load<SoundEffect>(_bgMusicList[_bgMusicIndex]).Play();
                                                _musicTimer.Change((int)_content.Load<SoundEffect>(_bgMusicList[_bgMusicIndex]).Duration.TotalMilliseconds,
                                                               (int)_content.Load<SoundEffect>(_bgMusicList[_bgMusicIndex]).Duration.TotalMilliseconds);
            }, null, 0, (int)_content.Load<SoundEffect>(_bgMusicList[_bgMusicIndex]).Duration.TotalMilliseconds);
             */

            _explosionSprites = _content.Load<Texture2D>("explosion");
            _explosionSpriteWidth = _explosionSprites.Width/5;
            _explosionSpriteHeight = _explosionSprites.Height/5;
        }