Пример #1
0
 public override void loadContent(ContentManager content)
 {
     background = content.Load <Texture2D>("maps/map1_1");
     Mario.loadContent(content);
     Brick.loadContent(content);
     ItemBlock.loadContent(content);
     FireBall.loadContent(content);
     Item.loadContent(content);
     Enemy.loadContent(content);
 }
Пример #2
0
        public ItemBlockUpdateCommand(Level level, ItemBlock gameObject, IMario player)
        {
            mushroom       = false;
            this.level     = level;
            this.itemBlock = gameObject;
            IMario      mario   = player;
            IMarioPower powerUp = mario.Power;

            if (powerUp is SmallMario)
            {
                mushroom = true;
            }
        }
Пример #3
0
        public MarioItemBlockHandler(CollisionObject collision, Level level)
        {
            if (collision.LeftSlot is IMario)
            {
                mario     = (IMario)collision.LeftSlot;
                itemBlock = (ItemBlock)collision.RightSlot;
            }
            else
            {
                mario     = (IMario)collision.RightSlot;
                itemBlock = (ItemBlock)collision.LeftSlot;
            }
            direction   = (int)collision.CollisionType;
            commandList = new List <ICommand>();

            Rectangle MarioRectangle     = new Rectangle(mario.XCoordinate, mario.YCoordinate, mario.Width, mario.Height);
            Rectangle ItemBlockRectangle = new Rectangle(itemBlock.XCoordinate, itemBlock.YCoordinate, itemBlock.Width, itemBlock.Height);
            Rectangle result             = Rectangle.Intersect(MarioRectangle, ItemBlockRectangle);
            int       deltaX             = result.Right - result.Left;
            int       deltaY             = result.Bottom - result.Top;

            if (direction == 0)
            {
                commandList.Add(new PushMarioRightCommand(mario, deltaX));
            }
            else if (direction == 1)
            {
                commandList.Add(new PushMarioLeftCommand(mario, deltaX));
            }
            else if (direction == 2 && !GlobalVariables.FlipGravity)
            {
                commandList.Add(new PushMarioUpCommand(mario, deltaY));
            }
            else if (direction == 3 && !GlobalVariables.FlipGravity)
            {
                commandList.Add(new PushMarioDownCommand(mario, deltaY));
                commandList.Add(new ItemBlockUpdateCommand(level, itemBlock, mario));
                MusicPlayer.EffectList("powerupAppear").Play();
            }
            else if (direction == 3 && GlobalVariables.FlipGravity)
            {
                commandList.Add(new PushMarioDownCommand(mario, deltaY));
            }
            else if (direction == 2 && GlobalVariables.FlipGravity)
            {
                commandList.Add(new PushMarioUpCommand(mario, deltaY));
                commandList.Add(new ItemBlockUpdateCommand(level, itemBlock, mario));
                MusicPlayer.EffectList("powerupAppear").Play();
            }
        }