예제 #1
0
        //判断两个像素点是否相等
        public override bool Equals(Object o)
        {
            CanvasPoint p = (CanvasPoint)o;

            return(pic == p.pic && backColor == p.backColor &&
                   forceColor == p.forceColor);
        }
예제 #2
0
 public void DrawCoordinate(int x, int y)
 {
     //坐标轴往左上角移一位
     x--;
     y--;
     //画坐标轴
     for (int i = 0; i < 21; i++)
     {
         int first = (i + x) / 10;
         int next  = (i + x) % 10;
         if ((i + x) % 2 == 0)
         {
             //第一个字符
             uibuffer[2 * i, 0] = new CanvasPoint(first.ToString()[0], ConsoleColor.Black, ConsoleColor.Blue);
             //第二个字符
             uibuffer[2 * i + 1, 0] = new CanvasPoint(next.ToString()[0], ConsoleColor.Black, ConsoleColor.Blue);
         }
         else
         {
             //第一个字符
             uibuffer[2 * i, 0] = new CanvasPoint(first.ToString()[0], ConsoleColor.Black, ConsoleColor.Red);
             //第二个字符
             uibuffer[2 * i + 1, 0] = new CanvasPoint(next.ToString()[0], ConsoleColor.Black, ConsoleColor.Red);
         }
     }
     for (int i = 0; i < 21; i++)
     {
         int first = (i + y) / 10;
         int next  = (i + y) % 10;
         if ((i + y) % 2 == 0)
         {
             //第一个字符
             uibuffer[0, i] = new CanvasPoint(first.ToString()[0], ConsoleColor.Black, ConsoleColor.Blue);
             //第二个字符
             uibuffer[1, i] = new CanvasPoint(next.ToString()[0], ConsoleColor.Black, ConsoleColor.Blue);
         }
         else
         {
             //第一个字符
             uibuffer[0, i] = new CanvasPoint(first.ToString()[0], ConsoleColor.Black, ConsoleColor.Red);
             //第二个字符
             uibuffer[1, i] = new CanvasPoint(next.ToString()[0], ConsoleColor.Black, ConsoleColor.Red);
         }
     }
 }
예제 #3
0
        //这个相当于console.write(); 将字符串写入点p位置
        public void WriteBuffer(Pos p, string str)
        {
            int x = p.x, y = p.y;

            char[] cs = str.ToCharArray();

            for (int i = 0; i < str.Length; i++)
            {
                if (IsChinese(cs[i]))
                {
                    buffer[x, y]     = new CanvasPoint(cs[i], color);
                    buffer[x + 1, y] = new CanvasPoint(' ', buffer[x, y].backColor, buffer[x, y].forceColor);
                    x = x + 2;
                }
                else
                {
                    buffer[x, y] = new CanvasPoint(cs[i], color);
                    x++;
                }
            }
        }
예제 #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);
        }