Example #1
0
        public Block(Game game, Vector2 position, BlockColour blockColour)
            : base(null, position, new Point(77, 28), 1)
        {
            _whiteTexture = game.Content.Load<Texture2D>(@"Sprites/WhiteBlock");
            _blueTexture = game.Content.Load<Texture2D>(@"Sprites/BlueBlock");
            _redTexture = game.Content.Load<Texture2D>(@"Sprites/RedBlock");

            BlockColour = blockColour;
        }
Example #2
0
 private BlockColour RandomColour(Difficulty diff, BlockColour n1)
 {
     return RandomColour(diff, n1, BlockColour.Empty);
 }
Example #3
0
        /// <summary>
        /// Picks a random block colour which is not the same as any of the passed colours.
        /// </summary>
        private BlockColour RandomColour(Difficulty diff, BlockColour n1, BlockColour n2)
        {
            int count;
            int bump1 = 10, bump2 = 10; // Initially higher than any possible value so they don't interfere

            if ((n1 == BlockColour.Empty) && (n2 == BlockColour.Empty))
            {
                count = (diff > Difficulty.Normal) ? 7 : 6;
            }
            else if ((n1 == n2) || (n2 == BlockColour.Empty) || (n1 == BlockColour.Empty))
            {
                count = (diff > Difficulty.Normal) ? 6 : 5;
                bump1 = (int)n1;
            }
            else
            {
                count = (diff > Difficulty.Normal) ? 5 : 4;
                bump1 = (int)n1;
                bump2 = (int)n2;
                if (bump1 > bump2) // sort
                {
                    int w = bump2;
                    bump2 = bump1;
                    bump1 = w;
                }
            }

            int result = therand.Next(1, count);
            if (result >= bump1) result++;
            if (result >= bump2) result++;
            return (BlockColour)(result);
        }