示例#1
0
    public override void HitBottom(UnityBlock b)
    {
        if (!(this.groundState is FallingState))
        {
            mover.yMoveDir = -1;

            base.HitBottom(b);

            if (b is BrickBlock)
            {
                BrickBlock brick = (BrickBlock)b;
                if (!brick.isHit)
                {
                    SFX.PlayClip(SFX.blockClip);
                }
            }

            else if (b is QuestionBlock)
            {
                QuestionBlock question = (QuestionBlock)b;
                if (!question.struck)
                {
                    SFX.PlayClip(SFX.coinClip);
                }
            }

            b.HitBottom();
        }
    }
示例#2
0
 public BrickBlockStateMachine(BrickBlock brickBlock)
 {
     BrickBlockSprite = BlockSpriteFactory.Instance.CreateBrickBlockSprite();
     Width            = BrickBlockSprite.Width;
     Height           = BrickBlockSprite.Height;
     this.brickBlock  = brickBlock;
 }
示例#3
0
        private static void CreateItem(IWorld world, string type, float xPosition, float yPosition)
        {
            IBlock block        = new HiddenBlock(new Vector2(0, 0)); // Get size of an arbitrary block to be size of local collision detection scope
            int    blocksWidth  = block.Rectangle.Width;;
            int    blocksHeight = block.Rectangle.Height;
            int    blockIndexX  = (int)Math.Floor(xPosition / blocksWidth);
            int    blockIndexY  = (int)Math.Floor(yPosition / blocksHeight);

            block = world.Blocks[blockIndexX].OneBlockLevel[blockIndexY];
            if (type.Equals("StaticCoin"))
            {
                world.Items.Add(new Coin(new Vector2(xPosition, yPosition), true, new CollectDelegate(ScoreManager.Instance.CollectCoin)));
            }
            else if (block is BrickBlock)
            {
                BrickBlock brickBlock = block as BrickBlock;
                brickBlock.AddItem(type);
            }
            else if (block is QuestionBlock)
            {
                QuestionBlock questionBlock = block as QuestionBlock;
                questionBlock.AddItem(type);
            }
            else if (block is HiddenBlock)
            {
                HiddenBlock hiddenBlock = block as HiddenBlock;
                hiddenBlock.AddItem(type);
            }
        }
示例#4
0
        public IBlock HiddenBrickBlock()
        {
            BrickBlock b = new BrickBlock(BrickBlockSpriteSheet);

            b.BlockState = new BlockStateHidden(b);
            b.BlockState.Enter();
            return(b);
        }
 public static void HandleBrickBlockCollision(IPlayer player, BrickBlock brickBlock, CollisionSide side)
 {
     if (brickBlock.Breakable)
     {
         HandleBreakableBrickBlockCollision(player, brickBlock, side);
     }
     else
     {
         HandleUnbreakableBrickBlockCollision(player, brickBlock, side);
     }
 }
        public static void HandleBreakableBrickBlockCollision(IPlayer player, BrickBlock brickBlock, CollisionSide side)
        {
            PlayerBlockRepel(brickBlock, player, side);

            if ((side == CollisionSide.Bottom) && !brickBlock.Broken)
            {
                brickBlock.BeBumped();
                if (player.IsBig)
                {
                    brickBlock.Break();
                }
            }
        }
示例#7
0
        public Sprite BuildSprite(BlockType sprite, Vector2 loc)
        {
            Sprite toReturn = null;

            switch (sprite)
            {
            case BlockType.exploded:
            {
                toReturn = new ExplodingBlock(loc);
                break;
            }

            case BlockType.question:
            {
                toReturn = new QuestionBlock(loc);
                break;
            }

            case BlockType.used:
            {
                toReturn = new UsedBlock(loc);
                break;
            }

            case BlockType.brick:
            {
                toReturn = new BrickBlock(loc);
                break;
            }

            case BlockType.hidden:
            {
                toReturn = new HiddenBlock(loc);
                break;
            }

            case BlockType.pipe:
            {
                toReturn = new PipeBlock(loc);
                break;
            }

            case BlockType.bridge:
            {
                toReturn = new BridgeBlock(loc);
                break;
            }
            }
            return(toReturn);
        }
        public static void HandleUnbreakableBrickBlockCollision(IPlayer player, BrickBlock brickBlock, CollisionSide side)
        {
            PlayerBlockRepel(brickBlock, player, side);

            if ((side == CollisionSide.Bottom) && !brickBlock.Depleted)
            {
                brickBlock.BeBumped();
                brickBlock.SpawnItem();
                if (brickBlock.Depleted)
                {
                    brickBlock.BecomeUsed();                        // Become used after all contained items have been spawned
                }
            }
        }
        public Block(Vector2 position, string blockState, string itemType)
        {
            Position                    = position;
            Acceleration                = Vector2.Zero;
            InitialPosition             = position;
            blockStateTransitionMachine = new BlockStateTransitionMachine();
            IsMoving                    = false;

            if (blockState == "Brick")
            {
                BlockState = new BrickBlock(position, this, "Red");
            }
            else if (blockState == "BrickBlue")
            {
                BlockState = new BrickBlock(position, this, "Blue");
            }
            else if (blockState == "Question")
            {
                BlockState = new QuestionBlock(position, this);
            }
            else if (blockState == "Metal")
            {
                this.BlockState = new MetalBlock(position, this);
            }
            else if (blockState == "CoinBrick")
            {
                BlockState = new CoinBrickBlock(position, this);
                CoinCount  = GameValues.BlockCoinBrickCoinAmount;
            }
            else if (blockState == "Used")
            {
                BlockState = new UsedBlock(position, this);
            }

            CollisionRectangle = BlockState.CollisionRectangle;

            if (itemType == "RotatingCoin")
            {
                Item = new Item(new Vector2(Position.X + GameValues.BlockRotatingCoinInitialXPositionOffset, Position.Y), itemType);
            }
            else
            {
                Item = new Item(Position, itemType);
            }
        }
        private static void LoadLevel(XmlReader reader)
        {
            Random         random       = new Random();
            string         objectType   = "";
            string         objectName   = "";
            string         location     = "";
            bool           typeFlag     = false;
            bool           nameFlag     = false;
            bool           locationFlag = false;
            IList <IBlock> blockList    = new List <IBlock>();
            IList <IEnemy> enemyList    = new List <IEnemy>();
            IList <IItem>  itemList     = new List <IItem>();

            while (reader.Read())
            {
                if (reader.IsStartElement())
                {
                    switch (reader.Name.ToString())
                    {
                    case "ObjectType":
                        objectType = reader.ReadString();
                        typeFlag   = true;
                        break;

                    case "ObjectName":
                        objectName = reader.ReadString();
                        nameFlag   = true;
                        break;

                    case "Location":
                        location     = reader.ReadString();
                        locationFlag = true;
                        break;
                    }

                    if (typeFlag && nameFlag && locationFlag)
                    {
                        switch (objectType)
                        {
                        case "Player":
                            string[] coordinates = location.Split(' ');
                            Mario.Instance.ConditionState = new SmallMarioState(Mario.Instance);
                            Mario.Instance.Location       = new Vector2(Int32.Parse(coordinates[0]), Int32.Parse(coordinates[1]));
                            break;

                        case "Block":
                            switch (objectName)
                            {
                            case "HiddenBlock":
                                string[] blockCoordinates = location.Split(' ');
                                IBlock   block            = new HiddenBlock();
                                block.Location = new Vector2(Int32.Parse(blockCoordinates[0]), Int32.Parse(blockCoordinates[1]));
                                blockList.Add(block);
                                break;

                            case "HiddenBlockEmpty":
                                blockCoordinates = location.Split(' ');
                                block            = new HiddenBlockEmpty();
                                block.Location   = new Vector2(Int32.Parse(blockCoordinates[0]), Int32.Parse(blockCoordinates[1]));
                                blockList.Add(block);
                                break;

                            case "HiddenBlockCoin":
                                blockCoordinates = location.Split(' ');
                                block            = new HiddenBlockCoin();
                                block.Location   = new Vector2(Int32.Parse(blockCoordinates[0]), Int32.Parse(blockCoordinates[1]));
                                blockList.Add(block);
                                break;

                            case "HiddenBlockStar":
                                blockCoordinates = location.Split(' ');
                                block            = new HiddenBlockStar();
                                block.Location   = new Vector2(Int32.Parse(blockCoordinates[0]), Int32.Parse(blockCoordinates[1]));
                                blockList.Add(block);
                                break;

                            case "BrickBlock":
                                blockCoordinates = location.Split(' ');
                                block            = new BrickBlock();
                                block.Location   = new Vector2(Int32.Parse(blockCoordinates[0]), Int32.Parse(blockCoordinates[1]));
                                blockList.Add(block);
                                break;

                            case "BrickBlockEmpty":
                                blockCoordinates = location.Split(' ');
                                block            = new BrickBlockEmpty();
                                block.Location   = new Vector2(Int32.Parse(blockCoordinates[0]), Int32.Parse(blockCoordinates[1]));
                                blockList.Add(block);
                                break;

                            case "ItemBrick":
                                blockCoordinates = location.Split(' ');
                                block            = new BrickBlockWithItem();
                                block.Location   = new Vector2(Int32.Parse(blockCoordinates[0]), Int32.Parse(blockCoordinates[1]));
                                blockList.Add(block);
                                break;

                            case "ItemBrickCoin":
                                blockCoordinates = location.Split(' ');
                                block            = new BrickBlockWithCoin();
                                block.Location   = new Vector2(Int32.Parse(blockCoordinates[0]), Int32.Parse(blockCoordinates[1]));
                                blockList.Add(block);
                                break;

                            case "ItemBrickStar":
                                blockCoordinates = location.Split(' ');
                                block            = new BrickBlockWithStar();
                                block.Location   = new Vector2(Int32.Parse(blockCoordinates[0]), Int32.Parse(blockCoordinates[1]));
                                blockList.Add(block);
                                break;

                            case "QuestionBlock":
                                blockCoordinates = location.Split(' ');
                                block            = new QuestionBlock();
                                block.Location   = new Vector2(Int32.Parse(blockCoordinates[0]), Int32.Parse(blockCoordinates[1]));
                                blockList.Add(block);
                                break;

                            case "QuestionBlockEmpty":
                                blockCoordinates = location.Split(' ');
                                block            = new QuestionBlockEmpty();
                                block.Location   = new Vector2(Int32.Parse(blockCoordinates[0]), Int32.Parse(blockCoordinates[1]));
                                blockList.Add(block);
                                break;

                            case "QuestionBlockStar":
                                blockCoordinates = location.Split(' ');
                                block            = new QuestionBlockStar();
                                block.Location   = new Vector2(Int32.Parse(blockCoordinates[0]), Int32.Parse(blockCoordinates[1]));
                                blockList.Add(block);
                                break;

                            case "QuestionBlockCoin":
                                blockCoordinates = location.Split(' ');
                                block            = new QuestionBlockCoin();
                                block.Location   = new Vector2(Int32.Parse(blockCoordinates[0]), Int32.Parse(blockCoordinates[1]));
                                blockList.Add(block);
                                break;

                            case "UnbreakableBlock":
                                blockCoordinates = location.Split(' ');
                                block            = new UnbreakableBlock();
                                block.Location   = new Vector2(Int32.Parse(blockCoordinates[0]), Int32.Parse(blockCoordinates[1]));
                                blockList.Add(block);
                                break;

                            case "UsedBlock":
                                blockCoordinates = location.Split(' ');
                                block            = new UsedBlock();
                                block.Location   = new Vector2(Int32.Parse(blockCoordinates[0]), Int32.Parse(blockCoordinates[1]));
                                blockList.Add(block);
                                break;

                            case "GroundBlock":
                                blockCoordinates = location.Split(' ');
                                block            = new GroundBlock();
                                block.Location   = new Vector2(Int32.Parse(blockCoordinates[0]), Int32.Parse(blockCoordinates[1]));
                                blockList.Add(block);
                                break;

                            case "Pipe":
                                blockCoordinates = location.Split(' ');
                                block            = new Pipe();
                                block.Location   = new Vector2(Int32.Parse(blockCoordinates[0]), Int32.Parse(blockCoordinates[1]));
                                blockList.Add(block);
                                break;

                            case "PipeBottom":
                                blockCoordinates = location.Split(' ');
                                block            = new PipeBottom();
                                block.Location   = new Vector2(Int32.Parse(blockCoordinates[0]), Int32.Parse(blockCoordinates[1]));
                                blockList.Add(block);
                                break;

                            case "WarpPipe":
                                blockCoordinates = location.Split(' ');
                                WarpPipe pipe = new WarpPipe();
                                pipe.Location = new Vector2(Int32.Parse(blockCoordinates[0]), Int32.Parse(blockCoordinates[1]));
                                switch (pipe.Location.X)
                                {
                                case 1760:
                                    pipe.WarpDestination = new Vector2(8000, 384);
                                    break;

                                case 8736:
                                    pipe.WarpDestination = new Vector2(2080, 352);
                                    break;
                                }
                                blockList.Add((IBlock)pipe);
                                break;

                            case "FlagPole":
                                blockCoordinates = location.Split(' ');
                                block            = new FlagPole();
                                block.Location   = new Vector2(Int32.Parse(blockCoordinates[0]), Int32.Parse(blockCoordinates[1]));
                                blockList.Add(block);
                                break;
                            }
                            break;

                        case "Enemy":
                            switch (objectName)
                            {
                            case "Goomba":
                                string[] enemyCoordinates = location.Split(' ');
                                IEnemy   enemy            = new Goomba();
                                enemy.RowId    = random.Next(0, 160);
                                enemy.Location = new Vector2(Int32.Parse(enemyCoordinates[0]), Int32.Parse(enemyCoordinates[1]));
                                enemyList.Add(enemy);
                                break;

                            case "Koopa":
                                enemyCoordinates = location.Split(' ');
                                enemy            = new Koopa();
                                enemy.RowId      = random.Next(0, 160);
                                enemy.Location   = new Vector2(Int32.Parse(enemyCoordinates[0]), Int32.Parse(enemyCoordinates[1]));
                                enemyList.Add(enemy);
                                break;
                            }
                            break;

                        case "Item":
                            switch (objectName)
                            {
                            case "Coin":
                                string[] itemCoordinates = location.Split(' ');
                                IItem    item            = new Coin();
                                item.Location = new Vector2(Int32.Parse(itemCoordinates[0]), Int32.Parse(itemCoordinates[1]));
                                itemList.Add(item);
                                break;

                            case "FireFlower":
                                itemCoordinates = location.Split(' ');
                                item            = new FireFlower();
                                item.Location   = new Vector2(Int32.Parse(itemCoordinates[0]), Int32.Parse(itemCoordinates[1]));
                                itemList.Add(item);
                                break;

                            case "OneUpMush":
                                itemCoordinates = location.Split(' ');
                                item            = new OneUpMushroom();
                                item.Location   = new Vector2(Int32.Parse(itemCoordinates[0]), Int32.Parse(itemCoordinates[1]));
                                itemList.Add(item);
                                break;

                            case "SuperMush":
                                itemCoordinates = location.Split(' ');
                                item            = new SuperMushroom();
                                item.Location   = new Vector2(Int32.Parse(itemCoordinates[0]), Int32.Parse(itemCoordinates[1]));
                                itemList.Add(item);
                                break;

                            case "Star":
                                itemCoordinates = location.Split(' ');
                                item            = new Star();
                                item.Location   = new Vector2(Int32.Parse(itemCoordinates[0]), Int32.Parse(itemCoordinates[1]));
                                itemList.Add(item);
                                break;
                            }
                            break;
                        }
                        typeFlag     = false;
                        nameFlag     = false;
                        locationFlag = false;
                    }
                }
            }
            PlayerLevel.Instance.BlockArray = blockList;
            PlayerLevel.Instance.EnemyArray = enemyList;
            PlayerLevel.Instance.ItemArray  = itemList;
        }
示例#11
0
        public bool TestMarioBlockCollisions()
        {
            IGameObject marioLeftBlock   = new Mario(new Vector2(40, 52));
            IGameObject leftBlock        = new BrickBlock(new Vector2(50, 50));
            IGameObject marioTopBlock    = new Mario(new Vector2(101, 90));
            IGameObject topBlock         = new BrickBlock(new Vector2(100, 100));
            IGameObject marioRightBlock  = new Mario(new Vector2(160, 153));
            IGameObject rightBlock       = new BrickBlock(new Vector2(150, 150));
            IGameObject marioBottomBlock = new Mario(new Vector2(200, 210));
            IGameObject bottomBlock      = new BrickBlock(new Vector2(200, 200));
            IGameObject marioNoBlock     = new Mario(new Vector2(0, 100));
            IGameObject noCollisionBlock = new BrickBlock(new Vector2(0, 0));

            Dictionary <Tuple <ObjectType, ObjectType, Object2Side>, ICollisionCommand> testDictionary = new Dictionary <Tuple <ObjectType, ObjectType, Object2Side>, ICollisionCommand>
            {
                { new Tuple <ObjectType, ObjectType, Object2Side>(ObjectType.Mario, ObjectType.Block, Object2Side.Top), new MarioBlockCollisionTopCommand() },
                { new Tuple <ObjectType, ObjectType, Object2Side>(ObjectType.Mario, ObjectType.Block, Object2Side.Right), new MarioBlockCollisionRightCommand() },
                { new Tuple <ObjectType, ObjectType, Object2Side>(ObjectType.Mario, ObjectType.Block, Object2Side.Bottom), new MarioBlockCollisionBottomCommand() },
                { new Tuple <ObjectType, ObjectType, Object2Side>(ObjectType.Mario, ObjectType.Block, Object2Side.Left), new MarioBlockCollisionLeftCommand() }
            };
            AllCollisionHandler testHandler = new AllCollisionHandler(testDictionary);

            Console.WriteLine("Tests for collision side of Mario-Brick collisions.");
            string leftOutputDetails        = "Succesful recognition of left side of block collision: ";
            bool   leftCollision            = TestCollisionSide(leftOutputDetails, AllCollisionHandler.DetermineCollisionSide(marioLeftBlock.Destination, leftBlock.Destination), Object2Side.Left);
            string topOutputDetails         = "Succesful recognition of top side of block collision: ";
            bool   topCollision             = TestCollisionSide(topOutputDetails, AllCollisionHandler.DetermineCollisionSide(marioTopBlock.Destination, topBlock.Destination), Object2Side.Top);
            string rightOutputDetails       = "Succesful recognition of right side of block collision: ";
            bool   rightCollision           = TestCollisionSide(rightOutputDetails, AllCollisionHandler.DetermineCollisionSide(marioRightBlock.Destination, rightBlock.Destination), Object2Side.Right);
            string bottomOutputDetails      = "Succesful recognition of bottom side of block collision: ";
            bool   bottomCollision          = TestCollisionSide(bottomOutputDetails, AllCollisionHandler.DetermineCollisionSide(marioBottomBlock.Destination, bottomBlock.Destination), Object2Side.Bottom);
            string noCollisionOutputDetails = "Succesful recognition of no block collision: ";
            bool   noCollision = TestCollisionSide(noCollisionOutputDetails, AllCollisionHandler.DetermineCollisionSide(marioNoBlock.Destination, noCollisionBlock.Destination), Object2Side.NoCollision);

            Console.WriteLine();

            bool areCollisionsSuccessful = leftCollision && topCollision && rightCollision && bottomCollision && noCollision;

            testHandler.HandleCollision(marioLeftBlock, leftBlock);
            testHandler.HandleCollision(marioRightBlock, rightBlock);
            testHandler.HandleCollision(marioBottomBlock, bottomBlock);
            testHandler.HandleCollision(marioTopBlock, topBlock);
            testHandler.HandleCollision(marioNoBlock, noCollisionBlock);

            Console.WriteLine("Tests for collision side of handled Mario-Brick collisions (No collisions).");
            string leftHandledOutputDetails = "Succesful handling of left side of block collision: ";
            bool   leftHandled             = TestCollisionSide(leftHandledOutputDetails, AllCollisionHandler.DetermineCollisionSide(marioLeftBlock.Destination, leftBlock.Destination), Object2Side.NoCollision);
            string topHandledOutputDetails = "Succesful handling of top side of block collision: ";
            bool   topHandled = TestCollisionSide(topHandledOutputDetails, AllCollisionHandler.DetermineCollisionSide(marioTopBlock.Destination, topBlock.Destination), Object2Side.NoCollision);
            string rightHandledOutputDetails = "Succesful handling of right side of block collision: ";
            bool   rightHandled = TestCollisionSide(rightHandledOutputDetails, AllCollisionHandler.DetermineCollisionSide(marioRightBlock.Destination, rightBlock.Destination), Object2Side.NoCollision);
            string bottomHandledOutputDetails = "Succesful handling of bottom side of block collision: ";
            bool   bottomHandled = TestCollisionSide(bottomHandledOutputDetails, AllCollisionHandler.DetermineCollisionSide(marioBottomBlock.Destination, bottomBlock.Destination), Object2Side.NoCollision);
            string noCollisionHandledOutputDetails = "Succesful handling of no block collision: ";
            bool   noCollisionHandled = TestCollisionSide(noCollisionHandledOutputDetails, AllCollisionHandler.DetermineCollisionSide(marioNoBlock.Destination, noCollisionBlock.Destination), Object2Side.NoCollision);

            Console.WriteLine();

            bool areHandlingsSuccessful = leftHandled && topHandled && rightHandled && bottomHandled && noCollisionHandled;

            marioLeftBlock.Draw(spriteBatch);
            leftBlock.Draw(spriteBatch);
            marioTopBlock.Draw(spriteBatch);
            topBlock.Draw(spriteBatch);
            marioRightBlock.Draw(spriteBatch);
            rightBlock.Draw(spriteBatch);
            marioBottomBlock.Draw(spriteBatch);
            bottomBlock.Draw(spriteBatch);
            marioNoBlock.Draw(spriteBatch);
            noCollisionBlock.Draw(spriteBatch);

            return(areCollisionsSuccessful && areHandlingsSuccessful);
        }
示例#12
0
 public BrickBrokenState(BrickBlock block)
 {
     this.block = block;
 }
示例#13
0
    private void MoveMario()
    {
        controller2D.Move(velocity * Time.fixedDeltaTime);

        // After move check to see if we hit a ceiling or the ground.
        // If so we want to reset velocity.y to 0 as it means we're ending
        // a jump potentially.
        if (controller2D.collisions.above || controller2D.collisions.below)
        {
            velocity.y     = 0;
            jumping        = false;
            hitBlockOnJump = false;
        }

        if (controller2D.collisions.left || controller2D.collisions.right)
        {
            velocity.x = 0;
        }

        UpdateAnimations();

        if (!hitBlockOnJump)
        {
            GameObject ceilingObject = controller2D.HitCeilingObject();
            GameObject groundObject  = controller2D.HitGroundObject();

            if (ceilingObject)
            {
                if (ceilingObject.tag == "BrickBlock")
                {
                    BrickBlock brickBlock = ceilingObject.GetComponent <BrickBlock>();
                    brickBlock.HitBlock();
                    hitBlockOnJump = true;
                }

                if (ceilingObject.tag == "QuestionBlock")
                {
                    QuestionBlock questionBlock = ceilingObject.GetComponent <QuestionBlock>();
                    questionBlock.HitBlock();
                    hitBlockOnJump = true;
                }
            }

            if (groundObject)
            {
                if (groundObject.tag == "Enemy")
                {
                    Enemy enemy = groundObject.GetComponent <Enemy>();
                    enemy.Damage();
                    hitBlockOnJump = true;
                    velocity.y     = enemyJumpVelocity;
                    jumping        = true;
                }
            }
        }

        GameObject itemObject = controller2D.HitItem();

        if (itemObject)
        {
            if (itemObject.tag == "Mushroom")
            {
                MakeMarioBig();
                Destroy(itemObject);
            }
        }
    }
示例#14
0
        public IEntity AddBlock(XmlNode x, ContentManager content, GraphicsDevice graphics, CollisionDetection collisions)
        {
            bool isUnderworld = false;

            switch (type)
            {
            case ("questionblock"):
                QuestionBlock questionBlock = new QuestionBlock(content, graphics);
                if (x.HasChildNodes)
                {
                    for (int m = Constants.ZERO; m < x.ChildNodes.Count; m++)
                    {
                        IEntity childEntity = null;
                        XmlNode y           = x.ChildNodes[m];
                        GetAttributes(y);
                        if (tag.Equals("item"))
                        {
                            childEntity = AddItem(content, graphics);
                        }
                        else if (tag.Equals("block"))
                        {
                            childEntity = AddBlock(y, content, graphics, collisions);
                        }
                        entity = childEntity;
                        SetProperties(collisions);
                        questionBlock.AddContainedItem(childEntity);
                    }
                }
                GetAttributes(x);
                entity = questionBlock;
                break;

            case ("floorblock"):
                isUnderworld = false;
                entity       = new FloorBlock(content, graphics, isUnderworld);
                break;

            case ("underworldFloor"):
                isUnderworld = true;
                entity       = new FloorBlock(content, graphics, isUnderworld);
                break;

            case ("glassblock"):
                GlassBlock glassBlock = new GlassBlock(content, graphics);
                isGlass = true;
                if (x.HasChildNodes)
                {
                    for (int m = Constants.ZERO; m < x.ChildNodes.Count; m++)
                    {
                        IEntity childEntity = null;
                        XmlNode y           = x.ChildNodes[m];
                        GetAttributes(y);
                        if (tag.Equals("block"))
                        {
                            childEntity = AddBlock(y, content, graphics, collisions);
                        }
                        entity = childEntity;
                        SetProperties(collisions);
                        glassBlock.AddContainedItem(childEntity);
                    }
                }
                GetAttributes(x);
                entity = glassBlock;
                break;

            case ("brickblock"):
                isUnderworld = false;
                BrickBlock brickBlock = new BrickBlock(content, graphics, isUnderworld);
                if (x.HasChildNodes)
                {
                    for (int m = Constants.ZERO; m < x.ChildNodes.Count; m++)
                    {
                        IEntity childEntity = null;
                        XmlNode y           = x.ChildNodes[m];
                        GetAttributes(y);
                        if (tag.Equals("item"))
                        {
                            childEntity = AddItem(content, graphics);
                        }
                        else if (tag.Equals("block"))
                        {
                            childEntity = AddBlock(y, content, graphics, collisions);
                        }
                        entity = childEntity;
                        SetProperties(collisions);
                        brickBlock.AddContainedItem(childEntity);
                    }
                }
                GetAttributes(x);
                entity = brickBlock;
                break;

            case ("underworldBrick"):
                Underworld = true;
                BrickBlock underworldBrickBlock = new BrickBlock(content, graphics, Underworld);
                if (x.HasChildNodes)
                {
                    for (int m = Constants.ZERO; m < x.ChildNodes.Count; m++)
                    {
                        IEntity childEntity = null;
                        XmlNode y           = x.ChildNodes[m];
                        GetAttributes(y);
                        if (tag.Equals("item"))
                        {
                            childEntity = AddItem(content, graphics);
                        }
                        else if (tag.Equals("block"))
                        {
                            childEntity = AddBlock(y, content, graphics, collisions);
                        }
                        entity = childEntity;
                        SetProperties(collisions);
                        underworldBrickBlock.AddContainedItem(childEntity);
                    }
                }
                GetAttributes(x);
                entity = underworldBrickBlock;
                break;

            case ("warpPipe"):
                WarpPipe warpPipe = new WarpPipe(content, graphics, ExitPipe, Underworld, MiniGame);
                if (x.HasChildNodes)
                {
                    for (int m = Constants.ZERO; m < x.ChildNodes.Count; m++)
                    {
                        IEntity childEntity = null;
                        XmlNode y           = x.ChildNodes[m];
                        GetAttributes(y);
                        if (tag.Equals("enemy"))
                        {
                            childEntity = AddEnemy(content, graphics, peach);
                        }
                        else if (tag.Equals("block"))
                        {
                            childEntity = AddBlock(y, content, graphics, collisions);
                        }
                        entity = childEntity;
                        SetProperties(collisions);
                        warpPipe.AddContainedItem(childEntity);
                    }
                }
                GetAttributes(x);
                entity = warpPipe;
                break;

            case ("stairblock"):
                entity = new StairBlock(content, graphics);
                break;

            case ("usedblock"):
                entity = new UsedBlock(content, graphics);
                break;

            case ("hiddenblock"):
                isUnderworld = false;
                HiddenBlock hiddenBlock = new HiddenBlock(content, graphics);
                if (x.HasChildNodes)
                {
                    for (int m = Constants.ZERO; m < x.ChildNodes.Count; m++)
                    {
                        IEntity childEntity = null;
                        XmlNode y           = x.ChildNodes[m];
                        GetAttributes(y);
                        if (tag.Equals("item"))
                        {
                            childEntity = AddItem(content, graphics);
                        }
                        else if (tag.Equals("block"))
                        {
                            childEntity = AddBlock(y, content, graphics, collisions);
                        }
                        entity = childEntity;
                        SetProperties(collisions);
                        hiddenBlock.AddContainedItem(childEntity);
                    }
                }
                GetAttributes(x);
                entity = hiddenBlock;
                break;

            case ("pipe"):
                entity = new Pipe(content, graphics);
                break;

            case ("explodingBlock"):
                entity = new ExplodingBlock(content, graphics, isGlass);
                break;

            case ("exitPipe"):
                entity = new WarpPipe(content, graphics, ExitPipe, Underworld, MiniGame);
                break;

            default:
                break;
            }
            return(entity);
        }
示例#15
0
        public void BuildBlocks(string input)
        {
            if (Room.Id == 13)
            {
                buildblocks13(input); return;
            }
            switch (input)
            {
            //BLOCKS

            case "TILE":
                IBlock tile = new FloorBlock(Position);
                Room.blocks.Add(tile);
                break;

            case "BLOK":
                IBlock blok = new RegularBlock(Position);
                Room.blocks.Add(blok);
                break;

            case "RFSH":
                IBlock rfsh = new Face1Block(Position);
                Room.blocks.Add(rfsh);
                break;

            case "LFSH":
                IBlock lfsh = new Face2Block(Position);
                Room.blocks.Add(lfsh);
                break;

            case "SPOT":
                IBlock spot = new SpottedBlock(Position);
                Room.blocks.Add(spot);
                break;

            case "BLCK":
                IBlock blck = new BlackBlock(Position);
                Room.blocks.Add(blck);
                break;

            case "BRIK":
                IBlock brik = new BrickBlock(Position);
                Room.blocks.Add(brik);
                break;

            case "DARK":
                IBlock dark = new DarkBlueBlock(Position);
                Room.blocks.Add(dark);
                break;

            case "STAR":
                IBlock star = new StairsBlock(Position);
                Room.blocks.Add(star);
                break;

            case "STIP":
                IBlock stip = new StripeBlock(Position);
                Room.blocks.Add(stip);
                break;

            case "MVBK":
                IBlock mvbk = new MovingVertBlock(Position);
                Room.blocks.Add(mvbk);
                break;

            case "MLBK":
                IBlock mlbk = new MovingLeftBlock(Position);
                Room.blocks.Add(mlbk);
                break;

            //ENEMIES
            case "BBAT":
                IEntity bat = new BlueBatEnemy(Position);
                Room.enemies.Add(enemyID, bat);
                enemyID++;
                break;

            case "SKLN":
                IEntity skel = new SkeletonEnemy(Position);
                Room.enemies.Add(enemyID, skel);
                enemyID++;
                break;

            case "BOSS":
                IAttack up     = new FireAttack(1);
                IAttack center = new FireAttack(0);
                IAttack down   = new FireAttack(2);
                Room.enemies.Add(enemyID, up);
                enemyID++;
                Room.enemies.Add(enemyID, down);
                enemyID++;
                Room.enemies.Add(enemyID, center);
                enemyID++;
                Room.enemies.Add(enemyID, new FinalBossEnemy(Position, up, center, down));
                enemyID++;
                break;

            case "FIRE":
                IEntity fire = new FireEnemy(Position);
                Room.enemies.Add(enemyID, fire);
                enemyID++;
                break;

            case "GELY":
                IEntity gel = new GelEnemy(Position);
                gel.X = gel.Position.X + FOUR * Global.Var.SCALE;
                gel.Y = gel.Position.Y + FOUR * Global.Var.SCALE;
                Room.enemies.Add(enemyID, gel);
                enemyID++;
                break;

            case "GORY":
                IBoomerang goriyaBoomerang = new BoomerangItem();
                IEntity    goriya          = new GoriyaEnemy(goriyaBoomerang, Position);
                Room.enemyProj.Add(goriyaBoomerang);
                Room.enemies.Add(enemyID, goriya);
                enemyID++;
                break;

            case "HAND":
                IEntity hand = new HandEnemy(Position);
                Room.enemies.Add(enemyID, hand);
                enemyID++;
                break;

            case "OLDM":
                IEntity man = new OldManNPC(Position);
                man.X = man.Position.X + EIGHT * Global.Var.SCALE;
                Room.enemies.Add(enemyID, man);
                enemyID++;
                break;

            case "MNFR":
                IEntity fire1 = new FireEnemy(Position);
                IEntity fire2 = new FireEnemy(Position);
                Room.enemies.Add(enemyID, fire1);
                enemyID++;
                Room.enemies.Add(enemyID, fire2);
                enemyID++;

                IEntity manAndFire = new OldMan_FireEnemy(Position, fire1, fire2);
                manAndFire.X = manAndFire.Position.X + EIGHT * Global.Var.SCALE;
                Room.enemies.Add(enemyID, manAndFire);
                enemyID++;
                break;

            case "SPKE":
                IEntity spike = new SpikeEnemy(Position, spikeNum);
                Room.enemies.Add(enemyID, spike);
                enemyID++;
                spikeNum++;
                if (spikeNum > 4)
                {
                    spikeNum = 1;
                }
                break;


            //ITEMS
            // Probably could use a static bomb and boomerang object now that I think of it.
            case "KEYI":
                IItem key = new KeyItem(Position);
                key.X = key.Position.X + FOUR * Global.Var.SCALE;
                Room.items.Add(key);
                break;

            case "BOWI":
                IItem bow = new BowItem(Position);
                Room.items.Add(bow);
                break;

            case "CLCK":
                IItem clock = new ClockItem(Position);
                Room.items.Add(clock);
                break;

            case "CMPS":
                IItem compass = new CompassItem(Position);
                compass.X = compass.Position.X + TWO * Global.Var.SCALE;
                compass.Y = compass.Position.Y + TWO * Global.Var.SCALE;
                Room.items.Add(compass);
                break;

            case "FARY":
                IItem fairy = new FairyItem(Position);
                Room.items.Add(fairy);
                break;

            case "HCON":
                IItem hcont = new HeartContainerItem(Position);
                hcont.X = hcont.Position.X + ONE * Global.Var.SCALE;
                hcont.Y = hcont.Position.Y + ONE * Global.Var.SCALE;
                Room.items.Add(hcont);
                break;

            case "HART":
                IItem heart = new HeartItem(Position);
                Room.items.Add(heart);
                break;

            case "MAPI":
                IItem map = new MapItem(Position);
                map.X = map.Position.X + FOUR * Global.Var.SCALE;
                Room.items.Add(map);
                break;

            case "RUPE":
                IItem rupee = new RupeeItem(Position);
                Room.items.Add(rupee);
                break;

            case "BOMB":
                IItem bomb = new BombStaticItem(Position);
                Room.items.Add(bomb);
                break;

            case "BMRG":
                IItem boom = new BoomerangStaticItem(Position);
                boom.X = boom.Position.X + BMRG_X_OFFSET * Global.Var.SCALE;
                boom.Y = boom.Position.Y + BMRG_Y_OFFSET * Global.Var.SCALE;
                Room.items.Add(boom);
                break;

            case "BRUP":
                IItem brup = new BlueRupeeItem(Position);
                Room.items.Add(brup);
                break;

            case "TRIF":
                IItem triforce = new TriforceItem(Position);
                triforce.X = triforce.Position.X + ELEVEN * Global.Var.SCALE;
                triforce.Y = triforce.Position.Y + ELEVEN * Global.Var.SCALE;
                Room.items.Add(triforce);
                break;
            }
        }
 public BrickBlockBrokenCommand(BrickBlock block)
 {
     brickBlock = block;
 }
示例#17
0
 public BrickBlockCommand(BrickBlock block, Peach peach)
 {
     Block = block;
     Peach = peach;
 }
示例#18
0
 public BrickStillState(BrickBlock block)
 {
     this.moveUp = false;
     this.block  = block;
 }