private void button12_Click(object sender, EventArgs e) { try { int i; i = listBox2.SelectedIndex; listBox3.SelectedIndex = i; ArrayList newwp = new ArrayList(); string name = listBox3.Text; //读取武器 FileStream fs = new FileStream(".\\data\\weapon\\" + name + ".dat", FileMode.Open); BinaryFormatter bf = new BinaryFormatter();//反序列化 newwp = bf.Deserialize(fs) as ArrayList; fs.Close(); shoptrade st = new shoptrade(); st.destroysomething(al, newwp, 1); MessageBox.Show("你丢掉了一个" + weaponIDtostr(Convert.ToString(name)) + "。"); f5(); } catch (Exception) { MessageBox.Show("请选择一个要丢的物品!"); } }
private void button13_Click(object sender, EventArgs e) { //解除装备 string midname = Convert.ToString(al[23]); loaddat ld = new loaddat(); shoptrade st = new shoptrade(); equipmentwear ew = new equipmentwear(); ew.equioff(al, ld.loadweapon(midname), 23); st.getsomething(al, ld.loadweapon(midname), 1); f5(); }
private void button1_Click(object sender, EventArgs e) { try { int i; i = listBox1.SelectedIndex; listBox2.SelectedIndex = i; listBox3.SelectedIndex = i; listBox4.SelectedIndex = i; int j = Convert.ToInt32(textBox1.Text); ArrayList newwp = new ArrayList(); string name = listBox2.Text; //读取武器 FileStream fs = new FileStream(".\\data\\weapon\\" + name + ".dat", FileMode.Open); BinaryFormatter bf = new BinaryFormatter();//反序列化 newwp = bf.Deserialize(fs) as ArrayList; fs.Close(); shoptrade st = new shoptrade(); if (Convert.ToInt32(al[16]) >= Convert.ToInt32(newwp[5]) * Convert.ToInt32(textBox1.Text)) { st.buysomething(al, newwp, j); MessageBox.Show("购买成功"); } else { MessageBox.Show("你的钱不够,需要" + uc.moneytochina(Convert.ToInt32(newwp[5]) * Convert.ToInt32(textBox1.Text)) + "。"); } f5(); } catch (Exception) { MessageBox.Show("请选择一个武器。"); } }
private void button11_Click(object sender, EventArgs e) { try { int i; string midname = Convert.ToString(al[23]); i = listBox2.SelectedIndex; listBox3.SelectedIndex = i; loaddat ld = new loaddat(); shoptrade st = new shoptrade(); equipmentwear ew = new equipmentwear(); ew.equioff(al, ld.loadweapon(midname), 23); st.getsomething(al, ld.loadweapon(midname), 1); ew.equiwear(al, ld.loadweapon(listBox3.Text), 23); if (Convert.ToString(al[23]) != "0") { st.destroysomething(al, ld.loadweapon(listBox3.Text), 1); MessageBox.Show("你成功装备了" + weaponIDtostr(Convert.ToString(listBox3.Text)) + "。"); } else { //ew.equiwear(al, ld.loadweapon(midname), 23); //st.destroysomething(al, ld.loadweapon(midname), 1); MessageBox.Show("装备" + weaponIDtostr(Convert.ToString(listBox3.Text)) + "失败。"); } f5(); } catch (Exception) { MessageBox.Show("请选择一个要装备的物品!"); } }
private void button2_Click(object sender, EventArgs e) { try { int i; i = listBox5.SelectedIndex; listBox7.SelectedIndex = i; listBox8.SelectedIndex = i; int j = Convert.ToInt32(textBox1.Text); if (true) { ArrayList newwp = new ArrayList(); string name = listBox8.Text; //读取武器 FileStream fs = new FileStream(".\\data\\weapon\\" + name + ".dat", FileMode.Open); BinaryFormatter bf = new BinaryFormatter();//反序列化 newwp = bf.Deserialize(fs) as ArrayList; fs.Close(); shoptrade st = new shoptrade(); st.sellsomething(al, newwp, j); } else { MessageBox.Show("出错"); } f5(); } catch (Exception) { MessageBox.Show("请选择一个武器!"); } }