Exemplo n.º 1
0
        private void TechnologyListItemSelected(ScreenItemList list, ScreenItemListItem item)
        {
            if (_playerGame.CurrentResearch.Count >= 3)
            {
                return;
            }
            Research research = (Research)item.AttachedInformation;

            ScreenItemDialog researchDialog = new ScreenItemDialog(controls.Game, skin,
                 research.Name, true);
            researchDialog.AttachedInformation = research;
            researchDialog.Items.Add(new ScreenItemImage(controls.Game, skin, 250, 5, research.Icon));
            ScreenItemButton researchButton = new ScreenItemButton(controls.Game, skin, 250 +
                (float)((research.Icon.Width - 125) / 2), research.Icon.Height + 10, 125, 20, "Begin Research");
            researchButton.OnClick += delegate(ScreenItem screenItem, MouseEventArgs args)
            {
                item.Enabled = false;
                _playerGame.BeginResearch(research);
                ReassignResearchProgressBars();
                researchDialog.Close();
            };
            researchDialog.Items.Add(researchButton);
            ScreenItemLabel description = new ScreenItemLabel(controls.Game, skin, 5, 5, 10, 240, research.Description);
            description.TextAlignment = ScreenItemTextAlignment.Center;
            researchDialog.Items.Add(description);
            controls.OpenDialog = researchDialog;
            researchDialog.Closed += delegate() { controls.OpenDialog = null; };
        }
Exemplo n.º 2
0
        private void OpenBuildingDialog(Building building)
        {
            ScreenItemDialog buildingDialog = new ScreenItemDialog(controls.Game, skin,
                 building.Name, true);
            buildingDialog.AttachedInformation = building;
            ScreenItemImage buildingIcon = new ScreenItemImage(controls.Game, skin, 5, 5,
                building.BuildingIcon);
            buildingDialog.Items.Add(buildingIcon);
            ScreenItemLabel buildingDescription = new ScreenItemLabel(controls.Game, skin,
                10 + (int)buildingIcon.Width, 5, 10, 240, building.Description);
            buildingDialog.Items.Add(buildingDescription);
            ScreenItemButton placeBuilding = new ScreenItemButton(controls.Game, skin,
                5 + (buildingIcon.Width - 75) / 2, buildingIcon.Height + 5,
                75, 20, "Build");
            placeBuilding.Enabled = building.Requirements.AreMet(_playerGame);
            placeBuilding.OnClick += delegate(ScreenItem item, MouseEventArgs args)
            {
                Map currentMap = null;
                switch (_currentMap)
                {
                    case SimulationScreenMap.Urban: currentMap = _playerGame.UrbanMap; break;
                    case SimulationScreenMap.Country: currentMap = _playerGame.CountryMap; break;
                    case SimulationScreenMap.Ocean: currentMap = _playerGame.OceanMap; break;
                }
                buildingDialog.Close();
                currentMap.BeginBuildingPlacement(building);
            };
            buildingDialog.Items.Add(placeBuilding);

            // Requirements
            float requirementsHeight = (int)buildingDescription.Height + 10;
            ScreenItemLabel requirementsLabel = new ScreenItemLabel(controls.Game, skin,
                20 + (int)buildingIcon.Width, (int)requirementsHeight, 13, "Requirements");
            requirementsHeight += requirementsLabel.Height;
            buildingDialog.Items.Add(requirementsLabel);
            if (building.Requirements.Money > 0)
            {
                ScreenItemLabel requirementsMoneyLabel = new ScreenItemLabel(controls.Game, skin,
                    36 + (int)buildingIcon.Width, (int)requirementsHeight,
                    10, "$" + building.Requirements.Money.ToString());
                requirementsMoneyLabel.FontColor = (building.Requirements.Money <= _playerGame.Money ?
                    Color.Black : Color.Red);
                ScreenItemImage requirementsMoneyIcon = new ScreenItemImage(controls.Game, skin,
                    20 + (int)buildingIcon.Width, (int)requirementsHeight, 16, 16, "MoneyIcon");
                requirementsHeight += requirementsMoneyLabel.Height;
                requirementsMoneyIcon.Tooltip = "Money";
                requirementsMoneyLabel.Tooltip = "Money";
                buildingDialog.Items.Add(requirementsMoneyLabel);
                buildingDialog.Items.Add(requirementsMoneyIcon);
            }
            if (building.Requirements.Food > 0)
            {
                ScreenItemLabel requirementsFoodLabel = new ScreenItemLabel(controls.Game, skin,
                    36 + (int)buildingIcon.Width, (int)requirementsHeight,
                    10, building.Requirements.Food.ToString() + " bushels");
                requirementsFoodLabel.FontColor = (building.Requirements.Food <= _playerGame.Food ?
                    Color.Black : Color.Red);
                ScreenItemImage requirementsFoodIcon = new ScreenItemImage(controls.Game, skin,
                    20 + (int)buildingIcon.Width, (int)requirementsHeight, 16, 16, "FoodIcon");
                requirementsHeight += requirementsFoodLabel.Height;
                requirementsFoodIcon.Tooltip = "Food";
                requirementsFoodLabel.Tooltip = "Food";
                buildingDialog.Items.Add(requirementsFoodLabel);
                buildingDialog.Items.Add(requirementsFoodIcon);
            }
            if (building.Requirements.Oil > 0)
            {
                ScreenItemLabel requirementsOilLabel = new ScreenItemLabel(controls.Game, skin,
                    36 + (int)buildingIcon.Width, (int)requirementsHeight,
                    10, building.Requirements.Oil.ToString() + " barrels");
                requirementsOilLabel.FontColor = (building.Requirements.Oil <= _playerGame.Oil ?
                    Color.Black : Color.Red);
                ScreenItemImage requirementsOilIcon = new ScreenItemImage(controls.Game, skin,
                    20 + (int)buildingIcon.Width, (int)requirementsHeight, 16, 16, "OilIcon");
                requirementsHeight += requirementsOilLabel.Height;
                requirementsOilIcon.Tooltip = "Oil";
                requirementsOilLabel.Tooltip = "Oil";
                buildingDialog.Items.Add(requirementsOilLabel);
                buildingDialog.Items.Add(requirementsOilIcon);
            }
            if (building.Requirements.Electricity > 0)
            {
                ScreenItemLabel requirementsElectricityLabel = new ScreenItemLabel(controls.Game, skin,
                    36 + (int)buildingIcon.Width, (int)requirementsHeight,
                    10, building.Requirements.Electricity.ToString() + " kwh");
                requirementsElectricityLabel.FontColor = (building.Requirements.Electricity <=
                    _playerGame.Electricity - _playerGame.ConsumedElectricity ? Color.Black : Color.Red);
                ScreenItemImage requirementsElectricityIcon = new ScreenItemImage(controls.Game, skin,
                    20 + (int)buildingIcon.Width, (int)requirementsHeight, 16, 16, "ElectricityIcon");
                requirementsHeight += requirementsElectricityLabel.Height;
                requirementsElectricityIcon.Tooltip = "Electricity";
                requirementsElectricityLabel.Tooltip = "Electricity";
                buildingDialog.Items.Add(requirementsElectricityLabel);
                buildingDialog.Items.Add(requirementsElectricityIcon);
            }

            // Benefits
            float benefitsHeight = (int)buildingDescription.Height + 10;
            ScreenItemLabel benefitsLabel = new ScreenItemLabel(controls.Game, skin,
                160 + (int)buildingIcon.Width, (int)benefitsHeight, 13, "Outputs");
            benefitsHeight += benefitsLabel.Height;
            buildingDialog.Items.Add(benefitsLabel);
            if (building.Benefits.Income.Value > 0)
            {
                ScreenItemLabel benefitsIncomeLabel = new ScreenItemLabel(controls.Game, skin,
                    176 + (int)buildingIcon.Width, (int)benefitsHeight,
                    10, "$" + building.Benefits.Income.Value.ToString() + " / minute");
                ScreenItemImage benefitsIncomeIcon = new ScreenItemImage(controls.Game, skin,
                    160 + (int)buildingIcon.Width, (int)benefitsHeight, 16, 16, "MoneyIcon");
                benefitsHeight += benefitsIncomeLabel.Height;
                benefitsIncomeIcon.Tooltip = "Income";
                benefitsIncomeLabel.Tooltip = "Income";
                buildingDialog.Items.Add(benefitsIncomeLabel);
                buildingDialog.Items.Add(benefitsIncomeIcon);
            }
            if (building.Benefits.Food.Value > 0)
            {
                ScreenItemLabel benefitsFoodLabel = new ScreenItemLabel(controls.Game, skin,
                    176 + (int)buildingIcon.Width, (int)benefitsHeight,
                    10, building.Benefits.Food.Value.ToString() + " bushels / minute");
                ScreenItemImage benefitsFoodIcon = new ScreenItemImage(controls.Game, skin,
                    160 + (int)buildingIcon.Width, (int)benefitsHeight, 16, 16, "FoodIcon");
                benefitsHeight += benefitsFoodLabel.Height;
                benefitsFoodIcon.Tooltip = "Food";
                benefitsFoodLabel.Tooltip = "Food";
                buildingDialog.Items.Add(benefitsFoodLabel);
                buildingDialog.Items.Add(benefitsFoodIcon);
            }
            if (building.Benefits.Oil.Value > 0)
            {
                ScreenItemLabel benefitsOilLabel = new ScreenItemLabel(controls.Game, skin,
                    176 + (int)buildingIcon.Width, (int)benefitsHeight,
                    10, building.Benefits.Oil.Value.ToString() + " barrels / minute");
                ScreenItemImage benefitsOilIcon = new ScreenItemImage(controls.Game, skin,
                    160 + (int)buildingIcon.Width, (int)benefitsHeight, 16, 16, "OilIcon");
                benefitsHeight += benefitsOilLabel.Height;
                benefitsOilIcon.Tooltip = "Oil";
                benefitsOilLabel.Tooltip = "Oil";
                buildingDialog.Items.Add(benefitsOilLabel);
                buildingDialog.Items.Add(benefitsOilIcon);
            }
            if (building.Benefits.Electricity.Value > 0)
            {
                ScreenItemLabel benefitsElectricityLabel = new ScreenItemLabel(controls.Game, skin,
                    176 + (int)buildingIcon.Width, (int)benefitsHeight,
                    10, building.Benefits.Electricity.Value.ToString() + " kwh");
                ScreenItemImage benefitsElectricityIcon = new ScreenItemImage(controls.Game, skin,
                    160 + (int)buildingIcon.Width, (int)benefitsHeight, 16, 16, "ElectricityIcon");
                benefitsHeight += benefitsElectricityLabel.Height;
                benefitsElectricityIcon.Tooltip = "Electricity";
                benefitsElectricityLabel.Tooltip = "Electricity";
                buildingDialog.Items.Add(benefitsElectricityLabel);
                buildingDialog.Items.Add(benefitsElectricityIcon);
            }

            controls.OpenDialog = buildingDialog;
            buildingDialog.Closed += delegate()
            {
                controls.OpenDialog = null;
            };
        }