Esempio n. 1
0
        public void mouseUp(int x, int y)
        {
            if (gameInputLock || thread.getState() == GameState.PAUSED)
            {
                return;
            }

            switch (inputState)
            {
            case InputState.RELEASED_NO_SELECTION:
            {
                break;
            }

            case InputState.SELECTING_ELEMENTS:
            {
                selToX = x / gameViewController.getCellWidth();
                selToY = y / gameViewController.getCellHeight();

                if (selToX < 0)
                {
                    selToX = 0;
                }
                if (selToX >= elementsX)
                {
                    --selToX;
                }
                if (selToY < 0)
                {
                    selToY = 0;
                }
                if (selToY >= elementsY)
                {
                    --selToY;
                }

                gameViewController.continueSelection(selToX, selToY);
                fixSelection();

                if (selFromX - selToX == 0 && selFromY - selToY == 0)
                {
                    if (lastSelOneItem)
                    {
                        lastSelOneItem = false;
                        if (lastSelX != selFromX || lastSelY != selFromY)
                        {
                            inputState    = InputState.ANIMATION;
                            gameInputLock = true;
                            gameViewController.stopSelection();
                            gameViewController.startMoveTwoPiecesAnimation(lastSelX, lastSelY, this);
                            break;
                        }
                    }
                    else
                    {
                        lastSelOneItem = true;
                        lastSelX       = selFromX;
                        lastSelY       = selFromY;
                    }
                }

                inputState = InputState.RELEASED_SELECTED;
                break;
            }

            case InputState.RELEASED_SELECTED:
            {
                break;
            }

            case InputState.MOVING_ELEMENTS:
            {
                inputState    = InputState.ANIMATION;
                gameInputLock = true;
                gameViewController.stopSelection();
                gameViewController.startMoveAnimation(this);
                break;
            }

            case InputState.ANIMATION:
            {
                break;
            }
            }
        }