Esempio n. 1
0
    //Comportamiento del Board en STATE_NORMAL
    public void tokenSelection()
    {
        if (CMouse.firstPress(0))
        {
            int[] mousePos = getMouseTile();
            if (mousePos[0] != -1 & secondSelect[0] == -1)
            {
                firstSelect[0] = mousePos[0];
                firstSelect[1] = mousePos[1];
                matrixBoard[firstSelect[0]][firstSelect[1]].select();
            }
        }
        if (CMouse.pressed(0))
        {
            int[] mousePos = getMouseTile();
            if (mousePos[0] != firstSelect[0] | mousePos[1] != firstSelect[1])
            {
                if (mousePos[0] == -1 & firstSelect[0] != -1)
                {
                    matrixBoard[firstSelect[0]][firstSelect[1]].deselect();
                    firstSelect[0] = -1;
                    firstSelect[1] = -1;
                }
                if (mousePos[0] != -1 & firstSelect[0] != -1)
                {
                    secondSelect[0] = mousePos[0];
                    secondSelect[1] = mousePos[1];
                    matrixBoard[secondSelect[0]][secondSelect[1]].select();

                    if (contiguousTiles(firstSelect[0], firstSelect[1], secondSelect[0], secondSelect[1]))
                    {
                        switchTokens(firstSelect[0], firstSelect[1], secondSelect[0], secondSelect[1]);
                        current_state = STATE_CHANGING;
                        matrixBoard[firstSelect[0]][firstSelect[1]].deselect();
                        matrixBoard[secondSelect[0]][secondSelect[1]].deselect();
                    }
                    else
                    {
                        matrixBoard[firstSelect[0]][firstSelect[1]].deselect();
                        matrixBoard[secondSelect[0]][secondSelect[1]].deselect();
                        firstSelect[0]  = -1;
                        firstSelect[1]  = -1;
                        secondSelect[0] = -1;
                        secondSelect[1] = -1;
                    }
                }
            }
        }
        if (CMouse.release(0) & firstSelect[0] != -1)
        {
            matrixBoard[firstSelect[0]][firstSelect[1]].deselect();
        }
    }
Esempio n. 2
0
    public override void update()
    {
        base.update();

        float scale = 1.0f;
        int   frame = 1;

        Vector3 mousePos = CMouse.getPos();

        mIsMouseOver = CMath.pointInRect(mousePos.x, mousePos.y, getX() - getWidth() / 2, getY() - getHeight() / 2, getWidth(), getHeight());

        if (CMouse.pressed())
        {
            if (mIsMouseOver)
            {
                scale = 0.9f;
                frame = 2;
            }
        }
        else
        {
            if (mIsMouseOver)
            {
                scale = 1.1f;
                frame = 1;
            }
            else
            {
                scale = 1.0f;
                frame = 1;
            }
        }

        setScale(scale);
        this.buttonText.setScale(scale);

        gotoAndStop(frame);

        this.buttonText.setXY(this.getX(), this.getY());
        this.buttonText.update();
    }
Esempio n. 3
0
 public bool pressed()
 {
     return(CMouse.pressed() && mIsMouseOver);
 }