Beispiel #1
0
        public void Init()
        {
            //加载boss的贴图
            StreamReader sr = FileController.GetFileReader("Boss.txt");

            for (int i = 0; i < 20; i++)
            {
                bossPic[i] = sr.ReadLine();
            }
            sr.Close();
            //真正的本体
            bossSelf = new Boss(scene, new Pos(33, 0), this);
            //加载boss的模型
            int wx = 33, wy = 0;

            for (int i = 0; i < 20; i++)
            {
                for (int j = 0; j < 6; j++)
                {
                    Boss b = new Boss(scene, new Pos(wx + i, wy + j), this);
                    bossList.Add(b);
                    b.pic = bossPic[14 + j].Substring(2 * i, 2);
                }
            }
            //加载神之掌击的范围 面前4行
            for (int i = 0; i < 20; i++)
            {
                for (int j = 0; j < 4; j++)
                {
                    hugeHandRange.Add(new Pos(wx + i, wy + 6 + j));
                }
            }
            //添加封锁烈焰的施法范围和生成范围
            int sx = 33, sy = 10;

            sr = FileController.GetFileReader("CrossFireRange.txt");
            for (int y = 0; y < 10; y++)
            {
                string str = sr.ReadLine();
                char[] cs  = str.ToCharArray();
                for (int x = 0; x < cs.Length; x++)
                {
                    if (cs[x] == 'X')
                    {
                        crossFireRange.Add(new Pos(sx + x, sy + y));
                    }
                    else if (cs[x] == 'O')
                    {
                        bornEnemyPoint.Add(new Pos(sx + x, sy + y));
                    }
                }
            }
            sr.Close();
        }
        //显示开始界面
        public Result LoadStartScene()
        {
            List <Pos> listP = new List <Pos>()
            {
                new Pos(12, 5),
                new Pos(12, 6), new Pos(12, 7), new Pos(12, 8), new Pos(12, 9)
            };
            List <string> listS = new List <string>()
            {
                scene.canvas.ShowString("1.开始游戏简单", 15), scene.canvas.ShowString("2.开始游戏困难", 15),
                scene.canvas.ShowString("3.开始多人游戏", 15),
                scene.canvas.ShowString("4.查看成就", 15), scene.canvas.ShowString("5.退出游戏", 15)
            };
            List <Result> listR = new List <Result>()
            {
                Result.startSingleEasy, Result.startSingleHard, Result.startMiuti,
                Result.startSingleTest, Result.startQuit
            };


            int selected = 1;

            Console.Clear();
            StreamReader sr  = FileController.GetFileReader("StartScene.txt");
            string       str = "";

            while ((str = sr.ReadLine()) != null)
            {
                Console.WriteLine(str);
            }

            while (true)
            {
                Show();
                ConsoleKeyInfo ck = Console.ReadKey();
                if (ck.Key == ConsoleKey.DownArrow)
                {
                    selected++;
                    if (selected == 5)
                    {
                        selected = 0;
                    }
                }
                else if (ck.Key == ConsoleKey.UpArrow)
                {
                    selected--;
                    if (selected == -1)
                    {
                        selected = 4;
                    }
                }
                else if (ck.Key == ConsoleKey.Enter)
                {
                    return(listR[selected]);
                }
            }
            void Show()
            {
                for (int i = 0; i < 5; i++)
                {
                    if (i == selected)
                    {
                        Console.BackgroundColor = ConsoleColor.Cyan;
                    }
                    else
                    {
                        Console.BackgroundColor = ConsoleColor.Black;
                    }
                    Console.SetCursorPosition(listP[i].x, listP[i].y);
                    Console.Write(listS[i]);
                }
            }
        }
        public Result LoadGameOverScene()
        {
            Console.Clear();
            List <Pos> listP = new List <Pos>()
            {
                new Pos(4, 2), new Pos(4, 3)
            };
            List <string> listS = new List <string>()
            {
                scene.canvas.ShowString("1.重新开始", 10),
                scene.canvas.ShowString("2.退出游戏", 10)
            };
            int selected = 0;

            StreamReader sr  = FileController.GetFileReader("DeadScene.txt");
            string       str = "";

            while ((str = sr.ReadLine()) != null)
            {
                Console.WriteLine(str);
            }

            while (true)
            {
                Show();
                ConsoleKeyInfo ck = Console.ReadKey();
                if (ck.Key == ConsoleKey.DownArrow)
                {
                    selected++;
                    if (selected == 2)
                    {
                        selected = 0;
                    }
                }
                else if (ck.Key == ConsoleKey.UpArrow)
                {
                    selected--;
                    if (selected == -1)
                    {
                        selected = 1;
                    }
                }
                else if (ck.Key == ConsoleKey.Enter)
                {
                    if (selected == 0)
                    {
                        return(Result.confirm);
                    }
                    else if (selected == 1)
                    {
                        return(Result.cancel);
                    }
                }
            }

            void Show()
            {
                Console.BackgroundColor = ConsoleColor.Black;
                Console.SetCursorPosition(1, 1);
                Console.Write(scene.canvas.ShowString("坚持了" + turns + "个回合", 10));
                for (int i = 0; i < 2; i++)
                {
                    if (i == selected)
                    {
                        Console.BackgroundColor = ConsoleColor.Cyan;
                    }
                    else
                    {
                        Console.BackgroundColor = ConsoleColor.Black;
                    }
                    Console.SetCursorPosition(listP[i].x, listP[i].y);
                    Console.Write(listS[i]);
                }
            }
        }
Beispiel #4
0
        public void InitUI()
        {
            sr = FileController.GetFileReader("UI.txt");
            string str;
            int    n = 0;

            while ((str = sr.ReadLine()) != null)
            {
                char[] cs = str.ToCharArray();
                width = str.Length;
                for (int i = 0; i < cs.Length; i++)
                {
                    if (cs[i] == '#')
                    {
                        switch (cs[i + 1])
                        {
                        case 'M':
                            mapPos = new Pos(i, n);
                            break;

                        case 'A':
                            turnsPos = new Pos(i, n);
                            break;

                        case 'B':
                            statePos = new Pos(i, n);
                            break;

                        case 'C':
                            targetPos = new Pos(i, n);
                            break;

                        case 'D':
                            DebugLogPos = new Pos(i, n);
                            break;

                        case 'E':
                            immediatePos = new Pos(i, n);
                            break;

                        case 'N':
                            namePos = new Pos(i, n);
                            break;

                        case 'H':
                            hpPos = new Pos(i, n);
                            break;
                        }
                    }
                }
                n++;
            }
            //给留空10格
            width     += 30;
            height     = n + 1;
            buffer     = new CanvasPoint[width, height];
            backBuffer = new CanvasPoint[width, height];
            uibuffer   = new CanvasPoint[width, height];
            //初始化两个buffer
            ClearBuffer();
            ClearUIBuffer();
            //初始化,将边框画在uibuffer里存起来
            sr.Close();
            sr = FileController.GetFileReader("UI.txt");
            n  = 0;
            while ((str = sr.ReadLine()) != null)
            {
                char[] cs = str.ToCharArray();
                for (int i = 0; i < cs.Length; i++)
                {
                    if (cs[i] == '#')
                    {
                        //把i往后扔一位然后填两个空格
                        uibuffer[i, n] = new CanvasPoint();
                        i++;
                        uibuffer[i, n] = new CanvasPoint();
                    }
                    else
                    {
                        uibuffer[i, n] = new CanvasPoint(cs[i]);
                    }
                }
                n++;
            }
            sr.Close();

            DrawCoordinate(0, 0);
        }