protected override void OnResume() { base.OnResume(); MessageAndroid.ShortAlert("OnResume MainActivity"); GetPersonDataAsync(); }
private async void HitDamage(TypeDiff td) { personData.HPDino -= personData.Coins * 3 * 5 / (int)td; if (personData.HPDino < 1) { personData.Coins++; personData.HPDino = personData.Coins * 100; personData.FullHPDino = personData.Coins * 100; } switch (td) { case TypeDiff.Easy: if (moveCounter < personData.EasySecRecord) { personData.EasySecRecord = moveCounter; MessageAndroid.ShortAlert("New Record!"); } break; case TypeDiff.Medum: if (moveCounter < personData.MediumSecRecord) { personData.MediumSecRecord = moveCounter; MessageAndroid.ShortAlert("New Record!"); } break; case TypeDiff.Hard: if (moveCounter < personData.HardSecRecord) { personData.HardSecRecord = moveCounter; MessageAndroid.ShortAlert("New Record!"); } break; } string serializeString; serializeString = JsonConvert.SerializeObject(personData); using (var writer = File.CreateText(backingFile)) { await writer.WriteLineAsync(serializeString); //Async } randomizeButton(); }
private void UpdateColorButton() { rightColor = 0; for (int i = 0; i < arrNums.Length; i++) { if (arrNums[i].LayoutParameters == arrRightsLayouts[i]) { arrNums[i].SetBackgroundResource(Resource.Color.green); rightColor++; } else { arrNums[i].SetBackgroundResource(Resource.Color.white); } } if (rightColor == 8) { MessageAndroid.ShortAlert($"Congratulations! You Win at {moveCounter} moves!\n You Damage is {typeDiff}"); HitDamage(typeDiff); } }
protected override void OnStart() { base.OnStart(); typeDiff = JsonConvert.DeserializeObject <TypeDiff>(Intent.GetStringExtra("TypeDiff")); if (typeDiff > 0) { MessageAndroid.ShortAlert(typeDiff.ToString()); } arrNums[0] = one; arrRightsLayouts[0] = one.LayoutParameters; one.SetOnClickListener(this); arrNums[1] = two; arrRightsLayouts[1] = two.LayoutParameters; two.SetOnClickListener(this); arrNums[2] = three; arrRightsLayouts[2] = three.LayoutParameters; three.SetOnClickListener(this); arrNums[3] = four; arrRightsLayouts[3] = four.LayoutParameters; four.SetOnClickListener(this); arrNums[4] = five; arrRightsLayouts[4] = five.LayoutParameters; five.SetOnClickListener(this); arrNums[5] = six; arrRightsLayouts[5] = six.LayoutParameters; six.SetOnClickListener(this); arrNums[6] = seven; arrRightsLayouts[6] = seven.LayoutParameters; seven.SetOnClickListener(this); arrNums[7] = eight; arrRightsLayouts[7] = eight.LayoutParameters; eight.SetOnClickListener(this); arrRightsLayouts[8] = emptyTextView.LayoutParameters; emptyTextView.SetOnClickListener(this); diffText.Text = typeDiff.ToString(); backButtonGameMain.Click += BackButtonGameMain_Click; determinateBar.Progress = 0; }
private void randomizeButton() { determinateBar.Progress = 0; sixCounter = 0; moveCounter = 0; int rndNum; int hard = 8; Random random = new Random(); IncreaseBarAsync(10); if (typeDiff == TypeDiff.Easy) { hard = 1; } else if (typeDiff == TypeDiff.Medum) { hard = 3; } else if (typeDiff == TypeDiff.Hard) { hard = 7; } else { MessageAndroid.ShortAlert("Something Wrong"); OnBackPressed(); } IncreaseBarAsync(20); ViewGroup.LayoutParams ll; for (int i = 0; i < hard * 20;) { if (i == hard * 10) { IncreaseBarAsync(80); } rndNum = random.Next(0, 8); if (emptyTextView.LayoutParameters == arrRightsLayouts[0] && ((rndNum == 3) || (rndNum == 1)) || emptyTextView.LayoutParameters == arrRightsLayouts[1] && ((rndNum == 0) || (rndNum == 4) || (rndNum == 2)) || emptyTextView.LayoutParameters == arrRightsLayouts[2] && ((rndNum == 1) || (rndNum == 5)) || emptyTextView.LayoutParameters == arrRightsLayouts[3] && ((rndNum == 0) || (rndNum == 4) || (rndNum == 6)) || emptyTextView.LayoutParameters == arrRightsLayouts[4] && ((rndNum == 1) || (rndNum == 3) || (rndNum == 5) || (rndNum == 7)) || emptyTextView.LayoutParameters == arrRightsLayouts[5] && ((rndNum == 2) || (rndNum == 4) || (rndNum == 8)) || emptyTextView.LayoutParameters == arrRightsLayouts[6] && ((rndNum == 3) || (rndNum == 7)) || emptyTextView.LayoutParameters == arrRightsLayouts[7] && ((rndNum == 6) || (rndNum == 4) || (rndNum == 8)) || emptyTextView.LayoutParameters == arrRightsLayouts[8] && ((rndNum == 5) || (rndNum == 7))) { foreach (Button item in arrNums) { if (item.LayoutParameters == arrRightsLayouts[rndNum]) { ll = emptyTextView.LayoutParameters; emptyTextView.LayoutParameters = item.LayoutParameters; item.LayoutParameters = ll; break; } } i++; } } IncreaseBarAsync(80); UpdateColorButton(); IncreaseBarAsync(100); }