Exemplo n.º 1
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 update()
 {
     VillageMap village = GameEngine.Instance.Village;
     if (village != null)
     {
         NumberFormatInfo nFI = GameEngine.NFI;
         VillageMap.StockpileLevels levels = new VillageMap.StockpileLevels();
         village.getStockpileLevels(levels);
         VillageMap.GranaryLevels levels2 = new VillageMap.GranaryLevels();
         village.getGranaryLevels(levels2);
         VillageMap.ArmouryLevels levels3 = new VillageMap.ArmouryLevels();
         village.getArmouryLevels(levels3);
         VillageMap.TownHallLevels levels4 = new VillageMap.TownHallLevels();
         village.getTownHallLevels(levels4);
         VillageMap.InnLevels levels5 = new VillageMap.InnLevels();
         village.getInnLevels(levels5);
         this.woodLabel.Text = levels.woodLevel.ToString("N", nFI);
         this.stoneLabel.Text = levels.stoneLevel.ToString("N", nFI);
         this.pitchLabel.Text = levels.pitchLevel.ToString("N", nFI);
         this.ironLabel.Text = levels.ironLevel.ToString("N", nFI);
         this.aleLabel.Text = levels5.aleLevel.ToString("N", nFI);
         this.applesLabel.Text = levels2.applesLevel.ToString("N", nFI);
         this.breadLabel.Text = levels2.breadLevel.ToString("N", nFI);
         this.cheeseLabel.Text = levels2.cheeseLevel.ToString("N", nFI);
         this.meatLabel.Text = levels2.meatLevel.ToString("N", nFI);
         this.vegLabel.Text = levels2.vegLevel.ToString("N", nFI);
         this.fishLabel.Text = levels2.fishLevel.ToString("N", nFI);
         this.bowsLabel.Text = levels3.bowsLevel.ToString("N", nFI);
         this.pikesLabel.Text = levels3.pikesLevel.ToString("N", nFI);
         this.swordsLabel.Text = levels3.swordsLevel.ToString("N", nFI);
         this.armourLabel.Text = levels3.armourLevel.ToString("N", nFI);
         this.catapultsLabel.Text = levels3.catapultsLevel.ToString("N", nFI);
         this.clothesLabel.Text = levels4.clothesLevel.ToString("N", nFI);
         this.furnitureLabel.Text = levels4.furnitureLevel.ToString("N", nFI);
         this.saltLabel.Text = levels4.saltLevel.ToString("N", nFI);
         this.wineLabel.Text = levels4.wineLevel.ToString("N", nFI);
         this.venisonLabel.Text = levels4.venisonLevel.ToString("N", nFI);
         this.spicesLabel.Text = levels4.spicesLevel.ToString("N", nFI);
         this.silkLabel.Text = levels4.silkLevel.ToString("N", nFI);
         this.metalwareLabel.Text = levels4.metalwareLevel.ToString("N", nFI);
         this.stockpileLimitLabel.Text = "(" + this.getCap(6).ToString("N", nFI) + ")";
         this.innLimitLabel.Text = "(" + this.getCap(12).ToString("N", nFI) + ")";
         this.granaryLimitLabel.Text = "(" + this.getCap(13).ToString("N", nFI) + ")";
         this.armouryLimitLabel.Text = "(" + this.getCap(0x1d).ToString("N", nFI) + ")";
         this.hallLimitLabel.Text = "(" + this.getCap(0x17).ToString("N", nFI) + ")";
         if (this.selectedResource >= 0)
         {
             this.selectedHeadingLabel.Text = VillageBuildingsData.getResourceNames(this.selectedResource) + ": " + ((int) village.getResourceLevel(this.selectedResource)).ToString("N", nFI);
             double num2 = village.getResourceProductionPerDay(this.selectedResource);
             this.dailyProductionValueLabel.Text = ((int) num2).ToString("N", nFI);
             this.totalBuildingsValueLabel.Text = village.numBuildingsOfType(this.selectedResource).ToString("N", nFI);
             this.workingBuildingsValueLabel.Text = village.numWorkingBuildingsOfType(this.selectedResource).ToString("N", nFI);
         }
         this.cardbar.update();
     }
 }
 public void updateGranary(GraphicsMgr gfx, VillageMap vm)
 {
     if (this.baseSprite != null)
     {
         if (this.granaryExtension == null)
         {
             this.granaryExtension = new VillageMapBuildingGranaryExtension();
             for (int j = 0; j < 0x15; j++)
             {
                 this.granaryExtension.cell[j] = new SpriteWrapper();
                 this.granaryExtension.cell[j].Visible = false;
                 this.granaryExtension.cell[j].PosX = 5 + VillageMapBuildingGranaryExtension.granaryLayout[j * 2];
                 this.granaryExtension.cell[j].PosY = -33 + VillageMapBuildingGranaryExtension.granaryLayout[(j * 2) + 1];
                 this.baseSprite.AddChild(this.granaryExtension.cell[j]);
                 this.granaryExtension.showGood(gfx, j, -1, 0);
             }
         }
         for (int i = 0; i < 0x15; i++)
         {
             this.granaryExtension.showGood(gfx, i, -1, 0);
         }
         VillageMap.GranaryLevels levels = new VillageMap.GranaryLevels();
         if (vm.getGranaryLevels(levels))
         {
             if (vm.granaryOpenCount == 0)
             {
                 this.open = false;
             }
             double num3 = ((((levels.applesLevel + levels.breadLevel) + levels.cheeseLevel) + levels.fishLevel) + levels.meatLevel) + levels.vegLevel;
             if (num3 > 0.0)
             {
                 if (vm.granaryOpenCount > 0)
                 {
                     this.open = true;
                 }
                 else
                 {
                     return;
                 }
                 int index = 0;
                 if (levels.meatLevel > 416.0)
                 {
                     index = 4;
                 }
                 else if (levels.meatLevel > 96.0)
                 {
                     index = 3;
                 }
                 else if (levels.meatLevel > 16.0)
                 {
                     index = 2;
                 }
                 else if (levels.meatLevel > 0.0)
                 {
                     index = 1;
                 }
                 else
                 {
                     index = 0;
                 }
                 int num5 = 0;
                 if (levels.vegLevel > 96.0)
                 {
                     num5 = 3;
                 }
                 else if (levels.vegLevel > 16.0)
                 {
                     num5 = 2;
                 }
                 else if (levels.vegLevel > 0.0)
                 {
                     num5 = 1;
                 }
                 else
                 {
                     num5 = 0;
                 }
                 int num6 = 0;
                 if (levels.cheeseLevel > 416.0)
                 {
                     num6 = 4;
                 }
                 else if (levels.cheeseLevel > 96.0)
                 {
                     num6 = 3;
                 }
                 else if (levels.cheeseLevel > 16.0)
                 {
                     num6 = 2;
                 }
                 else if (levels.cheeseLevel > 0.0)
                 {
                     num6 = 1;
                 }
                 else
                 {
                     num6 = 0;
                 }
                 int num7 = 0;
                 if (levels.applesLevel > 96.0)
                 {
                     num7 = 3;
                 }
                 else if (levels.applesLevel > 16.0)
                 {
                     num7 = 2;
                 }
                 else if (levels.applesLevel > 0.0)
                 {
                     num7 = 1;
                 }
                 else
                 {
                     num7 = 0;
                 }
                 int num8 = 0;
                 if (levels.fishLevel > 96.0)
                 {
                     num8 = 3;
                 }
                 else if (levels.fishLevel > 16.0)
                 {
                     num8 = 2;
                 }
                 else if (levels.fishLevel > 0.0)
                 {
                     num8 = 1;
                 }
                 else
                 {
                     num8 = 0;
                 }
                 int num9 = 0;
                 if (levels.breadLevel > 832.0)
                 {
                     num9 = 4;
                 }
                 else if (levels.breadLevel > 192.0)
                 {
                     num9 = 3;
                 }
                 else if (levels.breadLevel > 32.0)
                 {
                     num9 = 2;
                 }
                 else if (levels.breadLevel > 0.0)
                 {
                     num9 = 1;
                 }
                 else
                 {
                     num9 = 0;
                 }
                 int cellID = 0;
                 for (int k = 0; k < index; k++)
                 {
                     cellID = this.meatPileOrder[k];
                     if (k != (index - 1))
                     {
                         this.granaryExtension.showGood(gfx, cellID, 0x10, 0x10);
                     }
                     else
                     {
                         int num12 = (((int) levels.meatLevel) - this.goods16Levels[index]) / this.goodsDividers[index];
                         this.granaryExtension.showGood(gfx, cellID, 0x10, Math.Min(num12, 0x10));
                     }
                 }
                 for (int m = 0; m < num5; m++)
                 {
                     cellID = this.vegPileOrder[m];
                     if (m != (num5 - 1))
                     {
                         this.granaryExtension.showGood(gfx, cellID, 15, 0x10);
                     }
                     else
                     {
                         int num14 = (((int) levels.vegLevel) - this.goods16Levels[num5]) / this.goodsDividers[num5];
                         this.granaryExtension.showGood(gfx, cellID, 15, Math.Min(num14, 0x10));
                     }
                 }
                 for (int n = 0; n < num6; n++)
                 {
                     cellID = this.cheesePileOrder[n];
                     if (n != (num6 - 1))
                     {
                         this.granaryExtension.showGood(gfx, cellID, 0x11, 0x10);
                     }
                     else
                     {
                         int num16 = (((int) levels.cheeseLevel) - this.goods16Levels[num6]) / this.goodsDividers[num6];
                         this.granaryExtension.showGood(gfx, cellID, 0x11, Math.Min(num16, 0x10));
                     }
                 }
                 for (int num17 = 0; num17 < num7; num17++)
                 {
                     cellID = this.applesPileOrder[num17];
                     if (num17 != (num7 - 1))
                     {
                         this.granaryExtension.showGood(gfx, cellID, 13, 0x10);
                     }
                     else
                     {
                         int num18 = (((int) levels.applesLevel) - this.goods16Levels[num7]) / this.goodsDividers[num7];
                         this.granaryExtension.showGood(gfx, cellID, 13, Math.Min(num18, 0x10));
                     }
                 }
                 for (int num19 = 0; num19 < num8; num19++)
                 {
                     cellID = this.fishPileOrder[num19];
                     if (num19 != (num8 - 1))
                     {
                         this.granaryExtension.showGood(gfx, cellID, 0x12, 0x10);
                     }
                     else
                     {
                         int num20 = (((int) levels.fishLevel) - this.goods16Levels[num8]) / this.goodsDividers[num8];
                         this.granaryExtension.showGood(gfx, cellID, 0x12, Math.Min(num20, 0x10));
                     }
                 }
                 for (int num21 = 0; num21 < num9; num21++)
                 {
                     cellID = this.breadPileOrder[num21];
                     if (num21 != (num9 - 1))
                     {
                         this.granaryExtension.showGood(gfx, cellID, 14, 0x20);
                     }
                     else
                     {
                         int num22 = (((int) levels.breadLevel) - (this.goods16Levels[num9] * 2)) / this.goodsDividers[num9];
                         this.granaryExtension.showGood(gfx, cellID, 14, Math.Min(num22, 0x20));
                     }
                 }
             }
         }
     }
 }
 public void updateValues()
 {
     NumberFormatInfo nFI = GameEngine.NFI;
     VillageMap village = GameEngine.Instance.Village;
     if (village == null)
     {
         for (int i = 0; i < 8; i++)
         {
             this.setRowValues(i, -1, -1, -1);
         }
         this.tradersAvailableValue.Text = "0/0";
         this.traderCapacityValue.Text = "0";
     }
     else
     {
         StockExchangeInfo info2 = null;
         if ((this.selectedStockExchange >= 0) && (this.stockExchanges[this.selectedStockExchange] != null))
         {
             info2 = (StockExchangeInfo) this.stockExchanges[this.selectedStockExchange];
             this.updateDeliveryTime(this.selectedStockExchange);
         }
         WorldData localWorldData = GameEngine.Instance.LocalWorldData;
         switch (this.lastTab)
         {
             case 1:
             {
                 VillageMap.StockpileLevels levels = new VillageMap.StockpileLevels();
                 village.getStockpileLevels(levels);
                 if (info2 != null)
                 {
                     this.setRowValues(0, (int) levels.woodLevel, info2.woodLevel, TradingCalcs.calcSellCost(localWorldData, info2.getFakeLevel(6), 6));
                     this.setRowValues(1, (int) levels.stoneLevel, info2.stoneLevel, TradingCalcs.calcSellCost(localWorldData, info2.getFakeLevel(7), 7));
                     this.setRowValues(2, (int) levels.ironLevel, info2.ironLevel, TradingCalcs.calcSellCost(localWorldData, info2.getFakeLevel(8), 8));
                     this.setRowValues(3, (int) levels.pitchLevel, info2.pitchLevel, TradingCalcs.calcSellCost(localWorldData, info2.getFakeLevel(9), 9));
                     break;
                 }
                 this.setRowValues(0, (int) levels.woodLevel, -1, -1);
                 this.setRowValues(1, (int) levels.stoneLevel, -1, -1);
                 this.setRowValues(2, (int) levels.ironLevel, -1, -1);
                 this.setRowValues(3, (int) levels.pitchLevel, -1, -1);
                 break;
             }
             case 2:
             {
                 VillageMap.GranaryLevels levels2 = new VillageMap.GranaryLevels();
                 village.getGranaryLevels(levels2);
                 VillageMap.InnLevels levels3 = new VillageMap.InnLevels();
                 village.getInnLevels(levels3);
                 if (info2 != null)
                 {
                     this.setRowValues(0, (int) levels2.applesLevel, info2.applesLevel, TradingCalcs.calcSellCost(localWorldData, info2.getFakeLevel(13), 13));
                     this.setRowValues(1, (int) levels2.cheeseLevel, info2.cheeseLevel, TradingCalcs.calcSellCost(localWorldData, info2.getFakeLevel(0x11), 0x11));
                     this.setRowValues(2, (int) levels2.meatLevel, info2.meatLevel, TradingCalcs.calcSellCost(localWorldData, info2.getFakeLevel(0x10), 0x10));
                     this.setRowValues(3, (int) levels2.breadLevel, info2.breadLevel, TradingCalcs.calcSellCost(localWorldData, info2.getFakeLevel(14), 14));
                     this.setRowValues(4, (int) levels2.vegLevel, info2.vegLevel, TradingCalcs.calcSellCost(localWorldData, info2.getFakeLevel(15), 15));
                     this.setRowValues(5, (int) levels2.fishLevel, info2.fishLevel, TradingCalcs.calcSellCost(localWorldData, info2.getFakeLevel(0x12), 0x12));
                     this.setRowValues(6, (int) levels3.aleLevel, info2.aleLevel, TradingCalcs.calcSellCost(localWorldData, info2.getFakeLevel(12), 12));
                     break;
                 }
                 this.setRowValues(0, (int) levels2.applesLevel, -1, -1);
                 this.setRowValues(1, (int) levels2.cheeseLevel, -1, -1);
                 this.setRowValues(2, (int) levels2.meatLevel, -1, -1);
                 this.setRowValues(3, (int) levels2.breadLevel, -1, -1);
                 this.setRowValues(4, (int) levels2.vegLevel, -1, -1);
                 this.setRowValues(5, (int) levels2.fishLevel, -1, -1);
                 this.setRowValues(6, (int) levels3.aleLevel, -1, -1);
                 break;
             }
             case 3:
             {
                 VillageMap.ArmouryLevels levels4 = new VillageMap.ArmouryLevels();
                 village.getArmouryLevels(levels4);
                 if (info2 != null)
                 {
                     this.setRowValues(0, (int) levels4.bowsLevel, info2.bowsLevel, TradingCalcs.calcSellCost(localWorldData, info2.getFakeLevel(0x1d), 0x1d));
                     this.setRowValues(1, (int) levels4.pikesLevel, info2.pikesLevel, TradingCalcs.calcSellCost(localWorldData, info2.getFakeLevel(0x1c), 0x1c));
                     this.setRowValues(2, (int) levels4.armourLevel, info2.armourLevel, TradingCalcs.calcSellCost(localWorldData, info2.getFakeLevel(0x1f), 0x1f));
                     this.setRowValues(3, (int) levels4.swordsLevel, info2.swordsLevel, TradingCalcs.calcSellCost(localWorldData, info2.getFakeLevel(30), 30));
                     this.setRowValues(4, (int) levels4.catapultsLevel, info2.catapultsLevel, TradingCalcs.calcSellCost(localWorldData, info2.getFakeLevel(0x20), 0x20));
                     break;
                 }
                 this.setRowValues(0, (int) levels4.bowsLevel, -1, -1);
                 this.setRowValues(1, (int) levels4.pikesLevel, -1, -1);
                 this.setRowValues(2, (int) levels4.armourLevel, -1, -1);
                 this.setRowValues(3, (int) levels4.swordsLevel, -1, -1);
                 this.setRowValues(4, (int) levels4.catapultsLevel, -1, -1);
                 break;
             }
             case 4:
             {
                 VillageMap.TownHallLevels levels5 = new VillageMap.TownHallLevels();
                 village.getTownHallLevels(levels5);
                 if (info2 != null)
                 {
                     this.setRowValues(0, (int) levels5.venisonLevel, info2.venisonLevel, TradingCalcs.calcSellCost(localWorldData, info2.getFakeLevel(0x16), 0x16));
                     this.setRowValues(1, (int) levels5.furnitureLevel, info2.furnitureLevel, TradingCalcs.calcSellCost(localWorldData, info2.getFakeLevel(0x15), 0x15));
                     this.setRowValues(2, (int) levels5.metalwareLevel, info2.metalwareLevel, TradingCalcs.calcSellCost(localWorldData, info2.getFakeLevel(0x1a), 0x1a));
                     this.setRowValues(3, (int) levels5.clothesLevel, info2.clothesLevel, TradingCalcs.calcSellCost(localWorldData, info2.getFakeLevel(0x13), 0x13));
                     this.setRowValues(4, (int) levels5.wineLevel, info2.wineLevel, TradingCalcs.calcSellCost(localWorldData, info2.getFakeLevel(0x21), 0x21));
                     this.setRowValues(5, (int) levels5.saltLevel, info2.saltLevel, TradingCalcs.calcSellCost(localWorldData, info2.getFakeLevel(0x17), 0x17));
                     this.setRowValues(6, (int) levels5.spicesLevel, info2.spicesLevel, TradingCalcs.calcSellCost(localWorldData, info2.getFakeLevel(0x18), 0x18));
                     this.setRowValues(7, (int) levels5.silkLevel, info2.silkLevel, TradingCalcs.calcSellCost(localWorldData, info2.getFakeLevel(0x19), 0x19));
                     break;
                 }
                 this.setRowValues(0, (int) levels5.venisonLevel, -1, -1);
                 this.setRowValues(1, (int) levels5.furnitureLevel, -1, -1);
                 this.setRowValues(2, (int) levels5.metalwareLevel, -1, -1);
                 this.setRowValues(3, (int) levels5.clothesLevel, -1, -1);
                 this.setRowValues(4, (int) levels5.wineLevel, -1, -1);
                 this.setRowValues(5, (int) levels5.saltLevel, -1, -1);
                 this.setRowValues(6, (int) levels5.spicesLevel, -1, -1);
                 this.setRowValues(7, (int) levels5.silkLevel, -1, -1);
                 break;
             }
         }
         this.numTraders = village.numTraders();
         this.numFreeTraders = village.numFreeTraders();
         if (this.numFreeTraders > this.numTraders)
         {
             village.refreshTraderNumbers();
         }
         this.tradersAvailableValue.Text = this.numFreeTraders.ToString() + "/" + this.numTraders.ToString();
         this.traderCapacityValue.Text = (this.currentResourcePacketSize * this.numFreeTraders).ToString("N", nFI);
     }
     this.showBuySellWindow();
 }
 public void updateGranary(GraphicsMgr gfx, VillageMap vm)
 {
     if (this.baseSprite != null)
     {
         if (this.granaryExtension == null)
         {
             this.granaryExtension = new VillageMapBuildingGranaryExtension();
             for (int j = 0; j < 0x15; j++)
             {
                 this.granaryExtension.cell[j]         = new SpriteWrapper();
                 this.granaryExtension.cell[j].Visible = false;
                 this.granaryExtension.cell[j].PosX    = 5 + VillageMapBuildingGranaryExtension.granaryLayout[j * 2];
                 this.granaryExtension.cell[j].PosY    = -33 + VillageMapBuildingGranaryExtension.granaryLayout[(j * 2) + 1];
                 this.baseSprite.AddChild(this.granaryExtension.cell[j]);
                 this.granaryExtension.showGood(gfx, j, -1, 0);
             }
         }
         for (int i = 0; i < 0x15; i++)
         {
             this.granaryExtension.showGood(gfx, i, -1, 0);
         }
         VillageMap.GranaryLevels levels = new VillageMap.GranaryLevels();
         if (vm.getGranaryLevels(levels))
         {
             if (vm.granaryOpenCount == 0)
             {
                 this.open = false;
             }
             double num3 = ((((levels.applesLevel + levels.breadLevel) + levels.cheeseLevel) + levels.fishLevel) + levels.meatLevel) + levels.vegLevel;
             if (num3 > 0.0)
             {
                 if (vm.granaryOpenCount > 0)
                 {
                     this.open = true;
                 }
                 else
                 {
                     return;
                 }
                 int index = 0;
                 if (levels.meatLevel > 416.0)
                 {
                     index = 4;
                 }
                 else if (levels.meatLevel > 96.0)
                 {
                     index = 3;
                 }
                 else if (levels.meatLevel > 16.0)
                 {
                     index = 2;
                 }
                 else if (levels.meatLevel > 0.0)
                 {
                     index = 1;
                 }
                 else
                 {
                     index = 0;
                 }
                 int num5 = 0;
                 if (levels.vegLevel > 96.0)
                 {
                     num5 = 3;
                 }
                 else if (levels.vegLevel > 16.0)
                 {
                     num5 = 2;
                 }
                 else if (levels.vegLevel > 0.0)
                 {
                     num5 = 1;
                 }
                 else
                 {
                     num5 = 0;
                 }
                 int num6 = 0;
                 if (levels.cheeseLevel > 416.0)
                 {
                     num6 = 4;
                 }
                 else if (levels.cheeseLevel > 96.0)
                 {
                     num6 = 3;
                 }
                 else if (levels.cheeseLevel > 16.0)
                 {
                     num6 = 2;
                 }
                 else if (levels.cheeseLevel > 0.0)
                 {
                     num6 = 1;
                 }
                 else
                 {
                     num6 = 0;
                 }
                 int num7 = 0;
                 if (levels.applesLevel > 96.0)
                 {
                     num7 = 3;
                 }
                 else if (levels.applesLevel > 16.0)
                 {
                     num7 = 2;
                 }
                 else if (levels.applesLevel > 0.0)
                 {
                     num7 = 1;
                 }
                 else
                 {
                     num7 = 0;
                 }
                 int num8 = 0;
                 if (levels.fishLevel > 96.0)
                 {
                     num8 = 3;
                 }
                 else if (levels.fishLevel > 16.0)
                 {
                     num8 = 2;
                 }
                 else if (levels.fishLevel > 0.0)
                 {
                     num8 = 1;
                 }
                 else
                 {
                     num8 = 0;
                 }
                 int num9 = 0;
                 if (levels.breadLevel > 832.0)
                 {
                     num9 = 4;
                 }
                 else if (levels.breadLevel > 192.0)
                 {
                     num9 = 3;
                 }
                 else if (levels.breadLevel > 32.0)
                 {
                     num9 = 2;
                 }
                 else if (levels.breadLevel > 0.0)
                 {
                     num9 = 1;
                 }
                 else
                 {
                     num9 = 0;
                 }
                 int cellID = 0;
                 for (int k = 0; k < index; k++)
                 {
                     cellID = this.meatPileOrder[k];
                     if (k != (index - 1))
                     {
                         this.granaryExtension.showGood(gfx, cellID, 0x10, 0x10);
                     }
                     else
                     {
                         int num12 = (((int)levels.meatLevel) - this.goods16Levels[index]) / this.goodsDividers[index];
                         this.granaryExtension.showGood(gfx, cellID, 0x10, Math.Min(num12, 0x10));
                     }
                 }
                 for (int m = 0; m < num5; m++)
                 {
                     cellID = this.vegPileOrder[m];
                     if (m != (num5 - 1))
                     {
                         this.granaryExtension.showGood(gfx, cellID, 15, 0x10);
                     }
                     else
                     {
                         int num14 = (((int)levels.vegLevel) - this.goods16Levels[num5]) / this.goodsDividers[num5];
                         this.granaryExtension.showGood(gfx, cellID, 15, Math.Min(num14, 0x10));
                     }
                 }
                 for (int n = 0; n < num6; n++)
                 {
                     cellID = this.cheesePileOrder[n];
                     if (n != (num6 - 1))
                     {
                         this.granaryExtension.showGood(gfx, cellID, 0x11, 0x10);
                     }
                     else
                     {
                         int num16 = (((int)levels.cheeseLevel) - this.goods16Levels[num6]) / this.goodsDividers[num6];
                         this.granaryExtension.showGood(gfx, cellID, 0x11, Math.Min(num16, 0x10));
                     }
                 }
                 for (int num17 = 0; num17 < num7; num17++)
                 {
                     cellID = this.applesPileOrder[num17];
                     if (num17 != (num7 - 1))
                     {
                         this.granaryExtension.showGood(gfx, cellID, 13, 0x10);
                     }
                     else
                     {
                         int num18 = (((int)levels.applesLevel) - this.goods16Levels[num7]) / this.goodsDividers[num7];
                         this.granaryExtension.showGood(gfx, cellID, 13, Math.Min(num18, 0x10));
                     }
                 }
                 for (int num19 = 0; num19 < num8; num19++)
                 {
                     cellID = this.fishPileOrder[num19];
                     if (num19 != (num8 - 1))
                     {
                         this.granaryExtension.showGood(gfx, cellID, 0x12, 0x10);
                     }
                     else
                     {
                         int num20 = (((int)levels.fishLevel) - this.goods16Levels[num8]) / this.goodsDividers[num8];
                         this.granaryExtension.showGood(gfx, cellID, 0x12, Math.Min(num20, 0x10));
                     }
                 }
                 for (int num21 = 0; num21 < num9; num21++)
                 {
                     cellID = this.breadPileOrder[num21];
                     if (num21 != (num9 - 1))
                     {
                         this.granaryExtension.showGood(gfx, cellID, 14, 0x20);
                     }
                     else
                     {
                         int num22 = (((int)levels.breadLevel) - (this.goods16Levels[num9] * 2)) / this.goodsDividers[num9];
                         this.granaryExtension.showGood(gfx, cellID, 14, Math.Min(num22, 0x20));
                     }
                 }
             }
         }
     }
 }
 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();
         }
     }
 }