zoukankan      html  css  js  c++  java
  • VS 游戏:推箱子&对战游戏

    推箱子

    //只做了两关

        class Program
        {
            static void Main(string[] args)
            {
                int x = 1;
                int y = 8;
                int z = 0;
    
                int end1x = 6;
                int end1y = 3;
    
                int end2x = 6;
                int end2y = 3;
    
                #region 地图绘制
                string[,,] map = new string[3, 10, 10]
                {
                  { {"", "", "", "", "", "", "", "", "", ""},
                    {"", " ", " ", " ", " ", " ", " ", " ", " ", ""},
                    {"", " ", " ", " ", " ", " ", " ", " ", " ", ""},
                    {"", " ", " ", " ", " ", " ", "", " ", " ", ""},
                    {"", " ", "", " ", " ", " ", " ", " ", " ", ""},
                    {"", " ", " ", " ", " ", " ", " ", " ", " ", ""},
                    {"", " ", " ", " ", " ", " ", " ", " ", " ", ""},
                    {"", " ", " ", " ", " ", " ", " ", " ", " ", ""},
                    {"", "", " ", " ", " ", " ", " ", " ", " ", ""},
                    {"", "", "", "", "", "", "", "", "", ""} },
    
    
                  { {"", "", "", "", "", "", "", "", "", " "},
                    {"", " ", " ", "", " ", " ", " ", " ", "", " "},
                    {"", " ", " ", "", " ", " ", " ", " ", "", " "},
                    {"", " ", " ", "", " ", " ", "", " ", "", " "},
                    {"", " ", "", " ", " ", " ", " ", " ", "", ""},
                    {"", " ", " ", " ", " ", " ", " ", " ", " ", ""},
                    {"", "", "", " ", " ", "", " ", " ", " ", ""},
                    {"", " ", " ", " ", " ", "", " ", " ", " ", ""},
                    {"", "", " ", " ", " ", "", " ", " ", " ", ""},
                    {"", "", "", "", "", "", "", "", "", ""} },
    
                  { {" ", " ", "", "", "", "", "", "", "", " "},
                    {" ", " ", "", " ", " ", " ", " ", " ", "", " "},
                    {" ", " ", "", " ", "", " ", " ", " ", "", " "},
                    {" ", " ", "", " ", " ", " ", " ", " ", "", " "},
                    {"", "", "", " ", " ", " ", "", " ", "", ""},
                    {"", " ", " ", " ", " ", " ", " ", " ", " ", ""},
                    {"", " ", " ", " ", " ", "", " ", " ", " ", ""},
                    {"", "", "", " ", " ", "", " ", " ", "", ""},
                    {"", " ", "", " ", " ", "", " ", "", " ", ""},
                    {"", "", "", "", "", "", "", "", "", ""} }
    
                };
                #endregion
    
    
                while (true)
                {
                    Console.Clear();
    
                    #region 打印地图
                    //打印地图
                    for (int i = 0; i <= 9; i++)
                    {
                        for (int j = 0; j <= 9; j++)
                        {
                            Console.Write(map[z, i, j]);
                        }
                        Console.WriteLine();
                    }
                    #endregion
    
                    if (map[z, end1y, end1x] == "")
                    {
                        Console.WriteLine("你赢了!!");
                        Console.WriteLine("按任意键进入下一关...");
                        Console.ReadKey();
    
    
                        int x1 = 1;
                        int y1 = 8;
    
    
                        while (true)
                        {
                            Console.Clear();
    
                            for (int i = 0; i <= 9; i++)
                            {
                                for (int j = 0; j <= 9; j++)
                                {
                                    Console.Write(map[z + 1, i, j]);
                                }
                                Console.WriteLine();
                            }
    
                            if (map[z + 1, end2y, end2x] == "")
                            {
                                Console.WriteLine("你赢了!!");
                                Console.WriteLine("按任意键进入下一关...");
                                Console.ReadKey();
                            }
    
    
                        ConsoleKeyInfo Key = Console.ReadKey();
    
                        #region 第二关向上
                        if (Key.Key.ToString() == "UpArrow")
                        {
                            if (map[z + 1, y1 - 1, x1] == "")
                            { }
                            else
                            {
                                if (map[z + 1, y1 - 1, x1] == "")
                                {
                                    if (map[z + 1, y1 - 2, x1] == "")
                                    { }
                                    else
                                    {
                                        if (map[z + 1, y1 - 2, x1] == "")
                                        {
                                            map[z + 1, y1 - 2, x1] = "";
                                            map[z + 1, y1 - 1, x1] = " ";
                                            string D = map[z + 1, y1, x1];
                                     map[z + 1, y1, x1] = map[z + 1, y1 - 1, x1];
                                            map[z + 1, y1 - 1, x1] = D;
                                            y1--;
                                        }
                                        else
                                        {
                                            string D = map[z + 1, y1 - 1, x1];
                                   map[z + 1, y1 - 1, x1] = map[z + 1, y1 - 2, x1];
                                            map[z + 1, y1 - 2, x1] = D;
                                            D = map[z + 1, y1, x1];
                                 map[z + 1, y1, x1] = map[z + 1, y1 - 1, x1];
                                            map[z + 1, y1 - 1, x1] = D;
                                            y1--;
    
                                        }
                                    }
                                }
                                else
                                {
                                    string D = map[z + 1, y1, x1];
                                    map[z + 1, y1, x1] = map[z + 1, y1 - 1, x1];
                                    map[z + 1, y1 - 1, x1] = D;
                                    y1--;
                                }
                            }
                        }
                        #endregion
    
                        #region 第二关向下
                        else if (Key.Key.ToString() == "DownArrow")
                        {
                            if (map[z + 1, y1 + 1, x1] == "")
                            { }
                            else
                            {
                                if (map[z + 1, y1 + 1, x1] == "")
                                {
                                    if (map[z + 1, y1 + 2, x1] == "")
                                    { }
                                    else
                                    {
                                        if (map[z + 1, y1 + 2, x1] == "")
                                        {
                                            map[z + 1, y1 + 2, x1] = "";
                                            map[z + 1, y1 + 1, x1] = " ";
                                            string D = map[z + 1, y1, x1];
                                map[z + 1, y1, x1] = map[z + 1, y1 + 1, x1];
                                            map[z + 1, y1 + 1, x1] = D;
                                            y1++;
                                        }
                                        else
                                        {
                                            string D = map[z + 1, y1 + 1, x1];
                       map[z + 1, y1 + 1, x1] = map[z + 1, y1 + 2, x1];
                                            map[z + 1, y1 + 2, x1] = D;
                                            D = map[z + 1, y1, x1];
                                    map[z + 1, y1, x1] = map[z + 1, y1 + 1, x1];
                                            map[z + 1, y1 + 1, x1] = D;
                                            y1++;
    
                                        }
                                    }
                                }
                                else
                                {
                                    string D = map[z + 1, y1, x1];
                                    map[z + 1, y1, x1] = map[z + 1, y1 + 1, x1];
                                    map[z + 1, y1 + 1, x1] = D;
                                    y1++;
                                }
                            }
                        }
                        #endregion
    
                        #region 第二关向左
                        else if (Key.Key.ToString() == "LeftArrow")
                        {
                            if (map[z + 1, y1, x1 - 1] == "")
                            { }
                            else
                            {
                                if (map[z + 1, y1, x1 - 1] == "")
                                {
                                    if (map[z + 1, y1, x1 - 2] == "")
                                    { }
                                    else
                                    {
                                        if (map[z + 1, y1, x1 - 2] == "")
                                        {
                                            map[z + 1, y1, x1 - 2] = "";
                                            map[z + 1, y1, x1 - 1] = " ";
                                            string D = map[z + 1, y1, x1];
                                       map[z + 1, y1, x1] = map[z + 1, y1, x1 - 1];
                                            map[z + 1, y1, x1 - 1] = D;
                                            x1--;
                                        }
                                        else
                                        {
                                            string D = map[z + 1, y1, x1 - 1];
                                map[z + 1, y1, x1 - 1] = map[z + 1, y1, x1 - 2];
                                            map[z + 1, y1, x1 - 2] = D;
                                            D = map[z + 1, y1, x1];
                                   map[z + 1, y1, x1] = map[z + 1, y1, x1 - 1];
                                            map[z + 1, y1, x1 - 1] = D;
                                            x1--;
    
                                        }
                                    }
                                }
                                else
                                {
                                    string D = map[z + 1, y1, x1];
                                    map[z + 1, y1, x1] = map[z + 1, y1, x1 - 1];
                                    map[z + 1, y1, x1 - 1] = D;
                                    x1--;
                                }
                            }
                        }
                        #endregion
    
                        #region 第二关向右
                        else if (Key.Key.ToString() == "RightArrow")
                        {
                            if (map[z + 1, y1, x1 + 1] == "")
                            { }
                            else
                            {
                                if (map[z + 1, y1, x1 + 1] == "")
                                {
                                    if (map[z + 1, y1, x1 + 2] == "")
                                    { }
                                    else
                                    {
                                        if (map[z + 1, y1, x1 + 2] == "")
                                        {
                                            map[z + 1, y1, x1 + 2] = "";
                                            map[z + 1, y1, x1 + 1] = " ";
                                            string D = map[z + 1, y1, x1];
                               map[z + 1, y1, x1] = map[z + 1, y1, x1 + 1];
                                            map[z + 1, y1, x1 + 1] = D;
                                            x1++;
                                        }
                                        else
                                        {
                                            string D = map[z + 1, y1, x1 + 1];
                                 map[z + 1, y1, x1 + 1] = map[z + 1, y1, x1 + 2];
                                            map[z + 1, y1, x1 + 2] = D;
                                            D = map[z + 1, y1, x1];
                                   map[z + 1, y1, x1] = map[z + 1, y1, x1 + 1];
                                            map[z + 1, y1, x1 + 1] = D;
                                            x1++;
    
                                        }
                                    }
                                }
                                else
                                {
                                    string D = map[z + 1, y1, x1];
                                    map[z + 1, y1, x1] = map[z + 1, y1, x1 + 1];
                                    map[z + 1, y1, x1 + 1] = D;
                                    x1++;
                                }
                            }
                        }
                        #endregion
    
                    }
                }
                ConsoleKeyInfo K = Console.ReadKey();
                #region 往上走
                //往上走
                if (K.Key.ToString() == "UpArrow")
                {
                    if (map[z, y - 1, x] == "")
                    { }
                    else
                    {
                        if (map[z, y - 1, x] == "")
                        {
                            if (map[z, y - 2, x] == "")
                            { }
                            else
                            {
                                if (map[z, y - 2, x] == "")
                                {
                                    map[z, y - 2, x] = "";
                                    map[z, y - 1, x] = " ";
                                    string D = map[z, y, x];
                                    map[z, y, x] = map[z, y - 1, x];
                                    map[z, y - 1, x] = D;
                                    y--;
                                }
                                else
                                {
                                    string D = map[z, y - 1, x];
                                    map[z, y - 1, x] = map[z, y - 2, x];
                                    map[z, y - 2, x] = D;
                                    D = map[z, y, x];
                                    map[z, y, x] = map[z, y - 1, x];
                                    map[z, y - 1, x] = D;
                                    y--;
    
                                }
                            }
                        }
                        else
                        {
                            string D = map[z, y, x];
                            map[z, y, x] = map[z, y - 1, x];
                            map[z, y - 1, x] = D;
                            y--;
                        }
                    }
                }
                #endregion
    
                #region 往下走
                //往下走
                else if (K.Key.ToString() == "DownArrow")
                {
                    if (map[z, y + 1, x] == "")
                    { }
                    else
                    {
                        if (map[z, y + 1, x] == "")
                        {
                            if (map[z, y + 2, x] == "")
                            { }
                            else
                            {
                                if (map[z, y + 2, x] == "")
                                {
                                    map[z, y + 2, x] = "";
                                    map[z, y + 1, x] = " ";
                                    string D = map[z, y, x];
                                    map[z, y, x] = map[z, y + 1, x];
                                    map[z, y + 1, x] = D;
                                    y++;
                                }
                                else
                                {
                                    string D = map[z, y + 1, x];
                                    map[z, y + 1, x] = map[z, y + 2, x];
                                    map[z, y + 2, x] = D;
                                    D = map[z, y, x];
                                    map[z, y, x] = map[z, y + 1, x];
                                    map[z, y + 1, x] = D;
                                    y++;
                                }
                            }
                        }
                        else
                        {
                            string D = map[z, y, x];
                            map[z, y, x] = map[z, y + 1, x];
                            map[z, y + 1, x] = D;
                            y++;
                        }
                    }
                }
                #endregion
    
                #region 往左走
                //往左走
                else if (K.Key.ToString() == "LeftArrow")
                {
                    if (map[z, y, x - 1] == "")
                    { }
                    else
                    {
                        if (map[z, y, x - 1] == "")
                        {
                            if (map[z, y, x - 2] == "")
                            { }
                            else
                            {
                                if (map[z, y, x - 2] == "")
                                {
                                    map[z, y, x - 2] = "";
                                    map[z, y, x - 1] = " ";
                                    string D = map[z, y, x];
                                    map[z, y, x] = map[z, y, x - 1];
                                    map[z, y, x - 1] = D;
                                    x--;
                                }
                                else
                                {
                                    string D = map[z, y, x - 1];
                                    map[z, y, x - 1] = map[z, y, x - 2];
                                    map[z, y, x - 2] = D;
                                    D = map[z, y, x];
                                    map[z, y, x] = map[z, y, x - 1];
                                    map[z, y, x - 1] = D;
                                    x--;
                                }
                            }
                        }
                        else
                        {
                            string D = map[z, y, x];
                            map[z, y, x] = map[z, y, x - 1];
                            map[z, y, x - 1] = D;
                            x--;
                        }
    
                    }
                }
                #endregion
    
                #region 往右走
                //往右走
                else if (K.Key.ToString() == "RightArrow")
                {
                    if (map[z, y, x + 1] == "")
                    { }
                    else
                    {
                        if (map[z, y, x + 1] == "")
                        {
                            if (map[z, y, x + 2] == "")
                            { }
                            else
                            {
                                if (map[z, y, x + 2] == "")
                                {
                                    map[z, y, x + 2] = "";
                                    map[z, y, x + 1] = " ";
                                    string D = map[z, y, x];
                                    map[z, y, x] = map[z, y, x + 1];
                                    map[z, y, x + 1] = D;
                                    x++;
                                }
                                else
                                {
                                    string D = map[z, y, x + 1];
                                    map[z, y, x + 1] = map[z, y, x + 2];
                                    map[z, y, x + 2] = D;
                                    D = map[z, y, x];
                                    map[z, y, x] = map[z, y, x + 1];
                                    map[z, y, x + 1] = D;
                                    x++;
                                }
                            }
                        }
                        else
                        {
                            string D = map[z, y, x];
                            map[z, y, x] = map[z, y, x + 1];
                            map[z, y, x + 1] = D;
                            x++;
                        }
    
                    }
                }
            }
            #endregion
        }
    }

    对战游戏

        class Program
        {
            public struct ChengXiang // 创建
            {
                public string name;
                public int shanghai;
                public int xueliang;
                public int minjie;
            }
            public struct JiNeng // 技能
            {
                public string name;
                public double shanghai;
            }
            public struct ZhuangBei//装备
            {
                public string name;
                public int GongJi;
            }
    
            public struct ZhiLiao
            {
                public string name;
                public int HP;
            }
            public struct HuJia
            {
                public string name;
                public int hj;
            }
    
            static void Main(string[] args)
            {
                Random RA = new Random();
    
    
    
                #region  装备
                ArrayList ZB = new ArrayList();
                ZhuangBei ZB1 = new ZhuangBei
                {
                    name = "青龙偃月刀",
                    GongJi = 200
                };
                ZhuangBei ZB2 = new ZhuangBei
                {
                    name = "阴阳剑",
                    GongJi = 100
                };
                ZhuangBei ZB3 = new ZhuangBei
                {
                    name = "八丈矛",
                    GongJi = 150
                };
                ZhuangBei ZB4 = new ZhuangBei
                {
                    name = "峨眉玄孤刺",
                    GongJi = 130
                };
                ZhuangBei ZB5 = new ZhuangBei
                {
                    name = "凤翅镏金镋",
                    GongJi = 210
                };
                ZhuangBei ZB6 = new ZhuangBei
                {
                    name = "方天画戟",
                    GongJi = 220
                };
                ZhuangBei ZB7 = new ZhuangBei
                {
                    name = "鑗斧",
                    GongJi = 300
                };
                ZB.Add(ZB1);
                ZB.Add(ZB2);
                ZB.Add(ZB3);
                ZB.Add(ZB4);
                ZB.Add(ZB5);
                ZB.Add(ZB6);
                ZB.Add(ZB7);
    
                #endregion
    
    
                #region 护甲装
                ArrayList HJZ = new ArrayList();
                HuJia HJ1 = new HuJia
                {
                    name = "锁子甲",
                    hj = 200
                };
                HuJia HJ2 = new HuJia
                {
                    name = "木甲",
                    hj = 210
                };
                HuJia HJ3 = new HuJia
                {
                    name = "宣纸甲",
                    hj = 300
                };
                HJZ.Add(HJ1);
                HJZ.Add(HJ2);
                HJZ.Add(HJ3);
                #endregion
    
    
                #region  技能
                ArrayList JiNenga = new ArrayList();
                JiNeng JN1 = new JiNeng();
                JN1.name = "天外飞仙";
                JN1.shanghai = 2;
                JiNeng JN2 = new JiNeng();
                JN2.name = "无影腿";
                JN2.shanghai = 2;
                JiNeng JN3 = new JiNeng();
                JN3.name = "九阴白骨爪";
                JN3.shanghai = 2.5;
                JiNeng JN4 = new JiNeng();
                JN4.name = "蛤蟆功";
                JN4.shanghai = 3;
                JiNeng JN5 = new JiNeng();
                JN5.name = "圆舞斩";
                JN5.shanghai = 3.8;
                JiNeng JN6 = new JiNeng();
                JN6.name = "六脉神剑";
                JN6.shanghai = 4.2;
                JiNenga.Add(JN1);
                JiNenga.Add(JN2);
                JiNenga.Add(JN3);
                JiNenga.Add(JN4);
                JiNenga.Add(JN5);
                JiNenga.Add(JN6);
    
                #endregion
    
    
                #region 治疗
                ArrayList ZL = new ArrayList();
                ZhiLiao ZL1 = new ZhiLiao
                {
                    name = "回天术",
                    HP = 150
                };
                ZhiLiao ZL2 = new ZhiLiao
                {
                    name = "冲虚养气",
                    HP = 260
                };
                ZhiLiao ZL3 = new ZhiLiao
                {
                    name = "春花秋月",
                    HP = 360
                };
    
                ZL.Add(ZL1);
                ZL.Add(ZL2);
                ZL.Add(ZL3);
    
    
    
                #endregion
    
    
                #region  创建人物
                ChengXiang CX1 = new ChengXiang();
                Console.Write("请输入第一个丞相的名称:");
                CX1.name = Console.ReadLine();
    
    
    
                CX1.minjie = RA.Next(10, 101);
                CX1.shanghai = RA.Next(100, 301);
                CX1.xueliang = RA.Next(3000, 5401);
                int zhuangb = RA.Next(1, 101);
                int hujia = RA.Next(1, 101);
                if(hujia <= 40)
                {
                    Console.WriteLine(CX1.name + "获得了护甲:" + HJ3.name);
                    HJ3.hj += CX1.xueliang;
    
                }else if (hujia <= 50)
                {
                    Console.WriteLine(CX1.name + "获得了护甲:" + HJ2.name);
                    HJ2.hj += CX1.xueliang;
                }else if (hujia <= 80)
                {
                    Console.WriteLine(CX1.name + "获得了护甲:" + HJ1.name);
                    HJ1.hj += CX1.xueliang;
                }
                else
                {
                    Console.WriteLine("运气真差!");
                }
    
    
    
    
                if (zhuangb <= 10)
                {
                    Console.WriteLine(CX1.name + "获得了武器:" + ZB7.name);
                    ZB7.GongJi += CX1.shanghai;
    
                }
                else if (zhuangb <= 20)
                {
                    Console.WriteLine(CX1.name + "获得了武器:" + ZB6.name);
                    ZB6.GongJi += CX1.shanghai;
                }
                else if (zhuangb <= 40)
                {
                    Console.WriteLine(CX1.name + "获得了武器:" + ZB5.name);
                    ZB5.GongJi += CX1.shanghai;
                }
                else if (zhuangb <= 50)
                {
                    Console.WriteLine(CX1.name + "获得了武器:" + ZB1.name);
                    ZB1.GongJi += CX1.shanghai;
                }
                else if (zhuangb <= 60)
                {
                    Console.WriteLine(CX1.name + "获得了武器:" + ZB4.name);
                    ZB4.GongJi += CX1.shanghai;
                }
                else if (zhuangb <= 70)
                {
                    Console.WriteLine(CX1.name + "获得了武器:" + ZB3.name);
                    ZB3.GongJi += CX1.shanghai;
                }
                else if (zhuangb <= 80)
                {
                    Console.WriteLine(CX1.name + "获得了武器:" + ZB2.name);
                    ZB2.GongJi += CX1.shanghai;
                }
                else
                {
                    Console.WriteLine("哈哈哈,啥都没有");
                }
    
                Console.WriteLine("丞相的名字为:" + CX1.name + " " + "攻击力为:" + CX1.shanghai + " " + "血量为:" + CX1.xueliang + "敏捷为:" + CX1.minjie);
    
    
    
    
    
                //第二个丞相
                ChengXiang CX2 = new ChengXiang();
                Console.Write("请输入第二个丞相的名称:");
                CX2.name = Console.ReadLine();
    
    
                CX2.minjie = RA.Next(10, 101);
                CX2.shanghai = RA.Next(100, 301);
                CX2.xueliang = RA.Next(3000, 5401);
                int zhuangb1 = RA.Next(1, 101);
                int hujia1 = RA.Next(1, 101);
                if (hujia1 <= 40)
                {
                    Console.WriteLine(CX2.name + "获得了护甲:" + HJ3.name);
                    HJ3.hj += CX2.xueliang;
    
                }
                else if (hujia1 <= 50)
                {
                    Console.WriteLine(CX2.name + "获得了护甲:" + HJ2.name);
                    HJ2.hj += CX2.xueliang;
                }
                else if (hujia1 <= 80)
                {
                    Console.WriteLine(CX2.name + "获得了护甲:" + HJ1.name);
                    HJ1.hj += CX2.xueliang;
                }
                else
                {
                    Console.WriteLine("运气真差!");
                }
    
    
                if (zhuangb1 <= 10)
                {
                    Console.WriteLine(CX2.name + "获得了武器:" + ZB7.name);
                    ZB7.GongJi += CX2.shanghai;
    
                }
                else if (zhuangb1 <= 20)
                {
                    Console.WriteLine(CX2.name + "获得了武器:" + ZB6.name);
                    ZB6.GongJi += CX2.shanghai;
                }
                else if (zhuangb1 <= 40)
                {
                    Console.WriteLine(CX2.name + "获得了武器:" + ZB5.name);
                    ZB5.GongJi += CX2.shanghai;
                }
                else if (zhuangb1 <= 50)
                {
                    Console.WriteLine(CX2.name + "获得了武器:" + ZB1.name);
                    ZB1.GongJi += CX2.shanghai;
                }
                else if (zhuangb1 <= 60)
                {
                    Console.WriteLine(CX2.name + "获得了武器:" + ZB4.name);
                    ZB4.GongJi += CX2.shanghai;
                }
                else if (zhuangb1 <= 70)
                {
                    Console.WriteLine(CX2.name + "获得了武器:" + ZB3.name);
                    ZB3.GongJi += CX2.shanghai;
                }
                else if (zhuangb1 <= 80)
                {
                    Console.WriteLine(CX2.name + "获得了武器:" + ZB2.name);
                    ZB2.GongJi += CX2.shanghai;
                }
                else
                {
                    Console.WriteLine("哈哈哈,啥都没有");
                }
                Console.WriteLine("丞相的名字为:" + CX2.name + " " + "攻击力为:" + CX2.shanghai + " " + "血量为:" + CX2.xueliang + "敏捷为:" + CX2.minjie);
                Console.WriteLine("请按任意键开始游戏");
                Console.ReadKey();
    
                #endregion
    
    
                #region  对战
                while (true)
                {
    
                    Console.ForegroundColor = ConsoleColor.White;
                    //对战第一个
    
                    if (CX1.minjie > CX2.minjie)
                    {
                        for (var s = 0; s <= RA.Next(0, 2); s++)
                        {
                            int zhil = RA.Next(1, 11);
                            int gongji = 0;
                            int FDZ = RA.Next(1, 11);
    
    
                            if (FDZ <= 3)
                            {
                                JiNeng DZ = (JiNeng)JiNenga[RA.Next(0, JiNenga.Count)];
                                gongji = Convert.ToInt32(Program.GJ(CX1.shanghai) * DZ.shanghai);
                                CX2.xueliang = CX2.xueliang - gongji;
    
                                Console.ForegroundColor = ConsoleColor.Red;
    Console.WriteLine(CX1.name + "发动了" + "〓〓〓〓" + DZ.name + "〓〓〓〓" + "打了" + gongji + "的伤害," + CX2.name + "剩余血量" + CX2.xueliang + "滴血");
    
    
                                Console.WriteLine();
                                System.Threading.Thread.Sleep(1000);
                            }
                            else
                            {
                                Console.ForegroundColor = ConsoleColor.Green;
                                if (zhil <= 2)
                                {
                                    Console.WriteLine(CX1.name + "发动了" + ZL3.name +" "+ "剩余血量:" + CX1.xueliang + "滴血");
                                    ZL3.HP += CX1.xueliang;
                                }
                                else if (zhil <= 3)
                                {
                                    Console.WriteLine(CX1.name + "发动了" + ZL2.name + " " + "剩余血量:" + CX1.xueliang + "滴血");
                                    ZL2.HP += CX1.xueliang;
                                }
                                else if (zhil <= 5)
                                {
                                    Console.WriteLine(CX1.name + "发动了" + ZL1.name + " " + "剩余血量:" + CX1.xueliang + "滴血");
                                    ZL1.HP += CX1.xueliang;
                                }
    
                                Console.WriteLine();
    
    
                                Console.ForegroundColor = ConsoleColor.White;
                                gongji = GJ(CX1.shanghai);
                                CX2.xueliang = CX2.xueliang - gongji;
                                Console.WriteLine(CX1.name + "发动了普通攻击,打了" + gongji + "的伤害," + CX2.name + "剩余血量" + CX2.xueliang + "滴血");
    
                                Console.WriteLine();
                                System.Threading.Thread.Sleep(1000);
                            }
    
                        }
    
                        //对战第二个
                        int zhil1 = RA.Next(1, 11);
                        int gongji1 = 0;
                        int FDZ1 = RA.Next(1, 11);
                        if (FDZ1 <= 3)
                        {
                            JiNeng DZ = (JiNeng)JiNenga[RA.Next(0, JiNenga.Count)];
                            gongji1 = Convert.ToInt32(Program.GJ(CX2.shanghai) * DZ.shanghai);
                            CX1.xueliang = CX1.xueliang - gongji1;
    
    
                            Console.ForegroundColor = ConsoleColor.Blue;
    Console.WriteLine(CX2.name + "发动了" + "〓〓〓〓" + DZ.name + "〓〓〓〓" + "打了" + gongji1 + "的伤害," + CX1.name + "剩余血量" + CX1.xueliang + "滴血");
    
    
                            Console.WriteLine();
                            System.Threading.Thread.Sleep(1000);
                        }
                        else
                        {
                            Console.ForegroundColor = ConsoleColor.Green;
                            if (zhil1 <= 2)
                            {
                                Console.WriteLine(CX2.name + "发动了" + ZL3.name + " " + "剩余血量:" + CX2.xueliang + "滴血");
                                ZL3.HP += CX2.xueliang;
                            }
                            else if (zhil1 <= 3)
                            {
                                Console.WriteLine(CX2.name + "发动了" + ZL2.name + " " + "剩余血量:" + CX2.xueliang + "滴血");
                                ZL2.HP += CX2.xueliang;
                            }
                            else if (zhil1 <= 5)
                            {
                                Console.WriteLine(CX2.name + "发动了" + ZL1.name + " " + "剩余血量:" + CX2.xueliang + "滴血");
                                ZL1.HP += CX2.xueliang;
                            }
    
                            Console.WriteLine();
    
                            Console.ForegroundColor = ConsoleColor.White;
                            gongji1 = Program.GJ(CX2.shanghai);
                            CX1.xueliang = CX1.xueliang - gongji1;
                            Console.WriteLine(CX2.name + "发动了普通攻击,打了" + gongji1 + "的伤害," + CX1.name + "剩余血量" + CX1.xueliang + "滴血");
    
                            Console.WriteLine();
                            System.Threading.Thread.Sleep(1000);
                        }
    
                    }
    
    
    
    
    
                    else
                    {
                        for (var s = 0; s <= RA.Next(0, 2); s++)
                        {
                            int zhil = RA.Next(1, 11);
                            int gongji = 0;
                            int FDZ = RA.Next(1, 11);
                            if (FDZ <= 3)
                            {
                                JiNeng DZ = (JiNeng)JiNenga[RA.Next(0, JiNenga.Count)];
                                gongji = Convert.ToInt32(Program.GJ(CX2.shanghai) * DZ.shanghai);
                                CX1.xueliang = CX1.xueliang - gongji;
    
    
                                Console.ForegroundColor = ConsoleColor.Red;
     Console.WriteLine(CX2.name + "发动了" + "〓〓〓〓" + DZ.name + "〓〓〓〓" + "打了" + gongji + "的伤害," + CX1.name + "剩余血量" + CX1.xueliang + "滴血");
    
                                Console.WriteLine();
                                System.Threading.Thread.Sleep(1000);
                            }
                            else
                            {
                                Console.ForegroundColor = ConsoleColor.Green;
                                if (zhil <= 2)
                                {
                                    Console.WriteLine(CX1.name + "发动了" + ZL3.name + " " + "剩余血量:" + CX1.xueliang + "滴血");
                                    ZL3.HP += CX1.xueliang;
                                }
                                else if (zhil <= 3)
                                {
                                    Console.WriteLine(CX2.name + "发动了" + ZL2.name + " " + "剩余血量:" + CX1.xueliang + "滴血");
                                    ZL2.HP += CX1.xueliang;
                                }
                                else if (zhil <= 5)
                                {
                                    Console.WriteLine(CX2.name + "发动了" + ZL1.name + " " + "剩余血量:" + CX1.xueliang + "滴血");
                                    ZL1.HP += CX1.xueliang;
                                }
    
                                Console.WriteLine();
    
    
                                gongji = GJ(CX2.shanghai);
                                CX2.xueliang = CX2.xueliang - gongji;
    
    
                                Console.ForegroundColor = ConsoleColor.White;
                                Console.WriteLine(CX2.name + "发动了普通攻击,打了" + gongji + "的伤害," + CX1.name + "剩余血量" + CX1.xueliang + "滴血");
    
                                Console.WriteLine();
                                System.Threading.Thread.Sleep(1000);
                            }
    
                        }
    
                        //对战第二个
                        int zhil1 = RA.Next(1, 11);
                        int gongji1 = 0;
                        int FDZ1 = RA.Next(1, 11);
                        if (FDZ1 <= 3)
                        {
                            JiNeng DZ = (JiNeng)JiNenga[RA.Next(0, JiNenga.Count)];
                            gongji1 = Convert.ToInt32(Program.GJ(CX1.shanghai) * DZ.shanghai);
                            CX2.xueliang = CX2.xueliang - gongji1;
                            Console.ForegroundColor = ConsoleColor.Blue;
    Console.WriteLine(CX1.name + "发动了" + "〓〓〓〓" + DZ.name + "〓〓〓〓" + "打了" + gongji1 + "的伤害," + CX2.name + "剩余血量" + CX2.xueliang + "滴血");
    
    
                            Console.WriteLine();
                            System.Threading.Thread.Sleep(1000);
                        }
                        else
                        {
                            Console.ForegroundColor = ConsoleColor.Green;
                            if (zhil1 <= 2)
                            {
                                Console.WriteLine(CX2.name + "发动了" + ZL3.name + " " + "剩余血量:" + CX2.xueliang + "滴血");
                                ZL3.HP += CX2.xueliang;
                            }
                            else if (zhil1 <= 3)
                            {
                                Console.WriteLine(CX2.name + "发动了" + ZL2.name + " " + "剩余血量:" + CX2.xueliang + "滴血");
                                ZL2.HP += CX2.xueliang;
                            }
                            else if (zhil1 <= 5)
                            {
                                Console.WriteLine(CX2.name + "发动了" + ZL1.name + " " + "剩余血量:" + CX2.xueliang + "滴血");
                                ZL1.HP += CX2.xueliang;
                            }
    
                            Console.WriteLine();
    
                            Console.ForegroundColor = ConsoleColor.White;
                            gongji1 = Program.GJ(CX1.shanghai);
                            CX2.xueliang = CX2.xueliang - gongji1;
    Console.WriteLine(CX1.name + "发动了普通攻击,打了" + gongji1 + "的伤害," + CX2.name + "剩余血量" + CX2.xueliang + "滴血");
    
                            Console.WriteLine();
                            System.Threading.Thread.Sleep(1000);
                        }
                    }
    
    
    
                    //开始对战
                    Console.ForegroundColor = ConsoleColor.White;
                    if (CX1.xueliang <= 0 || CX2.xueliang <= 0)
                    {
                        if (CX1.xueliang <= 0 && CX2.xueliang <= 0)
                        {
                            Console.WriteLine("GM发动大招同归于尽!!");
                        }
                        else
                        {
                            if (CX2.xueliang <= 0)
                            {
                                Console.WriteLine("恭喜" + CX1.name + "取胜");
                            }
                            else
                            {
                                Console.WriteLine("恭喜" + CX2.name + "取胜");
                            }
                        }
                        break;
                    }
    
                }
                Console.ReadKey();
            }
            #endregion
    
    
    
            #region   随机攻击力浮动
            /// <summary>
            /// 随机攻击力
            /// </summary>
            /// <param name="sh">攻击力浮动</param>
            /// <returns></returns>
    
            public static int GJ(int sh)
            {
                int a = 0;
                Random r = new Random();
                int b = r.Next(0, 80);
                int c = r.Next(0, 2);
                if (c == 0)
                {
                    a = sh + b;
                }
                else
                {
                    a = sh - b;
                }
                return a;
    
            }
            #endregion
    
    
    
        }
  • 相关阅读:
    [Taro] 解决 使用 Taro UI 小程序下 Iconfont 图标 不显示问题
    [Taro] Taro 环境安装 (一)
    [RN] react-native FlatList 实现列表选中的最佳方式(刷新指定Item)
    [RN] React Native FlatList 选中后 状态没有立即发生改变,而在下一次生效的问题
    [RN] React Native 使用 Redux 比较详细和深刻的教程
    [Taro] taro 缓存
    个人总结第十五周
    个人总结第十四周
    个人总结第十三周
    个人总结第十二周
  • 原文地址:https://www.cnblogs.com/zJuevers/p/7811396.html
Copyright © 2011-2022 走看看