public void update()
        {
            VillageMap village = GameEngine.Instance.Village;

            if (village != null)
            {
                if (GameEngine.Instance.World.isRegionCapital(village.VillageID))
                {
                    this.stockpileHeaderLabel.Text = SK.Text("ResourcesPanel_Parish_Resources", "Parish Resources");
                }
                else if (GameEngine.Instance.World.isCountyCapital(village.VillageID))
                {
                    this.stockpileHeaderLabel.Text = SK.Text("ResourcesPanel_County_Resources", "County Resources");
                }
                else if (GameEngine.Instance.World.isProvinceCapital(village.VillageID))
                {
                    this.stockpileHeaderLabel.Text = SK.Text("ResourcesPanel_Province_Resources", "Province Resources");
                }
                else if (GameEngine.Instance.World.isCountryCapital(village.VillageID))
                {
                    this.stockpileHeaderLabel.Text = SK.Text("ResourcesPanel_Country_Resources", "Country Resources");
                }
                NumberFormatInfo           nFI    = GameEngine.NFI;
                VillageMap.StockpileLevels levels = new VillageMap.StockpileLevels();
                village.getStockpileLevels(levels);
                this.woodLabel.Text  = SK.Text("ResourceTypeWood", "Wood") + ": " + levels.woodLevel.ToString("N", nFI);
                this.stoneLabel.Text = SK.Text("ResourceType_Stone", "Stone") + ": " + levels.stoneLevel.ToString("N", nFI);
                this.pitchLabel.Text = SK.Text("ResourceType_Pitch", "Pitch") + ": " + levels.pitchLevel.ToString("N", nFI);
                this.ironLabel.Text  = SK.Text("ResourceType_Iron", "Iron") + ": " + levels.ironLevel.ToString("N", nFI);
            }
        }
예제 #2
0
        public void okClicked()
        {
            this.m_questDef = NewQuests.getNewQuestDef(this.m_questID);
            VillageMap map = GameEngine.Instance.getVillage(this.m_villageID);

            if (map == null)
            {
                this.confirmAvailableSpace();
            }
            else
            {
                VillageMap.StockpileLevels levels  = new VillageMap.StockpileLevels();
                VillageMap.GranaryLevels   levels2 = new VillageMap.GranaryLevels();
                map.getStockpileLevels(levels);
                map.getGranaryLevels(levels2);
                bool   flag = false;
                double num  = 0.0;
                double num2 = 0.0;
                if (this.m_questDef.reward_apples > 0)
                {
                    num2 = GameEngine.Instance.World.UserResearchData.getResourceCap(GameEngine.Instance.LocalWorldData, 0x12, false) * CardTypes.getResourceCapMultiplier(0x12, GameEngine.Instance.World.UserCardData);
                    num  = num2 - levels2.fishLevel;
                    if (Convert.ToInt32(num) < this.m_questDef.reward_apples)
                    {
                        flag = true;
                    }
                }
                if ((this.m_questDef.reward_stone > 0) && !flag)
                {
                    num2 = GameEngine.Instance.World.UserResearchData.getResourceCap(GameEngine.Instance.LocalWorldData, 7, false) * CardTypes.getResourceCapMultiplier(7, GameEngine.Instance.World.UserCardData);
                    num  = num2 - levels.stoneLevel;
                    if (Convert.ToInt32(num) < this.m_questDef.reward_stone)
                    {
                        flag = true;
                    }
                }
                if ((this.m_questDef.reward_wood > 0) && !flag)
                {
                    num2 = GameEngine.Instance.World.UserResearchData.getResourceCap(GameEngine.Instance.LocalWorldData, 6, false) * CardTypes.getResourceCapMultiplier(6, GameEngine.Instance.World.UserCardData);
                    num  = num2 - levels.woodLevel;
                    if (Convert.ToInt32(num) < this.m_questDef.reward_wood)
                    {
                        flag = true;
                    }
                }
                if (!flag || (MyMessageBox.Show(SK.Text("Quest_Reward_Insufficient_Space", "You do not have enough room to store all of the reward at this village. Are you sure you want to send the reward to this village?"), SK.Text("Quest_Reward_Insufficient_Space_header", "Insufficient Space"), MessageBoxButtons.YesNo) != DialogResult.No))
                {
                    this.CompleteQuest();
                }
            }
        }
        public void updateStockpile(GraphicsMgr gfx, VillageMap vm)
        {
            if (this.baseSprite != null)
            {
                if (this.stockpileExtension == null)
                {
                    this.stockpileExtension = new VillageMapBuildingStockpileExtension();
                    for (int j = 0; j < 0x10; j++)
                    {
                        this.stockpileExtension.cell[j] = new SpriteWrapper();
                        this.stockpileExtension.cell[j].Visible = false;
                        this.stockpileExtension.cell[j].PosX = -96 + VillageMapBuildingStockpileExtension.stockpileLayout[j * 2];
                        this.stockpileExtension.cell[j].PosY = -43 + VillageMapBuildingStockpileExtension.stockpileLayout[(j * 2) + 1];
                        this.baseSprite.AddChild(this.stockpileExtension.cell[j]);
                        this.stockpileExtension.showGood(gfx, j, -1, 0);
                    }
                }
                for (int i = 0; i < 0x10; i++)
                {
                    this.stockpileExtension.showGood(gfx, i, -1, 0);
                }
                VillageMap.StockpileLevels levels = new VillageMap.StockpileLevels();
                if (!vm.getStockpileLevels(levels))
                {
                    for (int k = 0; k < 0x10; k++)
                    {
                        this.stockpileExtension.showGood(gfx, k, -1, 0);
                    }
                }
                else
                {
                    int index = 0;
                    if (levels.woodLevel > 13333248.0)
                    {
                        index = 12;
                    }
                    else if (levels.woodLevel > 3733248.0)
                    {
                        index = 11;
                    }
                    else if (levels.woodLevel > 1333248.0)
                    {
                        index = 10;
                    }
                    else if (levels.woodLevel > 373248.0)
                    {
                        index = 9;
                    }
                    else if (levels.woodLevel > 133248.0)
                    {
                        index = 8;
                    }
                    else if (levels.woodLevel > 37248.0)
                    {
                        index = 7;
                    }
                    else if (levels.woodLevel > 13248.0)
                    {
                        index = 6;
                    }
                    else if (levels.woodLevel > 3648.0)
                    {
                        index = 5;
                    }
                    else if (levels.woodLevel > 1248.0)
                    {
                        index = 4;
                    }
                    else if (levels.woodLevel > 288.0)
                    {
                        index = 3;
                    }
                    else if (levels.woodLevel > 48.0)
                    {
                        index = 2;
                    }
                    else if (levels.woodLevel > 0.0)
                    {
                        index = 1;
                    }
                    else
                    {
                        index = 0;
                    }
                    int num4 = 0;
                    if (levels.stoneLevel > 13333248.0)
                    {
                        num4 = 12;
                    }
                    else if (levels.stoneLevel > 3733248.0)
                    {
                        num4 = 11;
                    }
                    else if (levels.stoneLevel > 1333248.0)
                    {
                        num4 = 10;
                    }
                    else if (levels.stoneLevel > 373248.0)
                    {
                        num4 = 9;
                    }
                    else if (levels.stoneLevel > 133248.0)
                    {
                        num4 = 8;
                    }
                    else if (levels.stoneLevel > 37248.0)
                    {
                        num4 = 7;
                    }
                    else if (levels.stoneLevel > 13248.0)
                    {
                        num4 = 6;
                    }
                    else if (levels.stoneLevel > 3648.0)
                    {
                        num4 = 5;
                    }
                    else if (levels.stoneLevel > 1248.0)
                    {
                        num4 = 4;
                    }
                    else if (levels.stoneLevel > 288.0)
                    {
                        num4 = 3;
                    }
                    else if (levels.stoneLevel > 48.0)
                    {
                        num4 = 2;
                    }
                    else if (levels.stoneLevel > 0.0)
                    {
                        num4 = 1;
                    }
                    else
                    {
                        num4 = 0;
                    }
                    int num5 = 0;
                    if (levels.ironLevel > 13333248.0)
                    {
                        num5 = 12;
                    }
                    else if (levels.ironLevel > 3733248.0)
                    {
                        num5 = 11;
                    }
                    else if (levels.ironLevel > 1333248.0)
                    {
                        num5 = 10;
                    }
                    else if (levels.ironLevel > 373248.0)
                    {
                        num5 = 9;
                    }
                    else if (levels.ironLevel > 133248.0)
                    {
                        num5 = 8;
                    }
                    else if (levels.ironLevel > 37248.0)
                    {
                        num5 = 7;
                    }
                    else if (levels.ironLevel > 13248.0)
                    {
                        num5 = 6;
                    }
                    else if (levels.ironLevel > 3648.0)
                    {
                        num5 = 5;
                    }
                    else if (levels.ironLevel > 1248.0)
                    {
                        num5 = 4;
                    }
                    else if (levels.ironLevel > 288.0)
                    {
                        num5 = 3;
                    }
                    else if (levels.ironLevel > 48.0)
                    {
                        num5 = 2;
                    }
                    else if (levels.ironLevel > 0.0)
                    {
                        num5 = 1;
                    }
                    else
                    {
                        num5 = 0;
                    }
                    int num6 = 0;
                    if (levels.pitchLevel > 4444416.0)
                    {
                        num6 = 12;
                    }
                    else if (levels.pitchLevel > 1244416.0)
                    {
                        num6 = 11;
                    }
                    else if (levels.pitchLevel > 444416.0)
                    {
                        num6 = 10;
                    }
                    else if (levels.pitchLevel > 124416.0)
                    {
                        num6 = 9;
                    }
                    else if (levels.pitchLevel > 44416.0)
                    {
                        num6 = 8;
                    }
                    else if (levels.pitchLevel > 12416.0)
                    {
                        num6 = 7;
                    }
                    else if (levels.pitchLevel > 4416.0)
                    {
                        num6 = 6;
                    }
                    else if (levels.pitchLevel > 1216.0)
                    {
                        num6 = 5;
                    }
                    else if (levels.pitchLevel > 416.0)
                    {
                        num6 = 4;
                    }
                    else if (levels.pitchLevel > 96.0)
                    {
                        num6 = 3;
                    }
                    else if (levels.pitchLevel > 16.0)
                    {
                        num6 = 2;
                    }
                    else if (levels.pitchLevel > 0.0)
                    {
                        num6 = 1;
                    }
                    else
                    {
                        num6 = 0;
                    }
                    for (int m = 0; m < 0x10; m++)
                    {
                        this.pilesUsed[m] = false;
                    }
                    int num8 = ((index + num4) + num5) + num6;
                    if (num8 > 0x10)
                    {
                        int num9 = 0x10;
                        int num10 = 0;
                        if (index >= 1)
                        {
                            num10++;
                        }
                        if (num4 >= 1)
                        {
                            num10++;
                        }
                        if (num5 >= 1)
                        {
                            num10++;
                        }
                        if (num6 >= 1)
                        {
                            num10++;
                        }
                        num9 -= num10;
                        double num11 = ((double) num9) / ((double) (num8 - num10));
                        PileOrderSort[] sortArray = new PileOrderSort[4];
                        int num12 = 0;
                        if (index > 1)
                        {
                            PileOrderSort sort;
                            sort = new PileOrderSort {
                                origPiles = index - 1,
                                numPiles = index - 1,
                                type = 0
                            };
                            sortArray[num12++] = sort;
                        }
                        if (num4 > 1)
                        {
                            PileOrderSort sort2;
                            sort2 = new PileOrderSort {
                                origPiles = num4 - 1,
                                numPiles = num4 - 1,
                                type = 3
                            };
                            sortArray[num12++] = sort2;
                        }
                        if (num5 > 1)
                        {
                            PileOrderSort sort3;
                            sort3 = new PileOrderSort {
                                origPiles = num5 - 1,
                                numPiles = num5 - 1,
                                type = 4
                            };
                            sortArray[num12++] = sort3;
                        }
                        if (num6 > 1)
                        {
                            PileOrderSort sort4;
                            sort4 = new PileOrderSort {
                                origPiles = num6 - 1,
                                numPiles = num6 - 1,
                                type = 5
                            };
                            sortArray[num12++] = sort4;
                        }
                        if (num12 > 1)
                        {
                            for (int num13 = 0; num13 < (num12 - 1); num13++)
                            {
                                for (int num14 = 0; num14 < (num12 - 1); num14++)
                                {
                                    if (sortArray[num14].numPiles < sortArray[num14 + 1].numPiles)
                                    {
                                        PileOrderSort sort5 = sortArray[num14];
                                        sortArray[num14] = sortArray[num14 + 1];
                                        sortArray[num14 + 1] = sort5;
                                    }
                                }
                            }
                        }
                        int num15 = 0;
                        for (int num16 = 0; num16 < num12; num16++)
                        {
                            sortArray[num16].numPiles = Math.Floor((double) (sortArray[num16].numPiles * num11));
                            num15 += (int) sortArray[num16].numPiles;
                        }
                        if (num15 < num9)
                        {
                            int num17 = num9 - num15;
                            for (int num18 = 0; num17 > 0; num18++)
                            {
                                int num19 = num18 % num12;
                                if (sortArray[num19].numPiles < sortArray[num19].origPiles)
                                {
                                    PileOrderSort sort1 = sortArray[num19];
                                    sort1.numPiles++;
                                    num17--;
                                }
                            }
                        }
                        if (index >= 1)
                        {
                            index = 1;
                        }
                        if (num4 >= 1)
                        {
                            num4 = 1;
                        }
                        if (num5 >= 1)
                        {
                            num5 = 1;
                        }
                        if (num6 >= 1)
                        {
                            num6 = 1;
                        }
                        for (int num20 = 0; num20 < num12; num20++)
                        {
                            int numPiles = (int) sortArray[num20].numPiles;
                            switch (sortArray[num20].type)
                            {
                                case 0:
                                    index += numPiles;
                                    break;

                                case 3:
                                    num4 += numPiles;
                                    break;

                                case 4:
                                    num5 += numPiles;
                                    break;

                                case 5:
                                    num6 += numPiles;
                                    break;
                            }
                        }
                        int num22 = ((index + num4) + num5) + num6;
                        if (num22 != 0x10)
                        {
                            index = 0;
                        }
                    }
                    int num23 = 0;
                    int num24 = 0;
                    for (int n = 0; n < index; n++)
                    {
                        num24 = this.woodPileOrder[num23++];
                        this.pilesUsed[num24] = true;
                        if (n != (index - 1))
                        {
                            this.stockpileExtension.showGood(gfx, num24, 6, 0x30);
                        }
                        else
                        {
                            int num26 = (((int) levels.woodLevel) - this.goods48Levels[index]) / this.goodsDividers[index];
                            this.stockpileExtension.showGood(gfx, num24, 6, Math.Min(num26, 0x30));
                        }
                    }
                    num23 = 0;
                    for (int num27 = 0; num27 < num5; num27++)
                    {
                        do
                        {
                            num24 = this.ironPileOrder[num23++];
                        }
                        while (this.pilesUsed[num24]);
                        this.pilesUsed[num24] = true;
                        if (num27 != (num5 - 1))
                        {
                            this.stockpileExtension.showGood(gfx, num24, 8, 0x30);
                        }
                        else
                        {
                            int num28 = (((int) levels.ironLevel) - this.goods48Levels[num5]) / this.goodsDividers[num5];
                            this.stockpileExtension.showGood(gfx, num24, 8, Math.Min(num28, 0x30));
                        }
                    }
                    num23 = 0;
                    for (int num29 = 0; num29 < num4; num29++)
                    {
                        do
                        {
                            num24 = this.stonePileOrder[num23++];
                        }
                        while (this.pilesUsed[num24]);
                        this.pilesUsed[num24] = true;
                        if (num29 != (num4 - 1))
                        {
                            this.stockpileExtension.showGood(gfx, num24, 7, 0x30);
                        }
                        else
                        {
                            int num30 = (((int) levels.stoneLevel) - this.goods48Levels[num4]) / this.goodsDividers[num4];
                            this.stockpileExtension.showGood(gfx, num24, 7, Math.Min(num30, 0x30));
                        }
                    }
                    num23 = 0;
                    for (int num31 = 0; num31 < num6; num31++)
                    {
                        do
                        {
                            num24 = this.pitchPileOrder[num23++];
                        }
                        while (this.pilesUsed[num24]);
                        this.pilesUsed[num24] = true;
                        if (num31 != (num6 - 1))
                        {
                            this.stockpileExtension.showGood(gfx, num24, 9, 0x10);
                        }
                        else
                        {
                            int num32 = (((int) levels.pitchLevel) - this.goods16Levels[num6]) / this.goodsDividers[num6];
                            this.stockpileExtension.showGood(gfx, num24, 9, Math.Min(num32, 0x10));
                        }
                    }
                }
            }
        }
        public void updateStockpile(GraphicsMgr gfx, VillageMap vm)
        {
            if (this.baseSprite != null)
            {
                if (this.stockpileExtension == null)
                {
                    this.stockpileExtension = new VillageMapBuildingStockpileExtension();
                    for (int j = 0; j < 0x10; j++)
                    {
                        this.stockpileExtension.cell[j]         = new SpriteWrapper();
                        this.stockpileExtension.cell[j].Visible = false;
                        this.stockpileExtension.cell[j].PosX    = -96 + VillageMapBuildingStockpileExtension.stockpileLayout[j * 2];
                        this.stockpileExtension.cell[j].PosY    = -43 + VillageMapBuildingStockpileExtension.stockpileLayout[(j * 2) + 1];
                        this.baseSprite.AddChild(this.stockpileExtension.cell[j]);
                        this.stockpileExtension.showGood(gfx, j, -1, 0);
                    }
                }
                for (int i = 0; i < 0x10; i++)
                {
                    this.stockpileExtension.showGood(gfx, i, -1, 0);
                }
                VillageMap.StockpileLevels levels = new VillageMap.StockpileLevels();
                if (!vm.getStockpileLevels(levels))
                {
                    for (int k = 0; k < 0x10; k++)
                    {
                        this.stockpileExtension.showGood(gfx, k, -1, 0);
                    }
                }
                else
                {
                    int index = 0;
                    if (levels.woodLevel > 13333248.0)
                    {
                        index = 12;
                    }
                    else if (levels.woodLevel > 3733248.0)
                    {
                        index = 11;
                    }
                    else if (levels.woodLevel > 1333248.0)
                    {
                        index = 10;
                    }
                    else if (levels.woodLevel > 373248.0)
                    {
                        index = 9;
                    }
                    else if (levels.woodLevel > 133248.0)
                    {
                        index = 8;
                    }
                    else if (levels.woodLevel > 37248.0)
                    {
                        index = 7;
                    }
                    else if (levels.woodLevel > 13248.0)
                    {
                        index = 6;
                    }
                    else if (levels.woodLevel > 3648.0)
                    {
                        index = 5;
                    }
                    else if (levels.woodLevel > 1248.0)
                    {
                        index = 4;
                    }
                    else if (levels.woodLevel > 288.0)
                    {
                        index = 3;
                    }
                    else if (levels.woodLevel > 48.0)
                    {
                        index = 2;
                    }
                    else if (levels.woodLevel > 0.0)
                    {
                        index = 1;
                    }
                    else
                    {
                        index = 0;
                    }
                    int num4 = 0;
                    if (levels.stoneLevel > 13333248.0)
                    {
                        num4 = 12;
                    }
                    else if (levels.stoneLevel > 3733248.0)
                    {
                        num4 = 11;
                    }
                    else if (levels.stoneLevel > 1333248.0)
                    {
                        num4 = 10;
                    }
                    else if (levels.stoneLevel > 373248.0)
                    {
                        num4 = 9;
                    }
                    else if (levels.stoneLevel > 133248.0)
                    {
                        num4 = 8;
                    }
                    else if (levels.stoneLevel > 37248.0)
                    {
                        num4 = 7;
                    }
                    else if (levels.stoneLevel > 13248.0)
                    {
                        num4 = 6;
                    }
                    else if (levels.stoneLevel > 3648.0)
                    {
                        num4 = 5;
                    }
                    else if (levels.stoneLevel > 1248.0)
                    {
                        num4 = 4;
                    }
                    else if (levels.stoneLevel > 288.0)
                    {
                        num4 = 3;
                    }
                    else if (levels.stoneLevel > 48.0)
                    {
                        num4 = 2;
                    }
                    else if (levels.stoneLevel > 0.0)
                    {
                        num4 = 1;
                    }
                    else
                    {
                        num4 = 0;
                    }
                    int num5 = 0;
                    if (levels.ironLevel > 13333248.0)
                    {
                        num5 = 12;
                    }
                    else if (levels.ironLevel > 3733248.0)
                    {
                        num5 = 11;
                    }
                    else if (levels.ironLevel > 1333248.0)
                    {
                        num5 = 10;
                    }
                    else if (levels.ironLevel > 373248.0)
                    {
                        num5 = 9;
                    }
                    else if (levels.ironLevel > 133248.0)
                    {
                        num5 = 8;
                    }
                    else if (levels.ironLevel > 37248.0)
                    {
                        num5 = 7;
                    }
                    else if (levels.ironLevel > 13248.0)
                    {
                        num5 = 6;
                    }
                    else if (levels.ironLevel > 3648.0)
                    {
                        num5 = 5;
                    }
                    else if (levels.ironLevel > 1248.0)
                    {
                        num5 = 4;
                    }
                    else if (levels.ironLevel > 288.0)
                    {
                        num5 = 3;
                    }
                    else if (levels.ironLevel > 48.0)
                    {
                        num5 = 2;
                    }
                    else if (levels.ironLevel > 0.0)
                    {
                        num5 = 1;
                    }
                    else
                    {
                        num5 = 0;
                    }
                    int num6 = 0;
                    if (levels.pitchLevel > 4444416.0)
                    {
                        num6 = 12;
                    }
                    else if (levels.pitchLevel > 1244416.0)
                    {
                        num6 = 11;
                    }
                    else if (levels.pitchLevel > 444416.0)
                    {
                        num6 = 10;
                    }
                    else if (levels.pitchLevel > 124416.0)
                    {
                        num6 = 9;
                    }
                    else if (levels.pitchLevel > 44416.0)
                    {
                        num6 = 8;
                    }
                    else if (levels.pitchLevel > 12416.0)
                    {
                        num6 = 7;
                    }
                    else if (levels.pitchLevel > 4416.0)
                    {
                        num6 = 6;
                    }
                    else if (levels.pitchLevel > 1216.0)
                    {
                        num6 = 5;
                    }
                    else if (levels.pitchLevel > 416.0)
                    {
                        num6 = 4;
                    }
                    else if (levels.pitchLevel > 96.0)
                    {
                        num6 = 3;
                    }
                    else if (levels.pitchLevel > 16.0)
                    {
                        num6 = 2;
                    }
                    else if (levels.pitchLevel > 0.0)
                    {
                        num6 = 1;
                    }
                    else
                    {
                        num6 = 0;
                    }
                    for (int m = 0; m < 0x10; m++)
                    {
                        this.pilesUsed[m] = false;
                    }
                    int num8 = ((index + num4) + num5) + num6;
                    if (num8 > 0x10)
                    {
                        int num9  = 0x10;
                        int num10 = 0;
                        if (index >= 1)
                        {
                            num10++;
                        }
                        if (num4 >= 1)
                        {
                            num10++;
                        }
                        if (num5 >= 1)
                        {
                            num10++;
                        }
                        if (num6 >= 1)
                        {
                            num10++;
                        }
                        num9 -= num10;
                        double          num11     = ((double)num9) / ((double)(num8 - num10));
                        PileOrderSort[] sortArray = new PileOrderSort[4];
                        int             num12     = 0;
                        if (index > 1)
                        {
                            PileOrderSort sort;
                            sort = new PileOrderSort {
                                origPiles = index - 1,
                                numPiles  = index - 1,
                                type      = 0
                            };
                            sortArray[num12++] = sort;
                        }
                        if (num4 > 1)
                        {
                            PileOrderSort sort2;
                            sort2 = new PileOrderSort {
                                origPiles = num4 - 1,
                                numPiles  = num4 - 1,
                                type      = 3
                            };
                            sortArray[num12++] = sort2;
                        }
                        if (num5 > 1)
                        {
                            PileOrderSort sort3;
                            sort3 = new PileOrderSort {
                                origPiles = num5 - 1,
                                numPiles  = num5 - 1,
                                type      = 4
                            };
                            sortArray[num12++] = sort3;
                        }
                        if (num6 > 1)
                        {
                            PileOrderSort sort4;
                            sort4 = new PileOrderSort {
                                origPiles = num6 - 1,
                                numPiles  = num6 - 1,
                                type      = 5
                            };
                            sortArray[num12++] = sort4;
                        }
                        if (num12 > 1)
                        {
                            for (int num13 = 0; num13 < (num12 - 1); num13++)
                            {
                                for (int num14 = 0; num14 < (num12 - 1); num14++)
                                {
                                    if (sortArray[num14].numPiles < sortArray[num14 + 1].numPiles)
                                    {
                                        PileOrderSort sort5 = sortArray[num14];
                                        sortArray[num14]     = sortArray[num14 + 1];
                                        sortArray[num14 + 1] = sort5;
                                    }
                                }
                            }
                        }
                        int num15 = 0;
                        for (int num16 = 0; num16 < num12; num16++)
                        {
                            sortArray[num16].numPiles = Math.Floor((double)(sortArray[num16].numPiles * num11));
                            num15 += (int)sortArray[num16].numPiles;
                        }
                        if (num15 < num9)
                        {
                            int num17 = num9 - num15;
                            for (int num18 = 0; num17 > 0; num18++)
                            {
                                int num19 = num18 % num12;
                                if (sortArray[num19].numPiles < sortArray[num19].origPiles)
                                {
                                    PileOrderSort sort1 = sortArray[num19];
                                    sort1.numPiles++;
                                    num17--;
                                }
                            }
                        }
                        if (index >= 1)
                        {
                            index = 1;
                        }
                        if (num4 >= 1)
                        {
                            num4 = 1;
                        }
                        if (num5 >= 1)
                        {
                            num5 = 1;
                        }
                        if (num6 >= 1)
                        {
                            num6 = 1;
                        }
                        for (int num20 = 0; num20 < num12; num20++)
                        {
                            int numPiles = (int)sortArray[num20].numPiles;
                            switch (sortArray[num20].type)
                            {
                            case 0:
                                index += numPiles;
                                break;

                            case 3:
                                num4 += numPiles;
                                break;

                            case 4:
                                num5 += numPiles;
                                break;

                            case 5:
                                num6 += numPiles;
                                break;
                            }
                        }
                        int num22 = ((index + num4) + num5) + num6;
                        if (num22 != 0x10)
                        {
                            index = 0;
                        }
                    }
                    int num23 = 0;
                    int num24 = 0;
                    for (int n = 0; n < index; n++)
                    {
                        num24 = this.woodPileOrder[num23++];
                        this.pilesUsed[num24] = true;
                        if (n != (index - 1))
                        {
                            this.stockpileExtension.showGood(gfx, num24, 6, 0x30);
                        }
                        else
                        {
                            int num26 = (((int)levels.woodLevel) - this.goods48Levels[index]) / this.goodsDividers[index];
                            this.stockpileExtension.showGood(gfx, num24, 6, Math.Min(num26, 0x30));
                        }
                    }
                    num23 = 0;
                    for (int num27 = 0; num27 < num5; num27++)
                    {
                        do
                        {
                            num24 = this.ironPileOrder[num23++];
                        }while (this.pilesUsed[num24]);
                        this.pilesUsed[num24] = true;
                        if (num27 != (num5 - 1))
                        {
                            this.stockpileExtension.showGood(gfx, num24, 8, 0x30);
                        }
                        else
                        {
                            int num28 = (((int)levels.ironLevel) - this.goods48Levels[num5]) / this.goodsDividers[num5];
                            this.stockpileExtension.showGood(gfx, num24, 8, Math.Min(num28, 0x30));
                        }
                    }
                    num23 = 0;
                    for (int num29 = 0; num29 < num4; num29++)
                    {
                        do
                        {
                            num24 = this.stonePileOrder[num23++];
                        }while (this.pilesUsed[num24]);
                        this.pilesUsed[num24] = true;
                        if (num29 != (num4 - 1))
                        {
                            this.stockpileExtension.showGood(gfx, num24, 7, 0x30);
                        }
                        else
                        {
                            int num30 = (((int)levels.stoneLevel) - this.goods48Levels[num4]) / this.goodsDividers[num4];
                            this.stockpileExtension.showGood(gfx, num24, 7, Math.Min(num30, 0x30));
                        }
                    }
                    num23 = 0;
                    for (int num31 = 0; num31 < num6; num31++)
                    {
                        do
                        {
                            num24 = this.pitchPileOrder[num23++];
                        }while (this.pilesUsed[num24]);
                        this.pilesUsed[num24] = true;
                        if (num31 != (num6 - 1))
                        {
                            this.stockpileExtension.showGood(gfx, num24, 9, 0x10);
                        }
                        else
                        {
                            int num32 = (((int)levels.pitchLevel) - this.goods16Levels[num6]) / this.goodsDividers[num6];
                            this.stockpileExtension.showGood(gfx, num24, 9, Math.Min(num32, 0x10));
                        }
                    }
                }
            }
        }