public void useitems(string shop_name)//商城物品的使用 { sql.Open(); string use = "select * from shop where itemname ='" + shop_name + "'"; SqlCommand use_item = new SqlCommand(use, sql); SqlDataReader read = use_item.ExecuteReader(); while (read.Read()) { all = read.GetString(read.GetOrdinal("function")); } read.Close(); string[] s1 = all.Split('_'); string s11 = s1[0]; string s12 = s1[1]; PERSON person1 = new PERSON(); if (s11 == "hp") { ATTACK bag = new ATTACK(); bag.hp_reflash(Convert.ToInt32(s12)); bag.items_delete(shop_name); } if (s11 == "wuli") { ATTACK bag = new ATTACK(); bag.wuli_add(Convert.ToInt32(s12)); bag.items_delete(shop_name); } }
public int losemoney(string shop_name)//购买物品减少金钱 { SSHOP shop1 = new SSHOP(); PERSON person = new PERSON(); int allmoney = person.Tiqu_person_money(); int lose_money = shop1.Tiqu_shop_money(shop_name); if (allmoney >= lose_money) { sql.Open(); string lose_money1 = "update person set person_money-=" + lose_money; SqlCommand command_losemoney = new SqlCommand(lose_money1, sql); try { command_losemoney.ExecuteNonQuery(); } catch { MessageBox.Show("减少金钱失败"); } finally { sql.Close(); } return(1); } else { return(0); } }
private void bag_FormClosing(object sender, FormClosingEventArgs e) { PERSON pERSON = new PERSON(); int xy = pERSON.Tiqu_person_grade(); Form1.form1.label1.Text = "人物属性\r\n名字:红凯 等级 : " + Convert.ToString(xy) + "\r\n血量 : " + Convert.ToString(pERSON.Tiqu_change_hp()) + "\r\n攻击力 : " + Convert.ToString(pERSON.Tiqu_person_wuli()) + "\r\n"; }
private void button2_Click_1(object sender, EventArgs e) { PERSON pERSON = new PERSON(); try { pERSON.add_money("小蛐蛐"); } catch { MessageBox.Show(" "); } }
public void chang_person_changehp(int hp) { sql.Open(); PERSON pERSON = new PERSON(); int x = pERSON.Tiqu_change_hp(); string changehp = "update person set change_hp-=" + hp; SqlCommand changhp = new SqlCommand(changehp, sql); try { } catch { } }
private void Form1_Load(object sender, EventArgs e) { Form1 a = new Form1(); music.PlayMusic(); label1.BackColor = Color.Transparent; label1.Parent = pictureBox1; progressBar1.Visible = false; Image picture1 = Resources.背景; pictureBox1.Image = picture1; // pictureBox2.Image = Image.FromFile("剑士.jpg"); PERSON pERSON = new PERSON(); int xy = pERSON.Tiqu_person_grade(); label1.Text = "人物属性\r\n名字:红凯 等级 : " + Convert.ToString(xy) + "\r\n血量 : " + Convert.ToString(pERSON.Tiqu_change_hp()) + "\r\n攻击力 : " + Convert.ToString(pERSON.Tiqu_person_wuli()) + "\r\n"; label1.Text += "金钱:" + pERSON.Tiqu_person_money(); }
public void hp_reflash(int xue) //道具的回血 { sql.Open(); PERSON person1 = new PERSON(); int hp = person1.Tiqu_person_hp(); int change_hp = person1.Tiqu_change_hp(); if (xue + change_hp < hp) { int he = xue + change_hp; string blood_return = "update person set change_hp+= " + he; SqlCommand blood_command = new SqlCommand(blood_return, sql); try { blood_command.ExecuteNonQuery(); } catch { MessageBox.Show("执行回血语句失败"); } finally { sql.Close(); } } else { string blood_return = "update person set change_hp= " + hp; SqlCommand blood_command = new SqlCommand(blood_return, sql); try { blood_command.ExecuteNonQuery(); } catch { MessageBox.Show("语句失败"); } finally { sql.Close(); } } }
public void blood_return()//回城恢复血量 { sql.Open(); PERSON pERSON = new PERSON(); string blood_return = "update person set change_hp= " + 500; SqlCommand blood_command = new SqlCommand(blood_return, sql); try { blood_command.ExecuteNonQuery(); } catch { MessageBox.Show("执行回血语句失败"); } finally { sql.Close(); } }
private void button1_Click_1(object sender, EventArgs e) { progressBar1.Visible = true; progressBar1.Maximum = 10; // progressBar1.Value = 0; progressBar1.Minimum = 0; for (int i = progressBar1.Minimum; i <= progressBar1.Maximum; i++) { System.Threading.Thread.Sleep(100); progressBar1.Value = i; this.Refresh(); } PERSON pERSON = new PERSON(); pERSON.blood_return(); int xy = pERSON.Tiqu_person_grade(); label1.Text = "人物属性\r\n名字:红凯 等级 : " + Convert.ToString(xy) + "\r\n血量 : " + Convert.ToString(pERSON.Tiqu_person_hp()) + "\r\n攻击力 : " + Convert.ToString(pERSON.Tiqu_person_wuli()) + "\r\n"; label1.Text += "金钱:" + pERSON.Tiqu_person_money(); MessageBox.Show("恢复成功", "提示"); progressBar1.Visible = false; }
private void button1_Click(object sender, EventArgs e) { panel1.Visible = true; PERSON person1 = new PERSON(); MONSTER monster1 = new MONSTER(); if (comboBox1.SelectedIndex == 0) { if (person1.attack(comboBox1.SelectedItem.ToString()) == 1) { richTextBox1.Text += "战斗成功,您获得了经验值:" + Convert.ToString(monster1.Tiqu_monster_experience(comboBox1.SelectedItem.ToString())) + "\r\n" + "您目前的等级为:" + Convert.ToString(person1.Tiqu_person_grade()) + "\r\n"; richTextBox1.Text += "您的血量还剩余:" + Convert.ToString(person1.Tiqu_change_hp()) + "\r\n"; richTextBox1.Text += "您获得金钱:" + Convert.ToString(monster1.Tiqu_monster_money(comboBox1.SelectedItem.ToString())) + "\r\n"; if (monster1.Tiqu_monster_equipment(comboBox1.SelectedItem.ToString()) != null) { richTextBox1.Text += "恭喜您获得了装备" + monster1.Tiqu_monster_equipment(comboBox1.SelectedItem.ToString()) + "\r\n"; } else { richTextBox1.Text += "战斗结束,您什么也没有获得\r\n"; } } else { richTextBox1.Text += "战斗失败,人物已死亡,请回城复活\r\n"; } } if (comboBox1.SelectedIndex == 1) { if (person1.attack(comboBox1.SelectedItem.ToString()) == 1) { richTextBox1.Text += "战斗成功,您获得了经验值:" + Convert.ToString(monster1.Tiqu_monster_experience(comboBox1.SelectedItem.ToString())) + "\r\n" + "您目前的等级为:" + Convert.ToString(person1.Tiqu_person_grade()) + "\r\n"; richTextBox1.Text += "您的血量还剩余:" + Convert.ToString(person1.Tiqu_change_hp()) + "\r\n"; richTextBox1.Text += "您获得金钱:" + Convert.ToString(monster1.Tiqu_monster_money(comboBox1.SelectedItem.ToString())) + "\r\n"; if (monster1.Tiqu_monster_equipment(comboBox1.SelectedItem.ToString()) != null) { richTextBox1.Text += "恭喜您获得了装备" + monster1.Tiqu_monster_equipment(comboBox1.SelectedItem.ToString()) + "\r\n"; } else { richTextBox1.Text += "战斗结束,您什么也没有获得\r\n"; } } else { richTextBox1.Text += "战斗失败,人物已死亡,请回城复活\r\n"; } } if (comboBox1.SelectedIndex == 2) { if (person1.attack(comboBox1.SelectedItem.ToString()) == 1) { richTextBox1.Text += "战斗成功,您获得了经验值:" + Convert.ToString(monster1.Tiqu_monster_experience(comboBox1.SelectedItem.ToString())) + "\r\n" + "您目前的等级为:" + Convert.ToString(person1.Tiqu_person_grade()) + "\r\n"; richTextBox1.Text += "您的血量还剩余:" + Convert.ToString(person1.Tiqu_change_hp()) + "\r\n"; richTextBox1.Text += "您获得金钱:" + Convert.ToString(monster1.Tiqu_monster_money(comboBox1.SelectedItem.ToString())) + "\r\n"; if (monster1.Tiqu_monster_equipment(comboBox1.SelectedItem.ToString()) != null) { richTextBox1.Text += "恭喜您获得了装备" + monster1.Tiqu_monster_equipment(comboBox1.SelectedItem.ToString()) + "\r\n"; } else { richTextBox1.Text += "战斗结束,您什么也没有获得\r\n"; } } else { richTextBox1.Text += "战斗失败,人物已死亡,请回城复活\r\n"; } } if (comboBox1.SelectedIndex == 3) { if (person1.attack(comboBox1.SelectedItem.ToString()) == 1) { richTextBox1.Text += "战斗成功,您获得了经验值:" + Convert.ToString(monster1.Tiqu_monster_experience(comboBox1.SelectedItem.ToString())) + "\r\n" + "您目前的等级为:" + Convert.ToString(person1.Tiqu_person_grade()) + "\r\n"; richTextBox1.Text += "您的血量还剩余:" + Convert.ToString(person1.Tiqu_change_hp()) + "\r\n"; richTextBox1.Text += "您获得金钱:" + Convert.ToString(monster1.Tiqu_monster_money(comboBox1.SelectedItem.ToString())) + "\r\n"; if (monster1.Tiqu_monster_equipment(comboBox1.SelectedItem.ToString()) != null) { richTextBox1.Text += "恭喜您获得了装备" + monster1.Tiqu_monster_equipment(comboBox1.SelectedItem.ToString()) + "\r\n"; } else { richTextBox1.Text += "战斗结束,您什么也没有获得\r\n"; } } else { richTextBox1.Text += "战斗失败,人物已死亡,请回城复活\r\n"; } } if (comboBox1.SelectedIndex == 4) { if (person1.attack(comboBox1.SelectedItem.ToString()) == 1) { richTextBox1.Text += "战斗成功,您获得了经验值:" + Convert.ToString(monster1.Tiqu_monster_experience(comboBox1.SelectedItem.ToString())) + "\r\n" + "您目前的等级为:" + Convert.ToString(person1.Tiqu_person_grade()) + "\r\n"; richTextBox1.Text += "您的血量还剩余:" + Convert.ToString(person1.Tiqu_change_hp()) + "\r\n"; richTextBox1.Text += "您获得金钱:" + Convert.ToString(monster1.Tiqu_monster_money(comboBox1.SelectedItem.ToString())) + "\r\n"; if (monster1.Tiqu_monster_equipment(comboBox1.SelectedItem.ToString()) != null) { richTextBox1.Text += "恭喜您获得了装备" + monster1.Tiqu_monster_equipment(comboBox1.SelectedItem.ToString()) + "\r\n"; } else { richTextBox1.Text += "战斗结束,您什么也没有获得\r\n"; } } else { richTextBox1.Text += "战斗失败,人物已死亡,请回城复活\r\n"; } }//战斗过程1代码合集 if (comboBox2.SelectedIndex == 0) { if (person1.attack(comboBox2.SelectedItem.ToString()) == 1) { richTextBox1.Text += "战斗成功,您获得了经验值:" + Convert.ToString(monster1.Tiqu_monster_experience(comboBox2.SelectedItem.ToString())) + "\r\n" + "您目前的等级为:" + Convert.ToString(person1.Tiqu_person_grade()) + "\r\n"; richTextBox1.Text += "您的血量还剩余:" + Convert.ToString(person1.Tiqu_change_hp()) + "\r\n"; richTextBox1.Text += "您获得金钱:" + Convert.ToString(monster1.Tiqu_monster_money(comboBox2.SelectedItem.ToString())) + "\r\n"; if (monster1.Tiqu_monster_equipment(comboBox2.SelectedItem.ToString()) != null) { richTextBox1.Text += "恭喜您获得了装备" + monster1.Tiqu_monster_equipment(comboBox2.SelectedItem.ToString()) + "\r\n"; } else { richTextBox1.Text += "战斗结束,您什么也没有获得\r\n"; } } else { richTextBox1.Text += "战斗失败,人物已死亡,请回城复活\r\n"; } } if (comboBox2.SelectedIndex == 1) { if (person1.attack(comboBox2.SelectedItem.ToString()) == 1) { richTextBox1.Text += "战斗成功,您获得了经验值:" + Convert.ToString(monster1.Tiqu_monster_experience(comboBox2.SelectedItem.ToString())) + "\r\n" + "您目前的等级为:" + Convert.ToString(person1.Tiqu_person_grade()) + "\r\n"; richTextBox1.Text += "您的血量还剩余:" + Convert.ToString(person1.Tiqu_change_hp()) + "\r\n"; richTextBox1.Text += "您获得金钱:" + Convert.ToString(monster1.Tiqu_monster_money(comboBox2.SelectedItem.ToString())) + "\r\n"; if (monster1.Tiqu_monster_equipment(comboBox2.SelectedItem.ToString()) != null) { richTextBox1.Text += "恭喜您获得了装备" + monster1.Tiqu_monster_equipment(comboBox2.SelectedItem.ToString()) + "\r\n"; } else { richTextBox1.Text += "战斗结束,您什么也没有获得\r\n"; } } else { richTextBox1.Text += "战斗失败,人物已死亡,请回城复活\r\n"; } } if (comboBox2.SelectedIndex == 2) { if (person1.attack(comboBox2.SelectedItem.ToString()) == 1) { richTextBox1.Text += "战斗成功,您获得了经验值:" + Convert.ToString(monster1.Tiqu_monster_experience(comboBox2.SelectedItem.ToString())) + "\r\n" + "您目前的等级为:" + Convert.ToString(person1.Tiqu_person_grade()) + "\r\n"; richTextBox1.Text += "您的血量还剩余:" + Convert.ToString(person1.Tiqu_change_hp()) + "\r\n"; richTextBox1.Text += "您获得金钱:" + Convert.ToString(monster1.Tiqu_monster_money(comboBox2.SelectedItem.ToString())) + "\r\n"; if (monster1.Tiqu_monster_equipment(comboBox2.SelectedItem.ToString()) != null) { richTextBox1.Text += "恭喜您获得了装备" + monster1.Tiqu_monster_equipment(comboBox2.SelectedItem.ToString()) + "\r\n"; } else { richTextBox1.Text += "战斗结束,您什么也没有获得\r\n"; } } else { richTextBox1.Text += "战斗失败,人物已死亡,请回城复活\r\n"; } } if (comboBox2.SelectedIndex == 3) { if (person1.attack(comboBox2.SelectedItem.ToString()) == 1) { richTextBox1.Text += "战斗成功,您获得了经验值:" + Convert.ToString(monster1.Tiqu_monster_experience(comboBox2.SelectedItem.ToString())) + "\r\n" + "您目前的等级为:" + Convert.ToString(person1.Tiqu_person_grade()) + "\r\n"; richTextBox1.Text += "您的血量还剩余:" + Convert.ToString(person1.Tiqu_change_hp()) + "\r\n"; richTextBox1.Text += "您获得金钱:" + Convert.ToString(monster1.Tiqu_monster_money(comboBox2.SelectedItem.ToString())) + "\r\n"; if (monster1.Tiqu_monster_equipment(comboBox2.SelectedItem.ToString()) != null) { richTextBox1.Text += "恭喜您获得了装备" + monster1.Tiqu_monster_equipment(comboBox2.SelectedItem.ToString()) + "\r\n"; } else { richTextBox1.Text += "战斗结束,您什么也没有获得\r\n"; } } else { richTextBox1.Text += "战斗失败,人物已死亡,请回城复活\r\n"; } } if (comboBox2.SelectedIndex == 4) { if (person1.attack(comboBox2.SelectedItem.ToString()) == 1) { richTextBox1.Text += "战斗成功,您获得了经验值:" + Convert.ToString(monster1.Tiqu_monster_experience(comboBox2.SelectedItem.ToString())) + "\r\n" + "您目前的等级为:" + Convert.ToString(person1.Tiqu_person_grade()) + "\r\n"; richTextBox1.Text += "您的血量还剩余:" + Convert.ToString(person1.Tiqu_change_hp()) + "\r\n"; richTextBox1.Text += "您获得金钱:" + Convert.ToString(monster1.Tiqu_monster_money(comboBox2.SelectedItem.ToString())) + "\r\n"; if (monster1.Tiqu_monster_equipment(comboBox2.SelectedItem.ToString()) != null) { richTextBox1.Text += "恭喜您获得了装备" + monster1.Tiqu_monster_equipment(comboBox2.SelectedItem.ToString()) + "\r\n"; } else { richTextBox1.Text += "战斗结束,您什么也没有获得\r\n"; } } else { richTextBox1.Text += "战斗失败,人物已死亡,请回城复活\r\n"; } }//战斗过程2代码合集 }
public int attack(string monster_name)//战斗 { MONSTER mONSTER = new MONSTER(); int person_hp, person_wuli, monster_wuli, monster_hp; person_hp = Tiqu_change_hp(); if (person_hp > 0)//战斗之前先判断血量 { person_wuli = Tiqu_person_wuli(); monster_hp = mONSTER.Tiqu_monster_hp(monster_name); monster_wuli = mONSTER.Tiqu_monster_wuli(monster_name); while (monster_hp >= 0 && person_hp >= 0) { monster_hp -= person_wuli; person_hp -= monster_wuli; if (monster_hp <= 0)//战斗胜利 { sql.Open(); string attack = "update person set change_hp= " + person_hp; SqlCommand attack_person = new SqlCommand(attack, sql); string experience_add = "update person set Empirical= Empirical +" + mONSTER.Tiqu_monster_experience(monster_name); SqlCommand experience = new SqlCommand(experience_add, sql); try { attack_person.ExecuteNonQuery(); experience.ExecuteNonQuery(); PERSON pERSON = new PERSON(); pERSON.add_money(monster_name); string equpiment = mONSTER.Tiqu_monster_equipment(monster_name); if (equpiment != null) { ATTACK aTTACK = new ATTACK(); aTTACK.bag_add(equpiment); } } catch { MessageBox.Show("执行语句失败"); } finally { sql.Close(); } break; } else if (person_hp <= 0) { sql.Open(); string attack_lose = "update person set change_hp= 0 "; SqlCommand dead = new SqlCommand(attack_lose, sql); try { dead.ExecuteNonQuery(); } catch { MessageBox.Show("死亡失败"); } finally { sql.Close(); } return(0); } } return(1); } else { return(0); } }