Example #1
0
    void CrearPanel()
    {
        string[] indice = manager.DevolverIndiceSimple(true).ToArray();

        int x      = 0;
        int totalX = 9;
        int y      = 0;

        for (int i = 0; i < indice.Length; i++)
        {
            GameObject _obj = Instantiate(prefab);
            _obj.transform.parent = panel.transform;

            Carta _carta = _obj.GetComponent <Carta>();
            if (_carta != null)
            {
                _carta.ConfigurarCarta(new CartaInfo(indice[i].ToUpper()));
                Boton _boton = _obj.GetComponent <Boton>();
                _boton.pulsarBoton.AddListener(() => SeleccionarBoton(_carta, _boton));
            }

            _obj.transform.localPosition = new Vector3(inicialPos.x + sepX * x, inicialPos.y - sepY * y, inicialPos.z);

            x++;

            if (x == totalX)
            {
                x = 0;
                y++;
                totalX       = (y % 2 == 0) ? 9 : 10;
                inicialPos.x = (y % 2 == 0) ? -3.9f : -4.5f;
            }
        }
    }
Example #2
0
    public Carta CrearCarta(int idCarta)
    {
        GameObject obj    = Instantiate(cartas[idCarta].prefab != null ? cartas[idCarta].prefab : prefab);
        Carta      script = obj.GetComponent <Carta>();

        obj.transform.position = posGuardado;

        SetPanel(obj);
        script.ConfigurarCarta(cartas[idCarta]);
        return(script);
    }