Example #1
0
 public Bomb copy()
 {
     Bomb outputBomb= new Bomb();
     outputBomb._bombAnimation = new Animation(1000,_bombAnimationFrames);
     outputBomb._timeToLive = _timeToLive;
     outputBomb._origionalTime = _origionalTime;
     outputBomb.CollisionType= CollisionType;
     outputBomb._power = _power;
     return outputBomb;
 }
Example #2
0
        public void LoadContent(ContentManager content, GraphicsDeviceManager graphics)
        {
            _hitBoxTexture = new Texture2D(graphics.GraphicsDevice, 1, 1);
            _hitBoxTexture.SetData(new Color[] { Color.Red });
            _hitBox = new SpriteHelper(_hitBoxTexture, new Rectangle(0, 0, 1, 1));
            _playerDrawColor =GetPlayerDrawColor(_playerColor);

            Texture2D originalTexture = content.Load<Texture2D>("character1_sprites");
            _playerTexture = originalTexture;

            _player = new SpriteHelper(_playerTexture, _playerRectangle);

            #region AnnimationInit

            Rectangle idleFrame1Rectangle = new Rectangle(6, 7, 63 - 6, 84 - 7);
            Rectangle idleFrame2Rectangle = new Rectangle(63, 7, 120 - 63, 84 - 7);
            List<SpriteHelper> idleAnimationFrames = new List<SpriteHelper>();
            idleAnimationFrames.Add(new SpriteHelper(_playerTexture, idleFrame1Rectangle));
            idleAnimationFrames.Add(new SpriteHelper(_playerTexture, idleFrame2Rectangle));
            _idleAnimation = new Animation(300, idleAnimationFrames);

            Rectangle leftFrame1Rectangle = new Rectangle(6, 84, 67 - 6, 165 - 84);
            Rectangle leftFrame2Rectangle = new Rectangle(68, 84, 129 - 68, 165 - 84);
            Rectangle leftFrame3Rectangle = new Rectangle(129, 84, 189 - 129, 165 - 84);
            List<SpriteHelper> leftAnimationFrames = new List<SpriteHelper>();
            leftAnimationFrames.Add(new SpriteHelper(_playerTexture, leftFrame1Rectangle));
            leftAnimationFrames.Add(new SpriteHelper(_playerTexture, leftFrame2Rectangle));
            leftAnimationFrames.Add(new SpriteHelper(_playerTexture, leftFrame3Rectangle));
            _leftAnimation = new Animation(190, leftAnimationFrames);

            Texture2D vertFlipPlayer = SpriteHelper.Flip(_playerTexture, false, true);
            Rectangle rightFrame1Rectangle = new Rectangle(vertFlipPlayer.Width - 67, 84, 67 - 6, 165 - 84);
            Rectangle rightFrame2Rectangle = new Rectangle(vertFlipPlayer.Width - 129, 84, 129 - 68, 165 - 84);
            Rectangle rightFrame3Rectangle = new Rectangle(vertFlipPlayer.Width - 189, 84, 189 - 129, 165 - 84);
            List<SpriteHelper> rightAnimationFrames = new List<SpriteHelper>();
            rightAnimationFrames.Add(new SpriteHelper(vertFlipPlayer, rightFrame1Rectangle));
            rightAnimationFrames.Add(new SpriteHelper(vertFlipPlayer, rightFrame2Rectangle));
            rightAnimationFrames.Add(new SpriteHelper(vertFlipPlayer, rightFrame3Rectangle));
            _rightAnimation = new Animation(190, rightAnimationFrames);

            Rectangle downFrame1Rectangle = new Rectangle(6, 165, 65 - 6, 247 - 165);
            Rectangle downFrame2Rectangle = new Rectangle(65, 165, 124 - 65, 247 - 165);
            Rectangle downFrame3Rectangle = new Rectangle(124, 165, 183 - 124, 247 - 165);
            List<SpriteHelper> downAnimationFrames = new List<SpriteHelper>();
            downAnimationFrames.Add(new SpriteHelper(_playerTexture, downFrame1Rectangle));
            downAnimationFrames.Add(new SpriteHelper(_playerTexture, downFrame2Rectangle));
            downAnimationFrames.Add(new SpriteHelper(_playerTexture, downFrame3Rectangle));
            _downAnimation = new Animation(190, downAnimationFrames);

            Rectangle upFrame1Rectangle = new Rectangle(6, 247, 64 - 6, 328 - 247);
            Rectangle upFrame2Rectangle = new Rectangle(64, 247, 124 - 65, 328 - 247);
            Rectangle upFrame3Rectangle = new Rectangle(123, 247, 182 - 124, 328 - 247);
            List<SpriteHelper> upAnimationFrames = new List<SpriteHelper>();
            upAnimationFrames.Add(new SpriteHelper(_playerTexture, upFrame1Rectangle));
            upAnimationFrames.Add(new SpriteHelper(_playerTexture, upFrame2Rectangle));
            upAnimationFrames.Add(new SpriteHelper(_playerTexture, upFrame3Rectangle));
            _upAnimation = new Animation(190, upAnimationFrames);

            Rectangle deadFrame1Rectangle = new Rectangle(6, 328, 79 - 6, 408 - 328);
            Rectangle deadFrame2Rectangle = new Rectangle(79, 328, 152 - 79, 408 - 328);
            Rectangle deadFrame3Rectangle = new Rectangle(152, 328, 225 - 152, 408 - 328);
            Rectangle deadFrame4Rectangle = new Rectangle(225, 328, 299 - 225, 408 - 328);
            List<SpriteHelper> deadAnimationFrames = new List<SpriteHelper>();
            deadAnimationFrames.Add(new SpriteHelper(_playerTexture, deadFrame1Rectangle));
            deadAnimationFrames.Add(new SpriteHelper(_playerTexture, deadFrame2Rectangle));
            deadAnimationFrames.Add(new SpriteHelper(_playerTexture, deadFrame3Rectangle));
            deadAnimationFrames.Add(new SpriteHelper(_playerTexture, deadFrame4Rectangle));
            _deadAnimation = new Animation(190, deadAnimationFrames, true);

            Rectangle normalFrame1Rectangle = new Rectangle(6, 7, 63 - 6, 84 - 7);
            List<SpriteHelper> normalAnimationFrames = new List<SpriteHelper>();
            normalAnimationFrames.Add(new SpriteHelper(_playerTexture, normalFrame1Rectangle));
            _normalAnimation = new Animation(1000, normalAnimationFrames);

            #endregion

            bombProtoType = new Bomb();
            bombProtoType.LoadContent(content);
            _amountOfAllowedBombs = 3;
            _placedBombs = new List<Bomb>();
            _currentAnimation = _normalAnimation;
        }
Example #3
0
        private void CreateExplosion(Bomb placedBomb, int xPoint, int yPoint)
        {
            _gamefield[xPoint, yPoint].Items.Add(_explosionProtoType.Copy(ExplosionTypes.Cross));
            bool stopDown = false, stopUp = false, stopLeft = false, stopRight = false;

            for (int i = 1; i <= placedBomb.Power; i++)
            {

                HandleBricksforExplosion(xPoint, yPoint, i, ref stopLeft, ref stopDown, ref stopUp, ref stopRight);

                if (!stopRight)
                {
                    _gamefield[xPoint + i, yPoint].Items.Add(_explosionProtoType.Copy());
                    ExplodeBombHere(xPoint + i, yPoint);
                }

                if (!stopLeft)
                {
                    _gamefield[xPoint - i, yPoint].Items.Add(_explosionProtoType.Copy());
                    ExplodeBombHere(xPoint - i, yPoint);

                }
                if (!stopDown)
                {
                    _gamefield[xPoint, yPoint + i].Items.Add(_explosionProtoType.Copy());
                    ExplodeBombHere(xPoint, yPoint + i);
                }
                if (!stopUp)
                {
                    _gamefield[xPoint, yPoint - i].Items.Add(_explosionProtoType.Copy());
                    ExplodeBombHere(xPoint, yPoint - i);
                }
            }
        }