Beispiel #1
0
        protected void Button26_Click(object sender, EventArgs e)
        {
            char   columna = char.Parse(DropDownList4.SelectedValue.ToString());
            int    fila    = int.Parse(DropDownList5.SelectedValue.ToString());
            string idnave  = DropDownList6.SelectedValue.ToString();
            int    nivel;
            int    mov;
            int    alcance;
            int    ataque;
            int    vida;

            if (idnave == "Submarino")
            {
                nivel   = 0;
                mov     = 5;
                alcance = 1;
                ataque  = 2;
                vida    = 10;
            }
            else if (idnave == "Crucero" || idnave == "Fragata")
            {
                nivel = 1;
                if (idnave == "Crucero")
                {
                    mov     = 6;
                    alcance = 1;
                    ataque  = 3;
                    vida    = 15;
                }
                else
                {
                    mov     = 5;
                    alcance = 4;
                    ataque  = 3;
                    vida    = 10;
                }
            }
            else if (idnave == "Bombardero" || idnave == "Caza" || idnave.Contains("Helicoptero"))
            {
                nivel = 2;
                if (idnave == "Bombardero")
                {
                    mov     = 7;
                    alcance = 0;
                    ataque  = 5;
                    vida    = 10;
                }
                else if (idnave == "Caza")
                {
                    mov     = 9;
                    alcance = 1;
                    ataque  = 2;
                    vida    = 20;
                }
                else
                {
                    mov     = 9;
                    alcance = 1;
                    ataque  = 3;
                    vida    = 15;
                }
            }
            else
            {
                nivel   = 3;
                mov     = 6;
                alcance = 0;
                ataque  = 2;
                vida    = 10;
            }
            idnave += TextBox6.Text;
            ServiceReference1.WebServiceProyectoSoapClient sr = new ServiceReference1.WebServiceProyectoSoapClient();
            if (!sr.ExisteNodo(nivel, columna, fila))
            {
                sr.InsertarTablero(fila, columna, nivel, mov, alcance, ataque, vida, idnave, Session["Nombre"].ToString());
                Label18.Visible = DropDownList4.Visible = Label19.Visible = DropDownList5.Visible = Label20.Visible = DropDownList6.Visible = Label21.Visible = TextBox6.Visible = Button26.Visible = false;
            }
            else
            {
                ScriptManager.RegisterStartupScript(this, this.GetType(), "alertIns", "alert('Ya existe una unidad en esa posicion');", true);
            }
        }