void Awake() { au = GetComponent <AudioSource> (); recttran = GetComponent <RectTransform>(); recttranarribader = arribaderecha.GetComponent <RectTransform>(); recttranabajoder = abajoderecha.GetComponent <RectTransform>(); recttranarribaiz = arribaizquierda.GetComponent <RectTransform>(); recttranabajoiz = abajoizquierda.GetComponent <RectTransform>(); GameObject jugador = GameObject.FindGameObjectWithTag("Player"); scriptviento = jugador.GetComponent <Viento>(); }
private void rbViento_CheckedChanged(object sender, EventArgs e) { lInstrumento.Items.Clear(); //Variable local int contar; Instrumento encontrado; Viento otro = new Viento(); contar = funcion.ContarElementos(); for (int i = 0; i < contar; i++) { encontrado = funcion.BuscarPorPosicion(i); if (encontrado.GetType() == typeof(Viento)) { otro = (Viento)encontrado; lInstrumento.Items.Add(otro.ToString()); } } }
private void vientoToolStripMenuItem_Click(object sender, EventArgs e) //Instrumento de Viento { Viento actual = new Viento(); //Le pasa el parametro viento al formulario Agregar. agregar.tipo = "viento"; agregar.actualizando = false; //Se piden los valores al formulario agregar if (agregar.ShowDialog() == DialogResult.OK) { icodigo = agregar.codigo; snombre = agregar.nombre; smarca = agregar.marca; iunidades = agregar.unidades; dprecio = agregar.precio; smaterial = agregar.material; stipo = "viento"; actual = new Viento(icodigo, snombre, stipo, smarca, dprecio, iunidades, smaterial); //llamar a la funcion agregar de la librería funcion.Agregar(actual); //Limpia las variables icodigo = 0; snombre = ""; smarca = ""; iunidades = 0; dprecio = 0; smaterial = ""; stipo = ""; //Recargue la lista Automáticamente lInstrumento.Items.Add(actual.ToString()); //****Bandera**** int contar = funcion.ContarElementos(); MessageBox.Show("El objeto agregado es " + actual._nombre + " de la marca" + actual._marca + "\nLa cantidad de elementos en la lista es de " + contar); } }
private void bModificarInstrumento_Click(object sender, EventArgs e) { if (lInstrumento.SelectedIndex == -1) { MessageBox.Show("No se ha seleccionado ningun item de la lista.\nPor favor seleccione el instrumento a modificar.", "Se ha producido un error"); } else { //Se crea la instancia del formulario y la del instrumento FAgregar mostrar = new FAgregar(); Instrumento encontrado; Viento encontradoViento = new Viento(); Cuerda encontradoCuerda = new Cuerda(); Percucion encontradoPercucion = new Percucion(); //Asigno la variable string palabra = lInstrumento.SelectedItem.ToString(); //Llamo al método que extrae el código para buscar el objeto int objCodigo = extraerCodigo(palabra); //Manda a buscar el Instrumento y se lo asigna a Encontrado encontrado = funcion.Buscar(objCodigo); if (encontrado.GetType() == typeof(Viento)) { encontradoViento = (Viento)encontrado; } else if (encontrado.GetType() == typeof(Cuerda)) { encontradoCuerda = (Cuerda)encontrado; } else if (encontrado.GetType() == typeof(Percucion)) { encontradoPercucion = (Percucion)encontrado; } //Llamo al formulario y le asigno las variables del objeto encontrado. mostrar.actualizando = true; mostrar.tipo = encontrado._tipo; mostrar.codigo = encontrado._codigo; mostrar.marca = encontrado._marca; mostrar.nombre = encontrado._nombre; mostrar.precio = encontrado._precio; mostrar.unidades = encontrado._unidades; if (encontrado.GetType() == typeof(Viento)) { mostrar.material = encontradoViento._material; } else if (encontrado.GetType() == typeof(Cuerda)) { mostrar.nroCuerda = encontradoCuerda._nroCuerdas; } else if (encontrado.GetType() == typeof(Percucion)) { mostrar.afinado = encontradoPercucion._afinado; } if (mostrar.ShowDialog() == DialogResult.OK) { //CARGAR LO QUE VIENE DEL FORMULARIO "AGREGAR" EN LAS VARIABLES DE ESTE FORMULARIO (Globales) icodigo = mostrar.codigo; snombre = mostrar.nombre; smarca = mostrar.marca; iunidades = mostrar.unidades; dprecio = mostrar.precio; stipo = mostrar.tipo; //LLAMAR A UN MÉTODO QUE MODIFIQUE AL INSTRUMENTO ENCONTRADO CON TODAS LAS VARIABLES ANTERIORES if (stipo == "viento") { smaterial = mostrar.material; encontradoViento = new Viento(icodigo, snombre, stipo, smarca, dprecio, iunidades, smaterial); funcion.ModificarInstrumento(encontradoViento); } else if (stipo == "cuerda") { inroCuerdas = mostrar.nroCuerda; encontradoCuerda = new Cuerda(icodigo, snombre, stipo, smarca, dprecio, iunidades, inroCuerdas); funcion.ModificarInstrumento(encontradoCuerda); } else if (stipo == "percución") { bafinado = mostrar.afinado; encontradoPercucion = new Percucion(icodigo, snombre, stipo, smarca, dprecio, iunidades, bafinado); funcion.ModificarInstrumento(encontradoPercucion); } //LIMPIAR TODO icodigo = 0; snombre = " "; smarca = " "; iunidades = 0; dprecio = 0f; smaterial = " "; inroCuerdas = 0; bafinado = false; stipo = " "; } } }