Exemple #1
0
        //读取ini方法
        private void iniRead()
        {
            string s = System.Windows.Forms.Application.ExecutablePath;
            //取得config.ini路径
            string path = s.ToLower().Replace("flappybird.exe", "config.ini");

            if (System.IO.File.Exists(path))//判断是否存在
            {
                //读取.ini文件:DWORD GetPrivateProfileString(LPCTSTR lpAppName,LPCTSTR lpKeyName,LPCTSTR lpDefaut,LPSTR lpReturnedString,DWORD nSize,LPCTSTR lpFileName);
                //其中个参数的意思:
                //LPCTSTR lpAppName ------- INI文件中的一个字段名//
                //LPCTSTR lpKeyName -------- lpAppName 下的一个键名,也就是里面具体的变量名
                //LPCTSTR lpString ---------是键值,也就是变量的值, 必须为LPCTSTR或CString类型
                //LPCTSTR lpFileName --------完整的INI文件路径名
                //LPCTSTR lpDefaut ----------如果没有其前两个参数值,则将此值赋给变量
                //LPSTR lpReturnedString --------接收INI文件中的值的CString对象,即接收缓冲区
                //DWORD nSize ------接收缓冲区的大小

                StringBuilder str = new StringBuilder(255);
                GetPrivateProfileString("bird", "birdcolor", "", str, 255, path);
                //string->enum强制转换
                _nowColor = (BirdColor)Enum.Parse(typeof(BirdColor), str.ToString());

                StringBuilder str2 = new StringBuilder(255);
                GetPrivateProfileString("score", "first", "", str2, 255, path);
                _first = Convert.ToInt32(str2.ToString());
                StringBuilder str3 = new StringBuilder(255);
                GetPrivateProfileString("score", "second", "", str3, 255, path);
                _second = Convert.ToInt32(str3.ToString());
                StringBuilder str4 = new StringBuilder(255);
                GetPrivateProfileString("score", "third", "", str4, 255, path);
                _third = Convert.ToInt32(str4.ToString());
            }
        }
Exemple #2
0
        //皮肤功能按钮
        private void buttonSkin_Click(object sender, EventArgs e)
        {
            //播放声音文件
            PlaySound("sound/flappy2.wav");
            //新建皮肤选择对话框
            Skin skin = new Skin();

            skin.NowBirdColor = _nowColor;
            skin._Firstsc     = _first;
            if (skin.ShowDialog(this) == DialogResult.OK)
            {
                _nowColor = skin.NowBirdColor;
            }

            //写入ini
            iniWirte();
        }
Exemple #3
0
        //选中时的选择框展示及效果
        public void showCheck(BirdColor color)
        {
            if (color == BirdColor.yellow)
            {
                pictureBoxBg1.Visible = true;
                pictureBoxBg2.Visible = false;
                pictureBoxBg3.Visible = false;
                pictureBoxBg4.Visible = false;
            }
            else if (color == BirdColor.blue)
            {
                pictureBoxBg2.Visible = true;
                pictureBoxBg1.Visible = false;
                pictureBoxBg3.Visible = false;
                pictureBoxBg4.Visible = false;
            }
            else if (color == BirdColor.red)
            {
                pictureBoxBg3.Visible = true;
                pictureBoxBg2.Visible = false;
                pictureBoxBg1.Visible = false;
                pictureBoxBg4.Visible = false;
            }
            else if (color == BirdColor.black)
            {
                pictureBoxBg4.Visible = true;
                pictureBoxBg2.Visible = false;
                pictureBoxBg3.Visible = false;
                pictureBoxBg1.Visible = false;
            }

            if (_firstsc < 10)
            {
                labelb3.Text      = "SC>10";
                labelb3.ForeColor = System.Drawing.Color.Red;
            }
            if (_firstsc < 20)
            {
                labelb4.ForeColor = System.Drawing.Color.Red;
                labelb4.Text      = "SC>20";
            }
        }
Exemple #4
0
        private void pictureBoxBird4_Click(object sender, EventArgs e)
        {
            if (_firstsc >= 20)
            {
                _unlocked = true;
            }
            else
            {
                _unlocked = false;
            }

            if (_unlocked == true)
            {
                _nowBirdColor = BirdColor.black;
            }
            else
            {
                labelb4.Text = "SC>20";
            }
        }
Exemple #5
0
        private void pictureBoxBird3_Click(object sender, EventArgs e)
        {
            if (_firstsc >= 10)
            {
                _unlocked = true;
            }
            else
            {
                _unlocked = false;
            }

            if (_unlocked == true)
            {
                _nowBirdColor = BirdColor.red;
            }
            else
            {
                labelb3.Text = "SC>10";
            }
        }
Exemple #6
0
 private void pictureBoxBird2_Click(object sender, EventArgs e)
 {
     _nowBirdColor = BirdColor.blue;
 }
Exemple #7
0
 private void pictureBoxBird1_Click(object sender, EventArgs e)
 {
     _nowBirdColor = BirdColor.yellow;
 }
Exemple #8
0
 //
 public Bird(BirdColor bColor, State _state)
 {
     if (bColor == BirdColor.yellow)
     {
         //装载黄色小鸟位图
         _birdBmp[0] = new Bitmap("image/bird/yellow1.png");
         _birdBmp[1] = new Bitmap("image/bird/yellow2.png");
         _birdBmp[2] = new Bitmap("image/bird/yellow3.png");
         _birdBmp[3] = new Bitmap("image/bird/yellow4.png");
         _birdBmp[4] = new Bitmap("image/bird/yellow5.png");
         _birdBmp[5] = new Bitmap("image/bird/yellow6.png");
         _birdBmp[6] = new Bitmap("image/bird/yellow7.png");
         _birdBmp[7] = new Bitmap("image/bird/yellow8.png");
         _birdBmp[8] = new Bitmap("image/bird/yellow9.png");
         _birdBmp[9] = new Bitmap("image/bird/yellow10.png");
     }
     if (bColor == BirdColor.blue)
     {
         //装载蓝色小鸟位图
         _birdBmp[0] = new Bitmap("image/bird/blue1.png");
         _birdBmp[1] = new Bitmap("image/bird/blue2.png");
         _birdBmp[2] = new Bitmap("image/bird/blue3.png");
         _birdBmp[3] = new Bitmap("image/bird/blue4.png");
         _birdBmp[4] = new Bitmap("image/bird/blue5.png");
         _birdBmp[5] = new Bitmap("image/bird/blue6.png");
         _birdBmp[6] = new Bitmap("image/bird/blue7.png");
         _birdBmp[7] = new Bitmap("image/bird/blue8.png");
         _birdBmp[8] = new Bitmap("image/bird/blue9.png");
         _birdBmp[9] = new Bitmap("image/bird/blue10.png");
     }
     if (bColor == BirdColor.red)
     {
         //装载红色小鸟位图
         _birdBmp[0] = new Bitmap("image/bird/red1.png");
         _birdBmp[1] = new Bitmap("image/bird/red2.png");
         _birdBmp[2] = new Bitmap("image/bird/red3.png");
         _birdBmp[3] = new Bitmap("image/bird/red4.png");
         _birdBmp[4] = new Bitmap("image/bird/red5.png");
         _birdBmp[5] = new Bitmap("image/bird/red6.png");
         _birdBmp[6] = new Bitmap("image/bird/red7.png");
         _birdBmp[7] = new Bitmap("image/bird/red8.png");
         _birdBmp[8] = new Bitmap("image/bird/red9.png");
         _birdBmp[9] = new Bitmap("image/bird/red10.png");
     }
     if (bColor == BirdColor.black)
     {
         //装载黑色小鸟位图
         _birdBmp[0] = new Bitmap("image/bird/black1.png");
         _birdBmp[1] = new Bitmap("image/bird/black2.png");
         _birdBmp[2] = new Bitmap("image/bird/black3.png");
         _birdBmp[3] = new Bitmap("image/bird/black4.png");
         _birdBmp[4] = new Bitmap("image/bird/black5.png");
         _birdBmp[5] = new Bitmap("image/bird/black6.png");
         _birdBmp[6] = new Bitmap("image/bird/black7.png");
         _birdBmp[7] = new Bitmap("image/bird/black8.png");
         _birdBmp[8] = new Bitmap("image/bird/black9.png");
         _birdBmp[9] = new Bitmap("image/bird/black10.png");
     }
     //初始位图
     _nowBirdBmp = _birdBmp[1];
 }