public void onDigitsPress(int num) { GameController controller = GameController.getInstance(); controller.setCell(num); Invalidate(); }
public void OnClick(View v) { int num = 0; switch (v.Id) { case Resource.Id.button_1: num = 1; break; case Resource.Id.button_2: num = 2; break; case Resource.Id.button_3: num = 3; break; case Resource.Id.button_4: num = 4; break; case Resource.Id.button_5: num = 5; break; case Resource.Id.button_6: num = 6; break; case Resource.Id.button_7: num = 7; break; case Resource.Id.button_8: num = 8; break; case Resource.Id.button_9: num = 9; break; } ((SudokuFieldView)FindViewById(Resource.Id.game_field)).onDigitsPress(num); if (GameController.getInstance().isSolved()) { timerHandler.RemoveCallbacks(timerRunnable); DatabaseController dbc = new DatabaseController(); ISharedPreferences sPref = PreferenceManager.GetDefaultSharedPreferences(this); dbc.putRecord(time, sPref.GetString("difficultyPref", ""), ApplicationContext); } }
protected override void OnDraw(Canvas canvas) { Paint p = new Paint(); Paint n = new Paint(); n.Color = (Color.Black); n.TextAlign = (Paint.Align.Center); p.Color = (Color.Blue); p.Alpha = (50); canvas.DrawRect(picker, p); int[,] field = GameController.getInstance().getNumbers(); float widthStep = (float)MeasuredWidth / 9; float heightStep = (float)MeasuredHeight / 9; n.TextSize = (heightStep); int[,] initial = GameController.getInstance().getInitialNumber(); for (int i = 0; i < 9; i++) { for (int q = 0; q < 9; q++) { if (initial[i, q] != 0) { canvas.DrawText(initial[i, q] + "", widthStep * q + (widthStep / 2), heightStep * i + heightStep - (heightStep * 0.1f), n); } } } n.Alpha = (150); for (int i = 0; i < 9; i++) { for (int q = 0; q < 9; q++) { if (field[i, q] != 0) { canvas.DrawText(field[i, q] + "", widthStep * i + (widthStep / 2), heightStep * q + heightStep - (heightStep * 0.1f), n); } } } base.OnDraw(canvas); }
private void startGame() { ISharedPreferences sPref = PreferenceManager.GetDefaultSharedPreferences(this); string diff = sPref.GetString("difficultyPref", ""); Stream ist = null; if (diff.Equals("Medium")) { ist = Resources.OpenRawResource(Resource.Raw.medium); } else if (diff.Equals("Hard")) { ist = Resources.OpenRawResource(Resource.Raw.hard); } else { ist = Resources.OpenRawResource(Resource.Raw.easy); } GameController.getInstance().setInitial(SudokuFileReader.getRandSudoku(ist)); GameController.getInstance().clean(); FindViewById(Resource.Id.game_field).Invalidate(); }
public bool OnTouch(View v, MotionEvent e) { if (e.Action == MotionEventActions.Down) { GameController controller = GameController.getInstance(); double widthStep = (double)v.MeasuredWidth / 9; double heightStep = (double)v.MeasuredHeight / 9; int x = (int)((e.GetX()) / widthStep); int y = (int)((e.GetY()) / heightStep); controller.touch(x, y); IntPoint pickerPoint = controller.getActive(); if (pickerPoint.getX() == -1) { container.picker.Set(0, 0, 0, 0); } else { container.picker.Set((int)(x * widthStep), (int)(y * heightStep), (int)(x * widthStep + widthStep), (int)(y * heightStep + heightStep)); } container.Invalidate(); } return(true); }