コード例 #1
0
ファイル: UIViewModel.cs プロジェクト: charbean/StrategyClean
 public void UpdateBuildQueue( BuildQueue queue)
 {
     PlanetBuildingsData.UpdateCurrentBuildQueueItem( queue);
 }
コード例 #2
0
ファイル: Planet.cs プロジェクト: charbean/StrategyClean
        public Planet(int Distance, Texture2D planetTex, Vector2 Origin, Rectangle SystemRectangle,
            string name, int type, int texNum, string system, int listIndex, int systemIndex,
            MapGenerator planetMapGenerator, Player ControlledBy = null)
        {
            PlanetsListIndex = listIndex;
            if (ControlledBy == null)
            {
                OwnerName = "None";
            }
            else
            {
                OwnerName = ControlledBy.Name;
                Owner = ControlledBy;
            }
            OrbitingSystem = system;
            OrbitingSystemListPosition = systemIndex;
            distance = Distance;
            PlanetTex = planetTex;
            randomDouble = (StrategyGame.r.NextDouble() + 0.001);
            rotation = MathHelper.Lerp(0.0f, 100f, (float)randomDouble);
            speed = MathHelper.Lerp(0.0f, 0.0001f, (float)randomDouble);
            position = new Vector2(distance, distance);
            origin = Origin;
            PlanetName = CultureInfo.CurrentCulture.TextInfo.ToTitleCase(name);
            planetsResourcesList = new List<ResourceDeposit>();
            planetsBuildingList = new List<Building>();
            PlanetTier = type;
            TextureNum = texNum;
            this.planetMapGenerator = planetMapGenerator;
            if (SystemRectangle.Width > 100)
            {
                Rect = new Rectangle(0, 0, SystemRectangle.Width / 8, SystemRectangle.Height / 8);
            }
            else
            {
                Rect = new Rectangle(0, 0, SystemRectangle.Width / 5, SystemRectangle.Height / 5);
            }

            #region if Tier 2
            if (PlanetTier == 2)
            {
                IsHabited = true;
                Population = (11000000000 + StrategyGame.r.Next(500000000, 900000000));
                PopIncreaseRate = 0.01f;
                TaxRate = 30;
                int x;

                #region metal
                for (int i = 1; i <= NumMetals; i++)
                {
                    switch (i)
                    {
                        case 1:
                            x = ResourceQuantity(3);
                            planetsResourcesList.Add(new IronResource(x, 3));
                            planetsBuildingList.Add(
                                planetsResourcesList[planetsResourcesList.Count - 1].BuildOn(
                                    StartingExtractorSize, StartingExtractorLevel, planetsBuildingList.Count));
                            break;
                        case 2:
                            x = ResourceQuantity(4);
                            planetsResourcesList.Add(new ZincResource(x, 4));
                            planetsBuildingList.Add(
                                planetsResourcesList[planetsResourcesList.Count - 1].BuildOn(
                                    StartingExtractorSize, StartingExtractorLevel, planetsBuildingList.Count));
                            break;
                        case 3:
                            x = ResourceQuantity(4);
                            planetsResourcesList.Add(new CopperResource(x, 4));
                            planetsBuildingList.Add(
                                planetsResourcesList[planetsResourcesList.Count - 1].BuildOn(
                                    StartingExtractorSize, StartingExtractorLevel, planetsBuildingList.Count));
                            break;
                        case 4:
                            x = ResourceQuantity(4);
                            planetsResourcesList.Add(new AluminiumResource(x, 4));
                            planetsBuildingList.Add(
                                planetsResourcesList[planetsResourcesList.Count - 1].BuildOn(
                                    StartingExtractorSize, StartingExtractorLevel, planetsBuildingList.Count));
                            break;
                        case 5:
                            x = ResourceQuantity(3);
                            planetsResourcesList.Add(new TitaniumResource(x, 3));
                            planetsBuildingList.Add(
                                planetsResourcesList[planetsResourcesList.Count - 1].BuildOn(
                                    StartingExtractorSize, StartingExtractorLevel, planetsBuildingList.Count));
                            break;
                        case 6:
                            x = ResourceQuantity(4);
                            planetsResourcesList.Add(new MagnesiumResource(x, 4));
                            planetsBuildingList.Add(
                                planetsResourcesList[planetsResourcesList.Count - 1].BuildOn(
                                    StartingExtractorSize, StartingExtractorLevel, planetsBuildingList.Count));
                            break;
                        case 7:
                            x = ResourceQuantity(4);
                            planetsResourcesList.Add(new LeadResource(x, 4));
                            planetsBuildingList.Add(
                                planetsResourcesList[planetsResourcesList.Count - 1].BuildOn(
                                    StartingExtractorSize, StartingExtractorLevel, planetsBuildingList.Count));
                            break;
                    }
                }
                #endregion

                #region blues
                x = ResourceQuantity(1);
                planetsResourcesList.Add(new SilverResource(x, 1));
                x = ResourceQuantity(1);
                planetsResourcesList.Add(new GoldResource(x, 1));
                x = ResourceQuantity(1);
                planetsResourcesList.Add(new PlatinumResource(x, 1));
                x = ResourceQuantity(1);
                planetsResourcesList.Add(new DiamondResource(x, 1));
                #endregion

                #region fuels
                x = ResourceQuantity(StartingFuelDepositLevel);
                planetsResourcesList.Add(new CoalResource(x, StartingFuelDepositLevel));
                planetsBuildingList.Add(
                        planetsResourcesList[planetsResourcesList.Count - 1].BuildOn(
                            StartingExtractorSize, StartingExtractorLevel, planetsBuildingList.Count));

                x = ResourceQuantity(StartingFuelDepositLevel);
                planetsResourcesList.Add(new OilResource(x, StartingFuelDepositLevel));
                x = ResourceQuantity(StartingFuelDepositLevel);
                planetsResourcesList.Add(new NaturalGasResource(x, StartingFuelDepositLevel));
                x = ResourceQuantity(StartingFuelDepositLevel);
                planetsResourcesList.Add(new UraniumResource(x, StartingFuelDepositLevel));
                x = ResourceQuantity(StartingFuelDepositLevel);
                planetsResourcesList.Add(new ThoriumResource(x, StartingFuelDepositLevel));
                #endregion

                #region misc
                x = ResourceQuantity(StartingMiscDepositLevel);
                planetsResourcesList.Add(new TimberResource(x, StartingMiscDepositLevel));
                x = ResourceQuantity(StartingMiscDepositLevel);
                planetsResourcesList.Add(new LivestockResource(x, StartingMiscDepositLevel));
                planetsBuildingList.Add(
                                planetsResourcesList[planetsResourcesList.Count - 1].BuildOn(
                                    StartingExtractorSize, StartingExtractorLevel, planetsBuildingList.Count));

                x = ResourceQuantity(StartingMiscDepositLevel);
                planetsResourcesList.Add(new CropsResource(x, StartingMiscDepositLevel));
                planetsBuildingList.Add(
                                planetsResourcesList[planetsResourcesList.Count - 1].BuildOn(
                                    StartingExtractorSize, StartingExtractorLevel, planetsBuildingList.Count));

                x = ResourceQuantity(StartingMiscDepositLevel);
                planetsResourcesList.Add(new CleanWaterResource(x, StartingMiscDepositLevel));
                #endregion

            }
            #endregion

            #region if Tier 4
            else if (PlanetTier == 4)
            {
                IsHabited = false;
                Population = 0;
                PopIncreaseRate = 0;
                int[] resources = new int[Tier4NumMetalResources];
                int x;
                int randomResource;

                #region metal
                for (int i = 0; i < Tier4NumMetalResources; i++)
                {
                    do
                    {
                        x = ResourceQuantity(Tier4StartingMetalDepositLevel);
                        randomResource = StrategyGame.r.Next(1, 8);
                    } while (resources.Contains(randomResource));

                    resources[i] = randomResource;


                    switch (randomResource)
                    {
                        case 1:
                            planetsResourcesList.Add(new IronResource(x, Tier4StartingMetalDepositLevel));
                            break;
                        case 2:
                            planetsResourcesList.Add(new ZincResource(x, Tier4StartingMetalDepositLevel));
                            break;
                        case 3:
                            planetsResourcesList.Add(new CopperResource(x, Tier4StartingMetalDepositLevel));
                            break;
                        case 4:
                            planetsResourcesList.Add(new AluminiumResource(x, Tier4StartingMetalDepositLevel));
                            break;
                        case 5:
                            planetsResourcesList.Add(new TitaniumResource(x, Tier4StartingMetalDepositLevel));
                            break;
                        case 6:
                            planetsResourcesList.Add(new MagnesiumResource(x, Tier4StartingMetalDepositLevel));
                            break;
                        case 7:
                            planetsResourcesList.Add(new LeadResource(x, Tier4StartingMetalDepositLevel));
                            break;
                    }

                }
                #endregion

                resources = new int[Tier4NumFuelDeposits];
                #region fuel

                for (int i = 0; i < Tier4NumFuelDeposits; i++)
                {
                    do
                    {
                        x = ResourceQuantity(Tier4StartingFuelDepositsLevel);
                        randomResource = StrategyGame.r.Next(1, 6);
                    } while (resources.Contains(randomResource));
                    resources[i] = randomResource;

                    switch (randomResource)
                    {
                        case 1:
                            planetsResourcesList.Add(new OilResource(x, Tier4StartingFuelDepositsLevel));
                            break;
                        case 2:
                            planetsResourcesList.Add(new CoalResource(x, Tier4StartingFuelDepositsLevel));
                            break;
                        case 3:
                            planetsResourcesList.Add(new NaturalGasResource(x, Tier4StartingFuelDepositsLevel));
                            break;
                        case 4:
                            planetsResourcesList.Add(new UraniumResource(x, Tier4StartingFuelDepositsLevel));
                            break;
                        case 5:
                            planetsResourcesList.Add(new ThoriumResource(x, Tier4StartingFuelDepositsLevel));
                            break;
                    }
                }
                #endregion

                resources = new int[Tier4NumBlues];
                #region blues
                for (int i = 0; i < Tier4NumBlues; i++)
                {
                    do
                    {
                        x = ResourceQuantity(Tier4StartingBluesDepositsLevel);
                        randomResource = StrategyGame.r.Next(1, 5);
                    } while (resources.Contains(randomResource));

                    resources[i] = randomResource;


                    switch (randomResource)
                    {
                        case 1:
                            planetsResourcesList.Add(new SilverResource(x, Tier4StartingBluesDepositsLevel));
                            break;
                        case 2:
                            planetsResourcesList.Add(new GoldResource(x, Tier4StartingBluesDepositsLevel));
                            break;
                        case 3:
                            planetsResourcesList.Add(new PlatinumResource(x, Tier4StartingBluesDepositsLevel));
                            break;
                        case 4:
                            planetsResourcesList.Add(new DiamondResource(x, Tier4StartingBluesDepositsLevel));
                            break;
                    }
                }
                #endregion

            }
            #endregion

            #region if Tier 3
            else if (PlanetTier == 3)
            {
                IsHabited = false;
                Population = 0;
                PopIncreaseRate = 0;
                int[] resources = new int[Tier3NumMetalResources];
                int x, size;
                int randomResource;

                #region metals
                for (int i = 0; i < Tier3NumMetalResources; i++)
                {

                    size = StrategyGame.r.Next(Tier3MaxMetalResourceSize + 1);
                    do
                    {
                        size = StrategyGame.r.Next(1, Tier3MaxMetalResourceSize);
                        x = ResourceQuantity(size);
                        randomResource = StrategyGame.r.Next(1, 8);


                    } while (resources.Contains(randomResource));

                    resources[i] = randomResource;

                    switch (randomResource)
                    {
                        case 1:
                            planetsResourcesList.Add(new IronResource(x, size));
                            break;
                        case 2:
                            planetsResourcesList.Add(new ZincResource(x, size));
                            break;
                        case 3:
                            planetsResourcesList.Add(new CopperResource(x, size));
                            break;
                        case 4:
                            planetsResourcesList.Add(new AluminiumResource(x, size));
                            break;
                        case 5:
                            planetsResourcesList.Add(new TitaniumResource(x, size));
                            break;
                        case 6:
                            planetsResourcesList.Add(new MagnesiumResource(x, size));
                            break;
                        case 7:
                            planetsResourcesList.Add(new LeadResource(x, size));
                            break;
                    }
                }
                #endregion

                #region blues
                size = StrategyGame.r.Next(1, Tier3MaxBluesResourceSize);
                x = ResourceQuantity(size);
                randomResource = StrategyGame.r.Next(1, 5);
                switch (randomResource)
                {
                    case 1:
                        planetsResourcesList.Add(new SilverResource(x, size));
                        break;
                    case 2:
                        planetsResourcesList.Add(new GoldResource(x, size));
                        break;
                    case 3:
                        planetsResourcesList.Add(new PlatinumResource(x, size));
                        break;
                    case 4:
                        planetsResourcesList.Add(new DiamondResource(x, size));
                        break;
                }
                #endregion

                #region misc
                x = ResourceQuantity(Tier3StartingMiscDepositLevel);
                planetsResourcesList.Add(new TimberResource(x, Tier3StartingMiscDepositLevel));
                x = ResourceQuantity(Tier3StartingMiscDepositLevel);
                planetsResourcesList.Add(new LivestockResource(x, Tier3StartingMiscDepositLevel));
                x = ResourceQuantity(Tier3StartingMiscDepositLevel);
                planetsResourcesList.Add(new CropsResource(x, Tier3StartingMiscDepositLevel));
                x = ResourceQuantity(Tier3StartingMiscDepositLevel);
                planetsResourcesList.Add(new CleanWaterResource(x, Tier3StartingMiscDepositLevel));
                #endregion

            }
            #endregion

            #region if Tier 1
            else if (PlanetTier == 1)
            {
                IsHabited = false;
                Population = 0;
                PopIncreaseRate = 0;
                int[] resources = new int[Tier1NumMetalResources];
                int x, size;
                int randomResource;
                #region metal
                for (int i = 0; i < Tier1NumMetalResources; i++)
                {

                    do
                    {
                        size = StrategyGame.r.Next(1, Tier1MaxMetalResourceSize);
                        x = ResourceQuantity(size);
                        randomResource = StrategyGame.r.Next(1, 8);

                    } while (resources.Contains(randomResource));

                    resources[i] = randomResource;

                    switch (randomResource)
                    {
                        case 1:
                            planetsResourcesList.Add(new IronResource(x, size));
                            break;
                        case 2:
                            planetsResourcesList.Add(new ZincResource(x, size));
                            break;
                        case 3:
                            planetsResourcesList.Add(new CopperResource(x, size));
                            break;
                        case 4:
                            planetsResourcesList.Add(new AluminiumResource(x, size));
                            break;
                        case 5:
                            planetsResourcesList.Add(new TitaniumResource(x, size));
                            break;
                        case 6:
                            planetsResourcesList.Add(new MagnesiumResource(x, size));
                            break;
                        case 7:
                            planetsResourcesList.Add(new LeadResource(x, size));
                            break;
                    }
                }
                #endregion

                #region blues
                x = ResourceQuantity(Tier1StartingPreciousDepositLevel);
                planetsResourcesList.Add(new SilverResource(x, Tier1StartingPreciousDepositLevel));
                x = ResourceQuantity(Tier1StartingPreciousDepositLevel);
                planetsResourcesList.Add(new GoldResource(x, Tier1StartingPreciousDepositLevel));
                x = ResourceQuantity(Tier1StartingPreciousDepositLevel);
                planetsResourcesList.Add(new PlatinumResource(x, Tier1StartingPreciousDepositLevel));
                #endregion

                #region fuels
                x = ResourceQuantity(Tier1StartingFuelDepositLevel);
                planetsResourcesList.Add(new OilResource(x, Tier1StartingFuelDepositLevel));
                x = ResourceQuantity(Tier1StartingFuelDepositLevel);
                planetsResourcesList.Add(new UraniumResource(x, Tier1StartingFuelDepositLevel));
                x = ResourceQuantity(Tier1StartingFuelDepositLevel);
                planetsResourcesList.Add(new ThoriumResource(x, Tier1StartingFuelDepositLevel));
                #endregion 
            }
            #endregion

            #region Buildings
            buildQueue = new BuildQueue();
            if (ControlledBy != null)
            {

            }
            #endregion

            #region map
            mapSitesList = new List<Vector2>();
            for (int y = 2; y < MapHeight ; y += 40)
            {
                for(int x = StrategyGame.r.Next(1, 10); x < MapWidth - 20; x += StrategyGame.r.Next(40, 60))
                {
                    bool finishedX = false;
                    if(x > (MapWidth - 20))
                    {
                        finishedX = true;
                        x = MapWidth - 5;
                    }

                    bool finishedY = false;
                    if (y > (MapHeight - 20))
                    {
                        finishedY = true;
                        y = MapHeight - 5;
                    }

                    mapSitesList.Add(new Vector2(x, y));

                    if (finishedX)
                        x = MapWidth + 1;
                    if (finishedY)
                        y = MapHeight + 1;
                }
            }
                      
            #endregion
        }
コード例 #3
0
ファイル: UIViewModel.cs プロジェクト: charbean/StrategyClean
        public void UpdatePlanetInfo(PlanetInfo info, PlanetResourcesDetails resDetails, List<Building> buildings, 
            List<ResourceDeposit> unusedResources, BuildQueue queue)
        {           
            if (info.IsHabited.Equals("True"))
            {
                IsInhabited = true;
                if (info.IsOwnedByPlayer)
                {
                    SliderTaxRate = int.Parse(info.TaxRate);
                    IsDetailsEnabled = true;
                }
                else
                {
                    IsDetailsEnabled = false;
                }

            }
            else
            {
                IsInhabited = false;
                IsDetailsEnabled = false;
            }
            PlanetBuildingsData.UpdateBuildingDetails(buildings, unusedResources, queue);
            InfoTabData.UpdateDetails(info);
            PlanetResourcesData.UpdateResourceDetails(resDetails);
            RaisePropertyChanged("IsDetailsEnabled");
            RaisePropertyChanged("InfoTabData");
            RaisePropertyChanged("PlanetResourcesData");
            RaisePropertyChanged("PlanetBuildingsData");
        }
コード例 #4
0
        public void UpdateBuildingDetails(List<Building> buildings, List<ResourceDeposit> unusedResources,
                                          BuildQueue queue)
        {

            #region Set up variables

            BuildingNames.Clear();
            BuildingIcons = null;
            ProductionBuildingNames.Clear();
            ProductionBuildingIcons = null;
            ResearchBuildingNames.Clear();
            ResearchBuildingIcons = null;
            ResourcesBuildingNames.Clear();
            ResourcesBuildingIcons = null;
            MilitaryBuildingNames.Clear();
            MilitaryBuildingIcons = null;
            UnusedResourceNames.Clear();
            UnusedResourceIcons = null;
            AvailableBuildings = null;
            BuildQueue = null;

            BuildingIcons = new ObservableCollection<ListBoxItem>();
            ProductionBuildingIcons = new ObservableCollection<ListBoxItem>();
            ResearchBuildingIcons = new ObservableCollection<ListBoxItem>();
            ResourcesBuildingIcons = new ObservableCollection<ListBoxItem>();
            MilitaryBuildingIcons = new ObservableCollection<ListBoxItem>();
            UnusedResourceIcons = new ObservableCollection<ListBoxItem>();
            AvailableBuildings = new ObservableCollection<ComboBoxItem>();
            BuildQueue = new ObservableCollection<ListBoxItem>();

            RaisePropertyChanged("BuildingIcons");
            RaisePropertyChanged("ResourcesBuildingIcons");

            if (SelectedBuilding < 0)
            {
                SelectedBuilding = 0;
            }
            else if(SelectedBuilding >= buildings.Count)
            {
                SelectedBuilding = buildings.Count - 1;
            }

            #endregion

            float margin = 24f;
            bool firstItem = true;

            if (buildings.Count > 0)
            {

                CanUpgrade = buildings[SelectedBuilding].CanUpgrade;              
                currentList = new List<Building>(buildings); //pass list by value so the actualy game list object isn't altered when UI is updated 

                UpgradeText = "UPGRADE: ";
                if (currentList[SelectedBuilding].Level < 10)
                {
                    UpgradeText += currentList[SelectedBuilding].UpgradeCost.ToString();
                }
                else
                {
                    UpgradeText += "MAX LEVEL";
                }

                #region buildings

                foreach (Building b in buildings)
                {
                    if (!firstItem)
                    {
                        margin = 37.5f;
                    }
                    ToolTip tt = new ToolTip();
                    Image img = new Image();
                    img.Width = img.Height = 51;

                    BuildingNames.Add(new ListBoxItem
                    {
                        Content = b.Name.ToString(),
                        Margin = new EmptyKeys.UserInterface.Thickness(0, margin, 0, 0),
                        ToolTip = tt,
                        Name = b.ID                        
                    });
                    ToolTipService.SetInitialShowDelay(BuildingNames.Last(), 0);

                    img.Source = LocalisationHelper.GetLocalizedImage(b.Icon);

                    switch (b.BuildingCatagory)
                    {
                        case BuildingCatagories.Resources:

                            var tempBuild = b as ResourceExtractor;
                            if (tempBuild != null)
                            {
                                tt.Content = tempBuild.actualYield.ToString();
                            }

                            ResourcesBuildingNames.Add(new ListBoxItem
                            {
                                Content = b.Name.ToString(),
                                Margin = new EmptyKeys.UserInterface.Thickness(0, margin, 0, 0),
                                ToolTip = tt,
                                Name = b.ID
                            });

                            BuildingIcons.Add(new ListBoxItem
                            {
                                Content = img,
                                Height = ListIconHeight,
                                Margin = new Thickness(3)
                            });

                            ResourcesBuildingIcons.Add(new ListBoxItem
                            {
                                Content = img,
                                Height = ListIconHeight,
                                Margin = new Thickness(3)
                            });

                            ToolTipService.SetInitialShowDelay(ResourcesBuildingNames.Last(), 0);

                            break;

                        case BuildingCatagories.Military:

                            MilitaryBuildingNames.Add(new ListBoxItem
                            {
                                Content = b.Name.ToString(),
                                Margin = new EmptyKeys.UserInterface.Thickness(0, margin, 0, 0),
                                ToolTip = tt,
                                Name = b.ID
                            });
                            

                            BuildingIcons.Add(new ListBoxItem
                            {
                                Content = img,
                                Height = ListIconHeight
                            });

                            MilitaryBuildingIcons.Add(new ListBoxItem
                            {
                                Content = img,
                                Height = ListIconHeight
                            });

                            ToolTipService.SetInitialShowDelay(MilitaryBuildingNames.Last(), 0);

                            break;
                    }                    

                    if (firstItem)
                    {
                        firstItem = false;
                    }
                }

                AvailableBuildings.Add(new ComboBoxItem { Content = "Massive Extractor" });

                if (BuildingNames.Count > 0)
                {

                    CurrentBuilding = BuildingNames[SelectedBuilding].Content.ToString();
                    CanUpgrade = buildings[SelectedBuilding].CanUpgrade;
                    UpgradeText = "UPGRADE: ";
                    if (currentList[SelectedBuilding].Level < 10)
                    {
                        UpgradeText += currentList[SelectedBuilding].UpgradeCost.ToString();
                    }
                    else
                    {
                        UpgradeText += "MAX LEVEL";
                    }
                    DismantleText = "Dismantle: +" + currentList[SelectedBuilding].DismantleReturn;
                    BuildingProduction = "Production: " + currentList[SelectedBuilding].ProductionType;

                    if (currentList[SelectedBuilding].BuildingCatagory == BuildingCatagories.Resources)
                    {
                        ResourceExtractor extractor = (ResourceExtractor)currentList[SelectedBuilding];
                        BuildingProduction += " (" + extractor.actualYield.ToString() + ")";
                    }
                }
                if (previousSelectedBuilding < currentList.Count)
                {
                    SelectedBuilding = previousSelectedBuilding;
                }
                }
                else if (currentList != null)
                {
                    currentList.Clear();
                }

            #endregion

            #region resources

            margin = 20f;
            firstItem = true;

        if (unusedResources.Count > 0)
        {
            depositList = new List<ResourceDeposit>(unusedResources);

            foreach (ResourceDeposit d in depositList)
            {
                if (!firstItem)
                {
                    margin = 32f;
                }

                ToolTip tt = new ToolTip();
                tt.Content = d.Quantity;
                Image img = new Image();
                img.Width = 51;
                img.Height = 51;
                img.Margin = new EmptyKeys.UserInterface.Thickness(0, 3, 0, 0);

                UnusedResourceNames.Add(new ListBoxItem
                {
                    Content = d.Name,
                    Margin = new EmptyKeys.UserInterface.Thickness(0, margin, 0, 0),
                    ToolTip = tt
                });
                ToolTipService.SetInitialShowDelay(UnusedResourceNames.Last(), 0);

                img.Source = GetResourceLocalisedResImage(d.ResourceType);
                UnusedResourceIcons.Add(new ListBoxItem { Content = img, Height = ListIconHeight });

                if (firstItem)
                {
                    firstItem = false;
                }

            }

                BuildingBuildText = "";
                SelectedUnusedResource = 0;
        }
            #endregion

            #region build queue

            UpdateBuildQueue(queue);
            if(queue.queueLength > 0)
            {
                HasBuildQueue = true;
            }
            else
            {
                HasBuildQueue = false;
            }
            RaisePropertyChanged("HasBuildQueue");

            #endregion

        }
コード例 #5
0
        private void UpdateBuildQueue(BuildQueue queue, bool currentItemFinished = false)
        {
            BuildQueue.Clear();
            if (queue.queueLength > 0)
            {
                int startingQueueItem = 1;
                int currentQueueItem = 0;
                //if (currentItemFinished)
                //{
                //    currentQueueItem = 1;
                //    startingQueueItem = 2;
                //    if(queue.queueLength == 1)
                //    {

                //    }
                //}
                //need to be careful when there is only 1 item in build queue but it is finished
                CurrentQueueItemElapsedTime = 0;
                BuildQueueCurrentImage = GetBuildQueueLocalisedImage(
                    queue.queueItems[currentQueueItem].item.GetType().ToString().Remove(0, 21));
                QueueItemMaxBuildTime = queue.queueItems[currentQueueItem].buildTime;

                if (queue.queueLength > 1)
                {
                    for (int i = startingQueueItem; i < queue.queueLength; i++)
                    {
                        ToolTip tt = new ToolTip();
                        tt.Content = queue.queueItems[i].item.Name;
                        Image img = new Image();
                        img.Width = 27;
                        img.Height = 27;
                        img.Margin = new EmptyKeys.UserInterface.Thickness(3);

                        img.Source = GetBuildQueueLocalisedImage(
                            queue.queueItems[i].item.GetType().ToString().Remove(0, 21));

                        BuildQueue.Add(new ListBoxItem {  Name = "QueueItem" + i.ToString(),
                                Content = img, Height = 30, Width = 30, ToolTip = tt });
                        BuildQueue[BuildQueue.Count-1].MouseDoubleClick += PlanetBuildingsModel_MouseDoubleClick;
                        ToolTipService.SetInitialShowDelay(BuildQueue.Last(), 0);
                    }
                }
            }
            else
            {
                BuildQueueCurrentImage = new BitmapImage();
            }
            RaisePropertyChanged("BuildQueue");
            RaisePropertyChanged("BuildQueueCurrentImage");
            RaisePropertyChanged("QueueItemMaxBuildTime");
        }
コード例 #6
0
        public void UpdateCurrentBuildQueueItem(BuildQueue queue)
        {

            if (queue.isCurrentItemFinished)
            {
                UpdateBuildQueue(queue, true);
            }
            if (queue.queueItems.Count > 0)
            {
                HasBuildQueue = true;
                CurrentQueueItemElapsedTime = queue.queueItems[0].elapsedBuildTime;                
            }
            else
            {
                HasBuildQueue = false;
            }
            RaisePropertyChanged("HasBuildQueue");
        }
コード例 #7
0
ファイル: GUIManager.cs プロジェクト: charbean/StrategyClean
 public void UpdateBuildQueue(BuildQueue queue)
 {
     model.UpdateBuildQueue(queue); //need to remove items when finished immediately, add support for "Military" building catagory
 }
コード例 #8
0
ファイル: GUIManager.cs プロジェクト: charbean/StrategyClean
 public void UpdatePlanetInfo(PlanetInfo info, PlanetResourcesDetails resDetails, 
     List<Building> buildings, ResourceManager manager, List<ResourceDeposit> unusedResources,
     BuildQueue queue)
 {
     model.UpdatePlanetInfo(info, resDetails, buildings, unusedResources, queue);
     UpdateResources(manager);
 }