Exemplo n.º 1
0
        private void GameBlockRightButtonClick(object sender, RoutedEventArgs e)
        {
            Button button = sender as Button;

            if (button != null)
            {
                GameBlockSelector gameBlockWrapper = (GameBlockSelector)button.DataContext;

                gameBlockWrapper.BlockType = GameBoard.GameBlockType.Null;
            }
        }
Exemplo n.º 2
0
        private void GameBlockButtonClick(object sender, RoutedEventArgs e)
        {
            Button button = sender as Button;

            if (button != null)
            {
                GameBlockSelector gameBlockWrapper = (GameBlockSelector)button.DataContext;

                switch (gameBlockWrapper.BlockType)
                {
                case GameBoard.GameBlockType.Null:
                    gameBlockWrapper.BlockType = GameBoard.GameBlockType.Normal;
                    break;

                case GameBoard.GameBlockType.Normal:
                    gameBlockWrapper.BlockType = GameBoard.GameBlockType.Player;
                    break;

                case GameBoard.GameBlockType.Player:
                    gameBlockWrapper.BlockType = GameBoard.GameBlockType.ChangeDirection;
                    gameBlockWrapper.Direction = MovementDirection.Up;
                    break;

                case GameBoard.GameBlockType.ChangeDirection:
                    switch (gameBlockWrapper.Direction)
                    {
                    case MovementDirection.Up:
                        gameBlockWrapper.Direction = MovementDirection.Down;
                        break;

                    case MovementDirection.Down:
                        gameBlockWrapper.Direction = MovementDirection.Left;
                        break;

                    case MovementDirection.Left:
                        gameBlockWrapper.Direction = MovementDirection.Right;
                        break;

                    case MovementDirection.Right:
                        gameBlockWrapper.BlockType = GameBoard.GameBlockType.ExtraMove;
                        break;
                    }
                    break;

                case GameBoard.GameBlockType.ExtraMove:
                    gameBlockWrapper.BlockType     = GameBoard.GameBlockType.MultipleMoves;
                    gameBlockWrapper.NumberOfTimes = 2;
                    break;

                case GameBoard.GameBlockType.MultipleMoves:
                    if (gameBlockWrapper.NumberOfTimes < 6)
                    {
                        gameBlockWrapper.NumberOfTimes++;
                    }
                    else
                    {
                        gameBlockWrapper.BlockType = GameBoard.GameBlockType.Null;
                    }
                    break;
                }
            }
        }