Exemple #1
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);
            }
        }