Пример #1
0
    IEnumerator CheckCardsCOROT(int myPlayerinteger, IndividualCard[] cardsToCheck)
    {
        int totalMatched = 0;

        //check Cards
        for (int l = 0; l < cardsToCheck.Length; l++)
        {
            if (cardsToCheck[l] != null)
            {
                if (cardsToCheck[l].cBase != null)
                {
                    for (int k = l + 1; k < cardsToCheck.Length; k++)
                    {
                        if (cardsToCheck[k] != null && cardsToCheck[l] != null)
                        {
                            if (cardsToCheck[k].cBase != null && cardsToCheck[l].cBase != null)
                            {
                                if (k != l)
                                {
                                    if (cardsToCheck[k].cBase.dynamicCardID == cardsToCheck[l].cBase.dynamicCardID)
                                    {
                                        //Ultimate Poison Alert - player matched two poison cards
                                        if (cardsToCheck[k].cBase.isPoison)
                                        {
                                            PoisonMaster.s.ChoosePoisonCard(myPlayerinteger, cardsToCheck[k], "cardchecker");
                                            //PowerUpManager.s.ChoosePoisonCard (cardsToCheck [l]);
                                            ScoreBoardManager.s.AddScore(myPlayerinteger, 0, -GS.a.powerUpSettings.poison_combo, false);                                              //this is just poison score
                                        }
                                        else
                                        {
                                            //actual score adding happens here
                                            ComboDealer.s.ProcessCombo(myPlayerinteger, true, cardsToCheck[k], cardsToCheck[l]);
                                            totalMatched++;


                                            //gfxs
                                            IndividualCard.MatchCards(myPlayerinteger, cardsToCheck[k], cardsToCheck[l]);

                                            //networking
                                            DataHandler.s.SendPlayerAction(cardsToCheck[k].x, cardsToCheck[k].y, CardHandler.CardActions.Match, cardsToCheck[l].x, cardsToCheck[l].y);
                                        }
                                        yield return(new WaitForSeconds(0.1f));
                                    }
                                }
                            }
                        }
                    }

                    //normal poison alert - just one poison card
                    if (cardsToCheck[l].cBase.isPoison)
                    {
                        PoisonMaster.s.ChoosePoisonCard(myPlayerinteger, cardsToCheck[l], "cardchecker");                          //this is just poison score
                    }
                }
            }
        }

        yield return(new WaitForSeconds(0.5f));


        if (totalMatched == 0)
        {
            ComboDealer.s.NotMatched();
        }
        //Rotate unused cards
        UnSelectCards(cardsToCheck);
        //empty our array because no need left
        EmptyArray(cardsToCheck);
    }
    public void ReceiveAction(char player, int x, int y, CardHandler.CardActions action, int x2, int y2)
    {
        int            playerID = -1;
        IndividualCard myCard, matchPair = null;
        GameObject     myEffect;

        switch (player)
        {
        case 'B':
            playerID = 0;
            myEffect = GS.a.gfxs.selectEffects[1];
            break;

        case 'R':
            playerID = 1;
            myEffect = GS.a.gfxs.selectEffects[2];
            break;

        case 'G':
            playerID = 2;
            myEffect = GS.a.gfxs.selectEffects[3];
            break;

        case 'Y':
            playerID = 3;
            myEffect = GS.a.gfxs.selectEffects[4];
            break;

        default:
            myEffect = GS.a.gfxs.selectEffects[1];
            break;
        }

        myCard = CardHandler.s.allCards [x, y];
        if (x2 != -1)
        {
            matchPair = CardHandler.s.allCards[x2, y2];
        }


        switch (action)
        {
        case CardHandler.CardActions.Select:
            if (myCard.isSelectable)
            {
                myCard.selectedEffect = (GameObject)Instantiate(myEffect, myCard.transform.position, Quaternion.identity);
                myCard.selectEffectID = DataHandler.s.toInt(player);
                myCard.SelectCard(playerID);
            }
            else
            {
                DataHandler.s.NetworkCorrection(myCard);
            }
            break;

        case CardHandler.CardActions.UnSelect:
            if (myCard.isUnselectable)
            {
                myCard.UnSelectCard();
            }
            else
            {
                DataHandler.s.NetworkCorrection(myCard);
            }
            break;

        case CardHandler.CardActions.Match:
            if (!myCard.isSelectable && matchPair != null)
            {
                IndividualCard.MatchCards(playerID, myCard, matchPair);
            }
            else
            {
                DataHandler.s.NetworkCorrection(myCard);
                if (matchPair == null)
                {
                    DataHandler.s.NetworkCorrection(matchPair);
                }
            }
            break;

        default:
            break;
        }
    }