第08天

  1. 游戏头:

step 01:

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using System.Threading.Tasks;

 

namespace 飞行棋游戏

{

    class Program

    {

        static void Main(string[] args)

        {

            GameHead();

            Console.Read();

 

        }

 

        public static void GameHead()

        {

            Console.ForegroundColor = ConsoleColor.Blue;

            Console.WriteLine("*************************************");

            Console.ForegroundColor = ConsoleColor.Yellow;

            Console.WriteLine("*************************************");

            Console.ForegroundColor = ConsoleColor.Green;

            Console.WriteLine("*************************************");

            Console.ForegroundColor = ConsoleColor.Cyan;

            Console.WriteLine("********0326版骑士飞行棋--v1.0*******");

            Console.ForegroundColor = ConsoleColor.DarkRed;

            Console.WriteLine("*************************************");

            Console.ForegroundColor = ConsoleColor.Gray;

            Console.WriteLine("*************************************");

            Console.ForegroundColor = ConsoleColor.DarkCyan;

            Console.WriteLine("*************************************");

            Console.ForegroundColor = ConsoleColor.DarkMagenta;

            Console.WriteLine("*************************************");

        }

    }

}

 

step 02:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
 
namespace 飞行棋游戏
{
    class Program
    {
        public static int[] Maps = new int[100]; //存储地图的数组
 
        static void Main(string[] args)
        {
            GameHead();
            InitialMap();
            Console.Read();
 
        }
 
        /// <summary>
        /// 画游戏头
        /// </summary>
        public static void GameHead()
        {
            Console.ForegroundColor = ConsoleColor.Blue;
            Console.WriteLine("*************************************");
            Console.ForegroundColor = ConsoleColor.Yellow;
            Console.WriteLine("*************************************");
            Console.ForegroundColor = ConsoleColor.Green;
            Console.WriteLine("*************************************");
            Console.ForegroundColor = ConsoleColor.Cyan;
            Console.WriteLine("********0326版骑士飞行棋--v1.0*******");
            Console.ForegroundColor = ConsoleColor.DarkRed;
            Console.WriteLine("*************************************");
            Console.ForegroundColor = ConsoleColor.Gray;
            Console.WriteLine("*************************************");
            Console.ForegroundColor = ConsoleColor.DarkCyan;
            Console.WriteLine("*************************************");
            Console.ForegroundColor = ConsoleColor.DarkMagenta;
            Console.WriteLine("*************************************");
        }
 
        /// <summary>
        /// 初始化地图
        /// </summary>
        public static void InitialMap()
        {
            //我用0表示普通,显示给用户就是 □
            //....1...幸运轮盘,显示组用户就◎ 
            //....2...地雷,显示给用户就是 ☆
            //....3...暂停,显示给用户就是 ▲
            //....4...时空隧道,显示组用户就 卐
            int[] luckyturn = { 6, 23, 40, 55, 69, 83 };//幸运轮盘◎
            for (int i = 0; i < luckyturn.Length; i++)
            {
                Maps[luckyturn[i]] = 1;
            }
            int[] landMine = { 5, 13, 17, 33, 38, 50, 64, 80, 94 };//地雷☆
            for (int i = 0; i < landMine.Length; i++)
            {
                Maps[landMine[i]] = 2;
            }
            int[] pause = { 9, 27, 60, 93 };//暂停▲
            for (int i = 0; i < pause.Length; i++)
            {
                Maps[pause[i]] = 3;
            }
            int[] timeTunnel = { 20, 25, 45, 63, 72, 88, 90 };//时空隧道卐
            for (int i = 0; i < timeTunnel.Length; i++)
            {
                Maps[timeTunnel[i]] = 4;
            }
        }
    }
}

 

step 03:

u using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
 
namespace 飞行棋游戏
{
    class Program
    {
        public static int[] Maps = new int[100]; //存储地图的数组
        public static int[] PlayerPos = new int[2]; //PlayerPos[0] A的坐标
 
        static void Main(string[] args)
        {
            GameHead();
            InitialMap();
            Console.Read();
 
        }
        #region step 01
        /// <summary>
        /// 画游戏头
        /// </summary>
        public static void GameHead()
        {
            Console.ForegroundColor = ConsoleColor.Blue;
            Console.WriteLine("*************************************");
            Console.ForegroundColor = ConsoleColor.Yellow;
            Console.WriteLine("*************************************");
            Console.ForegroundColor = ConsoleColor.Green;
            Console.WriteLine("*************************************");
            Console.ForegroundColor = ConsoleColor.Cyan;
            Console.WriteLine("********0326版骑士飞行棋--v1.0*******");
            Console.ForegroundColor = ConsoleColor.DarkRed;
            Console.WriteLine("*************************************");
            Console.ForegroundColor = ConsoleColor.Gray;
            Console.WriteLine("*************************************");
            Console.ForegroundColor = ConsoleColor.DarkCyan;
            Console.WriteLine("*************************************");
            Console.ForegroundColor = ConsoleColor.DarkMagenta;
            Console.WriteLine("*************************************");
        }
        #endregion
 
        #region step 02
        /// <summary>
        /// 初始化地图
        /// </summary>
        public static void InitialMap()
        {
            //我用0表示普通,显示给用户就是 □
            //....1...幸运轮盘,显示组用户就◎ 
            //....2...地雷,显示给用户就是 ☆
            //....3...暂停,显示给用户就是 ▲
            //....4...时空隧道,显示组用户就 卐
            int[] luckyturn = { 6, 23, 40, 55, 69, 83 };//幸运轮盘◎
            for (int i = 0; i < luckyturn.Length; i++)
            {
                Maps[luckyturn[i]] = 1;
            }
            int[] landMine = { 5, 13, 17, 33, 38, 50, 64, 80, 94 };//地雷☆
            for (int i = 0; i < landMine.Length; i++)
            {
                Maps[landMine[i]] = 2;
            }
            int[] pause = { 9, 27, 60, 93 };//暂停▲
            for (int i = 0; i < pause.Length; i++)
            {
                Maps[pause[i]] = 3;
            }
            int[] timeTunnel = { 20, 25, 45, 63, 72, 88, 90 };//时空隧道卐
            for (int i = 0; i < timeTunnel.Length; i++)
            {
                Maps[timeTunnel[i]] = 4;
            }
        }
        #endregion
 
        #region step 03
        /// <summary>
        /// 画地图
        /// </summary>
        public static void DrawMap()
        {
            #region 第一横行
 
            for (int i = 0; i <= 29; i++)
            {
                if (PlayerPos[0] == PlayerPos[1] && PlayerPos[1] == i)
                {
                    Console.Write("<>");
                }
                else if (PlayerPos[0] == i)
                {
                    Console.Write("A");
                }else if (PlayerPos[1] == i)
                {
                    Console.Write("B");
                }
            }
            #endregion
        }
        #endregion
    }
}
 

 

step 04:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
 
namespace 飞行棋游戏
{
    class Program
    {
        public static int[] Maps = new int[100]; //存储地图的数组
        public static int[] PlayerPos = new int[2]; //PlayerPos[0] A的坐标
 
        static void Main(string[] args)
        {
            GameHead();
            InitialMap();
            DrawMap();
            Console.Read();
 
        }
        #region step 01
        /// <summary>
        /// 画游戏头
        /// </summary>
        public static void GameHead()
        {
            Console.ForegroundColor = ConsoleColor.Blue;
            Console.WriteLine("*************************************");
            Console.ForegroundColor = ConsoleColor.Yellow;
            Console.WriteLine("*************************************");
            Console.ForegroundColor = ConsoleColor.Green;
            Console.WriteLine("*************************************");
            Console.ForegroundColor = ConsoleColor.Cyan;
            Console.WriteLine("********0326版骑士飞行棋--v1.0*******");
            Console.ForegroundColor = ConsoleColor.DarkRed;
            Console.WriteLine("*************************************");
            Console.ForegroundColor = ConsoleColor.Gray;
            Console.WriteLine("*************************************");
            Console.ForegroundColor = ConsoleColor.DarkCyan;
            Console.WriteLine("*************************************");
            Console.ForegroundColor = ConsoleColor.DarkMagenta;
            Console.WriteLine("*************************************");
        }
        #endregion
 
        #region step 02
        /// <summary>
        /// 初始化地图
        /// </summary>
        public static void InitialMap()
        {
            //我用0表示普通,显示给用户就是 □
            //....1...幸运轮盘,显示组用户就◎ 
            //....2...地雷,显示给用户就是 ☆
            //....3...暂停,显示给用户就是 ▲
            //....4...时空隧道,显示组用户就 卐
            int[] luckyturn = { 6, 23, 40, 55, 69, 83 };//幸运轮盘◎
            for (int i = 0; i < luckyturn.Length; i++)
            {
                Maps[luckyturn[i]] = 1;
            }
            int[] landMine = { 5, 13, 17, 33, 38, 50, 64, 80, 94 };//地雷☆
            for (int i = 0; i < landMine.Length; i++)
            {
                Maps[landMine[i]] = 2;
            }
            int[] pause = { 9, 27, 60, 93 };//暂停▲
            for (int i = 0; i < pause.Length; i++)
            {
                Maps[pause[i]] = 3;
            }
            int[] timeTunnel = { 20, 25, 45, 63, 72, 88, 90 };//时空隧道卐
            for (int i = 0; i < timeTunnel.Length; i++)
            {
                Maps[timeTunnel[i]] = 4;
            }
        }
        #endregion
 
        #region step 03
        /// <summary>
        /// 画地图
        /// </summary>
        public static void DrawMap()
        {
            #region 第一横行
 
            for (int i = 0; i <= 29; i++)
            {
                if (PlayerPos[0] == PlayerPos[1] && PlayerPos[1] == i)
                {
                    Console.Write("<>");
                }
                else if (PlayerPos[0] == i)
                {
                    Console.Write("A");
                }else if (PlayerPos[1] == i)
                {
                    Console.Write("B");
                }
                #region step 04
                else
                {
                    switch (Maps[i])
                    {
                        case 0:
                            Console.ForegroundColor = ConsoleColor.DarkYellow; 
                            Console.Write("□");
                            break;
                        case 1:
                            Console.ForegroundColor = ConsoleColor.Red; 
                            Console.Write("◎");
                            break;
                        case 2:
                            Console.ForegroundColor = ConsoleColor.Green; 
                            Console.Write("☆");
                            break;
                        case 3:
                            Console.ForegroundColor = ConsoleColor.Blue; 
                            Console.Write("▲");
                            break;
                        case 4:
                            Console.ForegroundColor = ConsoleColor.DarkGray; 
                            Console.Write("卐");
                            break;
                    }
                }
                #endregion
            }
            #endregion
        }
        #endregion
    }
}

 

step 05:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
 
namespace 飞行棋游戏
{
    class Program
    {
        public static int[] Maps = new int[100]; //存储地图的数组
        public static int[] PlayerPos = new int[2]; //PlayerPos[0] A的坐标
 
        static void Main(string[] args)
        {
            GameHead();
            InitialMap();
            DrawMap();
            Console.Read();
 
        }
        #region step 01
        /// <summary>
        /// 画游戏头
        /// </summary>
        public static void GameHead()
        {
            Console.ForegroundColor = ConsoleColor.Blue;
            Console.WriteLine("*************************************");
            Console.ForegroundColor = ConsoleColor.Yellow;
            Console.WriteLine("*************************************");
            Console.ForegroundColor = ConsoleColor.Green;
            Console.WriteLine("*************************************");
            Console.ForegroundColor = ConsoleColor.Cyan;
            Console.WriteLine("********0326版骑士飞行棋--v1.0*******");
            Console.ForegroundColor = ConsoleColor.DarkRed;
            Console.WriteLine("*************************************");
            Console.ForegroundColor = ConsoleColor.Gray;
            Console.WriteLine("*************************************");
            Console.ForegroundColor = ConsoleColor.DarkCyan;
            Console.WriteLine("*************************************");
            Console.ForegroundColor = ConsoleColor.DarkMagenta;
            Console.WriteLine("*************************************");
        }
        #endregion
 
        #region step 02
        /// <summary>
        /// 初始化地图
        /// </summary>
        public static void InitialMap()
        {
            //我用0表示普通,显示给用户就是 □
            //....1...幸运轮盘,显示组用户就◎ 
            //....2...地雷,显示给用户就是 ☆
            //....3...暂停,显示给用户就是 ▲
            //....4...时空隧道,显示组用户就 卐
            int[] luckyturn = { 6, 23, 40, 55, 69, 83 };//幸运轮盘◎
            for (int i = 0; i < luckyturn.Length; i++)
            {
                Maps[luckyturn[i]] = 1;
            }
            int[] landMine = { 5, 13, 17, 33, 38, 50, 64, 80, 94 };//地雷☆
            for (int i = 0; i < landMine.Length; i++)
            {
                Maps[landMine[i]] = 2;
            }
            int[] pause = { 9, 27, 60, 93 };//暂停▲
            for (int i = 0; i < pause.Length; i++)
            {
                Maps[pause[i]] = 3;
            }
            int[] timeTunnel = { 20, 25, 45, 63, 72, 88, 90 };//时空隧道卐
            for (int i = 0; i < timeTunnel.Length; i++)
            {
                Maps[timeTunnel[i]] = 4;
            }
        }
        #endregion
 
        #region step 03
        /// <summary>
        /// 画地图
        /// </summary>
        public static void DrawMap()
        {
            #region 第一横行
 
            for (int i = 0; i <= 29; i++)
            {
                Console.Write(DrawStringMap(i));
                
            }
            #endregion
            Console.WriteLine();
            
            #region 第一竖行
 
            for (int i = 30; i <= 34; i++)
            {
                for (int j = 0; j < 29; j++)
                {
                    Console.Write("  ");
                }
                Console.WriteLine(DrawStringMap(i));
            }
            #endregion
        }
        #endregion
 
        #region step 05
        public static string DrawStringMap(int i)
        {
            string str = "";
            if (PlayerPos[0] == PlayerPos[1] && PlayerPos[1] == 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.DarkYellow;
                        str = "□";
                        break;
                    case 1:
                        Console.ForegroundColor = ConsoleColor.Red;
                        str = "◎";
                        break;
                    case 2:
                        Console.ForegroundColor = ConsoleColor.Green;
                        str = "☆";
                        break;
                    case 3:
                        Console.ForegroundColor = ConsoleColor.Blue;
                        str = "▲";
                        break;
                    case 4:
                        Console.ForegroundColor = ConsoleColor.DarkGray;
                        str = "卐";
                        break;
                }
            }
            return str;
        }
        #endregion
    }
}

 

step 06:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
 
namespace 飞行棋游戏
{
    class Program
    {
        public static int[] Maps = new int[100]; //存储地图的数组
        public static int[] PlayerPos = new int[2]; //PlayerPos[0] A的坐标
 
        static void Main(string[] args)
        {
            GameHead();
            InitialMap();
            DrawMap();
            Console.Read();
 
        }
        #region step 01
        /// <summary>
        /// 画游戏头
        /// </summary>
        public static void GameHead()
        {
            Console.ForegroundColor = ConsoleColor.Blue;
            Console.WriteLine("*************************************");
            Console.ForegroundColor = ConsoleColor.Yellow;
            Console.WriteLine("*************************************");
            Console.ForegroundColor = ConsoleColor.Green;
            Console.WriteLine("*************************************");
            Console.ForegroundColor = ConsoleColor.Cyan;
            Console.WriteLine("********0326版骑士飞行棋--v1.0*******");
            Console.ForegroundColor = ConsoleColor.DarkRed;
            Console.WriteLine("*************************************");
            Console.ForegroundColor = ConsoleColor.Gray;
            Console.WriteLine("*************************************");
            Console.ForegroundColor = ConsoleColor.DarkCyan;
            Console.WriteLine("*************************************");
            Console.ForegroundColor = ConsoleColor.DarkMagenta;
            Console.WriteLine("*************************************");
        }
        #endregion
 
        #region step 02
        /// <summary>
        /// 初始化地图
        /// </summary>
        public static void InitialMap()
        {
            //我用0表示普通,显示给用户就是 □
            //....1...幸运轮盘,显示组用户就◎ 
            //....2...地雷,显示给用户就是 ☆
            //....3...暂停,显示给用户就是 ▲
            //....4...时空隧道,显示组用户就 卐
            int[] luckyturn = { 6, 23, 40, 55, 69, 83 };//幸运轮盘◎
            for (int i = 0; i < luckyturn.Length; i++)
            {
                Maps[luckyturn[i]] = 1;
            }
            int[] landMine = { 5, 13, 17, 33, 38, 50, 64, 80, 94 };//地雷☆
            for (int i = 0; i < landMine.Length; i++)
            {
                Maps[landMine[i]] = 2;
            }
            int[] pause = { 9, 27, 60, 93 };//暂停▲
            for (int i = 0; i < pause.Length; i++)
            {
                Maps[pause[i]] = 3;
            }
            int[] timeTunnel = { 20, 25, 45, 63, 72, 88, 90 };//时空隧道卐
            for (int i = 0; i < timeTunnel.Length; i++)
            {
                Maps[timeTunnel[i]] = 4;
            }
        }
        #endregion
 
        #region step 03
        /// <summary>
        /// 画地图
        /// </summary>
        public static void DrawMap()
        {
            #region 第一横行
 
            for (int i = 0; i <= 29; i++)
            {
                Console.Write(DrawStringMap(i));
                
            }
            #endregion
            Console.WriteLine();
            
            #region 第一竖行
 
            for (int i = 30; i <= 34; i++)
            {
                for (int j = 0; j < 29; j++)
                {
                    Console.Write("  ");
                }
                Console.WriteLine(DrawStringMap(i));
            }
            #endregion
 
            #region 第二横行
 
            for (int i = 64; i >= 35; i--)
            {
                Console.Write(DrawStringMap(i));
            }
            #endregion
 
            Console.WriteLine();
 
            #region 第二竖行
 
            for (int i = 65; i < 70; i++)
            {
                Console.WriteLine(DrawStringMap(i));
            }
            #endregion
 
            #region 第三横行
 
            for (int i = 70; i < 100; i++)
            {
                Console.Write(DrawStringMap(i));
            }
            #endregion
        }
        #endregion
 
        #region step 05
        public static string DrawStringMap(int i)
        {
            string str = "";
            if (PlayerPos[0] == PlayerPos[1] && PlayerPos[1] == 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.DarkYellow;
                        str = "□";
                        break;
                    case 1:
                        Console.ForegroundColor = ConsoleColor.Red;
                        str = "◎";
                        break;
                    case 2:
                        Console.ForegroundColor = ConsoleColor.Green;
                        str = "☆";
                        break;
                    case 3:
                        Console.ForegroundColor = ConsoleColor.Blue;
                        str = "▲";
                        break;
                    case 4:
                        Console.ForegroundColor = ConsoleColor.DarkGray;
                        str = "卐";
                        break;
                }
            }
            return str;
        }
        #endregion
    }
}

 

step 07:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
 
namespace 飞行棋游戏
{
    class Program
    {
        public static int[] Maps = new int[100]; //存储地图的数组
        public static int[] PlayerPos = new int[2]; //PlayerPos[0] A的坐标
        public static string[] PlayerName = new string[2];
 
        static void Main(string[] args)
        {
            GameHead();
            #region Input username:
            Console.WriteLine("Please input A's name:");
            PlayerName[0] = Console.ReadLine();
            while (PlayerName[0] == "")
            {
                Console.WriteLine("Can't be nil");
                PlayerName[0] = Console.ReadLine();
            }
            Console.WriteLine("Please input B's name:");
            PlayerName[1] = Console.ReadLine();
            while (PlayerName[1] == "" || PlayerName[1] == PlayerName[0])
            {
                if (PlayerName[1] == "")
                {
                    Console.WriteLine("B's name can't be nil");
                    PlayerName[1] = Console.ReadLine();
                }
                else
                {
                    Console.WriteLine("A and B's name can't be the same.");
                    PlayerName[1] = Console.ReadLine();
                }
            }
            #endregion
            InitialMap();
            DrawMap();
            Console.Read();
 
        }
        #region step 01
        /// <summary>
        /// 画游戏头
        /// </summary>
        public static void GameHead()
        {
            Console.ForegroundColor = ConsoleColor.Blue;
            Console.WriteLine("*************************************");
            Console.ForegroundColor = ConsoleColor.Yellow;
            Console.WriteLine("*************************************");
            Console.ForegroundColor = ConsoleColor.Green;
            Console.WriteLine("*************************************");
            Console.ForegroundColor = ConsoleColor.Cyan;
            Console.WriteLine("********0326版骑士飞行棋--v1.0*******");
            Console.ForegroundColor = ConsoleColor.DarkRed;
            Console.WriteLine("*************************************");
            Console.ForegroundColor = ConsoleColor.Gray;
            Console.WriteLine("*************************************");
            Console.ForegroundColor = ConsoleColor.DarkCyan;
            Console.WriteLine("*************************************");
            Console.ForegroundColor = ConsoleColor.DarkMagenta;
            Console.WriteLine("*************************************");
        }
        #endregion
 
        #region step 02
        /// <summary>
        /// 初始化地图
        /// </summary>
        public static void InitialMap()
        {
            //我用0表示普通,显示给用户就是 □
            //....1...幸运轮盘,显示组用户就◎ 
            //....2...地雷,显示给用户就是 ☆
            //....3...暂停,显示给用户就是 ▲
            //....4...时空隧道,显示组用户就 卐
            int[] luckyturn = { 6, 23, 40, 55, 69, 83 };//幸运轮盘◎
            for (int i = 0; i < luckyturn.Length; i++)
            {
                Maps[luckyturn[i]] = 1;
            }
            int[] landMine = { 5, 13, 17, 33, 38, 50, 64, 80, 94 };//地雷☆
            for (int i = 0; i < landMine.Length; i++)
            {
                Maps[landMine[i]] = 2;
            }
            int[] pause = { 9, 27, 60, 93 };//暂停▲
            for (int i = 0; i < pause.Length; i++)
            {
                Maps[pause[i]] = 3;
            }
            int[] timeTunnel = { 20, 25, 45, 63, 72, 88, 90 };//时空隧道卐
            for (int i = 0; i < timeTunnel.Length; i++)
            {
                Maps[timeTunnel[i]] = 4;
            }
        }
        #endregion
 
        #region step 03
        /// <summary>
        /// 画地图
        /// </summary>
        public static void DrawMap()
        {
            #region 第一横行
 
            for (int i = 0; i <= 29; i++)
            {
                Console.Write(DrawStringMap(i));
                
            }
            #endregion
            Console.WriteLine();
            
            #region 第一竖行
 
            for (int i = 30; i <= 34; i++)
            {
                for (int j = 0; j < 29; j++)
                {
                    Console.Write("  ");
                }
                Console.WriteLine(DrawStringMap(i));
            }
            #endregion
 
            #region 第二横行
 
            for (int i = 64; i >= 35; i--)
            {
                Console.Write(DrawStringMap(i));
            }
            #endregion
 
            Console.WriteLine();
 
            #region 第二竖行
 
            for (int i = 65; i < 70; i++)
            {
                Console.WriteLine(DrawStringMap(i));
            }
            #endregion
 
            #region 第三横行
 
            for (int i = 70; i < 100; i++)
            {
                Console.Write(DrawStringMap(i));
            }
            #endregion
        }
        #endregion
 
        #region step 05
        public static string DrawStringMap(int i)
        {
            string str = "";
            if (PlayerPos[0] == PlayerPos[1] && PlayerPos[1] == 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.DarkYellow;
                        str = "□";
                        break;
                    case 1:
                        Console.ForegroundColor = ConsoleColor.Red;
                        str = "◎";
                        break;
                    case 2:
                        Console.ForegroundColor = ConsoleColor.Green;
                        str = "☆";
                        break;
                    case 3:
                        Console.ForegroundColor = ConsoleColor.Blue;
                        str = "▲";
                        break;
                    case 4:
                        Console.ForegroundColor = ConsoleColor.DarkGray;
                        str = "卐";
                        break;
                }
            }
            return str;
        }
        #endregion
    }
}

 

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using System.Threading.Tasks;

 

namespace 飞行棋游戏

{

    class Program

    {

        public static int[] Maps = new int[100]; //存储地图的数组

        public static int[] PlayerPos = new int[2]; //PlayerPos[0] A的坐标

        public static string[] PlayerName = new string[2];

 

        static void Main(string[] args)

        {

            GameHead();

            #region Input username:

            Console.WriteLine("Please input A's name:");

            PlayerName[0] = Console.ReadLine();

            while (PlayerName[0] == "")

            {

                Console.WriteLine("Can't be nil");

                PlayerName[0] = Console.ReadLine();

            }

            Console.WriteLine("Please input B's name:");

            PlayerName[1] = Console.ReadLine();

            while (PlayerName[1] == "" || PlayerName[1] == PlayerName[0])

            {

                if (PlayerName[1] == "")

                {

                    Console.WriteLine("B's name can't be nil");

                    PlayerName[1] = Console.ReadLine();

                }

                else

                {

                    Console.WriteLine("A and B's name can't be the same.");

                    PlayerName[1] = Console.ReadLine();

                }

            }

            #endregion

            Console.Clear();

            GameHead();

            Console.WriteLine("{0}的士兵用A表示", PlayerName[0]);

            Console.WriteLine("{0}的士兵用B表示", PlayerName[1]);

            InitialMap();

            DrawMap();

            while (PlayerPos[0] < 99 && PlayerPos[1] < 99)

            {

                Console.WriteLine("Player {0} begin:",PlayerName[0]);

                Console.ReadKey(true);

                Console.WriteLine("Player {0} rolled 4", PlayerName[0]);

                PlayerPos[0] += 4;

                Console.ReadKey(true);

                Console.WriteLine("Player {0} press any key to continue:", PlayerName[0]);

                Console.ReadKey(true);

                Console.WriteLine("Player {0} finished.", PlayerName[0]);

                Console.ReadKey(true);

                if (PlayerPos[0] == PlayerPos[1])

                {

                    Console.WriteLine("Player {0} hit Player {1}, {2} back 6", PlayerName[0], PlayerName[1],

                        PlayerName[1]);

                    Console.ReadKey(true);

                    PlayerPos[1] -= 6;

                    Console.WriteLine("Player {0} back 6 space.", PlayerName[1]);

                    Console.ReadKey(true);

                }

                else

                {

                    switch (Maps[PlayerPos[0]])

                    {

                        case 0:

                            Console.WriteLine("Player {0} hit square, nothing happen. ", PlayerName[0]);

                            Console.ReadKey(true);

                            break;

                        case 1:

                            Console.WriteLine("Player {0} hit lucky square, 1- change position, 2- bomb opponent", PlayerName[0]);

                            string input = Console.ReadLine();

                            while (true)

                            {

                                if (input == "1")

                                {

                                    Console.WriteLine("Player {0} change position with Player {1}.", PlayerName[0], PlayerName[1]);

                                    int temp = PlayerPos[0];

                                    PlayerPos[0] = PlayerPos[1];

                                    PlayerPos[1] = temp;

                                    Console.ReadKey(true);

                                    break;

                                }

                                else if (input == "2")

                                {

                                    Console.WriteLine("Player {0} bomb Player {1}, Player {2} back 6 spaces.",

                                        PlayerName[0], PlayerName[1], PlayerName[1]);

                                    PlayerPos[1] -= 6;

                                    Console.ReadKey(true);

                                    break;

                                }

                                else

                                {

                                    Console.WriteLine("Error input. 1- change position, 2- bomb opponent");

                                    input = Console.ReadLine();

                                }

                            }

                            Console.ReadKey(true);

                            break;

                        case 2:

                            Console.WriteLine("Player {0} hit mine, back 6 spaces.",PlayerName[0]);

                            PlayerPos[0] -= 6;

                            Console.ReadKey(true);

                            break;

                        case 3:

                            Console.WriteLine("Player {0} hit pause,pause one turn.", PlayerName[0]);

                            Console.ReadKey(true);

                            break;

                        case 4:

                            Console.WriteLine("Player {0} hit time shuffle, forward 10 spaces.", PlayerName[0]);

                            PlayerPos[0] += 10;

                            Console.ReadKey(true);

                            break;

                    }

                }

                Console.Clear();

                DrawMap();

            }

            Console.Read();

 

        }

        #region step 01

        /// <summary>

        /// 画游戏头

        /// </summary>

        public static void GameHead()

        {

            Console.ForegroundColor = ConsoleColor.Blue;

            Console.WriteLine("*************************************");

            Console.ForegroundColor = ConsoleColor.Yellow;

            Console.WriteLine("*************************************");

            Console.ForegroundColor = ConsoleColor.Green;

            Console.WriteLine("*************************************");

            Console.ForegroundColor = ConsoleColor.Cyan;

            Console.WriteLine("********0326版骑士飞行棋--v1.0*******");

            Console.ForegroundColor = ConsoleColor.DarkRed;

            Console.WriteLine("*************************************");

            Console.ForegroundColor = ConsoleColor.Gray;

            Console.WriteLine("*************************************");

            Console.ForegroundColor = ConsoleColor.DarkCyan;

            Console.WriteLine("*************************************");

            Console.ForegroundColor = ConsoleColor.White;

            Console.WriteLine("*************************************");

        }

        #endregion

 

        #region step 02

        /// <summary>

        /// 初始化地图

        /// </summary>

        public static void InitialMap()

        {

            //我用0表示普通,显示给用户就是 □

            //....1...幸运轮盘,显示组用户就◎ 

            //....2...地雷,显示给用户就是 ☆

            //....3...暂停,显示给用户就是 ▲

            //....4...时空隧道,显示组用户就 卐

            int[] luckyturn = { 6, 23, 40, 55, 69, 83 };//幸运轮盘◎

            for (int i = 0; i < luckyturn.Length; i++)

            {

                Maps[luckyturn[i]] = 1;

            }

            int[] landMine = { 5, 13, 17, 33, 38, 50, 64, 80, 94 };//地雷☆

            for (int i = 0; i < landMine.Length; i++)

            {

                Maps[landMine[i]] = 2;

            }

            int[] pause = { 9, 27, 60, 93 };//暂停▲

            for (int i = 0; i < pause.Length; i++)

            {

                Maps[pause[i]] = 3;

            }

            int[] timeTunnel = { 20, 25, 45, 63, 72, 88, 90 };//时空隧道卐

            for (int i = 0; i < timeTunnel.Length; i++)

            {

                Maps[timeTunnel[i]] = 4;

            }

        }

        #endregion

 

        #region step 03

        /// <summary>

        /// 画地图

        /// </summary>

        public static void DrawMap()

        {

            Console.WriteLine("图例:幸运轮盘:◎   地雷:☆   暂停:▲   时空隧道:卐");

            #region 第一横行

 

            for (int i = 0; i <= 29; i++)

            {

                Console.Write(DrawStringMap(i));

                

            }

            #endregion

            Console.WriteLine();

            

            #region 第一竖行

 

            for (int i = 30; i <= 34; i++)

            {

                for (int j = 0; j < 29; j++)

                {

                    Console.Write("  ");

                }

                Console.WriteLine(DrawStringMap(i));

            }

            #endregion

 

            #region 第二横行

 

            for (int i = 64; i >= 35; i--)

            {

                Console.Write(DrawStringMap(i));

            }

            #endregion

 

            Console.WriteLine();

 

            #region 第二竖行

 

            for (int i = 65; i < 70; i++)

            {

                Console.WriteLine(DrawStringMap(i));

            }

            #endregion

 

            #region 第三横行

 

            for (int i = 70; i < 100; i++)

            {

                Console.Write(DrawStringMap(i));

            }

            #endregion

 

            Console.WriteLine();

        }

        #endregion

 

        #region step 05

        public static string DrawStringMap(int i)

        {

            string str = "";

            if (PlayerPos[0] == PlayerPos[1] && PlayerPos[1] == 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.DarkYellow;

                        str = "□";

                        break;

                    case 1:

                        Console.ForegroundColor = ConsoleColor.Red;

                        str = "◎";

                        break;

                    case 2:

                        Console.ForegroundColor = ConsoleColor.Green;

                        str = "☆";

                        break;

                    case 3:

                        Console.ForegroundColor = ConsoleColor.Blue;

                        str = "▲";

                        break;

                    case 4:

                        Console.ForegroundColor = ConsoleColor.DarkGray;

                        str = "卐";

                        break;

                }

            }

            return str;

        }

        #endregion

    }

}

 

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using System.Threading.Tasks;

 

namespace 飞行棋游戏

{

    class Program

    {

        public static int[] Maps = new int[100]; //存储地图的数组

        public static int[] PlayerPos = new int[2]; //PlayerPos[0] A的坐标

        public static string[] PlayerName = new string[2];

        public static bool[] Flags = new bool[2];

 

        static void Main(string[] args)

        {

            GameHead();

            #region Input username:

            Console.WriteLine("Please input A's name:");

            PlayerName[0] = Console.ReadLine();

            while (PlayerName[0] == "")

            {

                Console.WriteLine("Can't be nil");

                PlayerName[0] = Console.ReadLine();

            }

            Console.WriteLine("Please input B's name:");

            PlayerName[1] = Console.ReadLine();

            while (PlayerName[1] == "" || PlayerName[1] == PlayerName[0])

            {

                if (PlayerName[1] == "")

                {

                    Console.WriteLine("B's name can't be nil");

                    PlayerName[1] = Console.ReadLine();

                }

                else

                {

                    Console.WriteLine("A and B's name can't be the same.");

                    PlayerName[1] = Console.ReadLine();

                }

            }

            #endregion

            Console.Clear();

            GameHead();

            Console.WriteLine("{0}的士兵用A表示", PlayerName[0]);

            Console.WriteLine("{0}的士兵用B表示", PlayerName[1]);

            InitialMap();

            DrawMap();

            while (PlayerPos[0] < 99 && PlayerPos[1] < 99)

            {

                if (Flags[0] == false)

                {

                    PlayGame(0);

                }

                else

                {

                    Flags[0] = false;

                }

                if (PlayerPos[0] >= 99)

                {

                    Console.WriteLine("{0} win.", PlayerName[0]);

                    break;

                }

                if (Flags[1] == false)

                {

                    PlayGame(1);

                }

                else

                {

                    Flags[1] = false;

                }

                if (PlayerPos[1] >= 99)

                {

                    Console.WriteLine("{0} win.",PlayerName[1]);

                    break;

                }

            }

            Win();

            Console.Read();

 

        }

        #region step 01

        /// <summary>

        /// 画游戏头

        /// </summary>

        public static void GameHead()

        {

            Console.ForegroundColor = ConsoleColor.Blue;

            Console.WriteLine("*************************************");

            Console.ForegroundColor = ConsoleColor.Yellow;

            Console.WriteLine("*************************************");

            Console.ForegroundColor = ConsoleColor.Green;

            Console.WriteLine("*************************************");

            Console.ForegroundColor = ConsoleColor.Cyan;

            Console.WriteLine("********0326版骑士飞行棋--v1.0*******");

            Console.ForegroundColor = ConsoleColor.DarkRed;

            Console.WriteLine("*************************************");

            Console.ForegroundColor = ConsoleColor.Gray;

            Console.WriteLine("*************************************");

            Console.ForegroundColor = ConsoleColor.DarkCyan;

            Console.WriteLine("*************************************");

            Console.ForegroundColor = ConsoleColor.White;

            Console.WriteLine("*************************************");

        }

        #endregion

 

        #region step 02

        /// <summary>

        /// 初始化地图

        /// </summary>

        public static void InitialMap()

        {

            //我用0表示普通,显示给用户就是 □

            //....1...幸运轮盘,显示组用户就◎ 

            //....2...地雷,显示给用户就是 ☆

            //....3...暂停,显示给用户就是 ▲

            //....4...时空隧道,显示组用户就 卐

            int[] luckyturn = { 6, 23, 40, 55, 69, 83 };//幸运轮盘◎

            for (int i = 0; i < luckyturn.Length; i++)

            {

                Maps[luckyturn[i]] = 1;

            }

            int[] landMine = { 5, 13, 17, 33, 38, 50, 64, 80, 94 };//地雷☆

            for (int i = 0; i < landMine.Length; i++)

            {

                Maps[landMine[i]] = 2;

            }

            int[] pause = { 9, 27, 60, 93 };//暂停▲

            for (int i = 0; i < pause.Length; i++)

            {

                Maps[pause[i]] = 3;

            }

            int[] timeTunnel = { 20, 25, 45, 63, 72, 88, 90 };//时空隧道卐

            for (int i = 0; i < timeTunnel.Length; i++)

            {

                Maps[timeTunnel[i]] = 4;

            }

        }

        #endregion

 

        #region step 03

        /// <summary>

        /// 画地图

        /// </summary>

        public static void DrawMap()

        {

            Console.WriteLine("图例:幸运轮盘:◎   地雷:☆   暂停:▲   时空隧道:卐");

            #region 第一横行

 

            for (int i = 0; i <= 29; i++)

            {

                Console.Write(DrawStringMap(i));

                

            }

            #endregion

            Console.WriteLine();

            

            #region 第一竖行

 

            for (int i = 30; i <= 34; i++)

            {

                for (int j = 0; j < 29; j++)

                {

                    Console.Write("  ");

                }

                Console.WriteLine(DrawStringMap(i));

            }

            #endregion

 

            #region 第二横行

 

            for (int i = 64; i >= 35; i--)

            {

                Console.Write(DrawStringMap(i));

            }

            #endregion

 

            Console.WriteLine();

 

            #region 第二竖行

 

            for (int i = 65; i < 70; i++)

            {

                Console.WriteLine(DrawStringMap(i));

            }

            #endregion

 

            #region 第三横行

 

            for (int i = 70; i < 100; i++)

            {

                Console.Write(DrawStringMap(i));

            }

            #endregion

 

            Console.WriteLine();

        }

        #endregion

 

        #region step 05

        public static string DrawStringMap(int i)

        {

            string str = "";

            if (PlayerPos[0] == PlayerPos[1] && PlayerPos[1] == 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.DarkYellow;

                        str = "□";

                        break;

                    case 1:

                        Console.ForegroundColor = ConsoleColor.Red;

                        str = "◎";

                        break;

                    case 2:

                        Console.ForegroundColor = ConsoleColor.Green;

                        str = "☆";

                        break;

                    case 3:

                        Console.ForegroundColor = ConsoleColor.Blue;

                        str = "▲";

                        break;

                    case 4:

                        Console.ForegroundColor = ConsoleColor.DarkGray;

                        str = "卐";

                        break;

                }

            }

            return str;

        }

        #endregion

 

        #region step 06

 

        public static void PlayGame(int playerNumber)

        {

            Random r = new Random();

            int rNumber = r.Next(1, 7);

            Console.WriteLine("Player {0} begin:", PlayerName[playerNumber]);

            Console.ReadKey(true);

            Console.WriteLine("Player {0} rolled {1}", PlayerName[playerNumber],rNumber);

 

            PlayerPos[playerNumber] += rNumber;

            ChangePos();

            Console.ReadKey(true);

            Console.WriteLine("Player {0} press any key to continue:", PlayerName[playerNumber]);

            Console.ReadKey(true);

            Console.WriteLine("Player {0} finished.", PlayerName[playerNumber]);

            Console.ReadKey(true);

            if (PlayerPos[playerNumber] == PlayerPos[1 - playerNumber])

            {

                Console.WriteLine("Player {0} hit Player {1}, {2} back 6", PlayerName[playerNumber], PlayerName[1 - playerNumber],

                    PlayerName[1 - playerNumber]);

                Console.ReadKey(true);

                PlayerPos[1 - playerNumber] -= 6;

                ChangePos();

                Console.WriteLine("Player {0} back 6 space.", PlayerName[1 - playerNumber]);

                Console.ReadKey(true);

            }

            else

            {

                switch (Maps[PlayerPos[playerNumber]])

                {

                    case 0:

                        Console.WriteLine("Player {0} hit square, nothing happen. ", PlayerName[playerNumber]);

                        Console.ReadKey(true);

                        break;

                    case 1:

                        Console.WriteLine("Player {0} hit lucky square, 1- change position, 2- bomb opponent", PlayerName[playerNumber]);

                        string input = Console.ReadLine();

                        while (true)

                        {

                            if (input == "1")

                            {

                                Console.WriteLine("Player {0} change position with Player {1}.", PlayerName[playerNumber], PlayerName[1 - playerNumber]);

                                int temp = PlayerPos[playerNumber];

                                PlayerPos[playerNumber] = PlayerPos[1 - playerNumber];

                                PlayerPos[1 - playerNumber] = temp;

                                ChangePos();

                                Console.ReadKey(true);

                                break;

                            }

                            else if (input == "2")

                            {

                                Console.WriteLine("Player {0} bomb Player {1}, Player {2} back 6 spaces.",

                                    PlayerName[playerNumber], PlayerName[1 - playerNumber], PlayerName[1 - playerNumber]);

                                PlayerPos[1 - playerNumber] -= 6;

                                ChangePos();

                                Console.ReadKey(true);

                                break;

                            }

                            else

                            {

                                Console.WriteLine("Error input. 1- change position, 2- bomb opponent");

                                input = Console.ReadLine();

                            }

                        }

                        Console.ReadKey(true);

                        break;

                    case 2:

                        Console.WriteLine("Player {0} hit mine, back 6 spaces.", PlayerName[playerNumber]);

                        PlayerPos[playerNumber] -= 6;

                        ChangePos();

                        Console.ReadKey(true);

                        break;

                    case 3:

                        Console.WriteLine("Player {0} hit pause,pause one turn.", PlayerName[playerNumber]);

                        Flags[playerNumber] = true;

                        Console.ReadKey(true);

                        break;

                    case 4:

                        Console.WriteLine("Player {0} hit time shuffle, forward 10 spaces.", PlayerName[playerNumber]);

                        PlayerPos[playerNumber] += 10;

                        ChangePos();

                        Console.ReadKey(true);

                        break;

                }

            }

            Console.Clear();

            DrawMap();

        }

        #endregion

 

        #region step 07

 

        public static void ChangePos()

        {

            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;

            }

        }

        #endregion

 

        /// <summary>

        /// 胜利啦!!!

        /// </summary>

        public static void Win()

        {

            Console.ForegroundColor = ConsoleColor.Red;

            Console.WriteLine("                                          ◆                      ");

            Console.WriteLine("                    ■                  ◆               ■        ■");

            Console.WriteLine("      ■■■■  ■  ■                ◆■         ■    ■        ■");

            Console.WriteLine("      ■    ■  ■  ■              ◆  ■         ■    ■        ■");

            Console.WriteLine("      ■    ■ ■■■■■■       ■■■■■■■   ■    ■        ■");

            Console.WriteLine("      ■■■■ ■   ■                ●■●       ■    ■        ■");

            Console.WriteLine("      ■    ■      ■               ● ■ ●      ■    ■        ■");

            Console.WriteLine("      ■    ■ ■■■■■■         ●  ■  ●     ■    ■        ■");

            Console.WriteLine("      ■■■■      ■             ●   ■   ■    ■    ■        ■");

            Console.WriteLine("      ■    ■      ■            ■    ■         ■    ■        ■");

            Console.WriteLine("      ■    ■      ■                  ■               ■        ■ ");

            Console.WriteLine("     ■     ■      ■                  ■           ●  ■          ");

            Console.WriteLine("    ■    ■■ ■■■■■■             ■              ●         ●");

            Console.ResetColor();

        }

    }

}

 

1、面向过程  面向对象

想吃煎饼

面向过程:拿着钱,从宿舍到煎饼摊。

面向对象:找个对象 帮你做事儿。

 

面向过程:面向的是这件事儿的过程,强调是做这件事儿的动作。

面向对象:面向的是对象。

用面向过程的思想:将大象塞进冰箱里

把大象塞进冰箱里  软件系统

1、打开冰箱门

2、把大象塞进去 ,亲下大象的屁股

//3、关闭冰箱门

 

杨浩然 高大  浑身都是肌肉

杨浩然可以自己打开冰箱门

杨浩然自己也可以把大象塞进去,亲下大象的屁股

//杨浩然可以自己关闭冰箱门

 

 

苏雷 130cm  30KG

苏蕾踩着凳子打开冰箱门

苏蕾 找杨浩然帮忙把大象塞进冰箱里,亲下大象的屁股

//苏蕾自己踩着凳子关闭冰箱门。

 

用面向对象的思想:将大象塞进冰箱里

把冰箱提取出来作为对象

1、冰箱门可以被打开

2、大象可以被塞进冰箱里,亲一下屁股

3、冰箱门可以被关闭

 

杨浩然:冰箱门可以被打开

杨浩然:大象可以被塞进冰箱里,亲一下屁股

杨浩然:冰箱门可以被关闭

 

去中关村买电脑

1、首先 查要买的电脑的型号和价格

2、做车去中关村

3、跟服务员讨价还价

4、被骗

 

 

杨浩然:大牛及神人

面向对象的3大特征:封装、继承、多态

 

关门

门可以被关闭

 

我在黑板上画了一个圆

黑板可以被画一个圆

 

描述杨浩然、苏雷的特征和行为

杨浩然:

姓名:杨浩然

性别:男

年龄:18

身高:180cm

体重:10kg

吃喝拉撒睡 吃喝嫖赌抽

 

苏雷:

姓名:苏雷

性别:男

年龄:81

身高:120cm

体重:20kg

吃喝拉撒睡 吃喝嫖赌抽

 

在程序中,我们描述一个对象,描述的是这个对象的属性和方法。

 

对象是实际存在的,一定是看得见摸得着的。

 

我们把这些具有相同属性和行为的对象进行进一步的封装,提取出了一个概念"类".

 

类就是一个模子,确定了对象将会拥有的属性和方法。

 

posted @ 2017-05-30 18:34  摩羯红梅  阅读(192)  评论(0编辑  收藏  举报