Beispiel #1
0
        private void AddPlane(Plane plane, PlaneDataType type)
        {
            PlaneData planeData = new PlaneData(type, game, cities.Values.ToList(), plane)
            {
                PlaneName = plane.Model.ToString(),
                CityName  = game.GetPlaneLocation(plane.ID) == null ? "-"
                     : game.GetPlaneLocation(plane.ID).Name,
                SpeedValue       = plane.Speed,
                DeprecationValue = plane.DeprecationDegree,
                PriceValue       = Math.Round(game.GetBuyPrice(plane.Model) * 0.7, 1),
                DefaultPrice     = Math.Round(game.GetBuyPrice(plane.Model) * 0.7, 1)
            };

            switch (type)
            {
            case PlaneDataType.TransferPlane:
                AddPlaneData(planeData);
                break;

            case PlaneDataType.SellPlane:
                AddPlaneDataSell(planeData);
                break;
            }
            planesUI.Add(plane.ID, planeData);
        }
        private void FillPlanes(PlaneDataType type, UserScroll userScroll)
        {
            // основные характеристики
            int startX = 10, startY = 5;
            var obsplane = game.GetPlanes();

            foreach (var plane in game.GetPlanes())
            {
                PlaneData planeData = new PlaneData(type, game, cities, plane)
                {
                    PlaneName = plane.Model.ToString(),
                    CityName  = game.GetPlaneLocation(plane.ID) == null ? "-"
                    : game.GetPlaneLocation(plane.ID).Name,
                    SpeedValue       = plane.Speed,
                    DeprecationValue = plane.DeprecationDegree,
                    Location         = new Point(startX, startY),
                };
                startY += planeData.Height + 10;
                userScroll.GetPanel.Controls.Add(planeData);
            }
        }
Beispiel #3
0
        private void FillPlanes(PlaneDataType type, UserScroll userScroll)
        {
            // основные характеристики
            int planesStartX = 10;
            int planesStartY = 5;

            foreach (var plane in game.GetPlanes())
            {
                PlaneData planeData = new PlaneData(type, game, cities.Values.ToList(), plane)
                {
                    PlaneName = plane.Model.ToString(),
                    CityName  = game.GetPlaneLocation(plane.ID) == null ? "-"
                    : game.GetPlaneLocation(plane.ID).Name,
                    SpeedValue       = plane.Speed,
                    DeprecationValue = plane.DeprecationDegree,
                    Location         = new Point(planesStartX, planesStartY),
                    PriceValue       = Math.Round(game.GetBuyPrice(plane.Model) * 0.7, 1),
                    DefaultPrice     = Math.Round(game.GetBuyPrice(plane.Model) * 0.7, 1)
                };
                planesStartY += planeData.Height + 10;
                if (userScroll.GetPanel.IsHandleCreated)
                {
                    userScroll.GetPanel.Invoke(new Action(() => userScroll.GetPanel.Controls.Add(planeData)));
                }
                else
                {
                    userScroll.GetPanel.Controls.Add(planeData);
                }
                switch (type)
                {
                case PlaneDataType.SellPlane:
                    planesToSellUI.Add(plane.ID, planeData);
                    break;

                case PlaneDataType.TransferPlane:
                    planesUI.Add(plane.ID, planeData);
                    break;
                }
            }
        }
        public PlaneData(PlaneDataType type, IGameLogicInteractable game, List <City> cities, Plane plane)
        {
            InitializeComponent();

            this.plane  = plane;
            this.game   = game;
            this.cities = cities;
            this.type   = type;
            planes      = game.GetPlanes();
            plane.DeprecationDegreeChanged += Plane_DeprecationDegreeChanged;

            BackColor             = MainForm.MostlyBackColor;
            btnFly.BackColor      = MainForm.MostlyBackColor;
            btnSell.BackColor     = MainForm.MostlyBackColor;
            lblCityName.BackColor = MainForm.MostlyBackColor;
            switch (type)
            {
            case PlaneDataType.SelectPlane:
            {
                btnFly.Visible        = false;
                lblPrice.Visible      = false;
                lblPriceValue.Visible = false;
                lblType.Visible       = false;
                lblTypeValue.Visible  = false;
                lblCityName.Visible   = false;
                lblCity.Visible       = false;
                btnSell.Visible       = false;

                RangeValue = plane.Range;
                SetMaxValue(plane.MaxSeatings, plane.Payload);
            } break;

            case PlaneDataType.TransferPlane:
            {
                rbCheck.Visible       = false;
                lblPrice.Visible      = false;
                lblPriceValue.Visible = false;
                lblType.Visible       = false;
                lblTypeValue.Visible  = false;
                btnSell.Visible       = false;
                lblRange.Visible      = false;
                lblRangeValue.Visible = false;
                lblMax.Visible        = false;
                lblMaxValue.Visible   = false;
            } break;

            case PlaneDataType.SellPlane:
            {
                btnFly.Visible       = false;
                rbCheck.Visible      = false;
                lblType.Visible      = false;
                lblTypeValue.Visible = false;
                lblCity.Visible      = false;
                lblCityName.Visible  = false;
                RangeValue           = plane.Range;
                SetMaxValue(plane.MaxSeatings, plane.Payload);
            } break;
            }
            switch (plane.Own)
            {
            case Plane.Owns.Rented:
                lblMarketContract.Text  = "Аренда:";
                lblMarketDaysValue.Text = plane.MarketC.Days.ToString() + " д.";
                break;

            case Plane.Owns.Bought:
                lblMarketDaysValue.Visible = false;
                lblMarketContract.Visible  = false;
                break;

            case Plane.Owns.Leased:
                if (Plane.MarketC.Days > 0)
                {
                    lblMarketContract.Text  = "Лизинг:";
                    lblMarketDaysValue.Text = plane.MarketC.Days.ToString() + " д.";
                }
                else
                {
                    lblMarketDaysValue.Visible = false;
                    lblMarketContract.Visible  = false;
                }
                break;
            }
        }