Example #1
0
        public void BuySomething(Label balance_capital, List <PictureBox> cells, List <Panel> firms_owners, List <Label> firms_costs, ListBox list_box, Button current_button, Button next_button, Form1 main_form)
        {
            string s = "";

            foreach (var item in firms_owners)
            {
                s = item.Name;
                s = s.Remove(s.LastIndexOf('_'));
                if (this.NameOfCurrentCard == s)
                {
                    int k = 0;
                    foreach (var i in list_box.Items)
                    {
                        if ("- " + s + " x1" == i.ToString())
                        {
                            k = 1;
                            break;
                        }
                        else if ("- " + s + " x2" == i.ToString())
                        {
                            k = 2;
                            break;
                        }
                        else if ("- " + s + " x3" == i.ToString())
                        {
                            k = 3;
                            break;
                        }
                        else if ("- " + s + " x4" == i.ToString())
                        {
                            k = 4;
                            break;
                        }
                        else if ("- " + s + " x5" == i.ToString())
                        {
                            return;
                        }
                    }
                    if (this.Balance >= Game.CostOfFirms[this.NameOfCurrentCard][k])
                    {
                        if (k == 0)
                        {
                            Firm firm = new Firm(s);
                            item.Visible = true;
                            if (this is Person)
                            {
                                item.BackColor = Color.Red;
                            }
                            if (this is Artificial_Intelligence)
                            {
                                item.BackColor = Color.Blue;
                            }
                            this.OwnedFirms.Add(firm);
                            list_box.Items.Add("- " + firm.Name + " x" + (k + 1).ToString());
                        }
                        else if (k == 1 || k == 2 || k == 3)
                        {
                            Filial filial = new Filial(new Firm(s));
                            this.OwnedFilials.Add(filial);
                            list_box.Items.Remove("- " + filial.Name + " x" + (k).ToString());
                            list_box.Items.Add("- " + filial.Name + " x" + (k + 1).ToString());
                        }
                        else if (k == 4)
                        {
                            Company company = new Company(new Firm(s));
                            this.OwnedCompany.Add(company);
                            list_box.Items.Remove("- " + company.Name + " x" + (k).ToString());
                            list_box.Items.Add("- " + company.Name + " x" + (k + 1).ToString());
                        }
                        this.Balance        -= Game.CostOfFirms[s][k];
                        this.CurrentProfit  += Game.CostOfFirms[s][k] * 0.1;
                        balance_capital.Text = this.Balance.ToString() + " | " + this.Capital.ToString() + " | " + this.CurrentProfit.ToString();
                        string s0 = s + "_cost";
                        foreach (var firm_cost in firms_costs)
                        {
                            if (firm_cost.Name == s0)
                            {
                                if (k <= 3)
                                {
                                    firm_cost.Text = Game.CostOfFirms[s][k + 1].ToString();
                                }
                                break;
                            }
                        }
                        s0 = this.CurrentPosition.ToString() + "N";
                        foreach (var cell in cells)
                        {
                            if (cell.Tag.ToString() == s0)
                            {
                                if (this is Person)
                                {
                                    cell.Tag = this.CurrentPosition.ToString() + "R";
                                }
                                if (this is Artificial_Intelligence)
                                {
                                    cell.Tag = this.CurrentPosition.ToString() + "B";
                                }
                                break;
                            }
                        }
                    }
                    break;
                }
            }
            if (this is Person)
            {
                current_button.Enabled   = false;
                current_button.BackColor = Color.Gray;
                next_button.Enabled      = true;
                next_button.BackColor    = Color.LimeGreen;
            }
        }
Example #2
0
 public Filial(Firm firm) : base(firm.Name, firm)
 {
     firm.Cost = Game.CostOfFirms[firm.Name][1];
 }
Example #3
0
 public Company(Firm firm) : base(firm.Name, firm)
 {
     firm.Cost = Game.CostOfFirms[firm.Name][4];
 }
Example #4
0
 public FirmDecorator(string name, Firm firm) : base(name)
 {
     this.firm = firm;
 }