コード例 #1
0
        ///Restart the falling item position
        private void InitializeFallingItemAtStartPosition(FallingBlocksWrapper obj)
        {
            int visibleCols = this.Renderer.GridMatrix.GetLength(1);
            int startRow = 5;
            int startCol = (visibleCols / 2) - 1;
            int randomColorsCounter = 0;

            ConsoleColor[] randomColors = 
            {
                (ConsoleColor)randomNumberGenerator.Next(1, 13),
                (ConsoleColor)secondRandomNumberGenerator.Next(5, 13),
                (ConsoleColor)thirdRandomNumberGenerator.Next(9, 13)
            };

            foreach (var fallingBlock in this.fallingBlocksWrapper)
            {
                fallingBlock.TopLeft = new Coordinates(startRow++, startCol);
                fallingBlock.ObjectColor = randomColors[randomColorsCounter++];
            }
        }
コード例 #2
0
        public Engine(Renderer renderer, int gameSpeed, Input movement)
        {
            this.Renderer = renderer;
            this.movement = movement;

            this.fallenObjectsContainerMatrix = new GameObject[this.Renderer.GridMatrix.GetLength(0), this.Renderer.GridMatrix.GetLength(1)];
            this.staticObjects = new List<GameObject>();
            this.movableObjects = new List<GameObject>();
            this.allObjects = new List<GameObject>();
            this.infoObjects = new List<GameObject>();
            this.gameSpeed = gameSpeed;

            //Adding falling blocks structure
            this.fallingBlocksWrapper = new FallingBlocksWrapper(new Coordinates(6, (this.Renderer.GridMatrix.GetLength(1) / 2) - 1), new Coordinates(1, 0));
            
            foreach (var fallingBlock in this.fallingBlocksWrapper)
            {
                this.AddObject(fallingBlock);
            }
        }