Exemplo n.º 1
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            SetContentView(Resource.Layout.Playing);
            //Get data from Main Activity
            Bundle extra = Intent.Extras;

            if (extra != null)
            {
                mode = extra.GetString("MODE");
            }
            db          = new DbHelper.DbHelper(this);
            txtScore    = FindViewById <TextView>(Resource.Id.txtScore);
            txtQuestion = FindViewById <TextView>(Resource.Id.txtQuestion);
            progressBar = FindViewById <ProgressBar>(Resource.Id.progressBar);
            imageView   = FindViewById <ImageView>(Resource.Id.question_flag);
            btnA        = FindViewById <Button>(Resource.Id.btnAnswerA);
            btnB        = FindViewById <Button>(Resource.Id.btnAnswerB);
            btnC        = FindViewById <Button>(Resource.Id.btnAnswerC);
            btnD        = FindViewById <Button>(Resource.Id.btnAnswerD);

            btnA.SetOnClickListener(this);
            btnB.SetOnClickListener(this);
            btnC.SetOnClickListener(this);
            btnD.SetOnClickListener(this);
        }
Exemplo n.º 2
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.Main);

            db       = new DbHelper.DbHelper(this);
            sqLiteDB = db.WritableDatabase;

            seekBar  = FindViewById <SeekBar>(Resource.Id.seekBar);
            txtMode  = FindViewById <TextView>(Resource.Id.txtMode);
            btnPlay  = FindViewById <Button>(Resource.Id.btnPlay);
            btnScore = FindViewById <Button>(Resource.Id.btnScore);

            seekBar.SetOnSeekBarChangeListener(this);
            btnPlay.Click += delegate
            {
                Intent intent = new Intent(this, typeof(Playing));
                intent.PutExtra("MODE", getPlayMode());
                StartActivity(intent);
                Finish();
            };
            btnScore.Click += delegate
            {
                Intent intent = new Intent(this, typeof(Score));
                StartActivity(intent);
                Finish();
            };
        }
Exemplo n.º 3
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            SetContentView(Resource.Layout.Score);
            listView = FindViewById <ListView>(Resource.Id.lstView);

            DbHelper.DbHelper db         = new DbHelper.DbHelper(this);
            List <Ranking>    lstRanking = db.GetRanking();

            if (lstRanking.Count > 0)
            {
                CustomAdapter adapter = new CustomAdapter(this, lstRanking);
                listView.Adapter = adapter;
            }
        }
Exemplo n.º 4
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            SetContentView(Resource.Layout.Done);

            DbHelper.DbHelper db = new DbHelper.DbHelper(this);
            btnTryAgain        = FindViewById <Button>(Resource.Id.btnTryAgain);
            txtTotalQuestion   = FindViewById <TextView>(Resource.Id.txtTotalQuestion);
            txtTotalScore      = FindViewById <TextView>(Resource.Id.txtTotalScore);
            progressBarResult  = FindViewById <ProgressBar>(Resource.Id.progressBardone);
            btnTryAgain.Click += delegate
            {
                Intent intent = new Intent(this, typeof(MainActivity));
                StartActivity(intent);
                Finish();
            };

            //Get Data
            Bundle bundle = Intent.Extras;

            if (bundle != null)
            {
                int score         = bundle.GetInt("SCORE");
                int totalQuestion = bundle.GetInt("TOTAL");
                int coreectAnswer = bundle.GetInt("CORRECT");

                //Update 2.0

                int playCount = 0;
                if (totalQuestion == 30)// Easy Mode
                {
                    playCount = db.GetPlayCount(0);
                    playCount++;
                    db.UpdatePlayCount(0, playCount);
                }
                else
                if (totalQuestion == 50)// Medium Mode
                {
                    playCount = db.GetPlayCount(1);
                    playCount++;
                    db.UpdatePlayCount(1, playCount);
                }
                else
                if (totalQuestion == 100)// Hard Mode
                {
                    playCount = db.GetPlayCount(2);
                    playCount++;
                    db.UpdatePlayCount(2, playCount);
                }
                else
                if (totalQuestion == 200)    // Hardest Mode
                {
                    playCount = db.GetPlayCount(3);
                    playCount++;
                    db.UpdatePlayCount(3, playCount);
                }

                double minus      = ((5.0 / (float)score) * 100) * (playCount - 1);
                double finalScore = score - minus;
                //
                txtTotalScore.Text         = $"SCORE :{ finalScore.ToString("0.00")} (-{ 5 * (playCount - 1)}%) ";
                txtTotalQuestion.Text      = $"PASSED : {coreectAnswer}/{totalQuestion}";
                progressBarResult.Max      = totalQuestion;
                progressBarResult.Progress = coreectAnswer;

                //Save Score
                db.InsertScore(score);
            }
        }