示例#1
0
 public Explosion(Microsoft.Xna.Framework.Game game) : base(game)
 {
     _game          = game;
     SpriteBatch    = (SpriteBatch)game.Services.GetService(typeof(SpriteBatch));
     _textureCenter = (TextureCenter)game.Services.GetService(typeof(TextureCenter));
     ParticleList   = new List <ParticleData>();
 }
示例#2
0
        public Scene1(Microsoft.Xna.Framework.Game game, GraphicsDevice device) : base(game)
        {
            _game  = game;
            Device = device;

            _textureCenter = (TextureCenter)game.Services.GetService(typeof(TextureCenter));
            SpriteBatch    = (SpriteBatch)game.Services.GetService(typeof(SpriteBatch));
            SoundCenter    = (SoundCenter)game.Services.GetService(typeof(SoundCenter));
            Font           = (SpriteFont)game.Services.GetService(typeof(SpriteFont));
            _rocket        = new Rocket(game);
            _explosion     = new Explosion(game);
            _birds         = new Bird[3];
            SceneComponents.Add(_explosion);
            SceneComponents.Add(_rocket);
            for (var index = 0; index < _birds.Length; index++)
            {
                _birds[index] = new Bird(game, index);
                SceneComponents.Add(_birds[index]);
            }
            GenerateTerrainContour();
            SetUpPlayers();
            _rocket.Color = _carriages[0].Color;
            foreach (var carriage in _carriages)
            {
                SceneComponents.Add(carriage);
            }
            FlattenTerrainBelowPlayers();
            CreateForeground();
            Debug.WriteLine("Scene1 constarcot end!");
        }
示例#3
0
 public Rocket(Microsoft.Xna.Framework.Game game) : base(game)
 {
     _textureCenter = (TextureCenter)game.Services.GetService(typeof(TextureCenter));
     _spriteBatch   = (SpriteBatch)game.Services.GetService(typeof(SpriteBatch));
     Gravity        = new Vector2(0, 1);
     MaxX           = Game1.ScreenWidth;
     MinX           = 0;
 }
示例#4
0
        public Carriage(Microsoft.Xna.Framework.Game game, int i) : base(game)
        {
            _spriteBatch   = (SpriteBatch)game.Services.GetService(typeof(SpriteBatch));
            _textureCenter = (TextureCenter)game.Services.GetService(typeof(TextureCenter));

            PlayerScaling = 40.0f / _textureCenter.CarriageTexture.Width;
            InitCarriage(i);

            game.IsMouseVisible = true;
        }
示例#5
0
 public Bird(Microsoft.Xna.Framework.Game game, int index) : base(game)
 {
     _spriteBacth   = (SpriteBatch)game.Services.GetService(typeof(SpriteBatch));
     _textureCenter = (TextureCenter)game.Services.GetService(typeof(TextureCenter));
     Rectangles     = new Rectangle[Frames];
     Index          = index;
     Width          = _textureCenter.BirdSprite.Width / Frames;
     Height         = _textureCenter.BirdSprite.Height;
     for (var i = 0; i < Frames; i++)
     {
         Rectangles[i] = new Rectangle(i * Width, 0, Width, Height);
     }
     FramesPerSecond = 10;
     IsAlive         = true;
     _birdSpeed      = new Vector2(MaxSpeed, 0);
     _birdPosition.X = Game1.ScreenWidth - Width;
     _birdPosition.Y = index * Height;
 }
示例#6
0
 protected override void LoadContent()
 {
     _spriteBatch   = new SpriteBatch(GraphicsDevice);
     _device        = _graphics.GraphicsDevice;
     ScreenWidth    = _device.PresentationParameters.BackBufferWidth;
     ScreenHeight   = _device.PresentationParameters.BackBufferHeight;
     _soundCenter   = new SoundCenter(this);
     _textureCenter = new TextureCenter(this);
     _font          = Content.Load <SpriteFont>("MyFont");
     Services.AddService(typeof(SpriteBatch), _spriteBatch);
     Services.AddService(typeof(SoundCenter), _soundCenter);
     Services.AddService(typeof(SpriteFont), _font);
     Services.AddService(typeof(TextureCenter), _textureCenter);
     _scene0 = new Scene0(this);
     _scene1 = new Scene1(this, _device);
     _scene1.Hide();
     _scene0.Show();
     Components.Add(_scene0);
     Components.Add(_scene1);
 }