private void Timer_3_sec_Tick(object sender, EventArgs e) { if (sessionHasPaid == false) { loadExesFromSQL(); foreach (string temp in programData.listOfExesRequiringCoins) { ExeMethods.checkForAndKillProcess(temp); } } else { int numCoins = CoinMethods.getCoins(Environment.UserName); if (numCoins < 1) { SqlMethods.writeToPointsLog("has stopped paying for games. " + numCoins + " Coins."); timer_1_min.Enabled = false; button_payForGames.Enabled = false; button_StartGames.Enabled = true; sessionHasPaid = false; } } isSessionDisabled(); label_numCoins.Text = CoinMethods.getCoins(Environment.UserName).ToString(); }
private void Button_payForGames_Click(object sender, EventArgs e) { int numCoins = CoinMethods.getCoins(Environment.UserName); SqlMethods.writeToPointsLog("has stop paying for games. " + numCoins + " Coins."); timer_1_min.Enabled = false; button_payForGames.Enabled = false; button_StartGames.Enabled = true; sessionHasPaid = false; }
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); } } }
private void Button_StartGames_Click(object sender, EventArgs e) { int numCoins = CoinMethods.getCoins(Environment.UserName); if (numCoins >= 1) //if(ExeMethods.payForExe(CoinMethods.getCoins(Environment.UserName), numCoinsRequiredToPlay, saveData.sessionLimit) == true) { SqlMethods.writeToPointsLog("has clicked pay for games. " + numCoins + " Coins."); timer_1_min.Enabled = true; button_payForGames.Enabled = true; button_StartGames.Enabled = false; sessionHasPaid = true; } }
private void isSessionDisabled() { saveData = (SaveData)StructMethods.LoadData(); if (saveData.isSessionDisabled == 1) { int numCoins = CoinMethods.getCoins(Environment.UserName); //if(ExeMethods.payForExe(CoinMethods.getCoins(Environment.UserName), numCoinsRequiredToPlay, saveData.sessionLimit) == true) { //SqlMethods.writeToPointsLog("has stopped paying for games. " + numCoins + " Coins."); timer_1_min.Enabled = false; button_payForGames.Enabled = false; button_StartGames.Enabled = true; sessionHasPaid = false; } } }
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); }