Exemplo n.º 1
0
        /// <summary>
        /// Used to update ghost position
        /// </summary>
        private void UpdateGhost()
        {
            Ghost = Controller.Clone();

            Tetromino test = Ghost;

            while (!Map.CheckPlaceCollision(test))
            {
                Ghost = test;
                test  = Ghost.Clone();
                test.Transform(0, Direction.Forward);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Used to move the tetromino controller
        /// </summary>
        /// <returns>if the transform was successful</returns>
        public bool Transform(Direction x, Direction y)
        {
            Tetromino test = Controller.Clone();

            test.Transform(x, y);

            if (y != Direction.None)
            {
                isTransformDownMade = true;

                if (Map.CheckPlaceCollision(test))
                {
                    // Checks for lose
                    if (Controller.Y < 0)
                    {
                        Reset();
                    }
                    else // Place tetromino
                    {
                        isNewHoldMade = false;
                        Map.PlaceTetromino(Controller);
                        Score += Map.ClearLines() * 100;
                        Next();
                    }
                    return(false);
                }
            }

            if ((!Map.CheckPlaceCollision(test)) && (!Map.CheckWallCloision(test)))
            {
                Controller = test;
            }

            UpdateGhost();

            return(true);
        }