// ---------------------------------------------------------------------------------------------------------------- // The game has ended so the score, and time will passed to userInputActivity. private void end() { try { chronometer.Stop(); string playersScore = LeaderBoardInterface.formatLeaderBoardScore("", score.ToString(), Intent.GetIntExtra(GlobalApp.getVariableDifficultyName(), 1), chronometer.Text); GlobalApp.BeginActivity(this, typeof(UserInputActivity), GlobalApp.getPlayersScoreVariable(), playersScore, GlobalApp.getVariableChoiceName(), Intent.GetIntExtra(GlobalApp.getVariableChoiceName(), 0)); } catch { GlobalApp.Alert(this, 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); } }
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); } }