/// <summary>
        /// Returns number of whole population of all planets
        /// </summary>
        /// <returns>double</returns>
        public double getPopulation()
        {
            double Population = 0;

            for (int i = 0; i < listOfPlanets.getPlanetsAmount(); i++)
            {
                Population += listOfPlanets.getCurrentPlanet().getInhabitants();
            }
            return(Population);
        }
 /// <summary>
 /// Function's trying to start resulting in removing one race from the planet
 /// The execution condition is proper density higher than 10 and proper amount of races
 /// Returns bool if war took place
 /// </summary>
 /// <returns>bool</returns>
 public bool TryToStartWar()
 {
     if (listOfPlanets.getCurrentPlanet().CheckIfDensityTooHigh() && listOfPlanets.getCurrentPlanet().getAmountfRaces() > 2)
     {
         if (random.Next(0, 4) == 0)
         {
             listOfPlanets.getCurrentPlanet().RemoveOneRaceFromPlanet();
             return(true);
         }
     }
     return(false);
 }
        /// <summary>
        /// Function tries to add new race to planet when density reaches proper level and returns true when succed
        /// </summary>
        /// <returns>bool</returns>
        public bool TryTooCreateNewRace()
        {
            if (listOfPlanets.getCurrentPlanet().CheckIfDensityTooHigh())
            {
                if (Random.Next(0, 3) == 0)
                {
                    listOfPlanets.getCurrentPlanet().AddOneNewRaceToPlanet();

                    factors.ModifyTechLevelByAddition(100);

                    return(true);
                }
            }
            return(false);
        }
        /// <summary>
        /// Function imitate random occurence of famine on each planet at the same time
        /// When occurs, TechLevel decreases by choosen number of points
        /// and whole population decreases by 0-90%
        /// </summary>
        /// <returns>bool</returns>
        public bool Famine()
        {
            if (random.Next(0, 80) == 0 && listOfPlanets.getPlanetsAmount() > 4)
            {
                for (int i = 0; i < listOfPlanets.getPlanetsAmount(); i++)
                {
                    listOfPlanets.getCurrentPlanet().SetInhabitants((((double)random.Next(0, 10)) / (double)10) * listOfPlanets.getCurrentPlanet().getInhabitants());
                }
                factors.ModifyTechLevelByAddition(-2000);
                return(true);
            }

            return(false);
        }
        private void timerMainTimer(object sender, EventArgs e)
        {
            //two functions below modify inhabitants number and techlevel
            factors.ModifyTechLevelByAddition(50);
            factors.ModifyInhabitantsByAddition();

            //functions below are responsible for gui and displaying stats
            labelPopulationNumber.Text = factors.getPopulation().ToString();
            labelInhabitants.Text      = listOfPlanets.getCurrentPlanet().getInhabitants().ToString();
            labelPlanetsNumber.Text    = listOfPlanets.getPlanetsAmount().ToString();
            labelTechLevel.Text        = factors.getTechLevel().ToString();
            labelRacesAmount.Text      = listOfPlanets.getCurrentPlanet().getAmountfRaces().ToString();
            labelDensity.Text          = listOfPlanets.getCurrentPlanet().getDensity().ToString();
            raceControl.TryTooCreateNewRace();

            //If war occurs, then picture changes
            if (warControl.TryToStartWar())
            {
                pictureBox.Image     = Properties.Resources.battle;
                labelWorldEvent.Text = "IT'S WAR TIME!";
            }

            //If colonisation occurs, then picture changes
            if (colonisation.tryToColonize())
            {
                pictureBox.Image     = Properties.Resources.colonisation;
                labelWorldEvent.Text = "IT'S COLONISATION TIME!";
            }

            //If famine occurs, then picture changes
            if (disaster.Famine())
            {
                pictureBox.Image     = Properties.Resources.famine;
                labelWorldEvent.Text = "IT'S FAMINE TIME!";
            }
        }
 /// <summary>
 /// The function adds another planet to list when density gains proper level
 /// </summary>
 /// <returns>bool</returns>
 public bool tryToColonize()
 {
     if (listOfPlanets.getCurrentPlanet().CheckIfDensityTooHigh())
     {
         if (factors.getTechLevel() > 3000)
         {
             if (random.Next(0, 25) == 0)
             {
                 factors.ModifyTechLevelByAddition(-3000);
                 listOfPlanets.AddNewPlanet();
                 return(true);
             }
         }
     }
     return(false);
 }