コード例 #1
0
    void _HandUI_OnHandSet()
    {
        //if there is a card selected then use its index, if not then use index 0
        int index   = (_HandUI.m_SelectedCardUI != null) ? _HandUI.m_SelectedCardUI._Index : 0;
        int r_Index = (index == _HandUI.m_NumberOfCards - 1) ? -1 : index + 1;
        int l_Index = (index == 0) ? -1 : index - 1;

        if (_HandUI.m_NumberOfCards == 0)
        {
            return;
        }

        //focused sprite
        _CentreCard.sprite  = _HandUI.GetSpriteOfCard(_HandUI.m_Cards[index]._Card.Type);
        _CenterValDis1.text = (_HandUI.m_Cards[index]._Card.Value > 0) ? _HandUI.m_Cards[index]._Card.Value.ToString() : "";

        //Hide the sideimages if they dont represent a card.
        if (r_Index != -1)
        {
            _RightCard.sprite = _HandUI.GetSpriteOfCard(_HandUI.m_Cards[r_Index]._Card.Type);
            _RightCard.color  = _LandR_Colour;

            //if not already set visiable
            if (_CGRightButton.alpha == 0)
            {
                _CGRightButton.alpha          = 1;
                _CGRightButton.interactable   = true;
                _CGRightButton.blocksRaycasts = true;
            }
        }
        else
        {
            _CGRightButton.alpha          = 0.0f;
            _CGRightButton.interactable   = false;
            _CGRightButton.blocksRaycasts = false;
            _RightCard.color = new Color(0, 0, 0, 0);
        }

        if (l_Index != -1)
        {
            _LeftCard.sprite = _HandUI.GetSpriteOfCard(_HandUI.m_Cards[l_Index]._Card.Type);
            _LeftCard.color  = _LandR_Colour;
            _LeftValDis.text = (_HandUI.m_Cards[l_Index]._Card.Value > 0) ? _HandUI.m_Cards[l_Index]._Card.Value.ToString() : "";

            //if not already set visiable
            if (_CGLeftButton.alpha == 0)
            {
                _CGLeftButton.alpha          = 1;
                _CGLeftButton.interactable   = true;
                _CGLeftButton.blocksRaycasts = true;
            }
        }
        else
        {
            _CGLeftButton.alpha          = 0.0f;
            _CGLeftButton.interactable   = false;
            _CGLeftButton.blocksRaycasts = false;
            _LeftCard.color  = new Color(0, 0, 0, 0);
            _LeftValDis.text = "";
        }

        //remenber selected index
        _currentCentreIndex = index;
    }