Пример #1
0
 //初始化场景
 public override void Init()
 {
     b = 0;
     //初始化Image
     xuanwo     = new CCustomImage(Properties.Resources.xuanwo, 100, 70);
     pattern1   = new CCustomImage(Properties.Resources.zhuan, 150, 150);
     pattern2   = new CCustomImage(Properties.Resources.chi, 150, 150);
     presen     = new CCustomImage(Properties.Resources.wujin, 400, 100);
     back       = new CCustomImage(Properties.Resources.mback, 170, 100);
     go         = new CCustomImage(Properties.Resources.Go, 100, 100);
     background = new CCustomImage(Properties.Resources.initpintu1, 795, 415);
     pattern1.SetPos(150, 80);
     pattern2.SetPos(400, 80);
     presen.SetPos(150, 250);
     xuanwo.SetPos(250, 50);
     go.SetPos(520, 260);
     back.SetPos(-5, 0);
     background.SetPos(-5, 0);
     //设置场景状态
     m_SceneState        = 1;
     pattern1.MouseDown += pattern1Run;
     pattern2.MouseDown += pattern2Run;
     go.MouseDown       += goRun;
     back.MouseDown     += backRun;
 }
Пример #2
0
        //初始化场景
        public override void Init()
        {
            lable            = new Label();
            lable.Content    = "Game Over";
            lable.Width      = 250;
            lable.Height     = 50;
            lable.FontSize   = 35;
            lable.FontFamily = new FontFamily("Consolas");
            Canvas.SetLeft(lable, 280);
            Canvas.SetTop(lable, 100);
            again = new CCustomImage(Properties.Resources.again, 130, 100);
            again.SetPos(550, 250);
            home = new CCustomImage(Properties.Resources.home, 130, 100);
            home.SetPos(380, 245);
            m_SceneState     = 1;
            again.MouseDown += againRun;
            home.MouseDown  += homeRun;

            m_path  = "..\\..\\rank.data";
            m_rdata = new byte[8];
            //安全检测
            if (!File.Exists(m_path))
            {
                return;
            }
            //打开文件
            FileStream stream = new FileStream(m_path, FileMode.OpenOrCreate);

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

            if ((byte)Score >= m_rdata[m_rdata.Length - 1])
            {
                m_rdata[m_rdata.Length - 1] = (byte)Score;
            }
            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--;
            }
            FileStream stream1 = new FileStream(m_path, FileMode.OpenOrCreate);

            //移动指针位置
            stream1.Seek(0, SeekOrigin.Begin);
            //读取文件信息
            stream1.Write(m_rdata, 0, 8);
            //关闭文件
            stream1.Close();
        }
Пример #3
0
        public override void Init()
        {
            string m_path;

            byte[] m_rdata;
            m_rdata = new byte[8];
            m_path  = "..\\..\\rank.data";
            //安全检测
            if (!File.Exists(m_path))
            {
                return;
            }
            //打开文件
            FileStream stream = new FileStream(m_path, FileMode.Open);

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


            m_LableList = new List <Label>();
            for (int i = 0; i < 8; i++)
            {
                R            = new Label();
                R.Width      = 400;
                R.Height     = 50;
                R.FontSize   = 22;
                R.FontFamily = new FontFamily("Consolas");
                Canvas.SetLeft(R, 250);
                Canvas.SetTop(R, 90 + i * 35);
                R.Content = "第 " + (i + 1).ToString() + " 名:\t" + (((int)m_rdata[i]) * 5).ToString() + " 分";
                m_LableList.Add(R);
            }
            back       = new CCustomImage(Properties.Resources.kback, 170, 100);
            background = new CCustomImage(Properties.Resources.initpintu1, 795, 415);
            rank       = new CCustomImage(Properties.Resources.rank, 200, 50);
            background.SetPos(-5, 0);
            rank.SetPos(270, 20);
            back.SetPos(632, 312);
            back.MouseDown += backRun;
            m_SceneState    = 1;
        }
Пример #4
0
 //初始化场景
 public override void Init()
 {
     //初始化Image
     title      = new CCustomImage(Properties.Resources.title, 424 / 2, 124 / 2);
     begin      = new CCustomImage(Properties.Resources.begingame, 337 / 3, 119 / 3);
     order      = new CCustomImage(Properties.Resources.order, 337 / 3, 119 / 3);
     background = new CCustomImage(Properties.Resources.initpintu1, 795, 415);
     gameover   = new CCustomImage(Properties.Resources.gameover, 337 / 3, 119 / 3);
     title.SetPos(280, 60);
     begin.SetPos(330, 180);
     order.SetPos(330, 240);
     gameover.SetPos(330, 300);
     background.SetPos(-5, 0);
     //设置场景状态
     m_SceneState        = 1;
     begin.MouseDown    += BeginRun;
     order.MouseDown    += OrderRun;
     gameover.MouseDown += overRun;
 }
Пример #5
0
        //初始化场景
        public override void Init()
        {
            b                = true;
            m_key            = false;
            fen              = 0;
            Score            = new Label();
            Score.Content    = "总分:  0";
            Score.Width      = 200;
            Score.Height     = 50;
            Score.FontSize   = 22;
            Score.FontFamily = new FontFamily("Consolas");
            Canvas.SetLeft(Score, 600);
            Canvas.SetTop(Score, 20);
            Snake = new CHero(50, 50, 30, 30, 2);
            Food  = new CFood(350, 200, 15, 15);
            if (MainWindow.On)
            {
                Snake.SetSpeed(2);
            }
            else
            {
                Snake.SetSpeed(30);
            }

            background = new CCustomImage(Properties.Resources.initpintu, 795, 415);
            snake      = new CCustomImage(Properties.Resources.head, Snake.GetW(), Snake.GetH());
            food       = new CCustomImage(Properties.Resources.brick, Food.GetW(), Food.GetH());
            pause      = new CCustomImage(Properties.Resources.pause1, 30, 30);
            runback    = new CCustomImage(Properties.Resources.runback, 30, 30);

            pause.SetPos(630, 60);
            runback.SetPos(680, 60);
            background.SetPos(-5, 0);
            food.SetPos(Food.GetX(), Food.GetY());
            snake.SetPos(Snake.GetX(), Snake.GetY());
            snake.SetAngle(0);
            pause.MouseDown   += pauseRun;
            runback.MouseDown += runbackRun;
            m_SceneState       = 1;
        }