Exemplo n.º 1
0
    public void MoveState(int index)
    {
        GameObject Card1;
        GameObject Card2;

        if (State == "Inicial")
        {
            baraja[index].GetComponent <Cardscript>().Toggle();
            CardsUp[0] = index;
            State      = "carta_descubierta";
        }
        else if (State == "carta_descubierta" && CardsUp[0] != index)
        {
            baraja[index].GetComponent <Cardscript>().Toggle();

            CardsUp[1] = index;

            Card1 = baraja[CardsUp[0]];
            Card2 = baraja[CardsUp[1]];



            if ((Card1.GetComponent <Cardscript>().Value) == (Card2.GetComponent <Cardscript>().Value))
            {
                Debug.Log("Las cartas son pareja.");
                parejas++;
                Marcador.GetComponent <Text>().text = "Parejas " + parejas;

                //Desactivar las cartas
                baraja[CardsUp[0]].gameObject.SetActive(false);
                baraja[CardsUp[1]].gameObject.SetActive(false);

                State = "Inicial";


                if (parejas == 5)
                {
                    Marcador.GetComponent <Text>().text = "Fin del Juego";
                }
                else
                {
                    Marcador.GetComponent <Text>().text = "Parejas " + parejas;
                }
            }
            //NO ACIERTO
            else
            {
                //baraja[CardsUp[1]].GetComponent<Cardscript>().Toggle();

                baraja[CardsUp[0]].GetComponent <Cardscript>().Toggle();
                baraja[CardsUp[1]].GetComponent <Cardscript>().Toggle();


                State = "Inicial";
                //Dar la vuelta a las cartas.
            }
        }
    }
Exemplo n.º 2
0
    public void Open()
    {
        GetComponent <CardManagerScr>().Box1();
        Bground.SetActive(false);
        Bgroundopen.SetActive(true);

        TempCard = new List <Card>();

        for (int i = 0; i < 6; i++)
        {
            TempCard.Add(CardManager.AllCards[Random.Range(0, CardManager.AllCards.Count)]);
        }

        //card1 = CardManager.AllCards[Random.Range(0, CardManager.AllCards.Count)];
        card1 = TempCard[0];
        Card1 = Instantiate(cardpref, CardField1, false);
        Card1.GetComponent <CardInfoScr>().ShowCardInfo(card1);
        // GetComponent<SaveScript>().CollectionCardTemp.Add(card1);

        //  Debug.Log(GetComponent<SaveScript>().sv.CollectionCard.Count);

        //card2 = CardManager.AllCards[Random.Range(0, CardManager.AllCards.Count)];
        card2 = TempCard[1];
        Card2 = Instantiate(cardpref, CardField2, false);
        Card2.GetComponent <CardInfoScr>().ShowCardInfo(card2);
        // GetComponent<SaveScript>().CollectionCardTemp.Add(card2);

        //card3 = CardManager.AllCards[Random.Range(0, CardManager.AllCards.Count)];
        card3 = TempCard[2];
        Card3 = Instantiate(cardpref, CardField3, false);
        Card3.GetComponent <CardInfoScr>().ShowCardInfo(card3);
        //  GetComponent<SaveScript>().CollectionCardTemp.Add(card3);

        //card4 = CardManager.AllCards[Random.Range(0, CardManager.AllCards.Count)];
        card4 = TempCard[3];
        Card4 = Instantiate(cardpref, CardField4, false);
        Card4.GetComponent <CardInfoScr>().ShowCardInfo(card4);
        // GetComponent<SaveScript>().CollectionCardTemp.Add(card4);

        //card5 = CardManager.AllCards[Random.Range(0, CardManager.AllCards.Count)];
        card5 = TempCard[4];
        Card5 = Instantiate(cardpref, CardField5, false);
        Card5.GetComponent <CardInfoScr>().ShowCardInfo(card5);
        // GetComponent<SaveScript>().CollectionCardTemp.Add(card5);

        //card6 = CardManager.AllCards[Random.Range(0, CardManager.AllCards.Count)];
        card6 = TempCard[5];
        Card6 = Instantiate(cardpref, CardField6, false);
        Card6.GetComponent <CardInfoScr>().ShowCardInfo(card6);
        // GetComponent<SaveScript>().CollectionCardTemp.Add(card6);

        // GetComponent<SaveScript>().SaveData();
    }