Exemplo n.º 1
0
    // 左右スワイプだった場合の処理
    void OnGoBackToDefaultPosition()
    {
        if (m_CurrentCard != null)
        {
            Card.State prev = m_CurrentCard.currentState;
            m_CurrentCard.currentState = m_CurrentCard.GetNextStateAfterAnimation();

            //ステートが実質的に変化ナシなら処理もナシ
            if (prev == m_CurrentCard.currentState)
            {
                return;
            }

            if (m_CurrentCard.currentState == Card.State.Join)
            {
                m_BattleMembers.AddMember(m_CurrentCard);
            }
            else if (m_CurrentCard.currentState == Card.State.Defection)
            {
                m_BattleMembers.DeleteMember(m_CurrentCard);
            }

            m_CurrentCard = null;
        }

        CheckFooterButton();
    }
Exemplo n.º 2
0
    void CardComparison(List <int> cardNumbers)
    {
        Card.flip = false;                                                                      // Disable flipping more than two cards

        Card.State x = Card.State.Obscured;                                                     // Initialize a state

        if (Card.AllCards[cardNumbers[0]].cardValue == Card.AllCards[cardNumbers[1]].cardValue) // Compare card values
        {
            Invoke("PlayMatchSound", _matchSoundDelay);
            x = Card.State.Matched; // Change the state
            _matches--;             // Decrease matches
            if (_matches == 0)
            {
                GameOver(); // If all cards are matched - start the game over sequence
            }
        }
        for (int i = 0; i < cardNumbers.Count; i++)
        {
            Card.AllCards[cardNumbers[i]].state = x; // Set the card state
            if (x == Card.State.Obscured)
            {
                Card.AllCards[cardNumbers[i]].InitiateDelay(); // Trigger delay before flipping back (if card state is obscured)
            }
            else
            {
                Card.flip = true; // Set flippability back to true
            }
        }
    }
Exemplo n.º 3
0
 internal void setState(Card.State s)
 {
     state = s;
     if (!init())
     {
         current.setState(s);
     }
 }
Exemplo n.º 4
0
    //左右のスクロール開始時に呼ばれる
    public void StartDragHorizontal(Card.State state)
    {
        m_CurrentState = state;

        switch (m_CurrentState)
        {
        case State.Defection:
            m_UnderCard.color = m_ActiveColor;
            break;

        case State.Join:
            m_UnderCard.color = m_CardColor;
            break;
        }
    }
Exemplo n.º 5
0
    //左右のスクロールから戻るアニメーションを行い、新しいStateを返す
    public Card.State GetNextStateAfterAnimation()
    {
        Card.State result   = m_CurrentState;
        float      duration = 0.4f;
        float      targetX  = 0;

        m_currentHorizontalScrollMode = HorizontalScrollMode.Non;

        switch (m_CurrentState)
        {
        case State.Defection:

            //閾値以上のドラッグかつメンバーがマックスに到達していなければカードがアクティブになる
            if (m_Body.rectTransform.anchoredPosition.x > m_ThresholdHorizontal)
            {
                targetX = m_ThresholdHorizontal;
                result  = SetJoin();
            }
            else
            {
                targetX = 0;
                result  = SetDefection();
            }
            break;

        case State.Join:
            targetX = 0;
            result  = SetDefection();
            break;
        }

        //トゥイーンアニメーション
        m_Body.transform.DOLocalMoveX(targetX, duration, true).SetEase(Ease.OutBack);

        //テキストが揺れる
        m_NameText.Play();

        return(result);
    }
Exemplo n.º 6
0
 /// <summary>
 /// pulling one card from the deck
 /// </summary>
 /// <returns>a card</returns>
 public Card PullCard(Card.State cardState)
 {
     cardIndex++;
     cards[cardIndex - 1].CardState = cardState;
     return(cards[cardIndex - 1]);
 }
Exemplo n.º 7
0
    //       } else {
    //           if (isClearing) {
    //               view_frame = view_period;
    //               isClearing = false;

    //           }
    //       }
    //   }

    //色の決定
    void ViewFadeColor()
    {
        //       if (view_frame == view_period - 1 && !isClearing) {

        //最初の色を決定
        if (!isClearing)
        {
            colorFrame = -1;
            colorFrom  = CardObj.GetStartColor(card);
        }

        //次の色を決定
        if (colorFrame < 0)
        {
            colorFrom = colorTo;
            int colorHave = 0;
            for (int i = 0; i < (int)Card.Color.size; ++i)
            {
                if (card.color[(i + 1 + (int)colorFrom) % (int)Card.Color.size] > 0)
                {
                    colorTo = (Card.Color)((i + 1 + (int)colorFrom)
                                           % (int)Card.Color.size);
                    ++colorHave; break;
                }
            }
            if (colorHave == 0)
            {
                colorTo = Card.Color.size; ++colorHave;
            }
            if (colorHave == 1)
            {
                colorFrame  = colorPeriodAdd;
                colorPeriod = colorPeriodAdd;
            }
            else
            {
                colorFrame             = colorPeriod
                                       = (colorPeriodMin + (colorHave - 2)
                                          * colorPeriodAdd) / (colorHave - 1);
            }
        }

        //色を確定させて塗る
        if (colorFrom != colorTo || !isClearing)
        {
            for (int i = 0; i < (int)CardObj.ColorMaterial.size; ++i)
            {
                Card.State iState = 0;
                switch ((CardObj.ColorMaterial)i)
                {
                case CardObj.ColorMaterial.frame:
                case CardObj.ColorMaterial.name: continue;

                case CardObj.ColorMaterial.cost: iState = Card.State.cost; break;

                case CardObj.ColorMaterial.power: iState = Card.State.power; break;

                case CardObj.ColorMaterial.toughness: iState = Card.State.toughness; break;
                }
                GameObject obj = obj_stateView[(int)iState];

                //外部のカードの情報を用いる
                Color color = Utility.GetRatio(
                    CardObj.colorList[(int)colorFrom][i], CardObj.colorList[(int)colorTo][i],
                    (Mathf.Cos(Mathf.PI * colorFrame / colorPeriod) + 1f) / 2);

                color.a = viewFrame / viewPeriod;
                obj.GetComponent <Image>().color = color;
                if ((CardObj.ColorMaterial)i == CardObj.ColorMaterial.cost)
                {
                    obj_characterStateView[(int)Card.CharacterState.mana].GetComponent <Image>().color = color;
                    obj_characterStateView[(int)Card.CharacterState.od].GetComponent <Image>().color   = color;
                }
            }
        }
        colorFrame = (colorFrame + 1) % colorPeriod;
    }