public void Update()
    {
        if (Input.GetMouseButtonDown(0))
        {
            clicks += 1;
            if (clicks == 1)
            {
                Debug.Log("Set timer");
                lastTimer = Time.unscaledTime;
            }
            if (clicks >= 2)
            {
                currentTimer = Time.unscaledTime;

                float difference = currentTimer - lastTimer;

                if (difference <= 0.2f)
                {
                    clicks = 0;
                    GameObject card = GetClickedCard();
                    if (card != null)
                    {
                        if (card.transform.IsChildOf(Collection.gameObject.transform))
                        {
                            card.transform.SetParent(Deck.gameObject.transform, false);
                            Deck.Reorganize();
                            Deck.UpdateList();
                        }
                        else if (card.transform.IsChildOf(Deck.gameObject.transform))
                        {
                            card.transform.SetParent(Collection.gameObject.transform, false);
                            Collection.Reorganize();
                            Collection.UpdateList();
                        }
                    }
                }
                else
                {
                    clicks = 0;
                }
            }
        }
        else
        {
            if (clicks < 2)
            {
                currentTimer = Time.unscaledTime;
                float difference = currentTimer - lastTimer;

                if (difference > .2f)
                {
                    clicks = 0;
                }
            }
        }
    }
Esempio n. 2
0
    public void Update()
    {
        if (Input.GetMouseButtonDown(0))
        {
            clicks += 1;
            if (clicks == 1)
            {
                Debug.Log("Set timer");
                lastTimer = Time.unscaledTime;
            }
            if (clicks >= 2)
            {
                currentTimer = Time.unscaledTime;

                float difference = currentTimer - lastTimer;

                if (difference <= 0.2f)
                {
                    clicks = 0;
                    GameObject card = GetClickedCard();
                    if (card != null)
                    {
                        if (card.transform.IsChildOf(Collection.gameObject.transform))
                        {
                            if (Deck.gameObject.transform.childCount > 0)
                            {
                                GameObject siblingCard = Deck.gameObject.transform.GetChild(0).gameObject;
                                if (siblingCard == null || card.GetComponent <CQBCard>().GetFaction() != siblingCard.GetComponent <CQBCard>().GetFaction())
                                {
                                    ActivateResponse();
                                    Invoke("DeactivateResponse", 3);
                                    return;
                                }
                            }
                            card.transform.SetParent(Deck.gameObject.transform, false);
                            Deck.Reorganize();
                            Collection.Reorganize();
                            Deck.UpdateList();
                        }
                        else if (card.transform.IsChildOf(Deck.gameObject.transform))
                        {
                            if (Collection.gameObject.transform.childCount > 0)
                            {
                                GameObject siblingCard = Collection.gameObject.transform.GetChild(0).gameObject;
                                if (siblingCard == null || card.GetComponent <CQBCard>().GetFaction() != siblingCard.GetComponent <CQBCard>().GetFaction())
                                {
                                    ActivateResponse();
                                    Invoke("DeactivateResponse", 3);
                                    return;
                                }
                            }
                            card.transform.SetParent(Collection.gameObject.transform, false);
                            Deck.Reorganize();
                            Collection.Reorganize();
                            Deck.UpdateList();
                        }
                    }
                }
                else
                {
                    clicks = 0;
                }
            }
        }
        else
        {
            if (clicks < 2)
            {
                currentTimer = Time.unscaledTime;
                float difference = currentTimer - lastTimer;

                if (difference > .2f)
                {
                    clicks = 0;
                }
            }
        }
    }