Exemplo n.º 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 (sensorOn)
     {
         sensorSwitch(false);
     }
     if (isReplay)
     {
         GlobalApp.BeginActivity(this, typeof(DiceRollsActivity), 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));
     }
 }
Exemplo n.º 2
0
        protected override void OnCreate(Bundle bundle)
        {
            try
            {
                base.OnCreate(bundle);
                SetContentView(Resource.Layout.TowersOfHanoi);

                _sensorManager = (SensorManager)GetSystemService(SensorService);
                sensorOn       = true;

                chronometer = FindViewById <Chronometer>(Resource.Id.cTimer);
                btnReplay   = FindViewById <Button>(Resource.Id.btnReplay);
                Button btnQuit = FindViewById <Button>(Resource.Id.btnQuit);
                txtOptimalNoOfMoves = FindViewById <TextView>(Resource.Id.txtViewOptNoOfMoves);
                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;
                //detirmine how many dice will be displayed based on difficulty
                switch (Intent.GetIntExtra(GlobalApp.getVariableDifficultyName(), 1))
                {
                case 2:
                    maxComponents = 5;
                    break;

                case 3:
                    maxComponents = 4;
                    break;

                case 4:
                    maxComponents = 3;
                    break;

                case 5:
                    maxComponents = 2;
                    break;

                default:
                    maxComponents = 1;
                    break;
                }

                Game();

                logic                    = new GameLogic.DiceRollsLogic(maxComponents);
                txtVScore.Text           = "Score: " + 0;
                txtOptimalNoOfMoves.Text = "no. of Rolls: " + numberOfRolls;
                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);
            }
        }