Dynamic_Games.NonCoopForm.Button1_Click C# (CSharp) Method

Button1_Click() private method

private Button1_Click ( object sender, EventArgs e ) : void
sender object
e EventArgs
return void
        private void Button1_Click(object sender, EventArgs e)
        {
            if (!checkParams())
            {
                return;
            }

            r = float.Parse(MultiTB.Text);
            c = Convert.ToInt32(InvestmentTB.Text);



            // If the simulation isn't running
            if (StartButton.Text.Equals("Start"))
            {

                // Counting the payoff values
                Random rand = new Random();

                N = Convert.ToInt32(NoPTB.Text);
                int coopPerc = rand.Next(50, 100);
                percTB.Text = coopPerc + "";
                nc = N * coopPerc / 100; int nd = N - nc;

                NrCoopTB.Text = nc + "";
                nrDefTB.Text = nd + "";
                addToChart(nc, nd);

                pd = (r * nc * c) / N; cd = pd - c;

                DefectorTB.Text = pd + "";
                ContributorTB.Text = cd + "";

                StartButton.Text = "Step";
                NoPTB.ReadOnly = true;


                float money = Int32.Parse(NrCoopTB.Text) * c * r;
                MoneyTB.Text = money + "";
                moneyArr[0] = money / N;
                investmentArr[0] = c;

                // Generating the graph
                edgeNr = rand.Next(N * (N - 1) / 2);
                Tuple<int[,], int[,]> t = ncManager.GenerateGraph(edgeNr, N);

                graph = t.Item1;
                checkMatrix = t.Item2;

                // Deciding whether a player contibutes or not
                colors = ncManager.GenColors(N, nc, nd);

                // Generating selflesness factors
                selflesness = ncManager.GenSelflesnessFactors(N);

                // Drawing the graph
                DrawGraph();
            }
            else
            {

                if (ruleCB.Text.Equals(""))
                {
                    MessageBox.Show("Please select a rule!");
                }
                else if (ruleCB.Text.Equals("Neighbors Decide"))
                {
                    //----------------------------------------------------------------------------------------------------------//
                    // If at least <RuleParamTB.text> % of my neighbors decide not to contribute, then I won't contribute either//
                    //----------------------------------------------------------------------------------------------------------//

                    int[] newColors = rules.NeighborsDecide(N, checkMatrix, colors, Convert.ToInt32(RuleParamTB.Text));

                    ReColor(newColors);

                }
                else if (ruleCB.Text.Equals("Mult. Fact. Grows"))
                {
                    //--------------------------------------------------------------------------------------------------------------//
                    // If <RuleParamTB.text> % of the players contribute, then the multiplication factor grows + Selfessness Factor //
                    // -------------------------------------------------------------------------------------------------------------//

                    MultiTB.Text = rules.MultFactGrows(N, r, Convert.ToInt32(RuleParamTB.Text), Convert.ToInt32(percTB.Text)) + "";
                    r = float.Parse(MultiTB.Text);


                    ReColor(rules.SelflesnessMultFactGrows(N, pd, c, moneyArr, investmentArr, selflesness, colors));
                }
                else
                {
                    //-------------------------------------------------------------------------------------------//
                    //                           Neighbors decide with Selflessness Factor                      //
                    // ----------------------------------------------------------------------------------------//

                    int[] newColors = rules.NeighborsAndSelflesness(N, c, pd, checkMatrix, colors, Convert.ToInt32(RuleParamTB.Text), selflesness, investmentArr, moneyArr);

                    ReColor(newColors);
                }

            }
        }