public override void Draw(GameTime gameTime, SpriteBatch spriteBatch)
 {
     if (IsActive)
     {
         WorldSprite.Draw(gameTime, spriteBatch);
     }
 }
Пример #2
0
        public WorldSprite SpriteAnimation()
        {
            WorldSprite s = new WorldSprite(_texture, InitalFrame, _cam);

            s.ClearFrames();
            s.AddFrames(AllTiles());
            return(s);
        }
 public WorldParticle(
     WorldSprite s, Camera cam,
     Vector2 accelleration, float maxSpeed, int duration, Color initialColor, Color finalColor)
     : base(cam, s)
 {
     _accelleration     = accelleration;
     _maxSpeed          = maxSpeed;
     _initialDuration   = duration;
     _remainingDuration = duration;
     _initialColor      = initialColor;
     _finalColor        = finalColor;
 }
Пример #4
0
        public override void LoadContent(TextureManager textureManager)
        {
            Texture2D spriteSheet = textureManager.OptionalLoadContent <Texture2D>(@"Textures\SpriteSheet");

            _tileMap.Intialise(spriteSheet);

            //_player = new Player(
            //    spriteSheet,
            //    new Rectangle(0, 64, 32, 32), 6,
            //    new Rectangle(0, 96, 32, 32), 1,
            //    new Vector2(300, 300),
            //    _cam
            //);

            Rectangle playerBaseInitialRectangle   = new Rectangle(0, 64, 32, 32);
            Rectangle playerTurretInitialRectangle = new Rectangle(0, 96, 32, 32);
            Vector2   playerLocation = new Vector2(300, 300);

            WorldSprite playerBase   = new WorldSprite(spriteSheet, playerBaseInitialRectangle, _cam);
            WorldSprite playerTurret = new WorldSprite(spriteSheet, playerTurretInitialRectangle, _cam);

            playerBase.AddAnimation(6);

            _player = new Player(playerBase, playerTurret, _cam)
            {
                WorldLocation = playerLocation
            };


            Rectangle      particleRect          = new Rectangle(0, 288, 2, 2);
            Rectangle      explosionParticleRect = new Rectangle(0, 256, 32, 32);
            WorldTileSheet explosionTileSheet    = new WorldTileSheet(spriteSheet, particleRect, _cam);
            WorldTileSheet particleTileSheet     = new WorldTileSheet(spriteSheet, explosionParticleRect, _cam, 3);

            _effectsManager = new EffectsManager(explosionTileSheet, particleTileSheet);

            // Shots
            Rectangle      shotRect      = new Rectangle(0, 128, 32, 32);
            WorldTileSheet shotTileSheet = new WorldTileSheet(spriteSheet, shotRect, _cam, 2);
            ShotFactory    shotFactory   = new ShotFactory(shotTileSheet, _cam);

            _shotManager = new ShotManager(shotFactory);
            //_shotManager.OnShotDestroyed += OnShotDestroyed;
            _shotManager.OnShotCollision += OnShotCollision;

            _player.ShotFired += PlayerShotFired;
        }
        public override void Update(GameTime gameTime)
        {
            // has to come before component update because components will
            // reference Location derived variabled (e.g. center) in their update routine
            LastKnownWorldLocation = WorldLocation;
            WorldLocation         += (Velocity * (float)gameTime.ElapsedGameTime.TotalSeconds);

            foreach (var c in Components)
            {
                c.Update(gameTime);
            }
            foreach (var c in ChildEntities)
            {
                c.Update(gameTime);
            }

            if (WorldSprite != null)
            {
                WorldSprite.Update(gameTime);
            }
        }
 public WorldEntity(Camera cam, WorldSprite sprite) : base(sprite)
 {
     this.Cam         = cam;
     this.WorldSprite = sprite;
 }