• 黑马程序员国字飞行棋


                             ------------------ Windows Phones 7手机开发.Net培训、期待与您交流! ----------------------
    
     
     
    View Code
      1 class Program
      2     {
      3         public static int[] Map = new int[305];
      4         public static int[] PlayerPos = new int[] { 1, 1 };
      5         public static string[] PlayerName = new string[2];
      6         public static bool[] result = new bool[2] { false, false };
      7         static void Main(string[] args)
      8         {
      9             string YesOrNo = "";
     10             do
     11             {
     12                // UI显示
     13                   showUi();
     14                // 判断玩家姓名:
     15                   DecidePlayerName();
     16                   Console.ReadKey();
     17                   Console.Clear();
     18                // 选择关卡
     19                   string msg = "请输入难度等级:";
     20                   CustomsPass(ReadInt(msg, 1, 6));
     21 
     22                 //画地图
     23                   DrawMap();
     24                // 玩家行动了
     25                   PlayerActSequence();
     26                 Console.WriteLine("您想要再来一局吗?(y/n)");
     27                 YesOrNo = Console.ReadLine();
     28                 if (YesOrNo.Equals("n", StringComparison.OrdinalIgnoreCase))
     29                 {
     30                     break;
     31                 }
     32 
     33             } while (true);
     34             Console.WriteLine("谢谢!");
     35             Console.ReadKey();
     36         }
     37 
     38         /// <summary>
     39         /// UI界面显示
     40         /// </summary>
     41         public static void showUi()
     42         {
     43             #region 符号
     44 
     45 
     46             /*Н О П Р С Т У Ф Х Ц Ч Ш Щ Ъ Ы Ь Э Ю Я а б в г д е ж з и й к л м н о п р с т у ф х ц ч ш щ ъ ы ь э ю я ё‐ – — ― ‖ ‘ ’ “ ” ‥ … ‰ ′ ″ ‵ ※  ̄ € ℃ ℅ ℉ № ℡ Ⅰ Ⅱ Ⅲ Ⅳ Ⅴ Ⅵ Ⅶ Ⅷ Ⅸ Ⅹ Ⅺ Ⅻ ⅰ ⅱ ⅲ ⅳ ⅴ ⅵ ⅶ ⅷ ⅸ ⅹ ← ↑ → ↓ ↖ ↗ ↘ ↙ ∈ ∏ ∑ ∕ ° √ ∝ ∞ ∟ ∠ ∣ ∥ ∧ ∨ ∩ ∪ ∫ ∮ ∴ ∵ ∶ ∷ ~ ∽ ≈ ≌ ≒ ≠ ≡ ≤ ≥ ≦ ≧ ≮ ≯ ⊕ ⊙ ⊥ ⊿ ⌒ ① ② ③ ④ ⑤ ⑥ ⑦ ⑧ ⑨ ⑩ ⑴ ⑵ ⑶ ⑷ ⑸ ⑹ ⑺ ⑻ ⑼ ⑽ ⑾ ⑿ ⒀ ⒁ ⒂ ⒃ ⒄ ⒅ ⒆ ⒇ ⒈ ⒉ ⒊ ⒋ ⒌ ⒍ ⒎ ⒏ ⒐ ⒑ ⒒ ⒓ ⒔ ⒕ ⒖ ⒗ ⒘ ⒙ ⒚ ⒛ ─ ━ │ ┃ ┄ ┅ ┆ ┇ ┈ ┉ ┊ ┋ ┌ ┍ ┎ ┏ ┐ ┑ ┒ ┓ └ ┕ ┖ ┗ ┘ ┙ ┚ ┛ ├ ┝ ┞ ┟ ┠ ┡ ┢ ┣ ┤ ┥ ┦ ┧ ┨ ┩ ┪ ┫ ┬ ┭ ┮ ┯ ┰ ┱ ┲ ┳ ┴ ┵ ┶ ┷ ┸ ┹ ┺ ┻ ┼ ┽ ┾ ┿ ╀ ╁ ╂ ╃ ╄ ╅ ╆ ╇ ╈ ╉ ╊ ╋ ═ ║ ╒ ╓ ╔ ╕ ╖ ╗ ╘ ╙ ╚ ╛ ╜ ╝ ╞ ╟ ╠ ╡ ╢ ╣ ╤ ╥ ╦ ╧ ╨ ╩ ╪ ╫ ╬ ╭ ╮ ╯ ╰ ╱ ╲ ╳ ▁ ▂ ▃ ▄ ▅ ▆ ▇ █ ▉ ▊ ▋ ▌ ▍ ▎ ▏ ▓ ▔ ▕ ■ □ ▲ △ ▼ ▽ ◆ ◇ ○ ◎ ● ◢ ◣ ◤ ◥ ★ ☆ ☉ ♀ ♂、 。 〃 々 〆 〇 〈 〉 《 》 「 」 『 』 【 】 〒 〓 〔 〕 〖 〗 〝 〞 〡 〢 〣 〤 〥 〦 〧 〨 〩 ぁ あ ぃ い ぅ う ぇ え ぉ お か が き ぎ く ぐ け げ こ ご さ ざ し じ す ず せ ぜ そ ぞ た だ ち ぢ っ つ づ て で と ど な に ぬ ね の は ば ぱ ひ び ぴ ふ ぶ ぷ へ べ ぺ ほ ぼ ぽ ま み む め も ゃ や ゅ ゆ ょ よ ら り る れ ろ ゎ わ ゐ ゑ を ん ゛ ゜ ゝ ゞ ァ ア ィ イ ゥ ウ ェ エ ォ オ カ ガ キ ギ ク グ ケ ゲ コ ゴ サ ザ シ ジ ス ズ セ ゼ ソ ゾ タ ダ チ ヂ ッ ツ ヅ テ デ ト ド ナ ニ ヌ ネ ノ ハ バ パ ヒ ビ ピ フ ブ プ ヘ ベ ペ ホ ボ ポ マ ミ ム メ モ ャ ヤ ュ ユ ョ ヨ ラ リ ル レ ロ ヮ ワ ヰ ヱ ヲ ン ヴ ヵ ヶ ー ヽ ヾ ㄅ ㄆ ㄇ ㄈ ㄉ ㄊ ㄋ ㄌ ㄍ ㄎ ㄏ ㄐ ㄑ ㄒ ㄓ ㄔ ㄕ ㄖ ㄗ ㄘ ㄙ ㄚ ㄛ ㄜ ㄝ ㄞ ㄟ ㄠ ㄡ ㄢ ㄣ ㄤ ㄥ ㄦ ㄧ ㄨ ㄩ ㈠ ㈡ ㈢ ㈣ ㈤ ㈥ ㈦ ㈧ ㈨ ㈩ ㈱ ㊣ ㎎ ㎏ ㎜ ㎝ ㎞ ㎡ ㏄ ㏎ ㏑ ㏒ ㏕                                         ︰ ︱ ︳ ︴ ︵ ︶ ︷ ︸ ︹ ︺ ︻ ︼ ︽ ︾ ︿ ﹀ ﹁ ﹂ ﹃ ﹄ ﹉
     47                  * */
     48             #endregion
     49             Console.WriteLine(@"┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓");
     50             Console.WriteLine(@"┃                           简简单单丶小生活                               ┃");
     51             Console.WriteLine(@"┃ ╔═══════════════╗ ╔═════════════════╗┃");
     52             Console.WriteLine(@"┃ ║ */.    .   .    *   房子  .  ║ ║             看日出               ║┃");
     53             Console.WriteLine(@"┃ ║ .\*    .    []            *__║ ║  ﹎ ┈ ┈ .o┈ ﹎  ﹎.. ○       ║┃");
     54             Console.WriteLine(@"┃ ║ */ .   ./\~~~~~~~~~~~~'\. |◆║ ║  ﹎┈﹎ ●  ○ .﹎ ﹎o▂▃▅▆   ║┃");
     55             Console.WriteLine(@"┃ ║ \*   ,/,..,\,...........,\.◆║ ║  ┈ ┈ /█\/▓\ ﹎ ┈ ﹎﹎ ┈﹎  ║┃");
     56             Console.WriteLine(@"┃ ║ ||  ..▎#  ▎田  田 ▎ | ▎◆║ ║ ▅▆▇█████▇▆▅▃▂┈﹎   ║┃");
     57             Console.WriteLine(@"┃ ║ ||  &&▎   ▎       ▎'|'▎ o║ ║ ██████████████▅▃ ║┃");
     58             Console.WriteLine(@"┃ ║ ||  ##■■■■■■■■■〓   ║ ║                                  ║┃");
     59             Console.WriteLine(@"┃ ╚═══════════════╝ ╚═════════════════╝┃");
     60             Console.WriteLine(@"┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛");
     61         }
     62         /// <summary>
     63         /// 玩家行动顺序
     64         /// </summary>
     65         public static void PlayerActSequence()
     66         {
     67             while (true)
     68             {
     69                 if (PlayerPos[0] < 305 && PlayerPos[1] < 305)
     70                 {
     71                     PlayerAct(0);
     72                 }
     73                 else
     74                 {
     75                     result[0] = false;
     76                 }
     77                 if (PlayerPos[0] == 305)
     78                 {
     79                     Console.Clear();
     80                     Win();
     81                     break;
     82                 }
     83                 if (PlayerPos[1] == 305)
     84                 {
     85                     Console.Clear();
     86                     Win();
     87                     break;
     88                 }
     89                 if (result[1] == false)
     90                 {
     91                     PlayerAct(1);
     92                 }
     93                 else
     94                 {
     95                     result[1] = false;
     96                 }
     97             }
     98         }
     99         /// <summary>
    100         /// 胜利图案
    101         /// </summary>
    102         public static void Win()
    103         {
    104             Console.WriteLine(@"┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓");
    105             Console.WriteLine(@"┃                           简简单单丶小生活                               ┃");
    106             Console.WriteLine(@"┃ ╔═══════════════╗ ╔═════════════════╗┃");
    107             Console.WriteLine(@"┃ ║ */.    .   .    *   房子  .  ║ ║             看日出               ║┃");
    108             Console.WriteLine(@"┃ ║ .\*    .    []            *__║ ║  ﹎ ┈ ┈ .o┈ ﹎  ﹎.. ○       ║┃");
    109             Console.WriteLine(@"┃ ║ */ .   ./\~~~~~~~~~~~~'\. |◆║ ║  ﹎┈﹎ ●  ○ .﹎ ﹎o▂▃▅▆   ║┃");
    110             Console.WriteLine(@"┃ ║ \*   ,/,..,\,...........,\.◆║ ║  ┈ ┈ /█\/▓\ ﹎ ┈ ﹎﹎ ┈﹎  ║┃");
    111             Console.WriteLine(@"┃ ║ ||  ..▎#  ▎田  田 ▎ | ▎◆║ ║ ▅▆▇█████▇▆▅▃▂┈﹎   ║┃");
    112             Console.WriteLine(@"┃ ║ ||  &&▎   ▎       ▎'|'▎ o║ ║ ██████████████▅▃ ║┃");
    113             Console.WriteLine(@"┃ ║ ||  ##■■■■■■■■■〓   ║ ║                                  ║┃");
    114             Console.WriteLine(@"┃ ╚═══════════════╝ ╚═════════════════╝┃");
    115             Console.WriteLine(@"┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛");
    116         }
    117         /// <summary>
    118         /// 玩家行动方法
    119         /// </summary>
    120         /// <param name="playerNumber">玩家代码坐标</param>
    121         public static void PlayerAct(int playerNumber)
    122         {
    123 
    124             string temp = "";
    125             Console.ForegroundColor = ConsoleColor.Green;
    126             Console.WriteLine("按任意键玩家{0}开始掷骰子...", PlayerName[playerNumber]);
    127             Random r = new Random();
    128             int num = r.Next(1, 7);
    129             ConsoleKeyInfo key = Console.ReadKey(true);
    130             #region 特殊代码
    131             if (key.Key == ConsoleKey.X)
    132             {
    133                 key = Console.ReadKey(true);
    134                 if (key.Key == ConsoleKey.I)
    135                 {
    136                     key = Console.ReadKey(true);
    137                     if (key.Key == ConsoleKey.A)
    138                     {
    139                         key = Console.ReadKey(true);
    140                         if (key.Key == ConsoleKey.O)
    141                         {
    142                             key = Console.ReadKey(true);
    143                             if (key.Key == ConsoleKey.Y)
    144                             {
    145                                 key = Console.ReadKey(true);
    146                                 if (key.Key == ConsoleKey.A)
    147                                 {
    148                                     key = Console.ReadKey(true);
    149                                     if (key.Key == ConsoleKey.N)
    150                                     {
    151                                         key = Console.ReadKey(true);
    152                                         if (key.Key == ConsoleKey.G)
    153                                         {
    154                                             key = Console.ReadKey(true);
    155                                             if (key.Key == ConsoleKey.S)
    156                                             {
    157                                                 key = Console.ReadKey(true);
    158                                                 if (key.Key == ConsoleKey.H)
    159                                                 {
    160                                                     key = Console.ReadKey(true);
    161                                                     if (key.Key == ConsoleKey.I)
    162                                                     {
    163                                                         key = Console.ReadKey(true);
    164                                                         if (key.Key == ConsoleKey.Z)
    165                                                         {
    166                                                             key = Console.ReadKey(true);
    167                                                             if (key.Key == ConsoleKey.U)
    168                                                             {
    169                                                                 key = Console.ReadKey(true);
    170                                                                 if (key.Key == ConsoleKey.I)
    171                                                                 {
    172                                                                     key = Console.ReadKey(true);
    173                                                                     if (key.Key == ConsoleKey.C)
    174                                                                     {
    175                                                                         key = Console.ReadKey(true);
    176                                                                         if (key.Key == ConsoleKey.H)
    177                                                                         {
    178                                                                             key = Console.ReadKey(true);
    179                                                                             if (key.Key == ConsoleKey.U)
    180                                                                             {
    181                                                                                 key = Console.ReadKey(true);
    182                                                                                 if (key.Key == ConsoleKey.N)
    183                                                                                 {
    184                                                                                     key = Console.ReadKey(true);
    185                                                                                     if (key.Key == ConsoleKey.J)
    186                                                                                     {
    187                                                                                         key = Console.ReadKey(true);
    188                                                                                         if (key.Key == ConsoleKey.I)
    189                                                                                         {
    190                                                                                             key = Console.ReadKey(true);
    191                                                                                             if (key.Key == ConsoleKey.E)
    192                                                                                             {
    193                                                                                                 key = Console.ReadKey(true);
    194                                                                                                 if (key.Key == ConsoleKey.D)
    195                                                                                                 {
    196                                                                                                     key = Console.ReadKey(true);
    197                                                                                                     if (key.Key == ConsoleKey.E)
    198                                                                                                     {
    199                                                                                                         PlayerPos[playerNumber] += 150;
    200                                                                                                         MapLength();
    201                                                                                                     }
    202                                                                                                 }
    203                                                                                             }
    204                                                                                         }
    205                                                                                     }
    206                                                                                 }
    207                                                                             }
    208                                                                         }
    209                                                                     }
    210                                                                 }
    211                                                             }
    212                                                         }
    213                                                     }
    214                                                 }
    215                                             }
    216                                         }
    217                                     }
    218                                 }
    219                             }
    220                         }
    221                     }
    222                 }
    223             }
    224             #endregion
    225             Console.ForegroundColor = ConsoleColor.Green;
    226             Console.WriteLine("玩家{0}掷出了{1}。按任意键开始行动...", PlayerName[playerNumber], num);
    227             Console.ReadKey(true);
    228             Console.Clear();
    229             PlayerPos[playerNumber] += num;
    230             MapLength();
    231             if (PlayerPos[playerNumber] == PlayerPos[1 - playerNumber])
    232             {
    233                 PlayerPos[1 - playerNumber] -= 40;
    234                 Console.ForegroundColor = ConsoleColor.Green;
    235                 temp = string.Format("玩家{0}被玩家{1}踩回退了40.非常高兴!~~~~~~~!", PlayerName[1 - playerNumber], PlayerName[playerNumber]);
    236             }
    237             else
    238             {
    239                 switch (Map[PlayerPos[playerNumber]])
    240                 {
    241                     case 0:
    242                         //无关卡
    243                         Console.ForegroundColor = ConsoleColor.Green;
    244                         break;
    245 
    246                     case 1:
    247                         //幸运轮盘
    248                         #region 幸运轮盘
    249                         {
    250                             Console.ForegroundColor = ConsoleColor.Green;
    251                             temp = string.Format("{0}走到幸运轮盘,请选择1---交换位置,1---PK对方。", PlayerName[playerNumber]);
    252                             int numxy = ReadInt(temp, 1, 2);
    253                             if (numxy == 1)
    254                             {
    255                                 int tem = PlayerPos[playerNumber];
    256                                 PlayerPos[playerNumber] = PlayerPos[1 - playerNumber];
    257                                 PlayerPos[1 - playerNumber] = tem;
    258                                 Console.ForegroundColor = ConsoleColor.Green;
    259                                 temp = string.Format("玩家{0}选择了与玩家{1}交换位置!", PlayerName[playerNumber], PlayerName[1 - playerNumber]);
    260                             }
    261                             else
    262                             {
    263                                 PlayerPos[1 - playerNumber] -= 20;
    264                                 MapLength();
    265                                 Console.ForegroundColor = ConsoleColor.Green;
    266                                 temp = string.Format("玩家{0}选择了与玩家{1}PK!让对方回退了20步", PlayerName[playerNumber], PlayerName[1 - playerNumber]);
    267                             }
    268                             break;
    269                         }
    270                         #endregion
    271                     case 2:
    272                         #region 地雷
    273                         PlayerPos[playerNumber] -= 15;
    274                         MapLength();
    275                         Console.ForegroundColor = ConsoleColor.Green;
    276                         temp = string.Format("恭喜玩家{0}踩到了烈性TNT回退了15步.", PlayerName[playerNumber]);
    277 
    278                         break;
    279                         #endregion
    280                     case 3:
    281                         #region 暂停
    282                         Console.ForegroundColor = ConsoleColor.Green;
    283                         temp = string.Format("{0}走到了小飞挖的粪坑!暂停一次!", PlayerName[playerNumber]);
    284                         result[playerNumber] = true;
    285                         #endregion
    286                         break;
    287                     case 4:
    288                         #region 时空隧道
    289                         PlayerPos[playerNumber] += 20;
    290                         MapLength();
    291                         Console.ForegroundColor = ConsoleColor.Green;
    292                         temp = string.Format("玩家{0}和川川一样猥琐!进了时空隧道!前进了20步。", PlayerName[playerNumber]);
    293                         #endregion
    294                         break;
    295                 }
    296             }
    297 
    298             DrawMap();
    299             Console.ForegroundColor = ConsoleColor.Green;
    300             Console.WriteLine(temp);
    301             Console.WriteLine("行动完毕!");
    302         }
    303         /// <summary>
    304         /// 判断是否超出地图
    305         /// </summary>
    306         public static void MapLength()
    307         {
    308             
    309             if (PlayerPos[0] >= 305)
    310             {
    311                 PlayerPos[0] = 305;
    312 
    313             }
    314             if (PlayerPos[0] <= 1)
    315             {
    316                 PlayerPos[0] = 1;
    317             }
    318             if (PlayerPos[1] >= 305)
    319             {
    320                 PlayerPos[1] = 305;
    321             }
    322             if (PlayerPos[1] <= 1)
    323             {
    324                 PlayerPos[1] = 1;
    325             }
    326         }
    327         /// <summary>
    328         /// 判断幸运轮盘
    329         /// </summary>
    330         /// <param name="temp">传入需要显示的字符串</param>
    331         /// <param name="min">需要输入的最小值int类型</param>
    332         /// <param name="max">需要输入的最大值int类型</param>
    333         /// <returns></returns>
    334         public static int ReadInt(string temp, int min, int max)
    335         {
    336             while (true)
    337             {
    338                 try
    339                 {
    340                     Console.WriteLine(temp);
    341                     if (max > 2)
    342                     {
    343                         Console.WriteLine("关卡选择:1:低级   2:初级   3:中级   4:高级   5:终极   6:毁灭");
    344                     }
    345                     int num = int.Parse(Console.ReadLine());
    346                     if (num >= min && num <= max)
    347                     {
    348                         return num;
    349                     }
    350                     else
    351                     {
    352                         Console.WriteLine("您输入非法!请输入{0}到{1}这些数字!", min, max);
    353                         continue;
    354                     }
    355                 }
    356                 catch
    357                 {
    358                     Console.WriteLine("您输入非法!请输入{0}到{1}这些数字!", min, max);
    359                 }
    360             }
    361 
    362         }
    363         /// <summary>
    364         /// 判断玩家姓名
    365         /// </summary>
    366         public static void DecidePlayerName()
    367         {
    368             Console.WriteLine("请输入玩家A的名字:");
    369             PlayerName[0] = Console.ReadLine();
    370             do
    371             {
    372                 if (PlayerName[0].Trim() == "")
    373                 {
    374                     Console.Write("玩家A姓名不能为空!");
    375                     PlayerName[0] = Console.ReadLine();
    376                     continue;
    377                 }
    378                 else
    379                 {
    380                     Console.WriteLine("请输入玩家B的名字:");
    381                     PlayerName[1] = Console.ReadLine();
    382                     if (PlayerName[1].Trim() == "")
    383                     {
    384                         Console.WriteLine("玩家B姓名不能为空!");
    385                         continue;
    386                     }
    387                     else if (PlayerName[0] == PlayerName[1])
    388                     {
    389                         Console.WriteLine("玩家B姓名不能与玩家[{0}]相同", PlayerName[0]);
    390                         continue;
    391                     }
    392                     else
    393                     {
    394                         Console.WriteLine("对战即将开始...");
    395                         Console.WriteLine("{0}士兵用◆表示...", PlayerName[0]);
    396                         Console.WriteLine("{0}士兵用◇表示...", PlayerName[1]);
    397                         break;
    398                     }
    399                 }
    400 
    401 
    402             } while (true);
    403         }
    404         /// <summary>
    405         /// 地图显示
    406         /// </summary>
    407         public static void DrawMap()
    408         {
    409             string kong = " ";
    410             #region 地图显示
    411             {
    412                 #region 第一行
    413                 Console.Write("{0,9}", kong);
    414                 for (int i = 1; i <= 31; i++)
    415                 {
    416                     Console.Write(DecideMap(i));
    417                 }
    418                 #endregion
    419                 Console.WriteLine();
    420                 #region 第二行
    421                 Console.Write("{0,69}", kong);
    422                 Console.Write(DecideMap(32));
    423                 #endregion
    424                 Console.WriteLine();
    425                 #region 第三行
    426                 Console.Write("{0,9}", kong);
    427                 for (int i = 108; i <= 136; i++)
    428                 {
    429                     Console.Write(DecideMap(i));
    430                 }
    431                 Console.Write("{0,2}", kong);
    432                 Console.Write("{0,1}", DecideMap(33));
    433                 #endregion
    434                 Console.WriteLine();
    435                 #region 第四行
    436                 Console.Write("{0,9}", kong);
    437                 Console.Write("{0,1}", DecideMap(107));
    438                 Console.Write("{0,54}", kong);
    439                 Console.Write("{0,1}", DecideMap(137));
    440                 Console.Write("{0,2}", kong);
    441                 Console.Write("{0,1}", DecideMap(34));
    442                 #endregion
    443                 Console.WriteLine();
    444                 #region 第五行
    445                 Console.Write("{0,9}", kong);
    446                 Console.Write("{0,1}", DecideMap(106));
    447                 Console.Write("{0,2}", kong);
    448                 Console.ForegroundColor = ConsoleColor.DarkGreen;
    449                 Console.Write("▇{0}", DecideMap(304));
    450                 for (int i = 303; i >= 294; i--)
    451                 {
    452                     Console.Write(DecideMap(i));
    453                 }
    454                 Console.Write("{0,4}", kong);
    455                 for (int i = 150; i >= 138; i--)
    456                 {
    457                     Console.Write(DecideMap(i));
    458                 }
    459                 Console.Write("{0,2}", kong);
    460                 Console.Write("{0,1}", DecideMap(35));
    461                 #endregion
    462                 Console.WriteLine();
    463                 #region 第六行
    464                 Console.Write("{0,9}", kong);
    465                 Console.Write("{0,1}", DecideMap(105));
    466                 Console.Write("{0,24}", kong);
    467                 Console.Write("{0,1}", DecideMap(293));
    468                 Console.Write("{0,4}", kong);
    469                 Console.Write("{0,1}", DecideMap(159));
    470                 Console.Write("{0,26}", kong);
    471                 Console.Write("{0,1}", DecideMap(36));
    472                 #endregion
    473                 Console.WriteLine();
    474                 #region 第七行
    475                 Console.Write("{0,9}", kong);
    476                 Console.Write("{0,1}", DecideMap(104));
    477                 Console.Write("{0,24}", kong);
    478                 Console.Write("{0,1}", DecideMap(292));
    479                 Console.Write("{0,4}", kong);
    480                 Console.Write("{0,1}", DecideMap(158));
    481                 Console.Write("{0,26}", kong);
    482                 Console.Write("{0,1}", DecideMap(37));
    483                 #endregion
    484                 Console.WriteLine();
    485                 #region 第八行
    486                 Console.Write("{0,9}", kong);
    487                 Console.Write("{0,1}", DecideMap(103));
    488                 Console.Write("{0,24}", kong);
    489                 Console.Write("{0,1}", DecideMap(291));
    490                 Console.Write("{0,4}", kong);
    491                 Console.Write("{0,1}", DecideMap(157));
    492                 Console.Write("{0,26}", kong);
    493                 Console.Write("{0,1}", DecideMap(38));
    494                 #endregion
    495                 Console.WriteLine();
    496                 #region 第九行
    497                 Console.Write("{0,9}", kong);
    498                 Console.Write("{0,1}", DecideMap(102));
    499                 Console.Write("{0,24}", kong);
    500                 Console.Write("{0,1}", DecideMap(290));
    501                 Console.Write("{0,4}", kong);
    502                 Console.Write("{0,1}", DecideMap(156));
    503                 Console.Write("{0,26}", kong);
    504                 Console.Write("{0,1}", DecideMap(39));
    505                 #endregion
    506                 Console.WriteLine();
    507                 #region 第十行
    508                 Console.Write("{0,9}", kong);
    509                 Console.Write("{0,1}", DecideMap(101));
    510                 Console.Write("{0,24}", kong);
    511                 Console.Write("{0,1}", DecideMap(289));
    512                 Console.Write("{0,4}", kong);
    513                 Console.Write("{0,1}", DecideMap(155));
    514                 Console.Write("{0,26}", kong);
    515                 Console.Write("{0,1}", DecideMap(40));
    516                 #endregion
    517                 Console.WriteLine();
    518                 #region 第十一行
    519                 Console.Write("{0,9}", kong);
    520                 Console.Write("{0,1}", DecideMap(100));
    521                 Console.Write("{0,24}", kong);
    522                 Console.Write("{0,1}", DecideMap(288));
    523                 Console.Write("{0,4}", kong);
    524                 Console.Write("{0,1}", DecideMap(154));
    525                 Console.Write("{0,26}", kong);
    526                 Console.Write("{0,1}", DecideMap(41));
    527                 #endregion
    528                 Console.WriteLine();
    529                 #region 第十二行
    530                 Console.Write("{0,9}", kong);
    531                 Console.Write("{0,1}", DecideMap(99));
    532                 Console.Write("{0,2}", kong);
    533                 for (int i = 275; i < 287; i++)
    534                 {
    535                     Console.Write(DecideMap(i));
    536                 }
    537                 Console.Write("{0,4}", kong);
    538                 for (int i = 157; i <= 169; i++)
    539                 {
    540                     Console.Write(DecideMap(i));
    541                 }
    542                 Console.Write("{0,2}", kong);
    543                 Console.Write("{0,1}", DecideMap(42));
    544                 #endregion
    545                 Console.WriteLine();
    546                 #region 第十三行
    547                 Console.Write("{0,9}", kong);
    548                 Console.Write("{0,1}", DecideMap(98));
    549                 Console.Write("{0,2}", kong);
    550                 Console.Write("{0,1}", DecideMap(274));
    551                 Console.Write("{0,50}", kong);
    552                 Console.Write("{0,1}", DecideMap(170));
    553                 Console.Write("{0,2}", kong);
    554                 Console.Write("{0,1}", DecideMap(43));
    555                 #endregion
    556                 Console.WriteLine();
    557                 #region 第十四行
    558                 Console.Write("{0,9}", kong);
    559                 Console.Write("{0,1}", DecideMap(97));
    560                 Console.Write("{0,2}", kong);
    561                 for (int i = 273; i > 261; i--)
    562                 {
    563                     Console.Write(DecideMap(i));
    564                 }
    565                 Console.Write("{0,4}", kong);
    566                 for (int i = 183; i >= 171; i--)
    567                 {
    568                     Console.Write(DecideMap(i));
    569                 }
    570                 Console.Write("{0,2}", kong);
    571                 Console.Write("{0,1}", DecideMap(44));
    572                 #endregion
    573                 Console.WriteLine();
    574                 #region 第十五行
    575                 Console.Write("{0,9}", kong);
    576                 Console.Write("{0,1}", DecideMap(96));
    577                 Console.Write("{0,24}", kong);
    578                 Console.Write("{0,1}", DecideMap(260));
    579                 Console.Write("{0,4}", kong);
    580                 Console.Write("{0,1}", DecideMap(184));
    581                 Console.Write("{0,10}", kong);
    582                 Console.Write("{0,1}", DecideMap(202));
    583                 Console.Write("{0,14}", kong);
    584                 Console.Write(DecideMap(45));
    585                 #endregion
    586                 Console.WriteLine();
    587                 #region 第十六行
    588                 Console.Write("{0,9}", kong);
    589                 Console.Write("{0,1}", DecideMap(95));
    590                 Console.Write("{0,24}", kong);
    591                 Console.Write("{0,1}", DecideMap(259));
    592                 Console.Write("{0,4}", kong);
    593                 Console.Write("{0,1}", DecideMap(185));
    594                 Console.Write("{0,8}", kong);
    595                 Console.Write("{0,1}", DecideMap(201));
    596                 Console.Write("{0,2}", kong);
    597                 Console.Write("{0,1}", DecideMap(203));
    598                 Console.Write("{0,12}", kong);
    599                 Console.Write(DecideMap(46));
    600                 #endregion
    601                 Console.WriteLine();
    602                 #region 第十七行
    603                 Console.Write("{0,9}", kong);
    604                 Console.Write("{0,1}", DecideMap(94));
    605                 Console.Write("{0,24}", kong);
    606                 Console.Write("{0,1}", DecideMap(258));
    607                 Console.Write("{0,4}", kong);
    608                 Console.Write("{0,1}", DecideMap(186));
    609                 Console.Write("{0,6}", kong);
    610                 Console.Write("{0,1}", DecideMap(200));
    611                 Console.Write("{0,6}", kong);
    612                 Console.Write("{0,1}", DecideMap(204));
    613                 Console.Write("{0,10}", kong);
    614                 Console.Write("{0,1}", DecideMap(47));
    615                 #endregion
    616                 Console.WriteLine();
    617                 #region 第十八行
    618                 Console.Write("{0,9}", kong);
    619                 Console.Write("{0,1}", DecideMap(93));
    620                 Console.Write("{0,24}", kong);
    621                 Console.Write("{0,1}", DecideMap(257));
    622                 Console.Write("{0,4}", kong);
    623                 Console.Write("{0,1}", DecideMap(187));
    624                 Console.Write("{0,7}", kong);
    625                 Console.Write("{0,1}", DecideMap(199));
    626                 Console.Write("{0,7}", kong);
    627                 Console.Write("{0,1}", DecideMap(205));
    628                 Console.Write("{0,8}", kong);
    629                 Console.Write("{0,1}", DecideMap(48));
    630                 #endregion
    631                 Console.WriteLine();
    632                 #region 第十九行
    633                 Console.Write("{0,9}", kong);
    634                 Console.Write("{0,1}", DecideMap(92));
    635                 Console.Write("{0,24}", kong);
    636                 Console.Write("{0,1}", DecideMap(256));
    637                 Console.Write("{0,4}", kong);
    638                 Console.Write("{0,1}", DecideMap(188));
    639                 Console.Write("{0,8}", kong);
    640                 Console.Write("{0,1}", DecideMap(198));
    641                 Console.Write("{0,5}", kong);
    642                 Console.Write("{0,1}", DecideMap(206));
    643                 Console.Write("{0,9}", kong);
    644                 Console.Write("{0,1}", DecideMap(49));
    645                 #endregion
    646                 Console.WriteLine();
    647                 #region 第二十行
    648                 Console.Write("{0,9}", kong);
    649                 Console.Write("{0,1}", DecideMap(91));
    650                 Console.Write("{0,24}", kong);
    651                 Console.Write("{0,1}", DecideMap(255));
    652                 Console.Write("{0,4}", kong);
    653                 Console.Write("{0,1}", DecideMap(189));
    654                 Console.Write("{0,9}", kong);
    655                 Console.Write("{0,1}", DecideMap(197));
    656                 Console.Write("{0,3}", kong);
    657                 Console.Write("{0,1}", DecideMap(207));
    658                 Console.Write("{0,10}", kong);
    659                 Console.Write("{0,1}", DecideMap(50));
    660                 #endregion
    661                 Console.WriteLine();
    662                 #region 第二十一行
    663                 Console.Write("{0,9}", kong);
    664                 Console.Write("{0,1}", DecideMap(90));
    665                 Console.Write("{0,2}", kong);
    666                 for (int i = 242; i < 254; i++)
    667                 {
    668                     Console.Write(DecideMap(i));
    669                 }
    670                 Console.Write("{0,4}", kong);
    671                 for (int i = 190; i <= 196; i++)
    672                 {
    673                     Console.Write(DecideMap(i));
    674                 }
    675                 Console.Write("{0,2}", kong);
    676                 for (int i = 208; i <= 212; i++)
    677                 {
    678                     Console.Write(DecideMap(i));
    679                 }
    680                 Console.Write("{0,2}", kong);
    681                 Console.Write(DecideMap(44));
    682                 #endregion
    683                 Console.WriteLine();
    684                 #region 第二十二行
    685                 Console.Write("{0,9}", kong);
    686                 Console.Write("{0,1}", DecideMap(89));
    687                 Console.Write("{0,2}", kong);
    688                 Console.Write("{0,1}", DecideMap(241));
    689                 Console.Write("{0,50}", kong);
    690                 Console.Write("{0,1}", DecideMap(213));
    691                 Console.Write("{0,2}", kong);
    692                 Console.Write("{0,1}", DecideMap(52));
    693                 #endregion
    694                 Console.WriteLine();
    695                 #region 第二十三行
    696                 Console.Write("{0,9}", kong);
    697                 Console.Write("{0,1}", DecideMap(88));
    698                 Console.Write("{0,2}", kong);
    699                 for (int i = 240; i >= 214; i--)
    700                 {
    701                     Console.Write(DecideMap(i));
    702                 }
    703                 Console.Write("{0,2}", kong);
    704                 Console.Write("{0,1}", DecideMap(53));
    705                 #endregion
    706                 Console.WriteLine();
    707                 #region 第二十四行
    708                 Console.Write("{0,9}", kong);
    709                 Console.Write("{0,1}", DecideMap(87));
    710                 Console.Write("{0,59}", DecideMap(54));
    711                 #endregion
    712                 Console.WriteLine();
    713                 #region 第二十五行
    714                 Console.Write("{0,9}", kong);
    715                 for (int i = 86; i >= 56; i--)
    716                 {
    717                     Console.Write(DecideMap(i));
    718                 }
    719                 #endregion
    720                 Console.WriteLine();
    721             }
    722             #endregion
    723         }
    724         /// <summary>
    725         /// 地图实例化
    726         /// </summary>
    727         /// <param name="pos">传入地图坐标</param>
    728         /// <returns></returns>
    729         public static string DecideMap(int pos)
    730         {
    731             #region 符号
    732 
    733 
    734             /*Н О П Р С Т У Ф Х Ц Ч Ш Щ Ъ Ы Ь Э Ю Я а б в г д е ж з и й к л м н о п р с т у ф х ц ч ш щ ъ ы ь э ю я ё‐ – — ― ‖ ‘ ’ “ ” ‥ … ‰ ′ ″ ‵ ※  ̄ € ℃ ℅ ℉ № ℡ Ⅰ Ⅱ Ⅲ Ⅳ Ⅴ Ⅵ Ⅶ Ⅷ Ⅸ Ⅹ Ⅺ Ⅻ ⅰ ⅱ ⅲ ⅳ ⅴ ⅵ ⅶ ⅷ ⅸ ⅹ ← ↑ → ↓ ↖ ↗ ↘ ↙ ∈ ∏ ∑ ∕ ° √ ∝ ∞ ∟ ∠ ∣ ∥ ∧ ∨ ∩ ∪ ∫ ∮ ∴ ∵ ∶ ∷ ~ ∽ ≈ ≌ ≒ ≠ ≡ ≤ ≥ ≦ ≧ ≮ ≯ ⊕ ⊙ ⊥ ⊿ ⌒ ① ② ③ ④ ⑤ ⑥ ⑦ ⑧ ⑨ ⑩ ⑴ ⑵ ⑶ ⑷ ⑸ ⑹ ⑺ ⑻ ⑼ ⑽ ⑾ ⑿ ⒀ ⒁ ⒂ ⒃ ⒄ ⒅ ⒆ ⒇ ⒈ ⒉ ⒊ ⒋ ⒌ ⒍ ⒎ ⒏ ⒐ ⒑ ⒒ ⒓ ⒔ ⒕ ⒖ ⒗ ⒘ ⒙ ⒚ ⒛ ─ ━ │ ┃ ┄ ┅ ┆ ┇ ┈ ┉ ┊ ┋ ┌ ┍ ┎ ┏ ┐ ┑ ┒ ┓ └ ┕ ┖ ┗ ┘ ┙ ┚ ┛ ├ ┝ ┞ ┟ ┠ ┡ ┢ ┣ ┤ ┥ ┦ ┧ ┨ ┩ ┪ ┫ ┬ ┭ ┮ ┯ ┰ ┱ ┲ ┳ ┴ ┵ ┶ ┷ ┸ ┹ ┺ ┻ ┼ ┽ ┾ ┿ ╀ ╁ ╂ ╃ ╄ ╅ ╆ ╇ ╈ ╉ ╊ ╋ ═ ║ ╒ ╓ ╔ ╕ ╖ ╗ ╘ ╙ ╚ ╛ ╜ ╝ ╞ ╟ ╠ ╡ ╢ ╣ ╤ ╥ ╦ ╧ ╨ ╩ ╪ ╫ ╬ ╭ ╮ ╯ ╰ ╱ ╲ ╳ ▁ ▂ ▃ ▄ ▅ ▆ ▇ █ ▉ ▊ ▋ ▌ ▍ ▎ ▏ ▓ ▔ ▕ ■ □ ▲ △ ▼ ▽ ◆ ◇ ○ ◎ ● ◢ ◣ ◤ ◥ ★ ☆ ☉ ♀ ♂、 。 〃 々 〆 〇 〈 〉 《 》 「 」 『 』 【 】 〒 〓 〔 〕 〖 〗 〝 〞 〡 〢 〣 〤 〥 〦 〧 〨 〩 ぁ あ ぃ い ぅ う ぇ え ぉ お か が き ぎ く ぐ け げ こ ご さ ざ し じ す ず せ ぜ そ ぞ た だ ち ぢ っ つ づ て で と ど な に ぬ ね の は ば ぱ ひ び ぴ ふ ぶ ぷ へ べ ぺ ほ ぼ ぽ ま み む め も ゃ や ゅ ゆ ょ よ ら り る れ ろ ゎ わ ゐ ゑ を ん ゛ ゜ ゝ ゞ ァ ア ィ イ ゥ ウ ェ エ ォ オ カ ガ キ ギ ク グ ケ ゲ コ ゴ サ ザ シ ジ ス ズ セ ゼ ソ ゾ タ ダ チ ヂ ッ ツ ヅ テ デ ト ド ナ ニ ヌ ネ ノ ハ バ パ ヒ ビ ピ フ ブ プ ヘ ベ ペ ホ ボ ポ マ ミ ム メ モ ャ ヤ ュ ユ ョ ヨ ラ リ ル レ ロ ヮ ワ ヰ ヱ ヲ ン ヴ ヵ ヶ ー ヽ ヾ ㄅ ㄆ ㄇ ㄈ ㄉ ㄊ ㄋ ㄌ ㄍ ㄎ ㄏ ㄐ ㄑ ㄒ ㄓ ㄔ ㄕ ㄖ ㄗ ㄘ ㄙ ㄚ ㄛ ㄜ ㄝ ㄞ ㄟ ㄠ ㄡ ㄢ ㄣ ㄤ ㄥ ㄦ ㄧ ㄨ ㄩ ㈠ ㈡ ㈢ ㈣ ㈤ ㈥ ㈦ ㈧ ㈨ ㈩ ㈱ ㊣ ㎎ ㎏ ㎜ ㎝ ㎞ ㎡ ㏄ ㏎ ㏑ ㏒ ㏕                                         ︰ ︱ ︳ ︴ ︵ ︶ ︷ ︸ ︹ ︺ ︻ ︼ ︽ ︾ ︿ ﹀ ﹁ ﹂ ﹃ ﹄ ﹉
    735                  * */
    736             #endregion
    737             string temp = "";
    738             if (PlayerPos[0] == PlayerPos[1] && PlayerPos[0] == pos)
    739             {
    740                 Console.ForegroundColor = ConsoleColor.Red;
    741                 temp = "@@";
    742             }
    743             else if (PlayerPos[0] == pos)
    744             {
    745                 Console.ForegroundColor = ConsoleColor.Red;
    746                 temp = "";
    747             }
    748             else if (PlayerPos[1] == pos)
    749             {
    750                 Console.ForegroundColor = ConsoleColor.Red;
    751                 temp = "";
    752             }
    753             else
    754             {
    755                 switch (Map[pos])
    756                 {
    757 
    758                     case 0:
    759                         Console.ForegroundColor = ConsoleColor.Gray;
    760                         temp = "";
    761                         break;
    762                     case 1:
    763                         Console.ForegroundColor = ConsoleColor.Green;
    764                         temp = "";
    765                         break;
    766                     case 2:
    767                         Console.ForegroundColor = ConsoleColor.Blue;
    768                         temp = "";
    769                         break;
    770                     case 3:
    771                         Console.ForegroundColor = ConsoleColor.Cyan;
    772                         temp = "";
    773                         break;
    774                     case 4:
    775                         Console.ForegroundColor = ConsoleColor.Yellow;
    776                         temp = "";
    777                         break;
    778                 }
    779             }
    780             return temp;
    781         }
    782         /// <summary>
    783         /// 关卡选择:1:低级   2:初级   3:中级   4:高级   5:终极  6:xx
    784         /// </summary>
    785         /// <param name="num"></param>
    786         public static void CustomsPass(int num)
    787         {
    788             switch (num)
    789             {
    790                 case 1: InitMap(10); break;
    791                 case 2: InitMap(20); break;
    792                 case 3: InitMap(35); break;
    793                 case 4: InitMap(50); break;
    794                 case 5: InitMap(70); break;
    795                 case 6: InitMap(82); break;
    796             }
    797 
    798         }
    799         /// <summary>
    800         /// 关卡难度设置,初始化地图
    801         /// </summary>
    802         /// <param name="num">传入关卡数量int类型</param>
    803         public static void InitMap(int num)
    804         {
    805             List<int> li = new List<int>();
    806             Random r = new Random();
    807             //幸运轮盘
    808             #region 幸运轮盘
    809             {
    810                 //for (int i = 0; i <= num; )
    811                 //{
    812                 //    int j = r.Next(1, 300);
    813                 //    if (Map[j] == 0)
    814                 //    {
    815                 //        Map[j] = 1; i++;
    816                 //    }
    817                 //    else
    818                 //    {
    819                 //        continue;
    820                 //    }
    821                 //}
    822 
    823                 for (int i = 0; i < num; )
    824                 {
    825                     int j = r.Next(1, 305);
    826                     if (!li.Contains(j))
    827                     {
    828                         Map[j] = 1;
    829                         i++;
    830                     }
    831                     else
    832                     {
    833                         continue;
    834                     }
    835                 }
    836             }
    837             #endregion
    838             #region 地雷
    839             {
    840                 //地雷
    841                 //for (int i = 0; i < num + 25; )
    842                 //{
    843                 //    int j = r.Next(2, 300);
    844                 //    if (Map[j] == 0)
    845                 //    {
    846                 //        Map[j] = 2;
    847                 //        i++;
    848                 //    }
    849                 //    else
    850                 //    {
    851                 //        continue;
    852                 //    }
    853                 //}
    854                 for (int i = 0; i < num + 35; )
    855                 {
    856                     int j = r.Next(1, 305);
    857                     if (!li.Contains(j))
    858                     {
    859                         Map[j] = 2;
    860                         i++;
    861                     }
    862                     else
    863                     {
    864                         continue;
    865                     }
    866                 }
    867             }
    868             #endregion
    869             #region 暂停
    870             {
    871                 //设置暂停
    872                 //for (int i = 0; i < num + 35; )
    873                 //{
    874 
    875                 //    int j = r.Next(3, 300);
    876                 //    if (Map[j] == 0)
    877                 //    {
    878                 //        Map[j] = 3;
    879                 //        i++;
    880                 //    }
    881                 //    else
    882                 //    {
    883                 //        continue;
    884                 //    }
    885                 //}
    886                 for (int i = 0; i < num + 35; )
    887                 {
    888                     int j = r.Next(1, 305);
    889                     if (!li.Contains(j))
    890                     {
    891                         Map[j] = 3;
    892                         i++;
    893                     }
    894                     else
    895                     {
    896                         continue;
    897                     }
    898                 }
    899             }
    900             #endregion
    901             #region 时空隧道
    902             {
    903                 //设置时空隧道
    904                 //for (int i = 0; i < num - 10; )
    905                 //{
    906 
    907                 //    int j = r.Next(5, 300);
    908                 //    if (Map[j] == 0)
    909                 //    {
    910                 //        Map[j] = 4;
    911                 //        i++;
    912                 //    }
    913                 //    else
    914                 //    {
    915                 //        continue;
    916                 //    }
    917                 //}
    918                 for (int i = 0; i < num - 20; )
    919                 {
    920                     int j = r.Next(5, 304);
    921                     if (!li.Contains(j))
    922                     {
    923                         Map[j] = 4;
    924                         i++;
    925                     }
    926                     else
    927                     {
    928                         continue;
    929                     }
    930                 }
    931             }
    932             #endregion
    933         }
    934     }
                             ------------------ Windows Phones 7手机开发.Net培训、期待与您交流! ----------------------
    

    __EOF__

    本文作者 Blank
    本文链接
    版权声明:本博客所有文章除特别声明外,均采用 BY-NC-SA 许可协议。转载请注明出处!
    声援博主:如果您觉得文章对您有帮助,可以点击文章右下角 推荐 一下。您的鼓励是博主的最大动力!
  • 相关阅读:
    0314:翻车总结
    机器人系统仿真(十一)——URDF集成Gazebo
    机器人系统仿真(十)——arbotix控制机器人运动
    机器人系统仿真(九)——xacro+摄像头+雷达传感器
    机器人系统仿真(八)——xacro小车底盘模型案例
    机器人系统仿真(七)——xacro语法详解
    机器人系统仿真(六)——xacro基本语法
    机器人系统仿真(五)——URDF工具
    机器人系统仿真(四)——四轮圆柱状机器人模型
    C++去除字符串空格和tab
  • 原文地址:https://www.cnblogs.com/alianblank/p/3000996.html
Copyright © 2020-2023  润新知