Beispiel #1
0
 private void storyShow(object sender, EventArgs e)
 {
     //If we are in this form, we hide it, and show the story
     if (this.Visible)
     {
         this.listEmployees.game.timer1.Stop();
         this.Hide();
         AfficheStory story = new AfficheStory(this, this.listEmployees.company, this.listEmployees.game.timer1, this.listEmployees.game.IndexStory);
         this.listEmployees.game.IndexStory++;
     }
 }
Beispiel #2
0
        public void timer1_Tick(object sender, EventArgs e)
        {
            //Refresh the date
            date        = date.AddDays(1);
            lbDate.Text = date.ToString("d MMM yyyy", CultureInfo.CreateSpecificCulture("en-US"));

            //We decrease the money of the company depending on the level of the company and the salaries
            int expense = this.company.LevelCompany ^ 2 * 10;

            foreach (Employee employee in company.ListEmployee)
            {
                expense += employee.Salary / 30;
            }
            this.company.Money -= expense;
            this.lbCA.Text      = String.Format("{0}$", this.company.Money);

            //We decrease the time to do the project for the competitor and for the company if there are employees assigned
            double unitWork = 1;

            unitWork = Math.Round(unitWork, 0);
            foreach (Project project in company.ListProjects)
            {
                foreach (Employee employee in project.EmployeeAssigned)
                {
                    project.Delay -= unitWork * employee.Level / employee.ProjectAssigned.Count;
                }
                project.DelayCompetition -= project.Level * unitWork;
            }

            //Verification if the projects are ended or not
            List <Project> copyListProject = company.ListProjects;

            for (int j = copyListProject.Count - 1; j >= 0; j--)
            {
                if (copyListProject[j].DelayCompetition <= 0)
                {
                    foreach (Employee employee in copyListProject[j].EmployeeAssigned)
                    {
                        employee.ProjectAssigned.Remove(copyListProject[j]);
                    }
                    company.removeProject(copyListProject[j]);
                    if (projectRemove != null)
                    {
                        projectRemove(this, EventArgs.Empty);
                    }
                }
                else
                {
                    if (copyListProject[j].Delay <= 0)
                    {
                        company.Money += copyListProject[j].Price;

                        foreach (Employee employee in copyListProject[j].EmployeeAssigned)
                        {
                            employee.Experience += 50;
                            employee.removeProject(copyListProject[j]);
                        }
                        company.removeProject(copyListProject[j]);
                        if (projectRemove != null)
                        {
                            projectRemove(this, EventArgs.Empty);
                        }
                    }
                }
            }

            //Add project in the list of the propositions
            if (i == 10)
            {
                i = 0;
                listProjects.Add(new Project(this.company.LevelCompany));
            }
            else
            {
                i++;
            }

            if (this.company.Money <= 0)
            {
                this.LostGame();
            }
            if (timeChange != null)
            {
                timeChange(this, EventArgs.Empty);
            }

            // If we we are the first of the month, we have the story
            if (date.Day == 1)
            {
                if (this.Visible)
                {
                    timer1.Stop();
                    this.Hide();
                    AfficheStory story = new AfficheStory(this, company, timer1, indexStory);
                    indexStory++;
                }
                else
                {
                    if (storyGoOn != null)
                    {
                        storyGoOn(this, EventArgs.Empty);
                    }
                }
            }
        }