//Comprueba si los requisitos para que la acción se muestre. Si no se cumplen, devuelve falso protected virtual bool MostrarAccion(DatosAccion datosAccion, Inventario inventario) { bool mostrarAccion = true; for (int i = 0; i < datosAccion.objetos.Count; i++) { //Si equipado es true //Si no tenemos el objeto la acción no se muestra if (datosAccion.objetos[i].equipado) { if (!inventario.ObjetoInventarioExiste(datosAccion.objetos[i].IDObjeto)) { mostrarAccion = false; } } //Si equipado es false //Si tenemos el objeto la acción no se muestra else { if (inventario.ObjetoInventarioExiste(datosAccion.objetos[i].IDObjeto)) { mostrarAccion = false; } } } return(mostrarAccion); }
protected override bool MostrarAccion(DatosAccion datosAccion, Inventario inventario) { bool mostrarAccion = base.MostrarAccion(datosAccion, inventario); if(mostrarAccion) { for(int i = 0; i < datosAccion.variables.Count; i++) { switch(datosAccion.variables[i].tipo) { case 0: // > es verdadero if(datosAccion.variables[i].valor <= datos.DevuelveValorVariable(datosAccion.variables[i].numVariable)) mostrarAccion = false; break; case 1: // == es verdadero if(datosAccion.variables[i].valor < datos.DevuelveValorVariable(datosAccion.variables[i].numVariable) || datosAccion.variables[i].valor < datos.DevuelveValorVariable(datosAccion.variables[i].numVariable)) mostrarAccion = false; break; case 2: // < es verdadero if(datosAccion.variables[i].valor >= datos.DevuelveValorVariable(datosAccion.variables[i].numVariable)) mostrarAccion = false; break; } } } return mostrarAccion; }
//Devuelve una lista con los objetos NPC_Dialogo del interactuable, vacía si no tiene ninguno public List <Dialogo> DevolverDialogos() { List <Dialogo> dialogos = new List <Dialogo>(); for (int i = 0; i < acciones.Count; i++) { DatosAccion datosAccion = acciones[i]; if (datosAccion.GetType() == typeof(DatosAccionDialogo)) { DatosAccionDialogo datosAccionDialogo = datosAccion as DatosAccionDialogo; dialogos.Add(datosAccionDialogo.DevuelveDialogo()); } } return(dialogos); }
//Devuelve un objeto NPC_Dialogo con la ID pasada (null si no lo ha encontrado) public Dialogo DevolverDialogo(int IDDialogo) { Dialogo dialogo = null; for (int i = 0; i < acciones.Count; i++) { DatosAccion datosAccion = acciones[i]; if (datosAccion.GetType() == typeof(DatosAccionDialogo)) { DatosAccionDialogo datosAccionDialogo = datosAccion as DatosAccionDialogo; if (IDDialogo == datosAccionDialogo.DevuelveIDDialogo()) { dialogo = datosAccionDialogo.DevuelveDialogo(); } } } return(dialogo); }
protected override bool MostrarAccion(DatosAccion datosAccion, Inventario inventario) { bool mostrarAccion = base.MostrarAccion(datosAccion, inventario); if (mostrarAccion) { for (int i = 0; i < datosAccion.variables.Count; i++) { switch (datosAccion.variables[i].tipo) { case 0: // > es verdadero if (datosAccion.variables[i].valor <= datos.DevuelveValorVariable(datosAccion.variables[i].numVariable)) { mostrarAccion = false; } break; case 1: // == es verdadero if (datosAccion.variables[i].valor < datos.DevuelveValorVariable(datosAccion.variables[i].numVariable) || datosAccion.variables[i].valor < datos.DevuelveValorVariable(datosAccion.variables[i].numVariable)) { mostrarAccion = false; } break; case 2: // < es verdadero if (datosAccion.variables[i].valor >= datos.DevuelveValorVariable(datosAccion.variables[i].numVariable)) { mostrarAccion = false; } break; } } } return(mostrarAccion); }
private void ReadLogXML(Stream stream) { String sPort = String.Empty; String sName = String.Empty; String sAccion = String.Empty; String sError = String.Empty; String sIcon = String.Empty; String sDescripcion = String.Empty; String sValor = String.Empty; Boolean bTratar = false; String sResultado = String.Empty; String sSubAccion = String.Empty; String sSubIcon = String.Empty; int sNumChar = 0; if (Xamarin.Forms.Device.Idiom == Xamarin.Forms.TargetIdiom.Tablet) { sNumChar = 58; } else { sNumChar = 23; } XmlReader xReader = XmlReader.Create(stream); List <DatosAccion> ListaDatos = new List <DatosAccion>(); List <DatosAccion> SubListaDatos = new List <DatosAccion>(); List <ItemsLog> SubItemLogs = new List <ItemsLog>(); while (xReader.Read()) { if (xReader.Name == "Mtus") { bTratar = true; } if (xReader.Name == "Error") { bTratar = true; } if (bTratar) { switch (xReader.NodeType) { case XmlNodeType.Element: if (xReader.Name == "Action") { if (xReader.Depth == 2) { sAccion = xReader.GetAttribute("display"); sIcon = "logs_file_button"; ListaDatos = new List <DatosAccion>(); SubItemLogs = new List <ItemsLog>(); } else if (xReader.Depth == 3) { sSubAccion = xReader.GetAttribute("display"); sSubIcon = "logs_file_button"; SubListaDatos = new List <DatosAccion>(); } } if (xReader.Name == "AppError") { sAccion = xReader.Name; sIcon = "error"; ListaDatos = new List <DatosAccion>(); } if (String.IsNullOrEmpty(xReader.GetAttribute("display"))) { sDescripcion = xReader.Name; } else { sDescripcion = xReader.GetAttribute("display"); } if (xReader.Name == "Message") { sError = xReader.GetAttribute("ErrorId"); } if (xReader.Name == "Port") { sPort = xReader.GetAttribute("display"); } break; case XmlNodeType.Text: sValor = xReader.Value; DatosAccion datosAccion = new DatosAccion(); if (!String.IsNullOrEmpty(sError) && sDescripcion == "Message") { datosAccion.Descripcion = String.Empty; //$"{sError} :"; } else if (String.IsNullOrEmpty(sPort)) { datosAccion.Descripcion = $"{sDescripcion}:"; } else { datosAccion.Descripcion = $" {sPort} {sDescripcion}:"; } if (!String.IsNullOrEmpty(datosAccion.Descripcion)) { datosAccion.Valor = sValor.Length > sNumChar ? $"{sValor.Substring(0, sNumChar)}..." : sValor; } else { datosAccion.Valor = sValor; } if (!string.IsNullOrEmpty(sSubAccion)) { SubListaDatos.Add(datosAccion); } else { ListaDatos.Add(datosAccion); } // sResultado = String.Concat(sResultado, $" : {xReader.Value}"); //listBox1.Items.Add(xReader.Value); break; case XmlNodeType.EndElement: if (xReader.Name == "Action") // si acaba la accion { if (xReader.Depth == 2 && !String.IsNullOrEmpty(sAccion)) { ItemsLog Item = new ItemsLog { Accion = sAccion, Icon = sIcon }; Item.HayLista = true; if (SubItemLogs.Count > 0) { ItemsLog Item1 = new ItemsLog { Accion = sAccion, Icon = sIcon }; Item1.ListaDatos = ListaDatos; Item1.HeightList = Item1.ListaDatos.Count > 5 ? Item1.ListaDatos.Count * 20: 100; Item.SubItemsLog = new List <ItemsLog>(); Item.SubItemsLog.Add(Item1); Item.SubItemsLog.AddRange(SubItemLogs); Item.HayLista = false; // Item.ListaDatos = null; } else { Item.ListaDatos = ListaDatos; Item.HeightList = Item.ListaDatos.Count > 5?(Item.ListaDatos.Count * 20): 100; } ItemsLog.Add(Item); sAccion = String.Empty; } else if (xReader.Depth == 3) { ItemsLog Item = new ItemsLog { Accion = sSubAccion, Icon = sSubIcon }; Item.ListaDatos = SubListaDatos; Item.HeightList = Item.ListaDatos.Count > 5 ? (Item.ListaDatos.Count * 20): 100; SubItemLogs.Add(Item); sSubAccion = String.Empty; } } if (xReader.Name == "AppError") // si acaba la accion { ItemsLog Item = new ItemsLog { Accion = $"Error {sError}", Icon = sIcon }; Item.HayLista = true; Item.ListaDatos = ListaDatos; Item.HeightList = 100; ItemsLog.Add(Item); } if (xReader.Name == "Port") { sPort = String.Empty; } if (xReader.Name == "AppError") { sIcon = String.Empty; sError = String.Empty; } if (xReader.Name == "Mtus" || xReader.Name == "Error") { bTratar = false; } //sResultado = String.Concat(sResultado, Environment.NewLine); //listBox1.Items.Add(""); break; } } } ItemsLog ItemNull = new ItemsLog { Accion = String.Empty, Icon = String.Empty }; ItemsLog.Add(ItemNull); ItemsLog.Add(ItemNull); // Application.Current.MainPage.DisplayAlert("XML", sResultado,"OK"); }
private void OtroRead(Stream stream) { String sPort = String.Empty; String sName = String.Empty; String sAccion = String.Empty; String sError = String.Empty; String sIcon = String.Empty; String sDescripcion = String.Empty; String sValor = String.Empty; Boolean bTratar = false; String sResultado = String.Empty; String sSubAccion = String.Empty; String sSubIcon = String.Empty; XmlReader xReader = XmlReader.Create(stream); List <DatosAccion> ListaDatos = new List <DatosAccion>(); List <DatosAccion> SubListaDatos = new List <DatosAccion>(); List <ItemsLog> SubItemLogs = new List <ItemsLog>(); while (xReader.Read()) { if (xReader.Name == "Mtus") { bTratar = true; } if (xReader.Name == "Error") { bTratar = true; } if (bTratar) { switch (xReader.NodeType) { case XmlNodeType.Element: if (xReader.Name == "Action") { if (xReader.Depth == 2) { sAccion = xReader.GetAttribute("display"); sIcon = "logs_file_button"; ListaDatos = new List <DatosAccion>(); SubItemLogs = new List <ItemsLog>(); } else if (xReader.Depth == 3) { sSubAccion = xReader.GetAttribute("display"); sSubIcon = "logs_file_button"; SubListaDatos = new List <DatosAccion>(); } } if (xReader.Name == "AppError") { sAccion = xReader.Name; sIcon = "error"; ListaDatos = new List <DatosAccion>(); } if (String.IsNullOrEmpty(xReader.GetAttribute("display"))) { sDescripcion = xReader.Name; } else { sDescripcion = xReader.GetAttribute("display"); } if (xReader.Name == "Message") { sError = xReader.GetAttribute("ErrorId"); } if (xReader.Name == "Port") { sPort = xReader.GetAttribute("display"); } break; case XmlNodeType.Text: sValor = xReader.Value; DatosAccion datosAccion = new DatosAccion(); if (!String.IsNullOrEmpty(sError) && sDescripcion == "Message") { datosAccion.Descripcion = String.Empty; //$"{sError} :"; } else if (String.IsNullOrEmpty(sPort)) { datosAccion.Descripcion = $"{sDescripcion}:"; } else { datosAccion.Descripcion = $" {sPort} {sDescripcion}:"; } datosAccion.Valor = sValor; if (!string.IsNullOrEmpty(sSubAccion)) { SubListaDatos.Add(datosAccion); } else { ListaDatos.Add(datosAccion); } // sResultado = String.Concat(sResultado, $" : {xReader.Value}"); //listBox1.Items.Add(xReader.Value); break; case XmlNodeType.EndElement: if (xReader.Name == "Action") // si acaba la accion { if (xReader.Depth == 2 && !String.IsNullOrEmpty(sAccion)) { ItemsLog Item = new ItemsLog { Accion = sAccion, Icon = sIcon }; Item.HayLista = true; if (SubItemLogs.Count > 0) { ItemsLog Item1 = new ItemsLog { Accion = sAccion, Icon = sIcon }; Item1.ListaDatos = ListaDatos; Item.SubItemsLog = new List <ItemsLog>(); Item.SubItemsLog.Add(Item1); Item.SubItemsLog.AddRange(SubItemLogs); Item.HayLista = false; // Item.ListaDatos = null; } else { Item.ListaDatos = ListaDatos; } ItemsLog.Add(Item); sAccion = String.Empty; } else if (xReader.Depth == 3) { //if (!String.IsNullOrEmpty(sAccion)) //{ // ItemsLog Item1 = new ItemsLog // { // Accion = sAccion, // Icon = sIcon // }; // Item1.ListaDatos = ListaDatos; // ItemsLog.Add(Item1); // sAccion = String.Empty; //} ItemsLog Item = new ItemsLog { Accion = sSubAccion, Icon = sSubIcon }; Item.ListaDatos = SubListaDatos; SubItemLogs.Add(Item); sSubAccion = String.Empty; } } if (xReader.Name == "AppError") // si acaba la accion { ItemsLog Item = new ItemsLog { Accion = $"Error {sError}", Icon = sIcon }; Item.HayLista = true; Item.ListaDatos = ListaDatos; ItemsLog.Add(Item); } if (xReader.Name == "Port") { sPort = String.Empty; } if (xReader.Name == "AppError") { sIcon = String.Empty; sError = String.Empty; } if (xReader.Name == "Mtus" || xReader.Name == "Error") { bTratar = false; } //sResultado = String.Concat(sResultado, Environment.NewLine); //listBox1.Items.Add(""); break; } } } // Application.Current.MainPage.DisplayAlert("XML", sResultado,"OK"); }
//Comprueba si los requisitos para que la acción se muestre. Si no se cumplen, devuelve falso protected virtual bool MostrarAccion(DatosAccion datosAccion, Inventario inventario) { bool mostrarAccion = true; for(int i = 0; i < datosAccion.objetos.Count; i++) { //Si equipado es true //Si no tenemos el objeto la acción no se muestra if(datosAccion.objetos[i].equipado) { if(!inventario.ObjetoInventarioExiste(datosAccion.objetos[i].IDObjeto)) { mostrarAccion = false; } } //Si equipado es false //Si tenemos el objeto la acción no se muestra else { if(inventario.ObjetoInventarioExiste(datosAccion.objetos[i].IDObjeto)) { mostrarAccion = false; } } } return mostrarAccion; }