成人午夜视频全免费观看高清-秋霞福利视频一区二区三区-国产精品久久久久电影小说-亚洲不卡区三一区三区一区

怎么用C#實(shí)現(xiàn)飛行棋項(xiàng)目

這篇文章主要講解了“怎么用C#實(shí)現(xiàn)飛行棋項(xiàng)目”,文中的講解內(nèi)容簡(jiǎn)單清晰,易于學(xué)習(xí)與理解,下面請(qǐng)大家跟著小編的思路慢慢深入,一起來(lái)研究和學(xué)習(xí)“怎么用C#實(shí)現(xiàn)飛行棋項(xiàng)目”吧!

創(chuàng)新互聯(lián)擁有一支富有激情的企業(yè)網(wǎng)站制作團(tuán)隊(duì),在互聯(lián)網(wǎng)網(wǎng)站建設(shè)行業(yè)深耕十多年,專業(yè)且經(jīng)驗(yàn)豐富。十多年網(wǎng)站優(yōu)化營(yíng)銷經(jīng)驗(yàn),我們已為1000多家中小企業(yè)提供了成都網(wǎng)站制作、網(wǎng)站設(shè)計(jì)、外貿(mào)網(wǎng)站建設(shè)解決方案,按需網(wǎng)站建設(shè),設(shè)計(jì)滿意,售后服務(wù)無(wú)憂。所有客戶皆提供一年免費(fèi)網(wǎng)站維護(hù)!

1.制作游戲頭部:游戲頭部介紹

2.繪制地圖

使用一維數(shù)組裝整個(gè)地圖的路線如果這個(gè)位置是0,繪制普通格子□如果這個(gè)位置是1,繪制幸運(yùn)輪盤(pán)◎如果這個(gè)位置是2,繪制地雷★如果這個(gè)位置是3,繪制暫停▲如果這個(gè)位置是4,繪制時(shí)空隧道卍

規(guī)劃幸運(yùn)輪盤(pán)位置int[] luckyturn = { 6, 23, 40, 55, 69, 83 };規(guī)劃地雷的位置int[] landMine = { 5,13,17,33,38,50,64,80,94};規(guī)劃暫停位置int[] pause = {9,27,60,93 };規(guī)劃時(shí)空隧道的位置int[] timeTunnel = { 20, 25, 45, 63, 72, 88, 90 };

3.設(shè)置特殊關(guān)卡

using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks;namespace 飛行棋{  class Program  {    /// <summary>    /// 整個(gè)地圖數(shù)組    /// </summary>    static int[] Maps = new int[100];    /// <summary>    /// 玩家的位置    /// </summary>    static int[] PlayerPos = new int[2];    /// <summary>    /// 玩家的姓名    /// </summary>    static string[] PlayerName = new string[2];    /// <summary>    /// 記錄兩名玩家是否可以擲骰子    /// </summary>    static bool[] PlayerFlag = new bool[2];    static void Main(string[] args)    {      //繪制地圖頭部      ShowTitle();      //輸入玩家姓名      Console.WriteLine("請(qǐng)輸入玩家A的姓名");      PlayerName[0]=Console.ReadLine();      while (PlayerName[0]=="")      {        Console.WriteLine("玩家A姓名不能為空,請(qǐng)重新輸入");        PlayerName[0]=Console.ReadLine();      }      Console.WriteLine("請(qǐng)輸入玩家B的姓名");      PlayerName[1] = Console.ReadLine();      while (PlayerName[1]=="" || PlayerName[1]==PlayerName[0])      {        if (PlayerName[1]=="")        {          Console.WriteLine("玩家B姓名不能為空,請(qǐng)重新輸入");          PlayerName[1] = Console.ReadLine();        }        if (PlayerName[1]==PlayerName[0])        {          Console.WriteLine("玩家B姓名與玩家A的姓名一致,請(qǐng)重新輸入");          PlayerName[1] = Console.ReadLine();        }      }      //輸入完姓名,清空屏幕      Console.Clear();      //重新繪制游戲標(biāo)題與游戲說(shuō)明      ShowTitle();      //初始化地圖關(guān)卡      InitialMap();      //顯示地圖      DrawMap();      //判斷如果沒(méi)有一個(gè)玩家到達(dá)終點(diǎn)則一直輪流擲篩子      while (PlayerPos[0]<99 && PlayerPos[1]<99)      {        if (PlayerFlag[0]==false)        {          PlayGame(0);        }        else        {          PlayerFlag[0] = false;        }        if (PlayerFlag[1]==false)        {          PlayGame(1);        }        else        {          PlayerFlag[1] = false;        }        if (PlayerPos[0] == 99)        {          Console.WriteLine("恭喜玩家【{0}】游戲獲勝!", PlayerName[0]);          break;        }        if (PlayerPos[1] == 99)        {          Console.WriteLine("恭喜玩家【{0}】游戲獲勝!", PlayerName[1]);          break;        }      }      Console.ReadLine();    }    #region 游戲標(biāo)題    /// <summary>    /// 設(shè)置游戲標(biāo)題    /// </summary>    static void ShowTitle()    {      Console.ForegroundColor = ConsoleColor.Blue;      Console.WriteLine("************************************");      Console.ForegroundColor = ConsoleColor.Green;      Console.WriteLine("************************************");      Console.ForegroundColor = ConsoleColor.Cyan;      Console.WriteLine("************************************");      Console.ForegroundColor = ConsoleColor.DarkRed;      Console.WriteLine("***************飛行棋***************");      Console.ForegroundColor = ConsoleColor.Cyan;      Console.WriteLine("************************************");      Console.ForegroundColor = ConsoleColor.Green;      Console.WriteLine("************************************");      Console.ForegroundColor = ConsoleColor.Blue;      Console.WriteLine("************************************");    }    #endregion    #region 初始化地圖關(guān)卡    /// <summary>    /// 初始化地圖關(guān)卡    /// </summary>    static void InitialMap()    {      //繪制幸運(yùn)輪盤(pán)的位置◎==1      int[] luckyturn = { 6, 23, 40, 55, 69, 83 };      for (int i = 0; i < luckyturn.Length; i++)      {        Maps[luckyturn[i]] = 1;      }      //繪制繪制地雷的位置★==2      int[] landMine = { 5, 13, 17, 33, 38, 50, 64, 80, 94 };      for (int i = 0; i < landMine.Length; i++)      {        Maps[landMine[i]] = 2;      }      //繪制暫停的位置▲==3      int[] pause = { 9, 27, 60, 93 };      for (int i = 0; i < pause.Length; i++)      {        Maps[pause[i]] = 3;      }      //繪制時(shí)空隧道的位置卍==4      int[] timeTunnel = { 20, 25, 45, 63, 72, 88, 90 };      for (int i = 0; i < timeTunnel.Length; i++)      {        Maps[timeTunnel[i]] = 4;      }    }    #endregion    #region 繪制地圖    /// <summary>    /// 繪制地圖    /// </summary>    static void DrawMap()    {      Console.ForegroundColor = ConsoleColor.DarkRed;      Console.WriteLine("玩家【{0}】使用A表示:",PlayerName[0]);      Console.WriteLine("玩家【{0}】使用B表示:", PlayerName[1]);      Console.WriteLine("游戲規(guī)則:");      Console.WriteLine();      Console.WriteLine("1.兩名玩家輪流擲骰子,規(guī)定A玩家先玩擲");      Console.WriteLine("2.踩到□格子安全,沒(méi)有獎(jiǎng)懲!");      Console.WriteLine("3.踩到◎幸運(yùn)輪盤(pán),可以進(jìn)行兩種選擇:a.置換與對(duì)方玩家位置;b.進(jìn)行轟炸對(duì)方,是對(duì)方倒退6步.");      Console.WriteLine("4.踩到★地雷,倒退6步!");      Console.WriteLine("5.踩到▲暫停,下一回合將暫停操作!");      Console.WriteLine("6.踩到卍時(shí)空隧道,直接前進(jìn)10步!");      Console.WriteLine("7.如果踩到對(duì)方,則對(duì)方直接退6步!");      ///第一橫行地圖      for (int i = 0; i < 30; i++)      {        Console.Write(DrawString(i));      }      Console.WriteLine();      ///第一豎行      for (int i = 30; i < 35; i++)      {        for (int j = 0; j < 29; j++)        {          Console.Write(" ");        }        Console.Write(DrawString(i));                Console.WriteLine();      }      ///第二橫行      for (int i = 64; i > 34; i--)      {        Console.Write(DrawString(i));      }      Console.WriteLine();      ///第二豎行      for (int i = 65; i < 70; i++)      {        Console.WriteLine(DrawString(i));      }      ///第三橫行      for (int i = 70; i < 100; i++)      {        Console.Write(DrawString(i));      }      Console.WriteLine();    }    #endregion    #region 設(shè)置地圖關(guān)卡,玩家初始位置        /// <summary>    /// 設(shè)置地圖關(guān)卡,玩家初識(shí)位置    /// </summary>    /// <param name="pos">索引</param>    private static string DrawString(int pos)    {      string str = "";      //判斷兩個(gè)玩家的位置一樣,確定兩個(gè)玩家都在地圖中      if (PlayerPos[0] == PlayerPos[1] && PlayerPos[0] == pos)      {        Console.ForegroundColor = ConsoleColor.Cyan;        str ="<>";      }      else if (PlayerPos[0] == pos)      {        Console.ForegroundColor = ConsoleColor.Cyan;        str ="A";      }      else if (PlayerPos[1] == pos)      {        Console.ForegroundColor = ConsoleColor.Red;        str = "B";      }      else      {        switch (Maps[pos])        {          case 0:            Console.ForegroundColor = ConsoleColor.Blue;            str = "□";            break;          case 1:            Console.ForegroundColor = ConsoleColor.Cyan;            str = "◎";            break;          case 2:            Console.ForegroundColor = ConsoleColor.DarkRed;            str = "★";            break;          case 3:            Console.ForegroundColor = ConsoleColor.DarkCyan;            str = "▲";            break;          case 4:            Console.ForegroundColor = ConsoleColor.Yellow;            str = "卍";            break;          default:            break;        }      }      return str;    }    #endregion    #region 開(kāi)始游戲        static void PlayGame(int PlayNum)    {      Random r = new Random();      Console.WriteLine("玩家【{0}】按下任意鍵擲骰子",PlayerName[PlayNum]);      Console.ReadKey(true);      int number = r.Next(1, 7);      Console.WriteLine("玩家【{0}】擲出<{1}>點(diǎn)。",PlayerName[PlayNum],number);      Console.WriteLine("玩家【{0}】按下任意鍵進(jìn)行移動(dòng)",PlayerName[PlayNum]);      Console.ReadKey(true);      PlayerPos[PlayNum] += number;      Console.WriteLine("玩家【{0}】移動(dòng)完成!",PlayerName[PlayNum]);      ChangedCheck();      //玩家踩到對(duì)方      if (PlayerPos[PlayNum]==PlayerPos[1-PlayNum])      {        Console.WriteLine("玩家【{0}】踩到玩家【{1}】,玩家【{1}】退6格",PlayerName[PlayNum],PlayerName[1-PlayNum]);        PlayerPos[1 - PlayNum] -= 6;      }      else      {        switch (Maps[PlayerPos[PlayNum]])        {          //踩到0普通地板,安全沒(méi)有獎(jiǎng)懲          case 0:            Console.WriteLine("玩家【{0}】踩到安全地帶,沒(méi)有獎(jiǎng)懲!按下任意鍵繼續(xù)游戲",PlayerName[PlayNum]);            Console.ReadKey(true);            break;          //踩到1幸運(yùn)輪盤(pán),選擇獎(jiǎng)勵(lì)          case 1:            Console.WriteLine("玩家【{0}】踩到幸運(yùn)輪盤(pán),選擇獎(jiǎng)勵(lì):a--->交換位置  b--->轟炸對(duì)方", PlayerName[PlayNum]);            string input = Console.ReadLine();            while (true)            {              if (input=="a")              {                Console.WriteLine("玩家【{0}】選擇與玩家【{1}】交換位置。",PlayerName[PlayNum],PlayerName[1-PlayNum]);                int temp = PlayerPos[PlayNum];                PlayerPos[PlayNum] = PlayerPos[1 - PlayNum];                PlayerPos[1 - PlayNum] = temp;                Console.WriteLine("玩家【{0}】與玩家【{1}】交換位置成功!按下任意鍵繼續(xù)游戲", PlayerName[PlayNum], PlayerName[1 - PlayNum]);                Console.ReadKey(true);                break;              }              else if (input=="b")              {                Console.WriteLine("玩家【{0}】選擇轟炸玩家【{1}】。", PlayerName[PlayNum], PlayerName[1 - PlayNum]);                PlayerPos[1 - PlayNum] -= 6;                Console.WriteLine("玩家【{0}】被轟炸倒退6步!按下任意鍵繼續(xù)游戲", PlayerName[1 - PlayNum]);                Console.ReadKey(true);                break;              }              else              {                Console.WriteLine("選擇格式錯(cuò)誤,請(qǐng)重新選擇!");                input = Console.ReadLine();              }            }            Console.ReadKey(true);            break;          //踩到2地雷,倒退6步          case 2:            Console.WriteLine("玩家【{0}】踩到地雷,倒退6步!按下任意鍵繼續(xù)游戲!",PlayerName[PlayNum]);            PlayerPos[PlayNum] -= 6;            Console.ReadKey(true);            break;          //踩到3暫停,下一回合不能擲骰子          case 3:            Console.WriteLine("玩家【{0}】踩到暫停,下一回合不能擲骰子!按下任意鍵繼續(xù)游戲!", PlayerName[PlayNum]);            PlayerFlag[PlayNum] = true;            Console.ReadKey(true);            break;          //踩到4時(shí)空穿梭,直接前進(jìn)10步          case 4:            Console.WriteLine("玩家【{0}】踩到時(shí)空穿梭,直接前進(jìn)10步!按下任意鍵繼續(xù)游戲!", PlayerName[PlayNum]);            PlayerPos[PlayNum] += 10;            Console.ReadKey(true);            break;          default:            break;        }      }      ChangedCheck();      Console.Clear();      ShowTitle();      DrawMap();          }    #endregion    static void ChangedCheck()    {      if (PlayerPos[0] < 0)      {        PlayerPos[0] = 0;      }      if (PlayerPos[0] > 99)      {        PlayerPos[0] = 99;      }      if (PlayerPos[1] < 0)      {        PlayerPos[1] = 0;      }      if (PlayerPos[1] > 99)      {        PlayerPos[1] = 99;      }    }  }}

感謝各位的閱讀,以上就是“怎么用C#實(shí)現(xiàn)飛行棋項(xiàng)目”的內(nèi)容了,經(jīng)過(guò)本文的學(xué)習(xí)后,相信大家對(duì)怎么用C#實(shí)現(xiàn)飛行棋項(xiàng)目這一問(wèn)題有了更深刻的體會(huì),具體使用情況還需要大家實(shí)踐驗(yàn)證。這里是創(chuàng)新互聯(lián),小編將為大家推送更多相關(guān)知識(shí)點(diǎn)的文章,歡迎關(guān)注!

網(wǎng)頁(yè)題目:怎么用C#實(shí)現(xiàn)飛行棋項(xiàng)目
文章出自:http://jinyejixie.com/article24/jjjgje.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供營(yíng)銷型網(wǎng)站建設(shè)、自適應(yīng)網(wǎng)站、網(wǎng)站維護(hù)域名注冊(cè)、App設(shè)計(jì)、關(guān)鍵詞優(yōu)化

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)

商城網(wǎng)站建設(shè)
全椒县| 上蔡县| 武隆县| 大兴区| 海淀区| 汤原县| 闵行区| 文安县| 汽车| 岳池县| 莲花县| 葵青区| 通城县| 灯塔市| 合阳县| 安达市| 贞丰县| 铜山县| 桑植县| 若羌县| 舒城县| 河源市| 平安县| 循化| 阿拉善盟| 龙门县| 周口市| 安岳县| 韶关市| 望江县| 四子王旗| 南汇区| 涞水县| 房山区| 威远县| 伊川县| 四平市| 申扎县| 那坡县| 克什克腾旗| 海淀区|