private void Timer_1_min_Tick(object sender, EventArgs e) { if (sessionHasPaid == true) { int numCoins = CoinMethods.getCoins(Environment.UserName); if (numCoins >= 1) { CoinMethods.decreaseCoinsForExe(numCoins, 1); } } }
static public bool payForExe(int numCoins, int numCoinsRequired, int sessionLimit) { bool result = false; if (numCoins >= numCoinsRequired) { DialogResult dialogResult = MessageBox.Show("Are you sure you want to pay " + numCoinsRequired.ToString() + " to play?", "Pay To Play", MessageBoxButtons.YesNo); if (dialogResult == DialogResult.Yes) { if (ProgramData.startTime.AddMinutes(sessionLimit - (sessionLimit * .4)) < DateTime.Now) // do not play { result = false; DialogResult dialogResult2 = MessageBox.Show("You do not have enough time to play, do you want to play anyway?", "Pay To Play", MessageBoxButtons.YesNo); if (dialogResult2 == DialogResult.Yes) { result = true; } else if (dialogResult2 == DialogResult.No) { result = false; } } else // ok play { result = true; } //do something } else if (dialogResult == DialogResult.No) { result = false; //do something else } } else { MessageBox.Show("You do not have enough coins to play. You need to earn " + (numCoinsRequired - numCoins).ToString() + " more coins."); } if (result) { CoinMethods.decreaseCoinsForExe(numCoins, numCoinsRequired); } return(result); }