예제 #1
0
        public void add_experience(string monster_name)//增加人物金钱
        {
            sql.Open();
            MONSTER    mONSTER           = new MONSTER();
            int        experience        = mONSTER.Tiqu_monster_experience(monster_name);
            string     money_add         = "update person set Empirical+=" + experience;
            SqlCommand command_money_add = new SqlCommand(money_add, sql);

            try
            {
                command_money_add.ExecuteNonQuery();
            }
            catch
            {
                MessageBox.Show("增加经验失败");
            }
            finally
            {
                sql.Close();
            }
        }
예제 #2
0
        public void add_money(string monster_name) //增加人物金钱
        {
            sql.Open();
            MONSTER    mONSTER           = new MONSTER();
            int        money             = mONSTER.Tiqu_monster_money(monster_name);
            string     money_add         = "update person set person_money+=" + money;
            SqlCommand command_money_add = new SqlCommand(money_add, sql);

            try
            {
                command_money_add.ExecuteNonQuery();
            }
            catch
            {
                MessageBox.Show("增加金钱失败");
            }
            finally
            {
                sql.Close();
            }
        }
예제 #3
0
파일: explore.cs 프로젝트: rmxob/xiangmu
        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代码合集
        }
예제 #4
0
        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);
            }
        }