public override void Run()
        {
            //打开文件
            FileStream stream = new FileStream(m_path, FileMode.Open);

            //移动指针位置
            stream.Seek(0, SeekOrigin.Begin);
            //读取文件信息
            stream.Read(m_rdata, 0, m_rdata.Length);
            //关闭文件
            stream.Close();
            CCommon.ColorWhite();
            Console.SetCursorPosition(10 * 2, 2);
            Console.Write(" 嘿!这里是蛇皮皮的排行榜哦~");
            for (int i = 0; i < 8; i++)
            {
                Console.SetCursorPosition(12 * 2, i + 4);
                Console.Write("第{0}名   \t{1}分", i + 1, ((int)m_rdata[i]) * 5);
            }
            CCommon.ColorBlack();
            Console.SetCursorPosition(15 * 2, 13);
            Console.Write("空格键返回");
            while (Console.KeyAvailable)
            {
                //按键
                char           input = new char();
                ConsoleKeyInfo c     = Console.ReadKey(true);
                input = c.KeyChar;
                if (input == ' ')
                {
                    GameState = 3;
                }
            }
            Thread.Sleep(100);
        }
        public override void Run()
        {
            CCommon.ColorWhite();
            //打开文件
            FileStream stream = new FileStream(m_path, FileMode.OpenOrCreate);

            //移动指针位置
            stream.Seek(0, SeekOrigin.Begin);
            //读取文件信息
            stream.Read(m_rdata, 0, m_rdata.Length);
            //关闭文件
            stream.Close();


            Console.SetCursorPosition(13 * 2, 3);
            Console.Write("游戏结束!总得分:{0}", CCommon.Score * 5);

            if (on)
            {
                if ((byte)CCommon.Score >= m_rdata[m_rdata.Length - 1])
                {
                    m_rdata[m_rdata.Length - 1] = (byte)CCommon.Score;
                    win = true;
                }

                for (int i = m_rdata.Length - 1; i > 0;)
                {
                    if (m_rdata[i] > m_rdata[i - 1])
                    {
                        byte bTmp = m_rdata[i];
                        m_rdata[i]     = m_rdata[i - 1];
                        m_rdata[i - 1] = bTmp;
                    }
                    i--;
                    if (m_rdata[i] == (byte)CCommon.Score)
                    {
                        num = i + 1;
                    }
                }
                on = false;
                //for (int i = 0; i < 8; i++)
                //{
                //    m_rdata[i] = 1;
                //}
                FileStream stream1 = new FileStream(m_path, FileMode.OpenOrCreate);
                //移动指针位置
                stream1.Seek(0, SeekOrigin.Begin);
                //读取文件信息
                stream1.Write(m_rdata, 0, 8);
                //关闭文件
                stream1.Close();
            }
            if (win)
            {
                Console.SetCursorPosition(8 * 2, 5);
                Console.Write("大兄弟厉害呀!成功登上皮皮排行榜第{0}名!", num);
            }
            else
            {
                Console.SetCursorPosition(7 * 2, 5);
                Console.Write("你是手残吗!连我蛇皮皮的排行榜都上不去!丢人!");
            }
            if (m_icon == 1)
            {
                CCommon.ColorBlack();
            }
            else
            {
                CCommon.ColorWhite();
            }
            Console.SetCursorPosition(10 * 2, 8);
            Console.Write("天生傲骨怎能服输!再来一局!");
            if (m_icon == 2)
            {
                CCommon.ColorBlack();
            }
            else
            {
                CCommon.ColorWhite();
            }
            Console.SetCursorPosition(12 * 2, 9);
            Console.Write("认怂!认怂!不玩了!");
            if (m_icon == 3)
            {
                CCommon.ColorBlack();
            }
            else
            {
                CCommon.ColorWhite();
            }
            Console.SetCursorPosition(12 * 2, 10);
            Console.Write("返回蛇皮皮的主菜单");
            while (Console.KeyAvailable)
            {
                //按键
                char           input = new char();
                ConsoleKeyInfo c     = Console.ReadKey(true);
                input = c.KeyChar;
                switch (input)
                {
                case 'w':
                {
                    if (m_icon == 2)
                    {
                        m_icon = 1;
                    }
                    else if (m_icon == 3)
                    {
                        m_icon = 2;
                    }
                }
                break;

                case 's':
                {
                    if (m_icon == 1)
                    {
                        m_icon = 2;
                    }
                    else if (m_icon == 2)
                    {
                        m_icon = 3;
                    }
                }
                break;

                case ' ':
                {
                    GameState = 3;
                }
                break;
                }
            }
            Thread.Sleep(100);
        }
Ejemplo n.º 3
0
        public override void Run()
        {
            go.Begin(0);
            go.DrawBmp(m_id, m_x, m_y);
            go.DrawBmp("开始", 14, 9);
            go.DrawBmp("排行", 14, 11);
            go.End();
            if (m_x + 5 > go.GetClientW() - 1)
            {
                m_id  = "头左";
                m_dir = -1;
            }
            else if (m_x < 1)
            {
                m_id  = "头右";
                m_dir = 1;
            }
            m_x += m_dir;
            Console.SetCursorPosition(11 * 2, 5);
            Console.Write("哦呦!这不是蛇皮皮嘛!");
            if (m_icon == 1)
            {
                CCommon.ColorBlack();
                Console.SetCursorPosition(14 * 2, 9);
                Console.Write("开始游戏");
            }
            if (m_icon == 2)
            {
                CCommon.ColorBlack();
                Console.SetCursorPosition(14 * 2, 11);
                Console.Write("皮皮排行");
            }
            CCommon.ColorWhite();
            while (Console.KeyAvailable)
            {
                //按键
                char           input = new char();
                ConsoleKeyInfo c     = Console.ReadKey(true);
                input = c.KeyChar;
                switch (input)
                {
                case 'w':
                {
                    if (m_icon == 2)
                    {
                        m_icon = 1;
                    }
                }
                break;

                case 's':
                {
                    if (m_icon == 1)
                    {
                        m_icon = 2;
                    }
                }
                break;

                case ' ':
                {
                    GameState = 3;
                }
                break;
                }
            }
            Thread.Sleep(60);
        }