Beispiel #1
0
        public Gameover(int score, int targetscore, int highestscore, int traintype, int levelnum)
        {
            InitializeComponent();
            this.score        = score;
            this.targetscore  = targetscore;
            this.highestscore = highestscore;
            this.traintype    = traintype;
            this.levelnum     = levelnum;
            label1.Parent     = pictureBox3;

            if (score < targetscore)
            {
                pictureBox1.Visible = true;
                //you lose!
            }
            else if (score > highestscore)
            {
                pictureBox3.Visible = true;
                //you win!新纪录:
                highestscore = score;
                label1.Text  = highestscore.ToString();
                Data_access.UpdateHscore(traintype, levelnum, highestscore);
                //更新数据库
            }
            else
            {
                pictureBox2.Visible = true;
                //you win!
            }
        }
Beispiel #2
0
        //       public Level(int traintype, int levelnum)
        //     {
        //       this.traintype = traintype;
        //     this.levelnum = levelnum;
        // }

        public void LevelInit()
        {
            SqlDataReader reader = Data_access.QueryLevelData(traintype, levelnum); //根据训练类型和关卡等级读取关卡数据

            while (reader.Read())
            {
                speed        = reader.GetInt32(2);
                targetscore  = reader.GetInt32(3);
                highestscore = reader.GetInt32(5);
            }
            reader.Close();

            if (traintype == 1 || traintype == 3)
            {
                timer1.Interval = 1500 / speed;
                timer1.Enabled  = true;
            } //设置按键亮起速度


            label5.Text = targetscore.ToString();
            label7.Text = highestscore.ToString();
        }