コード例 #1
0
ファイル: Overview.cs プロジェクト: charbean/StrategyClean
 internal void ConstructBuilding(Building building)
 {
     foreach (Planet p in selectedSystem.PlanetsList)
     {
         foreach (Planet ownedPlanet in HumanPlayer.OwnedPlanets)
         {
             if (ownedPlanet.PlanetName == p.PlanetName)
             {
                 if (building.BuildingCatagory == BuildingCatagories.Resources)
                 {
                     ResourceExtractor extractor = building as ResourceExtractor;
                     extractor.Resource.HasResourceBuilding = true;
                     UpdateResourcesDetails();
                     updateResources.Invoke(this, new EventArgs());
                 }
             }
         }
     }
 }
コード例 #2
0
ファイル: Overview.cs プロジェクト: charbean/StrategyClean
        internal void AddBuildQueueItem(Building buildingToBuild)
        {
            foreach (Planet p in selectedSystem.PlanetsList)
            {
                foreach (Planet ownedPlanet in HumanPlayer.OwnedPlanets)
                {
                    if (ownedPlanet.PlanetName == p.PlanetName)
                    {
                        if (HumanPlayer.resources.money >= buildingToBuild.BuildCost)
                        {
                            //TAKE MONEY FROM PLAYER
                            HumanPlayer.resources.money -= buildingToBuild.BuildCost;
                            //SET QUEUEITEMTYPE
                            QueueItemType itemType = QueueItemType.Building;
                            //CHECK IF RESOURCEBUILDING
                            if (buildingToBuild.BuildingCatagory == BuildingCatagories.Resources)
                            {
                                ResourceExtractor extractor = buildingToBuild as ResourceExtractor;
                                if (extractor != null)
                                {
                                    extractor.Resource.IsResourceBuildingInQueue = true;
                                    itemType = QueueItemType.BuildingResources;
                                }
                            }

                            selectedSystem.PlanetsList[p.PlanetsListIndex].buildQueue.AddQueueItem(buildingToBuild, itemType);
                            UpdateResourcesDetails();
                        }
                    }
                }
            }
        }
コード例 #3
0
        private void BuildingToBuildNameChanged(int i) //1 for extractor, 2 for other buildings
        {
            if (i == 0)
            {
                if (SelectedBuildingToBuild >= 0)
                {
                    if (AvailableBuildings != null)
                    {
                        if (AvailableBuildings.Count > 0)
                        {
                            BuildingToBuildName = AvailableBuildings[SelectedBuildingToBuild].Content.ToString();
                        }
                    }
                }
            }

            if (i == 1)
            {
                if (depositList != null)
                {
                    if (depositList.Count > 0)
                    {
                        if (SelectedExtractor >= 0 && SelectedUnusedResource >= 0)
                        {
                            
                            BuildingBuildText = "Build: ";

                            var tempExtractor = new ResourceExtractor(1, 1, depositList[SelectedUnusedResource], currentList.Count);

                            switch (depositList[SelectedUnusedResource].ExtractorName)
                            {
                                case "MiningFacility":
                                    tempExtractor = new MiningFacility(1, 1, depositList[SelectedUnusedResource], currentList.Count);
                                    break;
                                case "AdvancedMiningFacility":
                                    tempExtractor = new AdvancedMiningFacility(1, 1, depositList[SelectedUnusedResource], currentList.Count);
                                    break;
                                case "Farm":
                                    tempExtractor = new Farm(1, 1, depositList[SelectedUnusedResource], currentList.Count);
                                    break;
                                case "Pump":
                                    tempExtractor = new Pump(1, 1, depositList[SelectedUnusedResource], currentList.Count);
                                    break;
                                case "Sawmill":
                                    tempExtractor = new Sawmill(1, 1, depositList[SelectedUnusedResource], currentList.Count);
                                    break;
                            }

                            
                            tempExtractor.SizeChanged(SelectedExtractor + 1);
                            tempExtractor.LevelChanged(Int32.Parse(BuildingToBuildLevel));

                            BuildingToBuildName = tempExtractor.Name;

                            BuildingBuildText += tempExtractor.GetBuildCost().ToString();
                            YieldText = "Yield: " + tempExtractor.actualYield.ToString() + " (" + 
                                            (tempExtractor.percentYield * 100).ToString("0.0") + "%)";

                            depositList[SelectedUnusedResource].HasResourceBuilding = false;

                            tempBuilding = tempExtractor;
                        }
                    }
                    else
                    {
                        BuildingToBuildName = "N/a";
                        BuildingBuildText = "Build: ";
                    }
                }
            }
            
        }
コード例 #4
0
        public PlanetBuildingsModel(EventHandler buildEvent, EventHandler removeEvent)
        {
            
            //EVENTS
            constructEvent = buildEvent;
            removeQueueItemEvent = removeEvent;
            //INTS
            CurrentMoney = 0;
            SelectedBuilding = 0;
            QueueItemMaxBuildTime = 10;
            CurrentQueueItemElapsedTime = 0;
            //OBSERV COLLECT
            BuildingNames = new ObservableCollection<ListBoxItem>();
            //BuildingNames.Add(new ListBoxItem { Content = "DICKBUTT" });
            BuildingIcons = new ObservableCollection<ListBoxItem>();
            //IMAGES
            Image img = new Image();
            img.Source = LocalisationHelper.GetLocalizedImage("Building1");
            img.Width = 50;
            img.Height = 50;
            BuildingIcons.Add(new ListBoxItem { Content = img });
            BuildingIcons.Add(new ListBoxItem { Content = "content" });
            //BOOL
            CanUpgrade = false;
            HasBuildQueue = false;
            BuildQueueCurrentImage = new BitmapImage();

            AvailableResourceExtractors = new ObservableCollection<ComboBoxItem>();
            AvailableResourceExtractors.Add(new ComboBoxItem { Content = "Small Extractor" });
            AvailableResourceExtractors.Add(new ComboBoxItem { Content = "Medium Extractor" });
            AvailableResourceExtractors.Add(new ComboBoxItem { Content = "Large Extractor" });
            AvailableResourceExtractors.Add(new ComboBoxItem { Content = "Huge Extractor" });
            AvailableResourceExtractors.Add(new ComboBoxItem { Content = "Massive Extractor" });
            AvailableBuildings = new ObservableCollection<ComboBoxItem>();


            tempBuilding = new Building(1, 1, 0);

            ResourcesBuildingIcons = new ObservableCollection<ListBoxItem>();
            ResourcesBuildingNames = new ObservableCollection<ListBoxItem>();
            ProductionBuildingIcons = new ObservableCollection<ListBoxItem>();
            ProductionBuildingNames = new ObservableCollection<ListBoxItem>();
            ResearchBuildingIcons = new ObservableCollection<ListBoxItem>();
            ResearchBuildingNames = new ObservableCollection<ListBoxItem>();
            MilitaryBuildingIcons = new ObservableCollection<ListBoxItem>();
            MilitaryBuildingNames = new ObservableCollection<ListBoxItem>();
            UnusedResourceIcons = new ObservableCollection<ListBoxItem>();
            UnusedResourceNames = new ObservableCollection<ListBoxItem>();
            BuildQueue = new ObservableCollection<ListBoxItem>();

            currentList = new List<Building>();
            depositList = new List<ResourceDeposit>();

            //CurrentBuilding = BuildingNames[SelectedBuilding].Content.ToString();
            UpgradeText = "UPGRADE: ";
            BuildingBuildText = "BUILD: ";
            BuildingToBuildName = "Dickbutt";
            BuildingToBuildLevel = "1";

            BuildingBuildCommand = new RelayCommand(new Action<object>(BuildPressed));
        }
コード例 #5
0
 public void ConstructBuilding(Building building)
 {
     if(game != null)
     {
         game.ConstructBuilding(building);
     }
 }
コード例 #6
0
ファイル: GUIManager.cs プロジェクト: charbean/StrategyClean
 internal void ConstructBuilding(Building building)
 {
     BuildingToBuild = building;
     constructBuildingEvent.Invoke(this, new EventArgs()); //ADD ITEM TO BUILD QUEUE
 }