Beispiel #1
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.Playing);

            //Get Data from MainActivity
            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);
        }
Beispiel #2
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.Score);

            lstView = 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);
                lstView.Adapter = adapter;
            }
        }
Beispiel #3
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.doneProgressBar);

            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 correctAnswer = 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 : {correctAnswer}/{totalQuestion}";

                progressBarResult.Max      = totalQuestion;
                progressBarResult.Progress = correctAnswer;

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