示例#1
0
        /// <summary>
        /// Add a block with a random block size to the game field and place it randomly 
        /// </summary>
        /// <param name="game">Reference to the game.</param>
        public void addBlock(PungGame game)
        {
            // Create a new empty block, only his position is known at start.
            Block newBlock = new Block(game, blocksSafeZone);

            // Call the overloaded addBlock procedure to generate a texture and affect his objectRectangle
            addBlock(newBlock,
                Utilities.Randomizer.CreateRandom(MIN_BLOCK_SIZE, MAX_BLOCK_SIZE),
                Utilities.Randomizer.CreateRandom(MIN_BLOCK_SIZE, MAX_BLOCK_SIZE),
                new Color(255, 0, 0));
        }
示例#2
0
 /// <summary>
 /// Add an already instanciated block to the game field.
 /// </summary>
 /// <param name="newBlock">Block to be added to the game.</param>
 /// <remarks>
 /// The new block needs a texture already of the ObjectRectangle property will be null.
 /// 
 /// Procedure needs to be re-written due to it's unstableness and lack of current use.
 /// </remarks>
 public void addBlock(Block newBlock)
 {
     addBlock(newBlock, newBlock.ObjectRectangle.Width, newBlock.ObjectRectangle.Height, new Color(255, 255, 255));
 }
示例#3
0
 /// <summary>
 /// Remove a block from the game.
 /// </summary>
 /// <param name="targetBlock">The block to be removed.</param>
 public void removeBlock(Block targetBlock)
 {
     // Get the groups the same way as addBlock but uses those objects to remove a block from the collections.
     GroupList groupList = (GroupList)Game.Services.GetService(typeof(GroupList));
     Group collisionGroup = groupList.GetGroup("Collisions");
     collisionGroup.Remove(targetBlock);
     blocksList.Remove(targetBlock);
 }
示例#4
0
        /// <summary>
        /// Procedure to add a block to the Block Manager's list of blocks.
        /// </summary>
        /// <param name="newBlock">Instance of a new block.</param>
        /// <param name="width">Desired width of the block.</param>
        /// <param name="height">Desired height of the block.</param>
        /// <param name="blockColor">Color of desired the block's texture.</param>
        public void addBlock(Block newBlock, int width, int height, Color blockColor)
        {
            /* Get the group list service and get the group named Collisions.
             * take the new block and load it's texture then put it in the BlockBunch group then
             * add the newBlock to the collisionGroup
             */
            GroupList groupList = (GroupList)Game.Services.GetService(typeof(GroupList));
            Group collisionGroup = groupList.GetGroup("Collisions");

            newBlock.Texture = Utilities.ColorTexture.Create(Game.GraphicsDevice, width, height, blockColor);
            newBlock.ObjectRectangle = new Rectangle((int)newBlock.Position.X, (int)newBlock.Position.Y, newBlock.Texture.Width, newBlock.Texture.Height);
            blocksList.Add(newBlock);
            collisionGroup.Add(newBlock);
        }