Esempio n. 1
0
        public static void CreatPlayer()
        {
            Console.WriteLine("\n\t\t\t创建角色");
            Console.WriteLine("\t角色名称:");
            Console.Write("\t");
            Playerrole.Instance.name = Console.ReadLine();
            Console.WriteLine("\t角色职业:1.战士  2.刺客  3.法师(每个职业成长率不同,技能相同)\n\tps:因为太麻烦了...");
            Console.Write("\t");
            Playerrole.Instance.jobid = int.Parse(Console.ReadLine());
            Console.WriteLine("\t1.确认  2.重新输入");
            Console.Write("\t");
hehe:
            string cs = Console.ReadLine();

            if (cs == "")
            {
                goto hehe;
            }
            int n = int.Parse(cs);

            if (n == 1)
            {
                Instance.basehp   = GameRes.GetJob(Instance.jobid).hp;
                Instance.basemp   = GameRes.GetJob(Instance.jobid).mp;
                Instance.baseatk  = GameRes.GetJob(Instance.jobid).atk;
                Instance.hprate   = GameRes.GetJob(Instance.jobid).hprate;
                Instance.mprate   = GameRes.GetJob(Instance.jobid).mprate;
                Instance.atkrate  = GameRes.GetJob(Instance.jobid).atkrate;
                Playerrole.weapon = GameRes.GetWeapon(1);
                Playerrole.equip1 = GameRes.GetEquip(1);
                Playerrole.equip2 = GameRes.GetEquip(4);
                Playerrole.equip3 = GameRes.GetEquip(6);
                Playerrole.skill1 = GameRes.GetSkill(1);
                Playerrole.skill2 = GameRes.GetSkill(2);
                Playerrole.skill3 = GameRes.GetSkill(3);
                Playerrole.skill4 = GameRes.GetSkill(4);
                Playerrole.skill5 = GameRes.GetSkill(5);

                Program.Mainui();
            }
        }
Esempio n. 2
0
        public static bool LoadGameRes()
        {
            XmlDocument xml = new XmlDocument();

            try
            {
                xml.Load(Respath);
                XmlNode     root = xml.SelectSingleNode("config");
                XmlNodeList list = root.SelectNodes("job");
                foreach (XmlNode nd in list)
                {
                    Job jb = new Job
                    {
                        id      = int.Parse(nd.Attributes["id"].Value),
                        name    = nd.Attributes["name"].Value,
                        atk     = int.Parse(nd.Attributes["atk"].Value),
                        hp      = int.Parse(nd.Attributes["hp"].Value),
                        mp      = int.Parse(nd.Attributes["mp"].Value),
                        hprate  = int.Parse(nd.Attributes["hprate"].Value),
                        mprate  = int.Parse(nd.Attributes["mprate"].Value),
                        atkrate = int.Parse(nd.Attributes["atkrate"].Value)
                    };
                    Jobs.Add(jb.id, jb);
                }
                list = root.SelectNodes("weapon");
                foreach (XmlNode nd in list)
                {
                    Weapon wp = new Weapon
                    {
                        id    = int.Parse(nd.Attributes["id"].Value),
                        name  = (nd.Attributes["name"].Value),
                        atk   = int.Parse(nd.Attributes["atk"].Value),
                        price = int.Parse(nd.Attributes["price"].Value)
                    };
                    Weapons.Add(wp.id, wp);
                }
                list = root.SelectNodes("item");
                foreach (XmlNode nd in list)
                {
                    Item item = new Item
                    {
                        id    = int.Parse(nd.Attributes["id"].Value),
                        name  = nd.Attributes["name"].Value,
                        hp    = int.Parse(nd.Attributes["hp"].Value),
                        mp    = int.Parse(nd.Attributes["mp"].Value),
                        price = int.Parse(nd.Attributes["price"].Value)
                    };
                    Items.Add(item.id, item);
                }
                list = root.SelectNodes("monster");
                foreach (XmlNode nd in list)
                {
                    Monster monster = new Monster
                    {
                        id   = int.Parse(nd.Attributes["id"].Value),
                        name = (nd.Attributes["name"].Value),
                        hp   = int.Parse(nd.Attributes["hp"].Value),
                        atk  = int.Parse(nd.Attributes["atk"].Value)
                    };
                    Monsters.Add(monster.id, monster);
                }
                list = root.SelectNodes("equip");
                foreach (XmlNode nd in list)
                {
                    Equip equip = new Equip
                    {
                        id    = int.Parse(nd.Attributes["id"].Value),
                        name  = nd.Attributes["name"].Value,
                        hp    = int.Parse(nd.Attributes["hp"].Value),
                        mp    = int.Parse(nd.Attributes["mp"].Value),
                        price = int.Parse(nd.Attributes["price"].Value)
                    };
                    Equips.Add(equip.id, equip);
                }
                list = root.SelectNodes("skill");
                foreach (XmlNode nd in list)
                {
                    Skill skill = new Skill
                    {
                        id   = int.Parse(nd.Attributes["id"].Value),
                        name = nd.Attributes["name"].Value,
                        mp   = int.Parse(nd.Attributes["mp"].Value),
                        rate = float.Parse(nd.Attributes["rate"].Value)
                    };
                    Skills.Add(skill.id, skill);
                }
            }
            catch
            {
                return(false);
            }

            return(true);
        }
Esempio n. 3
0
        public static void shop()
        {
            Console.Clear();
            Console.WriteLine("欢迎来到商店(本店只卖不买,更换后原有装备消失)");
            Console.WriteLine("\t武器:");
            for (int i = 1; i < 6; i++)
            {
                _ = new Weapon();
                Weapon weapon = GameRes.GetWeapon(i);
                Console.WriteLine("id:{0}\t武器名:{1}\t攻击力:{2}\t价格:{3}", weapon.id, weapon.name, weapon.atk, weapon.price);
            }
            Console.WriteLine("\t装备:");
            for (int i = 1; i < 9; i++)
            {
                _ = new Equip();
                Equip equip = GameRes.GetEquip(i);
                Console.WriteLine("id:{0}\t装备名:{1}\t血量:{2}\t法力值:{3}\t价格{4}", equip.id, equip.name, equip.hp, equip.mp, equip.price);
            }
            Console.WriteLine("\t道具:");
            for (int i = 1; i < 6; i++)
            {
                _ = new Item();
                Item item = GameRes.GetItem(i);
                Console.WriteLine("id:{0}\t道具名:{1}\t回复血量:{2}\t回复法力值:{3}\t价格:{4}", item.id, item.name, item.hp, item.mp, item.price);
            }
            Console.SetCursorPosition(65, 3);
            Console.WriteLine("选择行动:");
            Console.SetCursorPosition(65, 4);
            Console.WriteLine("0.返回主界面");
            Console.SetCursorPosition(65, 5);
            Console.WriteLine("1.购买武器");
            Console.SetCursorPosition(65, 6);
            Console.WriteLine("2.购买装备");
            Console.SetCursorPosition(65, 7);
            Console.WriteLine("3.购买道具");
            Console.SetCursorPosition(0, 22);
            for (int i = 0; i < 79; i++)
            {
                Console.Write("-");
            }
            Console.SetCursorPosition(0, 23);
            Console.WriteLine("你的选择:");
            Console.SetCursorPosition(0, 24);
hehe:
            string cs = Console.ReadLine();

            if (cs == "")
            {
                goto hehe;
            }
            int n = int.Parse(cs);

            switch (n)
            {
            case 1: BuyWeapon(); break;

            case 2: BuyEquip(); break;

            case 3: BuyItem(); break;

            case 0: Program.Mainui(); break;

            default:
                goto hehe;
            }
        }
Esempio n. 4
0
        private static void BuyEquip()
        {
            hape :    Console.Clear();
            Console.WriteLine("\t装备");
            for (int i = 1; i < 9; i++)
            {
                _ = new Equip();
                Equip equip = GameRes.GetEquip(i);
                Console.WriteLine("id:{0}\t装备名:{1}\t血量:{2}\t法力值:{3}\t价格:{4}", equip.id, equip.name, equip.hp, equip.mp, equip.price);
            }
            Console.SetCursorPosition(0, 20);
            for (int a = 0; a < 79; a++)
            {
                Console.Write("-");
            }
            Console.SetCursorPosition(0, 21);
            Console.WriteLine("你的选择:(输入装备id购买,输入0返回商店)");
            Console.SetCursorPosition(0, 22);
hehe:
            string cs = Console.ReadLine();

            if (cs == "")
            {
                goto hehe;
            }
            int n = int.Parse(cs);

            switch (n)
            {
            case 0: shop(); break;

            case 1:
                if (Playerrole.Instance.gold >= GameRes.GetEquip(1).price)
                {
                    Playerrole.equip1         = GameRes.GetEquip(1);
                    Playerrole.Instance.gold -= Playerrole.equip1.price;
                    Console.WriteLine("购买成功.你还有{0}金币", Playerrole.Instance.gold);
                    Console.ReadKey();
                    Console.Clear();
                    goto hape;
                }
                else
                {
                    Console.WriteLine("没钱你还想买,白嫖吗?,想peach");
                    Console.ReadKey();
                    goto hehe;
                }

            case 2:
                if (Playerrole.Instance.gold >= GameRes.GetEquip(2).price)
                {
                    Playerrole.equip1         = GameRes.GetEquip(2);
                    Playerrole.Instance.gold -= Playerrole.equip1.price;
                    Console.WriteLine("购买成功.你还有{0}金币", Playerrole.Instance.gold);
                    Console.ReadKey();
                    Console.Clear();
                    goto hape;
                }
                else
                {
                    Console.WriteLine("没钱你还想买,白嫖吗?,想peach");
                    Console.ReadKey();
                    goto hehe;
                }

            case 3:
                if (Playerrole.Instance.gold >= GameRes.GetEquip(3).price)
                {
                    Playerrole.equip1         = GameRes.GetEquip(3);
                    Playerrole.Instance.gold -= Playerrole.equip1.price;
                    Console.WriteLine("购买成功.你还有{0}金币", Playerrole.Instance.gold);
                    Console.ReadKey();
                    Console.Clear();
                    goto hape;
                }
                else
                {
                    Console.WriteLine("没钱你还想买,白嫖吗?,想peach");
                    Console.ReadKey();
                    goto hehe;
                }

            case 4:
                if (Playerrole.Instance.gold >= GameRes.GetEquip(4).price)
                {
                    Playerrole.equip2         = GameRes.GetEquip(4);
                    Playerrole.Instance.gold -= Playerrole.equip2.price;
                    Console.WriteLine("购买成功.你还有{0}金币", Playerrole.Instance.gold);
                    Console.ReadKey();
                    Console.Clear();
                    goto hape;
                }
                else
                {
                    Console.WriteLine("没钱你还想买,白嫖吗?,想peach");
                    Console.ReadKey();
                    goto hehe;
                }

            case 5:
                if (Playerrole.Instance.gold >= GameRes.GetEquip(5).price)
                {
                    Playerrole.equip2         = GameRes.GetEquip(5);
                    Playerrole.Instance.gold -= Playerrole.equip2.price;
                    Console.WriteLine("购买成功.你还有{0}金币", Playerrole.Instance.gold);
                    Console.ReadKey();
                    Console.Clear();
                    goto hape;
                }
                else
                {
                    Console.WriteLine("没钱你还想买,白嫖吗?,想peach");
                    Console.ReadKey();
                    goto hehe;
                }

            case 6:
                if (Playerrole.Instance.gold >= GameRes.GetEquip(6).price)
                {
                    Playerrole.equip3         = GameRes.GetEquip(6);
                    Playerrole.Instance.gold -= Playerrole.equip3.price;
                    Console.WriteLine("购买成功.你还有{0}金币", Playerrole.Instance.gold);
                    Console.ReadKey();
                    Console.Clear();
                    goto hape;
                }
                else
                {
                    Console.WriteLine("没钱你还想买,白嫖吗?,想peach");
                    Console.ReadKey();
                    goto hehe;
                }

            case 7:
                if (Playerrole.Instance.gold >= GameRes.GetEquip(7).price)
                {
                    Playerrole.equip3         = GameRes.GetEquip(7);
                    Playerrole.Instance.gold -= Playerrole.equip3.price;
                    Console.WriteLine("购买成功.你还有{0}金币", Playerrole.Instance.gold);
                    Console.ReadKey();
                    Console.Clear();
                    goto hape;
                }
                else
                {
                    Console.WriteLine("没钱你还想买,白嫖吗?,想peach");
                    Console.ReadKey();
                    goto hehe;
                }

            case 8:
                if (Playerrole.Instance.gold >= GameRes.GetEquip(8).price)
                {
                    Playerrole.equip1         = GameRes.GetEquip(8);
                    Playerrole.Instance.gold -= Playerrole.equip1.price;
                    Console.WriteLine("购买成功.你还有{0}金币", Playerrole.Instance.gold);
                    Console.ReadKey();
                    Console.Clear();
                    goto hape;
                }
                else
                {
                    Console.WriteLine("没钱你还想买,白嫖吗?,想peach");
                    Console.ReadKey();
                    goto hehe;
                }

            default:
                goto hape;
            }
        }