Example #1
0
    // Update is called once per frame
    void Update()
    {
        if (Input.GetKeyDown(KeyCode.S))
        {
            deck.Shuffle();
        }
        if (Input.GetKeyDown(KeyCode.D))
        {
            BaseCardComponent card = deck.PopTopCard();
            if (card != null)
            {
                hand.Insert(card);
            }
        }
        if (Input.GetKeyDown(KeyCode.L))
        {
            deck.LoadDeck(cardIDs);
        }
        if (Input.GetKeyDown(KeyCode.E))
        {
            if (hand.IsArrangeFinish())
            {
                hand.SetSelectableType(true, false, false, false);
            }
        }

        if (hand.GetSelectedCard() != null)
        {
            Debug.Log("DeckTester/Update : " + hand.GetSelectedCard().GetBaseCard().ToString());
            hand.Remove(hand.GetSelectedCard());
            hand.GetSelectedCard().gameObject.SetActive(false);
            hand.SetSelectableType(false, false, false, false);
        }
    }
Example #2
0
    void HandleInput()
    {
        if (highlightedCard != null)
        {
            highlightedCard.SetHighlight(false);
            highlightedCard = null;
        }

        Vector2      mousePosition = Camera.main.ScreenToWorldPoint(Input.mousePosition);
        RaycastHit2D hitInfo       = Physics2D.Raycast(mousePosition, Vector2.zero, 0, LayerMask.GetMask("Hand"));

        if (hitInfo.collider != null)
        {
            highlightedCard = hitInfo.collider.gameObject.GetComponent <BaseCardComponent> ();
            if (selectableType[(int)highlightedCard.GetBaseCard().GetCardType()])
            {
                highlightedCard.SetHighlight(true);
            }
            else
            {
                highlightedCard = null;
            }
        }

        if (Input.GetMouseButtonDown(0) && selectedCard == null)
        {
            selectedCard = highlightedCard;
        }
    }
Example #3
0
    public void SetSelectableType(bool attack, bool defend, bool effect, bool serve)
    {
        selectableType [(int)CardType.Attack] = attack;
        selectableType [(int)CardType.Defend] = defend;
        selectableType [(int)CardType.Effect] = effect;
        selectableType [(int)CardType.Serve]  = serve;

        selectedCard = null;
    }
Example #4
0
    public void Insert(BaseCardComponent newCard)
    {
        cards.Add(newCard);
        newCard.transform.parent = transform;
        BoxCollider2D collider = newCard.gameObject.AddComponent <BoxCollider2D> ();

        collider.size = new Vector2(cardWidth, cardHeight);

        SetArrangePosition();
        lerpSpeed = 1;
    }
Example #5
0
    public bool Draw()
    {
        BaseCardComponent card = deck.PopTopCard();

        if (card != null)
        {
            hand.Insert(card);
            drawFinished = false;
            return(true);
        }
        return(false);
    }
Example #6
0
    public bool Remove(BaseCardComponent removedCard)
    {
        if (cards.Remove(removedCard))
        {
            removedCard.transform.parent = transform.parent;

            SetArrangePosition();
            lerpSpeed = 3;
            return(true);
        }

        return(false);
    }
Example #7
0
 public BaseCardComponent SelectCard()
 {
     selectedCard = hand.GetSelectedCard();
     if (selectedCard != null && hand.Remove(selectedCard))
     {
         selectedCard.transform.parent = transform;
         oldPosition    = selectedCard.transform.position;
         lerpT          = 0;
         moveFinished   = false;
         selectFinished = false;
     }
     return(selectedCard);
 }
    private void attackCardExecution()
    {
		selectedCard.Use ();
		GameObject.Destroy (selectedCard.gameObject);
		selectedCard = null;
    }
    private void attackCardSelect()
    {
		selectedCard = currentPlayer.SelectCard ();
    }
    private void conditionCardSelect()
    {
		selectedCard = currentPlayer.SelectCard ();
    }
    private void defendCardSelect()
    {
		selectedCard = currentPlayer.SelectCard ();
    }