private void InitializeUniqueBlocks()
 {
     foreach (Type type in Assembly.GetAssembly(typeof(UniqueBlock)).GetTypes()
              .Where(myType => myType.IsClass && !myType.IsAbstract && myType.IsSubclassOf(typeof(UniqueBlock))))
     {
         UniqueBlock block = (UniqueBlock)Activator.CreateInstance(type);
         UniqueBlocks[block.Name] = block;
     }
 }
Exemple #2
0
        /// <summary>
        /// Creates new block at position of random block in range
        /// </summary>
        /// <param name="field"></param>
        /// <param name="uniqueBlock"></param>
        /// <param name="range"></param>
        /// <returns></returns>
        public Block CreateBlockInRange(Field field, UniqueBlock uniqueBlock, List <Block> range)
        {
            Block block = new Block();

            block.Type        = uniqueBlock.BaseType;
            block.UniqueBlock = uniqueBlock;

            int   n = random.Next(0, range.Count);
            Block blockToReplace = range[n];

            block.SetXY(blockToReplace.X, blockToReplace.Y);
            block.RememberState(BlockState.CreatedAsComboResult);
            block.ReplacedBlock = blockToReplace;

            field.Blocks[block.X, block.Y] = block;

            return(block);
        }