示例#1
0
    //Undo selection change
    void UnselectCard(LargeCard c)
    {
        Image image = c.GetComponent <Image>();

        image.color = previousColor;

        selectedCards.Remove(c);
    }
示例#2
0
    //Somehow denote some kind of selection
    void SelectCard(LargeCard c)
    {
        Image image = c.GetComponent <Image>();

        previousColor = image.color;

        image.color = new Color(0, .5f, .5f);

        selectedCards.Add(c);
    }
示例#3
0
 void FindCardsAddTriggers()
 {
     //Get every card in scene and add trigger to them
     LargeCard[] cards = GameObject.FindObjectsOfType <LargeCard>();
     for (int i = 0; i < cards.Length; i++)
     {
         LargeCard          lCard   = cards[i];
         EventTrigger       trigger = lCard.GetComponent <EventTrigger>();
         EventTrigger.Entry entry   = new EventTrigger.Entry();
         entry.eventID = EventTriggerType.PointerClick;
         entry.callback.AddListener((data) => { TappedCard((PointerEventData)data); });
         trigger.triggers.Add(entry);
     }
 }
示例#4
0
    protected override void DoAfterLoad()
    {
        base.DoAfterLoad();
        //Set card in scene to this card data
        LargeCard lCard = GameObject.FindObjectOfType <LargeCard>();

        //If it contains game line trigger
        GameLineTrigger trigger = lCard.GetComponent <GameLineTrigger>();

        if (trigger != null)
        {
            trigger.PathType = PathType;
            trigger.Folder   = Folder;
        }
    }
示例#5
0
    void TappedCard(PointerEventData data)
    {
        //Ignore these flip events
        if (lockedSpin)
        {
            return;
        }
        GameObject go    = data.pointerCurrentRaycast.gameObject;
        LargeCard  lCard = go.GetComponentInParent <LargeCard>();

        if (!lCard.CanSpin || (selectedCard != null && !selectedCard.CanSpin) || ignoreSet.Contains(lCard.transform))
        {
            return;
        }
        if (selectedCard == null)
        {
            selectedCard = lCard;
        }
        else if (selectedCard == lCard)
        {
            selectedCard = null;
        }
        else
        {
            //Selected the correct second card (has to be facing the other way)
            if (lCard.GetCardData() == selectedCard.GetCardData() && (lCard.hideType != selectedCard.hideType))
            {
                //Disable interactivity
                //Can't just set canspin because canspin is constantly reset (can make it only reset cards that aren't in solved hashset if necessary)
                CanvasGroup lCardGroup    = lCard.GetComponent <CanvasGroup>();
                CanvasGroup selectedGroup = selectedCard.GetComponent <CanvasGroup>();
                lCardGroup.interactable      = false;
                selectedGroup.interactable   = false;
                lCardGroup.blocksRaycasts    = false;
                selectedGroup.blocksRaycasts = false;

                //Ignore these cards when forcing all cards to flip over
                ignoreSet.Add(lCard.transform);
                ignoreSet.Add(selectedCard.transform);

                //Show some other way that it was correct
                lCard.GetComponent <Image>().color        = Color.cyan;
                selectedCard.GetComponent <Image>().color = Color.cyan;
                ForceCardsOver();
                selectedCard = null;

                cardsCompleted += 2;
                CheckGameCompleted();
            }
            else
            {
                //Make sure second card is still flipped due to how events are passed
                lCard.SpinCard();
                //Force all other children cards over if they aren't in hashSet of solved cards or selected cards
                ignoreSet.Add(lCard.transform);
                ignoreSet.Add(selectedCard.transform);
                ForceCardsOver();
                //Enforce a delay to see that you made a mistake
                SetFlippingChildren(false);
                StartCoroutine(FlipBackCards(lCard, selectedCard));
                //Wrong second card, lock out spinning of all the cards in order to show mistake
                selectedCard = null;
            }
        }
    }