Exemple #1
0
 // ----------------------------------------------------------------------------------------------------------------
 // Determines the appropriate response if a particular button has been pressed.
 private void determineResponse(bool isReplay)
 {
     if (chronometer != null)
     {
         chronometer.Stop();
         chronometer = null;
     }
     if (logic != null)
     {
         logic.deleteBoard();
         logic = null;
     }
     if (isReplay)
     {
         GlobalApp.BeginActivity(this, typeof(TowersOfHanoiActivity), GlobalApp.getVariableDifficultyName(), Intent.GetIntExtra(GlobalApp.getVariableDifficultyName(), 1), GlobalApp.getVariableChoiceName(), Intent.GetIntExtra(GlobalApp.getVariableChoiceName(), 0));
     }
     else
     {
         GlobalApp.BeginActivity(this, typeof(GameMenuActivity), GlobalApp.getVariableChoiceName(), Intent.GetIntExtra(GlobalApp.getVariableChoiceName(), 0));
     }
 }
Exemple #2
0
        protected override void OnCreate(Bundle bundle)
        {
            try
            {
                base.OnCreate(bundle);
                SetContentView(Resource.Layout.TowersOfHanoi);

                btnReplay = FindViewById <Button>(Resource.Id.btnReplay);
                Button   btnQuit             = FindViewById <Button>(Resource.Id.btnQuit);
                TextView txtOptimalNoOfMoves = FindViewById <TextView>(Resource.Id.txtViewOptNoOfMoves);
                chronometer = FindViewById <Chronometer>(Resource.Id.cTimer);
                elapsedTime = FindViewById <TextView>(Resource.Id.txtVElapsedTime);
                txtVScore   = FindViewById <TextView>(Resource.Id.txtVScore);
                gameDisplay = FindViewById <LinearLayout>(Resource.Id.linLayGameDisplay);
                // Build the game display that the user will interact with;
                btnReplay.Enabled = false;
                Game();

                // Initializing data for the game.
                logic = new GameLogic.TowersOfHanoiLogic(MAXCOMPONENTS, Intent.GetIntExtra(GlobalApp.getVariableDifficultyName(), 1));
                txtOptimalNoOfMoves.Text = string.Format("{0}", "Optimal no. of moves: " + logic.calOptimalNoOfMoves(Intent.GetIntExtra(GlobalApp.getVariableDifficultyName(), 1)));
                txtVScore.Text           = "No. of moves: " + 0;
                chronometer.Visibility   = ViewStates.Invisible;

                // Event handlers:
                btnReplay.Click             += btnReplayOnClick;
                btnQuit.Click               += btnQuitOnClick;
                chronometer.ChronometerTick += chronometerOnTick;

                // Begin the timer;
                chronometer.Start();
            }
            catch
            {
                GlobalApp.Alert(this, 0);
            }
        }