C#第七课文字游戏2.0版本

using System;
using System.Threading;
namespace @new
{
   
    
    class Program
    {
   
        /*常量初始化*/
        #region 
        //昵称
        static string name = "";
        //生命
        static int hp;
        //当前生命
        static int c_hp;
        //成长生命
        static int g_hp;
        //攻击力
        static int atk;
        //成长攻击力
        static int g_atk;
        //防御
        static int def;
        //成长防御
        static int g_def;
        //速度
        static int speed;
        //成长速度
        static int g_speed;
        //等级 
        static int level = 1;
        //当前经验
        static int exp = 0;
        //升级所需经验
        static int g_exp = 1000;
        //金钱
        static int money = 100;
        //查看面板
        #endregion 

        //武器 衣服 鞋子
        static Equip wuqi;
        static int wuqi_atk;
        static Equip yifu;
        static int yifu_hp;
        static Equip xiezi;
        static int xiezi_speed;

        //装备中转站
        static string q1 = null;
        static string q2 = null;
        static string q3 = null;

        //装备道具
        enum EquipType
        {
   
            wuqi,
            yifu,
            xiezi
        }
        struct Equip
        {
   
            public EquipType type;
            public string name;
            public string des;
            public int hp;
            public int atk;
            public int speed;

            public Equip(EquipType type, string name, string des, int hp, int atk, int speed)
            {
   
                this.type = type;
                this.name = name;
                this.des = des;
                this.hp = hp;
                this.atk = atk;
                this.speed = speed;
            }
        }
        static void EquipItem(Equip a)
        {
   
            switch (a.type)
            {
   
                case EquipType.wuqi:
                    Log("你装备了武器:" + a.name + " 它" + a.des + " 攻击力+" + a.atk);
                    //装备穿戴
                    wuqi_atk = a.atk;
                    //装备中转站内装备放入背包数组
                    BeiBao(q1);
                    //新的装备再次放入装备中转站
                    q1 = a.name;
                    wuqi = a;
                    break;
                case EquipType.yifu:
                    Log("你装备了衣服:" + a.name + " 它" + a.des + " 生命+" + a.hp);
                    yifu_hp = a.hp;
                    BeiBao(q2);
                    q2 = a.name;
                    yifu = a;
                    break;
                case EquipType.xiezi:
                    Log("你装备了鞋子:" + a.name + " 它" + a.des + " 速度+" + a.speed);
                    xiezi_speed = a.speed;
                    BeiBao(q3);
                    q3 = a.name;
                    xiezi = a;
                    break;
            }
        }

        //背包
        static string[] a = new string[20];
        static void BeiBao(string str)
        {
   

            for (int n = 0; n < 10; n++)
            {
   
                if (a[n] == null)
                {
   
                    a[n] = str;
                    break;
                }
            }
            Console.WriteLine("当前你的背包里有:");
            for (int m = 0; m <= 9; m++)
            {
   
                if (a[m] == null)
                {
   
                    break;
                }
                Console.Write(a[m] + " ");
            }
            Console.WriteLine();

        }

        //面板提示
        static void ShowInfo()
        {
   
            Console.WriteLine("你现在状态:生命为:{0}/{1}+{2},攻击力为:{3}+{4},防御为:{5},速度为:{6}+{7},金钱为:{8},等级为:{9},经验为:{10}/{11}", c_hp, hp, yifu.hp, atk, wuqi.atk, def, speed, xiezi_speed, money, level, exp, g_exp);
            Log("武器:" + wuqi.name + " 衣服:" + yifu.name + " 鞋子:" + xiezi.name);
            Thread.Sleep(1000);
            BeiBao(null);

        }

        //延迟输出函数
        static void Log(string text)
        {
   
            Console.WriteLine(text);
            Thread.Sleep(1000);
        }

        //战前准备以及战斗过程
        static void Battle(string e_name, int e_hp, int e_atk, int e_speed, int e_satk, int e_miss, int e_money, int e_exp)
        {
   
            Log("你遇到了" + e_name + "!是否在战斗前消耗10银两回满生命?");
            ShowInfo();
            Console.WriteLine(e_name + "现在的状态:生命为:{0},攻击力为:{1},速度为:{2},暴击为:{3},闪避为:{4},金钱为:{5},经验为:{6}", e_hp, e_atk, e_speed, e_satk, e_miss, e_money, e_exp);
            Thread.Sleep(1000);
            Log("1,回满 2,跳过");
            string str = Console.ReadLine();
            if (str == "1" && money >= 10)
            {
   
                c_hp = hp+yifu_hp ;
                money -= 10;
                Log("血量已回满!");
                ShowInfo();
            }
            //判断先手
            bool playerAtk = speed + xiezi_speed > e_speed;
            while (true)
            {
   
                //如果是玩家攻击
                if (playerAtk)
                {
   
                    //下一次攻击轮到敌人
                    playerAtk = false;
                    //判定闪避
                    if (new Random().Next(0, 100) < e_miss)
                    {
   
                        Log("你向" + e_name + "砍出一刀,却被" + e_name + "轻松地躲了过去!");
                        continue;
                    }
                    //敌人掉血
                    int num = new Random().Next(atk + wuqi_atk - 5, atk + wuqi_atk + 5)
  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

葬月飘零

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值