public void ProcessAction(GameObject input)
    {
        if (!input.CompareTag("Card"))
        {
            return;
        }

        if (UtilsScript.Instance.selectedCards.Count != 1)
        {
            throw new System.ArgumentException("utils.selectedCards must be of size 1");
        }

        GameObject selectedCard = UtilsScript.Instance.selectedCards[0];

        if (CardTools.CanMatch(input.GetComponent <CardScript>(), selectedCard.GetComponent <CardScript>()))
        {
            UtilsScript.Instance.Match(input, selectedCard);
        }
    }
    private void FindMoves(GameObject selectedCard)
    {
        CardScript selectedCardScript = selectedCard.GetComponent <CardScript>();

        int selectedCardNum = selectedCardScript.cardNum;

        bool cardIsFromFoundation = selectedCardScript.container.CompareTag("Foundation");
        bool cardIsFromWastepile  = selectedCardScript.container.CompareTag("Wastepile");

        bool cardCanBeMatched = true;

        // if the card is in a foundation and not at the top of it
        if (cardIsFromFoundation && selectedCard !=
            selectedCardScript.container.GetComponent <FoundationScript>().cardList[0])
        {
            cardCanBeMatched = false;
        }

        if (cardCanBeMatched)
        {
            foreach (GameObject reactor in Config.config.reactors)
            {
                // if the card matches the card in the top of the reactor
                if (reactor.GetComponent <ReactorScript>().cardList.Count != 0 &&
                    CardTools.CanMatch(reactor.GetComponent <ReactorScript>().cardList[0].GetComponent <CardScript>(),
                                       selectedCardScript, checkIsTop: false))
                {
                    cardMatches.Add(reactor.GetComponent <ReactorScript>().cardList[0]);
                }
            }

            // if the card is not in the reactor
            if (!selectedCard.GetComponent <CardScript>().container.CompareTag("Reactor"))
            {
                // get the reactor that we can match into
                foreach (GameObject reactor in Config.config.reactors)
                {
                    if (CardTools.IsSameSuit(selectedCard, reactor))
                    {
                        reactorMove = reactor;
                        break;
                    }
                }
            }
        }

        foreach (GameObject foundation in Config.config.foundations)
        {
            if (foundation.GetComponent <FoundationScript>().cardList.Count != 0)
            {
                CardScript topFoundationCardScript = foundation.GetComponent <FoundationScript>().cardList[0].GetComponent <CardScript>();

                // if the card can match and matches with the foundation top
                if (cardCanBeMatched && CardTools.CanMatch(selectedCardScript, topFoundationCardScript, checkIsTop: false))
                {
                    cardMatches.Add(foundation.GetComponent <FoundationScript>().cardList[0]);
                }
                // if the card is not from a reactor can it stack?
                else if ((cardIsFromFoundation || cardIsFromWastepile) &&
                         topFoundationCardScript.cardNum == selectedCardNum + 1)
                {
                    cardMoves.Add(foundation.GetComponent <FoundationScript>().cardList[0]);
                }
            }
            else if (cardIsFromFoundation || cardIsFromWastepile)
            {
                foundationMoves.Add(foundation);
            }
        }

        // if the card can match and matches with the wastepile top
        if (cardCanBeMatched && WastepileScript.Instance.cardList.Count != 0)
        {
            GameObject topWastepileCard = WastepileScript.Instance.cardList[0];
            if (CardTools.CanMatch(topWastepileCard.GetComponent <CardScript>(), selectedCardScript, checkIsTop: false))
            {
                cardMatches.Add(topWastepileCard);
            }
        }
    }
Beispiel #3
0
    public void ProcessAction(GameObject input)
    {
        GameObject selectedCard       = UtilsScript.Instance.selectedCards[0];
        CardScript selectedCardScript = selectedCard.GetComponent <CardScript>();

        if (input.CompareTag("Card"))
        {
            CardScript inputCardScript = input.GetComponent <CardScript>();

            if (UtilsScript.Instance.selectedCards.Count == 1)
            {
                if (CardTools.CanMatch(inputCardScript, selectedCardScript))
                {
                    UtilsScript.Instance.Match(input, selectedCard);
                    return;
                }
                else if (inputCardScript.container.CompareTag("Reactor"))
                {
                    if (!CardTools.IsSameSuit(input, selectedCard))
                    {
                        return;
                    }

                    SoundEffectsController.Instance.CardToReactorSound();
                    selectedCardScript.MoveCard(inputCardScript.container);
                    UtilsScript.Instance.UpdateActions(1, checkGameOver: true);
                    return;
                }
                else if (inputCardScript.container.CompareTag("Foundation"))
                {
                    if (inputCardScript.container.GetComponent <FoundationScript>().cardList[0] != input ||
                        inputCardScript.cardNum != selectedCardScript.cardNum + 1)
                    {
                        return;
                    }

                    SoundEffectsController.Instance.CardStackSound();
                    selectedCardScript.MoveCard(inputCardScript.container);
                }
                else
                {
                    return;
                }
            }
            else if (inputCardScript.container.CompareTag("Foundation"))
            {
                if (inputCardScript.container.GetComponent <FoundationScript>().cardList[0] != input ||
                    inputCardScript.cardNum != selectedCardScript.cardNum + 1)
                {
                    return;
                }

                SoundEffectsController.Instance.CardStackSound();

                for (int i = 0; i < UtilsScript.Instance.selectedCards.Count - 1; i++) //goes through and moves all selesctedCards to clicked location
                {
                    UtilsScript.Instance.selectedCards[i].GetComponent <CardScript>().MoveCard(inputCardScript.container, isStack: true, showHolo: false);
                }

                UtilsScript.Instance.selectedCards[UtilsScript.Instance.selectedCards.Count - 1].GetComponent <CardScript>().MoveCard(inputCardScript.container, isStack: true);
            }
            else
            {
                return;
            }
        }
        else if (input.CompareTag("Reactor"))
        {
            if (UtilsScript.Instance.selectedCards.Count != 1 || !CardTools.IsSameSuit(input, selectedCard))
            {
                return;
            }

            SoundEffectsController.Instance.CardToReactorSound();
            selectedCardScript.MoveCard(input);
            UtilsScript.Instance.UpdateActions(1, checkGameOver: true);
            return;
        }
        else if (input.CompareTag("Foundation"))
        {
            if (input.GetComponent <FoundationScript>().cardList.Count != 0)
            {
                return;
            }

            SoundEffectsController.Instance.CardStackSound();

            if (UtilsScript.Instance.selectedCards.Count == 1)
            {
                selectedCardScript.MoveCard(input);
            }
            else
            {
                for (int i = 0; i < UtilsScript.Instance.selectedCards.Count - 1; i++) //goes through and moves all selesctedCards to clicked location
                {
                    UtilsScript.Instance.selectedCards[i].GetComponent <CardScript>().MoveCard(input, isStack: true, showHolo: false);
                }

                UtilsScript.Instance.selectedCards[UtilsScript.Instance.selectedCards.Count - 1].GetComponent <CardScript>().MoveCard(input, isStack: true);
            }
        }
        else
        {
            return;
        }

        UtilsScript.Instance.UpdateActions(1);
    }
Beispiel #4
0
    public void ProcessAction(GameObject input)
    {
        if (UtilsScript.Instance.selectedCards.Count != 1)
        {
            throw new System.ArgumentException("utils.selectedCards must be of size 1");
        }

        GameObject selectedCard       = UtilsScript.Instance.selectedCards[0];
        CardScript selectedCardScript = selectedCard.GetComponent <CardScript>();

        if (input.CompareTag("Card"))
        {
            CardScript inputCardScript = input.GetComponent <CardScript>();

            if (CardTools.CanMatch(inputCardScript, selectedCardScript))
            {
                UtilsScript.Instance.Match(input, selectedCard);
                return;
            }
            else if (inputCardScript.container.CompareTag("Reactor"))
            {
                if (!CardTools.IsSameSuit(input, selectedCard))
                {
                    return;
                }

                SoundEffectsController.Instance.CardToReactorSound();
                selectedCardScript.MoveCard(inputCardScript.container);
            }
            else if (inputCardScript.container.CompareTag("Foundation"))
            {
                if (inputCardScript.container.GetComponent <FoundationScript>().cardList[0] != input ||
                    inputCardScript.cardNum != selectedCardScript.cardNum + 1)
                {
                    return;
                }

                SoundEffectsController.Instance.CardStackSound();
                selectedCardScript.MoveCard(inputCardScript.container);
            }
            else
            {
                return;
            }
        }
        else if (input.CompareTag("Reactor"))
        {
            if (!CardTools.IsSameSuit(input, selectedCard))
            {
                return;
            }

            SoundEffectsController.Instance.CardToReactorSound();
            selectedCardScript.MoveCard(input);
        }
        else if (input.CompareTag("Foundation"))
        {
            if (input.GetComponent <FoundationScript>().cardList.Count != 0)
            {
                return;
            }

            SoundEffectsController.Instance.CardStackSound();
            selectedCardScript.MoveCard(input);
        }
        else
        {
            return;
        }

        UtilsScript.Instance.UpdateActions(1);
    }