Esempio n. 1
0
        private void Game_DateChanged(object sender, DateTime gameDate)
        {
            DateTime oldDate = DateValue;

            DateValue = gameDate;
            TimeValue = gameDate.TimeOfDay;
            //новый день
            if (!(oldDate.Day == gameDate.Day && oldDate.Month == gameDate.Month))
            {
                UpdatePlanesMarket();
                List <Plane> planesToRemove = new List <Plane>();
                foreach (Plane plane in planes)
                {
                    if (plane.Own == Plane.Owns.Rented)
                    {
                        plane.MarketC.NewDay();
                        if (plane.MarketC.Days <= 0)
                        {
                            if (planesUI[plane.ID].CityName == "В полёте")
                            {
                                game.PayFine(((Rent)plane.MarketC).Fine);
                            }
                            else
                            {
                                planesToRemove.Add(plane);
                            }
                        }
                    }
                    if (plane.Own == Plane.Owns.Leased && plane.MarketC.Days > 0)
                    {
                        plane.MarketC.NewDay();
                        if (plane.MarketC.Days > 0)
                        {
                            game.PayFine(((Lease)plane.MarketC).LeasePrice);
                        }
                    }
                }
                foreach (Plane plane  in planesToRemove)
                {
                    planes.Remove(plane);
                }
                UpdatePlanes();
            }
        }