Beispiel #1
0
        public override void update(GameTime gameTime)
        {
            mCursor.update(gameTime);

            processMouse();

            for (int i = 0; i < cards.Length; i++)
            {
                switch (cards[i].state)
                {
                case CARD_STATE.WRONG:
                    if (cards[i].revealStateTimer < 1000)
                    {
                        cards[i].revealStateTimer += gameTime.ElapsedGameTime.Milliseconds;
                    }
                    else
                    {
                        mousePressed              = false;
                        newState                  = CARD_STATE.NONE;
                        cards[i].up               = false;
                        cards[i].state            = newState;
                        cards[i].revealStateTimer = 0;
                    }
                    break;
                }
            }
        }
Beispiel #2
0
        private void processMouse()
        {
            var ms = Game1.getMousePosition();

            if (ms.LeftButton == ButtonState.Pressed)
            {
                mousePressed = true;
            }
            else
            {
                if (mousePressed)
                {
                    float x = mCursor.mX;
                    float y = mCursor.mY;

                    if (x > 30 && x < 570 && y > 30 && y < 570 && newState != CARD_STATE.WRONG)
                    {
                        int  cardX  = (int)((x - 30) / 135);
                        int  cardY  = (int)((y - 30) / 180);
                        int  cardID = cardX + cardY * 4;
                        Card card   = cards[cardID];

                        if (card.state == CARD_STATE.NONE)
                        {
                            cards[cardID].up = true;


                            card.state = CARD_STATE.SELECTED;
                            if (firstCardSelected)
                            {
                                if (cardID != card1)
                                {
                                    card2             = cardID;
                                    firstCardSelected = false;

                                    if (cards[card1].type == cards[card2].type)
                                    {
                                        newState = CARD_STATE.CORRECT;
                                    }
                                    else
                                    {
                                        newState = CARD_STATE.WRONG;
                                    }
                                    cards[card1].state = newState;
                                    cards[card2].state = newState;
                                }
                            }
                            else
                            {
                                card1             = cardID;
                                firstCardSelected = true;
                            }
                        }
                    }
                }
                mousePressed = false;
            }
        }
    public void SetState(CARD_STATE state)
    {
        _cardState = state;
        switch (_cardState)
        {
        case CARD_STATE.CARD_APPEAR:        _sprCard.alpha = 0;     break;

        case CARD_STATE.CARD_DISAPPEAR:     _sprCard.alpha = 1;     break;
        }
    }
Beispiel #4
0
    void OnDrag(Vector2 delta)
    {
        if (null == DackMgr.Instance.SelectedCard)
        {
            _btnScale.OnDisable();
            return;
        }

        //드래그하면 원래 상태로 돌린.
        _cardState = CARD_STATE.CARD_END;

        DackMgr.Instance.SetChangeCard_from(this);
    }
Beispiel #5
0
 public CardState(Card _card)
 {
     mCardReference = _card; //it works?
     mCardState     = CARD_STATE.INVALID;
     mCardReference.SetIsInAir(false);
 }