Beispiel #1
0
    private void Start()
    {
        parentTransform    = transform.GetChild(0);
        listaToggles       = new List <TextScript>();
        nombreEstadisticas = GetComponent <EstadisticaDeporte>();
        Array listaTipoEstadisticas = nombreEstadisticas.GetEstadisticas();

        for (int i = 0; i < listaTipoEstadisticas.Length; i++)
        {
            if ((EstadisticaDeporte.Estadisticas)listaTipoEstadisticas.GetValue(i) >= 0)
            {
                //SE DEBERÍA OBTENER DE nombreEstadisticas, EL TIPO DEL ENUM Y TRABAJR CON ESO EN VEZ DE CON EL NOMBRE
                GameObject toggleGO = Instantiate(togglePrefab, parentTransform, false);

                string[] nameEspañol = EstadisticasDeporteDisplay.GetStatisticsName((EstadisticaDeporte.Estadisticas)listaTipoEstadisticas.GetValue(i), AppController.Idiomas.Español); // nombreEstadisticas.GetStatisticsName(i, AppController.Idiomas.Español);
                string[] nameIngles  = EstadisticasDeporteDisplay.GetStatisticsName((EstadisticaDeporte.Estadisticas)listaTipoEstadisticas.GetValue(i), AppController.Idiomas.Ingles);  //nombreEstadisticas.GetStatisticsName(i, AppController.Idiomas.Ingles);

                TextScript txtScript = toggleGO.GetComponent <TextScript>();
                txtScript.SetTipoEstadistica((EstadisticaDeporte.Estadisticas)listaTipoEstadisticas.GetValue(i));
                txtScript.SetName(nameEspañol[0], nameEspañol[1], AppController.Idiomas.Español);
                toggleGO.GetComponent <TextScript>().SetName(nameIngles[0], nameIngles[1], AppController.Idiomas.Ingles);
                listaToggles.Add(toggleGO.GetComponent <TextScript>());
            }
        }

        /*
         * for (int i = 0; i < listaEstadisticas.Count; i++)
         * {
         *  GameObject toggleGO = Instantiate(togglePrefab, parentTransform, false);
         *  toggleGO.GetComponent<TextScript>().SetName(listaEstadisticas[i], listaIniciales[i]);
         *  listaToggles.Add(toggleGO.GetComponent<Toggle>());
         * }*/

        prefabHeight = togglePrefab.GetComponent <RectTransform>().rect.height;
    }
    virtual public void CrearPrefabs()
    {
        EstadisticaDeporte estDeporte = estadisticas.GetEstadisticaDeporte();
        Array listaTipoEstadisticas   = estDeporte.GetEstadisticas();

        int idxColor = 0;

        for (int i = 0; i < estDeporte.GetSize(); i++) //este cantidad categorias en realidad devuelve la cantidad que haya en el enum de estadisticas
        {
            if (estadisticas.Find(estDeporte.GetValueAtIndex(i))[0] == 1)
            {
                GameObject botonEstadisticaGO = Instantiate(botonEstadisticaPrefab, transformParent, false);
                botonEstadisticaGO.SetActive(true);
                BotonEstadistica botonEstadistica = botonEstadisticaGO.GetComponent <BotonEstadistica>();

                string statsNameEspañol = EstadisticasDeporteDisplay.GetStatisticsName((EstadisticaDeporte.Estadisticas)listaTipoEstadisticas.GetValue(i), AppController.Idiomas.Español)[0]; //estDeporte.GetStatisticsName(i, AppController.Idiomas.Español)[0];
                string statsNameIngles  = EstadisticasDeporteDisplay.GetStatisticsName((EstadisticaDeporte.Estadisticas)listaTipoEstadisticas.GetValue(i), AppController.Idiomas.Ingles)[0];

                botonEstadistica.SetTextInLanguage(statsNameEspañol, AppController.Idiomas.Español);
                botonEstadistica.SetTextInLanguage(statsNameIngles, AppController.Idiomas.Ingles);
                botonEstadistica.SetValorEstadistica(estadisticas.Find(statsNameEspañol.Replace(" ", string.Empty))[1].ToString());
                botonEstadistica.SetColor(coloresBotones[idxColor % coloresBotones.Count]);
                listaPrefabsTextos.Add(botonEstadisticaGO);
                idxColor++;
            }
        }

        /*
         * for (int i = 0; i < estadisticas.GetCantidadCategorias(); i++)
         * {
         *  GameObject botonEstadisticaGO = Instantiate(botonEstadisticaPrefab, transformParent, false);
         *  botonEstadisticaGO.SetActive(true);
         *
         *  BotonEstadistica botonEstadistica = botonEstadisticaGO.GetComponent<BotonEstadistica>();
         *  botonEstadistica.SetNombreEstadistica(estadisticas.GetKeyAtIndex(i));
         *  botonEstadistica.SetValorEstadistica(estadisticas.GetValueAtIndex(i).ToString());
         *
         *  listaPrefabsTextos.Add(botonEstadisticaGO);
         * }*/
    }