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

            string difficulty = Intent.GetStringExtra("difficulty"); // В эту строку передается сложность

            var recordsTable = RecordsHelper.GetRecordTable();

            RecordsHelper.GameDifficulty dif = RecordsHelper.GameDifficulty.hard;

            if (difficulty == "easy")
                dif = RecordsHelper.GameDifficulty.easy;
            else if (difficulty == "medium")
                dif = RecordsHelper.GameDifficulty.medium;

            int i = 0;

            TextView tv1 = FindViewById<TextView>(2131230852);
            TextView tv2 = FindViewById<TextView>(2131230853);
            TextView tv3 = FindViewById<TextView>(2131230854);
            TextView tv4 = FindViewById<TextView>(2131230855);
            TextView tv5 = FindViewById<TextView>(2131230856);


            foreach (var record in recordsTable)
            {
                if (record.Difficulty == dif)
                {
                    i++;
                    if (i == 1)
                        tv1.Text = $"1. {record.RecordTime.Minutes}:{record.RecordTime.Seconds}";
                    if (i == 2)
                        tv2.Text = $"2. {record.RecordTime.Minutes}:{record.RecordTime.Seconds}";
                    if (i == 3)
                        tv3.Text = $"3. {record.RecordTime.Minutes}:{record.RecordTime.Seconds}";
                    if (i == 4)
                        tv4.Text = $"4. {record.RecordTime.Minutes}:{record.RecordTime.Seconds}";
                    if (i == 5)
                        tv5.Text = $"5. {record.RecordTime.Minutes}:{record.RecordTime.Seconds}";
                }
            }

            ActionBar.SetHomeButtonEnabled(true);
            ActionBar.SetDisplayHomeAsUpEnabled(true);
        }
Beispiel #2
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            // Create your application here
            SetContentView(Resource.Layout.GridPage);

            ActionBar.SetHomeButtonEnabled(true);
            ActionBar.SetDisplayHomeAsUpEnabled(true);

            string difficulty = Intent.GetStringExtra("difficulty"); // В эту строку передается сложность

            RecordsHelper.GameDifficulty dif = RecordsHelper.GameDifficulty.hard;

            if (difficulty == "easy")
            {
                hintsCount = 5;
                dif        = RecordsHelper.GameDifficulty.easy;
            }
            else if (difficulty == "medium")
            {
                hintsCount = 3;
                dif        = RecordsHelper.GameDifficulty.medium;
            }

            try
            {
                field = Field.CreateField(difficulty, out fullField); // Готовое поле, на основке которого пишем интерфейс
            }
            catch (Exception)
            {
                field = Field.CreateField(difficulty, out fullField);
            }
            InitializeGameField(field);

            CreateEditorPanel();
            System.Diagnostics.Stopwatch swatch     = new System.Diagnostics.Stopwatch();
            AlertDialog.Builder          winDialog  = new AlertDialog.Builder(this);
            AlertDialog.Builder          loseDialog = new AlertDialog.Builder(this);
            swatch.Start();

            checkButton = FindViewById <Button>(2131230769);


            checkButton.Click += delegate(object sender, EventArgs e)
            {
                if (CheckField())
                {
                    if (isWon)
                    {
                        winDialog.Show();
                    }
                    else
                    {
                        swatch.Stop();
                        isWon = true;
                        winDialog.SetTitle("Победа!");
                        winDialog.SetMessage($"Вы смогли решить головоломку всего за {swatch.Elapsed.Minutes} минут и {swatch.Elapsed.Seconds} секунд!");
                        winDialog.SetNeutralButton("Ок", delegate
                        {
                        });
                        winDialog.Show();
                        RecordsHelper.GameRecord gameRecord = new RecordsHelper.GameRecord(dif, swatch.Elapsed);
                        RecordsHelper.UpdateRecordTable(gameRecord);
                        RecordsHelper.SaveRecordTable(RecordsHelper.GetRecordTable());
                    }
                }
                else
                {
                    loseDialog.SetTitle("Неправильно!");
                    loseDialog.SetMessage($"К сожалению, ваше решение неверное:(");
                    loseDialog.SetNeutralButton("Ок", delegate
                    {
                    });
                    loseDialog.Show();
                }
            };
        }