国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > C# > 正文

C#飛行棋小程序設計代碼

2020-01-24 00:57:19
字體:
來源:轉載
供稿:網友

飛行棋游戲大家應該都玩過吧,如何使用C#語言進行編寫,本文實例就為大家分享了飛行棋C#實現代碼,供大家參考,具體內容如下

using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks;namespace Pachee{  class Program  {    #region 靜態字段    // 關卡數量    public static int[] Maps = new int[100];    // 玩家坐標    public static int[] PlayerPos = new int[2];    // 玩家名稱    public static string[] PlayerNames = new string[2];    // 判斷玩家是否暫停    public static bool[] Flags = new bool[2];    #endregion    /// <summary>    /// 輸出游戲頭    /// </summary>    public static void ShowGame()    {      Console.ForegroundColor = ConsoleColor.Green;      Console.WriteLine("****************************");      Console.ForegroundColor = ConsoleColor.Blue;      Console.WriteLine("****************************");      Console.ForegroundColor = ConsoleColor.White;      Console.WriteLine("***C#基礎練習:飛行棋項目***");      Console.ForegroundColor = ConsoleColor.Yellow;      Console.WriteLine("****************************");      Console.ForegroundColor = ConsoleColor.Red;      Console.WriteLine("****************************");    }    /// <summary>    /// 接受用戶輸入的游戲名稱,判斷是否合法    /// </summary>    /// <returns>游戲名稱</returns>    public static string[] InputPlayerNames()    {      PlayerNames[0] = "";      PlayerNames[1] = "";      Console.ForegroundColor = ConsoleColor.White;      while (PlayerNames[0] == "")      {        Console.Write("Please enter the name of game A player: ");        PlayerNames[0] = Console.ReadLine().Trim();        if (PlayerNames[0] == "")        {          Console.WriteLine("A player name cannot be empty, please enter again.");          continue;        }        break;      }      while (PlayerNames[1] == "" || PlayerNames[0] == PlayerNames[1])      {        Console.Write("Please enter the name of game B player: ");        PlayerNames[1] = Console.ReadLine().Trim();        if (PlayerNames[1] == "")        {          Console.WriteLine("B player name cannot be empty, please enter again.");          continue;        }        else if (PlayerNames[1] == PlayerNames[0])        {          Console.WriteLine("The player name cannot be the same as the player A B, please enter again.");          continue;        }        break;      }      return PlayerNames;    }    /// <summary>    /// 初始化地圖,改變默認的地圖坐標類型    /// 0:方塊    /// 1:輪盤    /// 2:地雷    /// 3:暫停    /// 4:隧道    /// </summary>    public static void InitailMap()    {      #region 輪盤      int[] luckTrun = { 6, 23, 40, 55, 69, 83 };      for (int i = 0; i < luckTrun.Length; i++)      {        Maps[luckTrun[i]] = 1;      }      #endregion      #region 地雷      int[] landMine = { 5, 13, 17, 33, 38, 50, 64, 80, 94 };      for (int i = 0; i < landMine.Length; i++)      {        Maps[landMine[i]] = 2;      }      #endregion      #region 暫停      int[] pause = { 9, 27, 60, 93 };      for (int i = 0; i < pause.Length; i++)      {        Maps[pause[i]] = 3;      }      #endregion      #region 隧道      int[] timeTunnel = { 20, 25, 45, 63, 72, 88, 90 };      for (int i = 0; i < timeTunnel.Length; i++)      {        Maps[timeTunnel[i]] = 4;      }      #endregion    }    /// <summary>    /// 設定當前坐標的類型    /// </summary>    /// <param name="i">坐標</param>    /// <returns>坐標類型</returns>    public static string DrawStringMap(int i)    {      string str = null;      if (PlayerPos[0] == PlayerPos[1] && PlayerPos[0] == i)      {        str = "<>";      }      else if (PlayerPos[0] == i)      {        str = "A";      }      else if (PlayerPos[1] == i)      {        str = "B";      }      else      {        switch (Maps[i])        {          case 0:            Console.ForegroundColor = ConsoleColor.Yellow;            str = "□";            break;          case 1:            Console.ForegroundColor = ConsoleColor.Blue;            str = "◎";            break;          case 2:            Console.ForegroundColor = ConsoleColor.Green;            str = "☆";            break;          case 3:            Console.ForegroundColor = ConsoleColor.Red;            str = "▲";            break;          case 4:            Console.ForegroundColor = ConsoleColor.Cyan;            str = "

主站蜘蛛池模板:
车致|
普兰县|
调兵山市|
忻州市|
岑巩县|
嫩江县|
马山县|
乳山市|
河北区|
涪陵区|
余姚市|
濮阳县|
威远县|
唐海县|
泰顺县|
周宁县|
南京市|
云浮市|
太湖县|
黑水县|
治县。|
嵊州市|
密山市|
永昌县|
凤山县|
辛集市|
安塞县|
长葛市|
麻栗坡县|
临安市|
阳朔县|
施秉县|
阿城市|
色达县|
资阳市|
赤水市|
余干县|
霍林郭勒市|
辰溪县|
永新县|
淮滨县|