public void checalistaM(ArrayList arr) { Debug.Log("io:" + global_variables.io); clase_platillos cpp = (clase_platillos)global_variables.lista[0]; Debug.Log("cl:" + cpp.Nombre); //Debug.Log("**url:"+url+",id:"+id); foreach (clase_platillos platillo in global_variables.lista) { Debug.Log("2_///" + platillo.Id + "," + platillo.Nombre + "," + platillo.Imagen + "///"); } }
// Use this for initialization void Start() { clase_platillos Platillo = new clase_platillos(); Platillo.Nombre = nombre; Platillo.Precio = precio; Platillo.Descripcion = descripcion; Platillo.Estrellas = estrellas; Platillo.Votos = votos; Platillo.Id = id; Platillo.Calificacion_Acumulada_Total = caltotal; global_variables.lista.Add(Platillo); }
// Use this for initialization void Start() { //LEO LA LISTA DESDE EL PRINCIPIO Y LA AGREGO AL ARRAY StreamReader sr = new StreamReader(@".\Assets\Calificaciones\vv.txt"); string revisa = ""; //QUITE RL1 string revisas = sr.ReadLine();//solo dice S ////Debug.Log("RL2:"+revisas); if (revisas == "S") { do { clase_platillos Platillo = new clase_platillos(); string p = sr.ReadLine(); //P Platillo.Id = sr.ReadLine(); Debug.Log("agregado:" + Platillo.Id); ////Debug.Log("RL3:"+Platillo.Id); Platillo.Nombre = sr.ReadLine(); ////Debug.Log("RL4:"+Platillo.Nombre); Platillo.Precio = sr.ReadLine(); ////Debug.Log("RL5:"+Platillo.Precio); Platillo.Descripcion = sr.ReadLine(); ////Debug.Log("RL6:"+Platillo.Descripcion); Platillo.Estrellas = sr.ReadLine(); ////Debug.Log("RL7:"+Platillo.Estrellas); Platillo.Votos = sr.ReadLine(); ////Debug.Log("RL8:"+Platillo.Votos); Platillo.Calificacion_Acumulada_Total = sr.ReadLine(); //Debug.Log("RL9:"+Platillo.Calificacion_Acumulada_Total); global_variables.lista.Add(Platillo); }while(!sr.EndOfStream); sr.Close(); } else { ////Debug.Log("el txt esta vacio"); sr.Close(); } }
// Update is called once per frame void Update() { if (Input.GetKeyDown(KeyCode.P)) { for (int i = 0; i <= global_variables.lista.Count - 1; i++) { clase_platillos Platillox = (clase_platillos)global_variables.lista[i]; /*//Debug.Log(Platillox.Id); * //Debug.Log(Platillox.Nombre); * //Debug.Log(Platillox.Precio); * //Debug.Log(Platillox.Descripcion); * //Debug.Log(Platillox.Precio); * //Debug.Log(Platillox.Estrellas); * //Debug.Log(Platillox.Votos); * //Debug.Log("//////ELEMENTOS 7"+Platillox.Id); */ } } }
public void muestraPlatillo(){ imagenmuestra.sprite=imagenbase.sprite; global_variables.platillo_actual=id_platillo; ////Debug.Log("platillo actual:"+global_variables.platillo_actual); global_variables.restartbool=true; for(int i=0;i<=global_variables.lista.Count-1;i++){ clase_platillos platillo=(clase_platillos)global_variables.lista[i]; string sID=id_platillo+""; if(sID==platillo.Id){ textotitulo.text=platillo.Nombre; textodescripcion.text=platillo.Descripcion; textoprecio.text=platillo.Precio; double calificaciontotal_estrellas=0; int total=int.Parse(platillo.Calificacion_Acumulada_Total); int votos=int.Parse(platillo.Votos); calificaciontotal_estrellas=total/votos; textocalificacion.text=""+calificaciontotal_estrellas+"("+votos+")"; } } }
void separastring(string superstring) { clase_platillos clase_platillos = new clase_platillos(); string idstr = ""; string nombre = ""; string descripcion = ""; string costo = ""; string imagen = ""; //Debug.Log("lista:"+global_variables.lista.Count); for (int i = 0; i <= superstring.Length - 1; i++) { if (superstring[i] == '"') { if (superstring[i + 1] == 'i' || superstring[i + 1] == 'n' || superstring[i + 1] == 'd' || superstring[i + 1] == 'c') { //if // Debug.Log("HORA DE AGREGAR"); string title = "" + superstring[i + 1] + superstring[i + 2] + superstring[i + 3]; switch (title) { case "idP": for (int i2 = i + 14; i2 <= superstring.Length - 1; i2++) { if (superstring[i2] != '"') { idstr += superstring[i2]; } else { i2 = superstring.Length; } } //Debug.Log("idp:"+idstr); clase_platillos.Id = idstr; idstr = ""; break; //idPlatillo7 //"idPlatillo":"11" case "nom": for (int i2 = i + 10; i2 <= superstring.Length - 1; i2++) { if (superstring[i2] != '"') { nombre += superstring[i2]; } else { i2 = superstring.Length; } } // Debug.Log("nombre:"+nombre); clase_platillos.Nombre = nombre; break; //nombre case "des": for (int i2 = i + 15; i2 <= superstring.Length - 1; i2++) { if (superstring[i2] != '"') { descripcion += superstring[i2]; } else { i2 = superstring.Length; // Debug.Log("descripcion:"+descripcion); } } clase_platillos.Descripcion = descripcion; break; //descripcion case "cos": for (int i2 = i + 9; i2 <= superstring.Length - 1; i2++) { if (superstring[i2] != '"') { costo += superstring[i2]; } else { i2 = superstring.Length; // Debug.Log("costo:"+costo); } } clase_platillos.Precio = costo; break; //costo case "ima": for (int i2 = i + 19; i2 <= superstring.Length - 1; i2++) { if (superstring[i2] != '"') { if (superstring[i2] == '/') { string gg = imagen; // Debug.Log("X1imagen:"+imagen); imagen = ""; for (int z = 0; z <= gg.Length - 2; z++) { imagen += gg[z]; } // Debug.Log("X2imagen:"+imagen); } /* * tratare de descargar:https:\/\/blackdish.mx\/blackdish-beta-v3\/backend\/model\/img_admin\/WhatsApp_Image_2020-03-19_at_21-removebg-preview.png */ imagen += superstring[i2]; } else { i2 = superstring.Length; //Debug.Log("imagen:"+imagen); } } clase_platillos.Imagen = imagen; Debug.Log("por agregar:" + clase_platillos.Nombre + ";" + clase_platillos.Id + ";" + clase_platillos.Descripcion); global_variables.lista.Add(clase_platillos); // Debug.Log("agregado"); //borra datos idstr = ""; nombre = ""; descripcion = ""; costo = ""; imagen = ""; break; //imagen default: break; } //switch case // LA VARIABLE "nombre" si guarda algo, pero quiero ver si se guarda en clase_platillos.Nombre } //if(superstring[i+1]=='i'||superstring[i+1]=='n'||superstring[i+1]=='d'||superstring[i+1]=='c') } if (i == superstring.Length - 1) { global_variables.descargaterminada = true; } } //termina el for }
public void calificaM2(int c) { califcacion_public = c; //////Debug.Log("CAL:"+califcacion_public); int id_platillo = global_variables.platillo_actual; for (int i = 0; i <= global_variables.lista.Count - 1; i++) { clase_platillos platillo_lista = (clase_platillos)global_variables.lista[i]; string idplatillostring = platillo_lista.Id; //Debug.Log("idplatillo:"+idplatillostring); //DICE 2,4,1,5,P int idp = int.Parse(idplatillostring); //////Debug.Log(idplatillostring+" CALIFICAPLATILLOS.CS LN93"); //ACTIVA LO QUE SIGUE: if (id_platillo == idp) { //////Debug.Log("votos"+platillo_lista.Votos); //a la calificacion acumulada le sumo la calificacion actual if (platillo_lista.Calificacion_Acumulada_Total == "") { platillo_lista.Calificacion_Acumulada_Total = "0"; } ////Debug.Log("antes de double:"+platillo_lista.Calificacion_Acumulada_Total); //NO HAY NADA EN CALIFICACION ACUMULADA double caldouble = double.Parse(platillo_lista.Calificacion_Acumulada_Total); ////Debug.Log("double:"+caldouble); caldouble += califcacion_public; platillo_lista.Calificacion_Acumulada_Total = "" + caldouble; ////Debug.Log("dOUBLEJUAN:"+platillo_lista.Calificacion_Acumulada_Total); //////Debug.Log("%%%%%%%"); //////Debug.Log("CALIFICA PLATILLOS LN 102:"+platillo_lista.Calificacion_Acumulada_Total); //////Debug.Log("%%%%%%%"); int platillovotos = int.Parse(platillo_lista.Votos); platillovotos++; //////Debug.Log("calificaplatillos_LN103:"+platillovotos); int platillocalificacion_int = int.Parse(platillo_lista.Calificacion_Acumulada_Total); ////Debug.Log("Xcalificaplatillos_LN105:"+platillocalificacion_int); ////Debug.Log("X2:calString:"+platillo_lista.Calificacion_Acumulada_Total); double estrellasdouble = platillocalificacion_int / platillovotos; //////Debug.Log("calificaplatillos_LN107:"+estrellasdouble); platillo_lista.Votos = "" + platillovotos; //////Debug.Log("calificaplatillos_LN109:"+platillo_lista.Votos); platillo_lista.Estrellas = "" + estrellasdouble; //////Debug.Log("calificaplatillos_LN111:"+platillo_lista.Estrellas); ////////Debug.Log("CA:"+platillo_lista.Calificacion_Acumulada_Total+"/P:"+platillo_lista.Nombre+"/Es:"+platillo_lista.Estrellas+"/V:"+platillo_lista.Votos); } } //DirectoryNotFoundException: Could not find a part of the path "C:\Users\Norman\OneDrive\Documentos\blackdish_minigame\Assets\Calificaciones\vv.txt". StreamWriter Basededatosestrellas = new StreamWriter(@".\Assets\Calificaciones\vv.txt"); for (int i2 = 0; i2 <= global_variables.lista.Count - 1; i2++) { clase_platillos Platillo = (clase_platillos)global_variables.lista[i2]; Basededatosestrellas.WriteLine("P"); ////Debug.Log("P"); Basededatosestrellas.WriteLine(Platillo.Id); ////Debug.Log("id:"+Platillo.Id); Basededatosestrellas.WriteLine(Platillo.Nombre); ////Debug.Log("nombre:"+Platillo.Nombre); Basededatosestrellas.WriteLine(Platillo.Precio); ////Debug.Log("precio:"+Platillo.Precio); Basededatosestrellas.WriteLine(Platillo.Descripcion); ////Debug.Log("descripcion:"+Platillo.Descripcion); Basededatosestrellas.WriteLine(Platillo.Estrellas); ////Debug.Log("estrellas:"+Platillo.Estrellas); Basededatosestrellas.WriteLine(Platillo.Votos); ////Debug.Log("votos:"+Platillo.Votos); Basededatosestrellas.WriteLine(Platillo.Calificacion_Acumulada_Total); ////Debug.Log("total:"+Platillo.Calificacion_Acumulada_Total); /* //////Debug.Log("%%%%%%%"); * //////Debug.Log("CALIFICA PLATILLOS LN 135:"+Platillo.Calificacion_Acumulada_Total); * //////Debug.Log("%%%%%%%");*/ } //////Debug.Log(""+Basededatosestrellas); Basededatosestrellas.Close(); }