예제 #1
0
 private void launch()
 {
     if (this.sliderEnabled)
     {
         if (this.inLaunch)
         {
             TimeSpan span = (TimeSpan)(DateTime.Now - this.lastLaunchTime);
             if (span.TotalSeconds < 20.0)
             {
                 return;
             }
         }
         this.inLaunch       = true;
         this.lastLaunchTime = DateTime.Now;
         int numScouts = this.sliderImage.Value + 1;
         this.aiworld_Scout_ID_ownVillage      = this.m_ownVillage;
         this.aiworld_Scout_ID_selectedVillage = this.m_selectedVillage;
         this.aiworld_Scout_ID_numScouts       = numScouts;
         RemoteServices.Instance.set_SendScouts_UserCallBack(new RemoteServices.SendScouts_UserCallBack(this.sendScoutsCallback));
         RemoteServices.Instance.SendScouts(this.m_ownVillage, this.m_selectedVillage, numScouts);
         AllVillagesPanel.travellersChanged();
         VillageMap map = GameEngine.Instance.getVillage(this.m_ownVillage);
         if (map != null)
         {
             map.addTroops(0, 0, 0, 0, 0, -numScouts);
         }
         this.launchButton.Enabled = false;
         this.closeButton.Enabled  = false;
         CursorManager.SetCursor(CursorManager.CursorType.WaitCursor, base.ParentForm);
     }
 }
        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);
            }
        }
 public void update()
 {
     this.backGround.update();
     if ((this.m_person != null) && !this.m_person.dying)
     {
         if (this.m_person.person.state != this.lastState)
         {
             this.backGround.updateTravelButton(this.homeVillageButton, this.m_person.person.homeVillageID);
             this.backGround.updateTravelButton(this.targetVillageButton, this.m_person.person.targetVillageID);
             this.lastState = this.m_person.person.state;
             if (this.lastState == 0)
             {
                 InterfaceMgr.Instance.closePersonInfoPanel();
                 return;
             }
             if (((this.lastState == 1) || (this.lastState == 11)) || (((this.lastState == 0x15) || (this.lastState == 0x1f)) || (this.lastState == 0x4b)))
             {
                 this.travelDirection.Image = (Image)GFXLibrary.mrhp_travelling_arrows[0];
             }
             else if (this.lastState == 50)
             {
                 this.travelDirection.Image = (Image)GFXLibrary.mrhp_travelling_arrows[1];
             }
         }
         double num        = DXTimer.GetCurrentMilliseconds() / 1000.0;
         double num2       = this.m_person.localEndTime - num;
         string subHeading = VillageMap.createBuildTimeString((int)num2);
         this.backGround.updateSubHeading(subHeading);
     }
     else
     {
         InterfaceMgr.Instance.closePersonInfoPanel();
     }
 }
예제 #4
0
        public static void Init(VillageMap map, Game game)
        {
            Map           = map;
            CurrentGame   = game;
            _tileGraphics = new Dictionary <Tile, Texture2D>();

            MapStructManager = new MapStructManager <MapStructDef>(Map);


            var defs     = Village.Core.Loader.DefLoader.LoadDefs <MapStructDef>("C:/temp");
            var mapStruc = new BaseMapStructInstance <MapStructDef>(MapStructManager, Map, defs.First(), 2, 1);

            mapStruc.Def.SpriteDetails = new Village.Core.SpriteDetails
            {
                SpriteHeight  = 2,
                SpriteWidth   = 2,
                SpriteOffsetX = 0,
                SpriteOffsetY = -1,
                SpriteName    = "house"
            };
            MapStructManager.TryAddStructure(mapStruc);
            DebugDef = defs.First();
            MapStructManager.TryAddStructure(new BaseMapStructInstance <MapStructDef>(MapStructManager, Map, defs.Last(), 8, 3));


            foreach (var tile in Map.Tiles)
            {
                if (defaultGraphic == null)
                {
                    defaultGraphic = MakeTileGraphic(tile);
                }
                _tileGraphics.Add(tile, defaultGraphic);
            }
        }
예제 #5
0
        public void update()
        {
            this.backGround.update();
            bool     visible = this.lblProtectionType.Visible;
            int      num     = 0;
            TimeSpan span    = new TimeSpan();

            if (GameEngine.Instance.World.isVillageInterdictProtected(this.m_selectedVillage))
            {
                DateTime time  = GameEngine.Instance.World.getInterdictTime(this.m_selectedVillage);
                DateTime time2 = VillageMap.getCurrentServerTime();
                span = (TimeSpan)(time - time2);
                num  = 1;
            }
            if (num == 1)
            {
                int    totalSeconds = (int)span.TotalSeconds;
                string str          = VillageMap.createBuildTimeStringFull(totalSeconds);
                this.lblProtected.TextDiffOnly      = SK.Text("OtherVillagePanel_Cannot_Be_Attacked_For_X_Time", "Cannot be attacked for") + " : " + str;
                this.lblProtectionType.TextDiffOnly = SK.Text("OtherVillagePanel_Interdict", "Interdict");
                this.lblProtectionType.Visible      = true;
            }
            else
            {
                this.lblProtected.TextDiffOnly      = "";
                this.lblProtectionType.TextDiffOnly = "";
                this.lblProtectionType.Visible      = false;
            }
            if (visible != this.lblProtectionType.Visible)
            {
                this.updateSize();
            }
        }
            public bool update(double localTime)
            {
                if (this.btnCancel.Visible)
                {
                    if (this.m_army.localEndTime == 0.0)
                    {
                        return(false);
                    }
                    if ((this.m_army.localStartTime + (GameEngine.Instance.LocalWorldData.AttackCancelDuration * 60)) < localTime)
                    {
                        return(false);
                    }
                }
                else
                {
                    WorldMap.LocalArmyData data = GameEngine.Instance.World.getArmy(this.m_armyID);
                    if ((data == null) || (data.lootType != this.m_origLoot))
                    {
                        return(false);
                    }
                }
                DateTime time     = VillageMap.getCurrentServerTime();
                TimeSpan span     = (TimeSpan)(this.m_arrivalTime - time);
                int      secsLeft = (int)(span.TotalSeconds + 0.5);

                if (secsLeft < 1)
                {
                    secsLeft = 0;
                }
                this.lblArrivalTime.Text = VillageMap.createBuildTimeString(secsLeft);
                return(true);
            }
예제 #7
0
 public static bool isAccountPremium(WorldMap map)
 {
     if (premium)
     {
         return(true);
     }
     return(CardTypes.isPremiumToken(map.UserCardData.premiumCard) && (VillageMap.getCurrentServerTime() < map.UserCardData.premiumCardExpiry));
 }
 public void update()
 {
     this.backGround.update();
     if (this.m_trader != null)
     {
         if (this.m_trader.trader.traderState != this.lastState)
         {
             this.lastState = this.m_trader.trader.traderState;
             this.backGround.updateTravelButton(this.homeVillageButton, this.m_trader.trader.homeVillageID);
             this.backGround.updateTravelButton(this.targetVillageButton, this.m_trader.trader.targetVillageID);
             this.resourceImage.Visible       = false;
             this.resourceAmountLabel.Visible = false;
             if (this.lastState == 0)
             {
                 InterfaceMgr.Instance.closeTraderInfoPanel();
                 return;
             }
             if (((this.lastState == 1) || (this.lastState == 3)) || (this.lastState == 6))
             {
                 this.backGround.updatePanelText(SK.Text("SelectArmyPanel_Trading", "Trading"));
                 if (GameEngine.Instance.World.isUserVillage(this.m_trader.trader.homeVillageID))
                 {
                     this.resourceImage.Image   = (Image)GFXLibrary.getCommodity32DSImage(this.m_trader.trader.resource);
                     this.resourceImage.Visible = true;
                     NumberFormatInfo nFI = GameEngine.NFI;
                     this.resourceAmountLabel.TextDiffOnly = GameEngine.Instance.World.getTradingAmount(this.m_trader.traderID).ToString("N", nFI);
                     this.resourceAmountLabel.Visible      = true;
                 }
                 if (this.lastState == 6)
                 {
                     this.travelDirection.Image = (Image)GFXLibrary.mrhp_travelling_arrows[1];
                 }
                 else
                 {
                     this.travelDirection.Image = (Image)GFXLibrary.mrhp_travelling_arrows[0];
                 }
             }
             else if ((this.lastState == 2) || (this.lastState == 4))
             {
                 this.backGround.updatePanelText(SK.Text("SelectArmyPanel_Returning", "Returning"));
                 this.travelDirection.Image = (Image)GFXLibrary.mrhp_travelling_arrows[1];
             }
             else if (this.lastState == 5)
             {
                 this.backGround.updatePanelText(SK.Text("SelectArmyPanel_Collecting", "Collecting"));
                 this.travelDirection.Image = (Image)GFXLibrary.mrhp_travelling_arrows[0];
             }
         }
         double num2 = DXTimer.GetCurrentMilliseconds() / 1000.0;
         double num3 = this.m_trader.localEndTime - num2;
         if (num3 < 0.0)
         {
             num3 = 0.0;
         }
         string subHeading = VillageMap.createBuildTimeString((int)num3);
         this.backGround.updateSubHeading(subHeading);
     }
 }
예제 #9
0
        public static void dumpBuildingMap(int villageID)
        {
            Console.WriteLine("Building dump");
            VillageMap map = GameEngine.Instance.getVillage(villageID);

            foreach (var building in map.Buildings)
            {
                Console.WriteLine(((Point)building.buildingLocation).X.ToString() + " - " +
                                  ((Point)building.buildingLocation).Y.ToString() + " | " + building.buildingType);
            }
        }
 private bool isTallTreasureChestPanel(int villageID)
 {
     if ((GameEngine.Instance.World.isSpecial(villageID) && GameEngine.Instance.World.isAttackableSpecial(villageID)) && SpecialVillageTypes.IS_TREASURE_CASTLE(GameEngine.Instance.World.getSpecial(villageID)))
     {
         TimeSpan span = (TimeSpan)(VillageMap.getCurrentServerTime() - GameEngine.Instance.World.getLastTreasureCastleAttackTime());
         int      num2 = WorldMap.TreasureCastle_AttackGap;
         if (span.TotalSeconds < num2)
         {
             return(true);
         }
     }
     return(false);
 }
예제 #11
0
 public void init(string ipAddr, DateTime lastTime, TimeSpan duration)
 {
     this.lblIP.Text        = ipAddr;
     this.lblLoginTime.Text = lastTime.ToShortTimeString() + "  -  " + lastTime.ToLongDateString();
     if (duration != TimeSpan.MinValue)
     {
         this.lblDuration.Text = VillageMap.createBuildTimeString((int)duration.TotalSeconds);
     }
     else
     {
         this.lblDuration.Text = "";
     }
 }
예제 #12
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();
                }
            }
        }
        private void sendClick()
        {
            int num = (((this.peasantsTrack.Value + this.archerTrack.Value) + this.pikemanTrack.Value) + this.swordsmanTrack.Value) + this.catapultTrack.Value;

            if (num > 0)
            {
                VillageMap village = GameEngine.Instance.Village;
                if (village != null)
                {
                    RemoteServices.Instance.set_SendTroopsToCapital_UserCallBack(new RemoteServices.SendTroopsToCapital_UserCallBack(this.sendTroopsToCapitalCallback));
                    RemoteServices.Instance.SendTroopsToCapital(village.VillageID, this.m_selectedVillage, this.peasantsTrack.Value, this.archerTrack.Value, this.pikemanTrack.Value, this.swordsmanTrack.Value, this.catapultTrack.Value);
                }
            }
        }
 public void initStorageBuilding(GraphicsMgr gfx, VillageMap vm)
 {
     if (this.buildingType == 2)
     {
         this.updateStockpile(gfx, vm);
     }
     if (this.buildingType == 3)
     {
         this.updateGranary(gfx, vm);
     }
     if (this.buildingType == 0x23)
     {
         this.updateInn(gfx, vm);
     }
 }
 public void sendTroopsToCapitalCallback(SendTroopsToCapital_ReturnType returnData)
 {
     if (returnData.Success)
     {
         ArmyReturnData[] armyReturnData = new ArmyReturnData[] { returnData.armyData };
         GameEngine.Instance.World.doGetArmyData(armyReturnData, null, false);
         InterfaceMgr.Instance.getMainTabBar().changeTab(9);
         InterfaceMgr.Instance.getMainTabBar().changeTab(0);
         VillageMap map = GameEngine.Instance.getVillage(returnData.villageID);
         if (map != null)
         {
             map.addTroops(-returnData.numPeasants, -returnData.numArchers, -returnData.numPikemen, -returnData.numSwordsmen, -returnData.numCatapults);
         }
     }
 }
예제 #16
0
        public void update()
        {
            this.cardbar.update();
            this.onVillageLoadUpdate(this.m_ownVillage, false);
            this.numLabel.Text = this.numLabel.Text;
            double num = this.storedPreCardDistance * CardTypes.getScoutSpeed(GameEngine.Instance.World.UserCardData);

            if (((int)num) != this.timeLabel.CustomTooltipData)
            {
                string str = VillageMap.createBuildTimeString((int)num);
                this.timeLabel.Text              = str;
                this.timeLabel.CustomTooltipID   = 0x4e20;
                this.timeLabel.CustomTooltipData = (int)num;
            }
        }
 public void update()
 {
     if (this.proclamationLabel.Visible)
     {
         TimeSpan span = (TimeSpan)(VillageMap.getCurrentServerTime() - this.lastProclamationTime);
         if (span.TotalDays >= 7.0)
         {
             this.proclamationLabel.Visible  = false;
             this.proclamationButton.Enabled = true;
         }
         else
         {
             this.proclamationLabel.Text = SK.Text("Proclamations_time_to_go", "Time before next Proclamation : ") + VillageMap.createBuildTimeString(0x93a80 - ((int)span.TotalSeconds));
         }
     }
 }
        public void updateValues()
        {
            VillageMap village = GameEngine.Instance.Village;

            if (village != null)
            {
                this.peasantStoredValue.Text   = village.m_numPeasants.ToString();
                this.archerStoredValue.Text    = village.m_numArchers.ToString();
                this.pikemanStoredValue.Text   = village.m_numPikemen.ToString();
                this.swordsmanStoredValue.Text = village.m_numSwordsmen.ToString();
                this.catapultStoredValue.Text  = village.m_numCatapults.ToString();
                this.peasantsTrack.Max         = village.m_numPeasants;
                this.archerTrack.Max           = village.m_numArchers;
                this.pikemanTrack.Max          = village.m_numPikemen;
                this.swordsmanTrack.Max        = village.m_numSwordsmen;
                this.catapultTrack.Max         = village.m_numCatapults;
                this.updateSlider();
            }
        }
 private void updateTreasureCastleTimeout()
 {
     if (GameEngine.Instance.World.isSpecial(this.m_selectedVillage) && GameEngine.Instance.World.isAttackableSpecial(this.m_selectedVillage))
     {
         TimeSpan span = (TimeSpan)(VillageMap.getCurrentServerTime() - GameEngine.Instance.World.getLastTreasureCastleAttackTime());
         int      num  = WorldMap.TreasureCastle_AttackGap;
         if (span.TotalSeconds < num)
         {
             this.treasureCastleTimeoutLabel.TextDiffOnly = SK.Text("EmptyVillage_NextAttackAvailable", "Next Attack Available in") + " " + VillageMap.createBuildTimeString(num - ((int)span.TotalSeconds));
         }
         else
         {
             this.treasureCastleTimeoutLabel.TextDiffOnly = "";
             if (this.treasureCastleTimeoutLabel.Visible && !GameEngine.Instance.World.isCapital(InterfaceMgr.Instance.OwnSelectedVillage))
             {
                 this.attackButton.Enabled = true;
             }
         }
     }
 }
예제 #20
0
 public void sendTroopsToVassalCallback(SendTroopsToVassal_ReturnType returnData)
 {
     if (returnData.Success)
     {
         if (returnData.vassalArmyReturnData != null)
         {
             this.getVassalArmyInfoCallback(returnData.vassalArmyReturnData);
         }
         if (returnData.armyData != null)
         {
             ArmyReturnData[] armyReturnData = new ArmyReturnData[] { returnData.armyData };
             GameEngine.Instance.World.doGetArmyData(armyReturnData, null, false);
             VillageMap map = GameEngine.Instance.getVillage(returnData.villageID);
             if (map != null)
             {
                 map.addTroops(-returnData.numPeasants, -returnData.numArchers, -returnData.numPikemen, -returnData.numSwordsmen, -returnData.numCatapults);
             }
             this.updateValues();
         }
     }
 }
        private void disbandClick()
        {
            int amount = this.tbTroopsDisband.Value;

            if (amount > 0)
            {
                VillageMap village = GameEngine.Instance.Village;
                if (village != null)
                {
                    GameEngine.Instance.playInterfaceSound("DisbandTroopsPopup_disband");
                    if (this.m_isTroops)
                    {
                        village.disbandTroops(this.m_troopType, amount);
                    }
                    else
                    {
                        village.disbandPeople(this.m_troopType, amount);
                    }
                    this.m_parent.Close();
                }
            }
        }
예제 #22
0
        public void updateResearchTime(ResearchData data)
        {
            int width = -1;

            if ((data != null) && (data.researchingType >= 0))
            {
                DateTime time         = VillageMap.getCurrentServerTime();
                TimeSpan span         = (TimeSpan)(data.research_completionTime - time);
                int      totalSeconds = (int)span.TotalSeconds;
                TimeSpan span2        = data.calcResearchTime(data.research_pointCount - 1, GameEngine.Instance.World.UserCardData, GameEngine.Instance.LocalWorldData);
                if (GameEngine.Instance.LocalWorldData.Alternate_Ruleset == 1)
                {
                    span2 = new TimeSpan(span2.Ticks / 2L);
                }
                int num3 = (int)span2.TotalSeconds;
                if ((num3 == 30) && (GameEngine.Instance.World.getTutorialStage() == 5))
                {
                    num3 = 11;
                }
                this.images[6] = GFXLibrary.tab_3b_normal;
                this.images[7] = GFXLibrary.tab_3b_selected;
                this.tabControl1.addOverlayImages(3, GFXLibrary.tab_3c_normal, GFXLibrary.tab_3c_selected, 0xff);
                width = 3 + ((0x2c * (num3 - totalSeconds)) / num3);
                this.tabControl1.setOverlayWidth(3, width);
                this.refresh = true;
            }
            else
            {
                this.images[6] = GFXLibrary.tab_3_normal;
                this.images[7] = GFXLibrary.tab_3_selected;
                this.tabControl1.addOverlayImages(3, null, null, 0xff);
            }
            this.tabControl1.updateImageArray(this.images);
            if (width != this.lastWidth)
            {
                this.refresh = true;
            }
            this.lastWidth = width;
        }
예제 #23
0
        private void sendClick()
        {
            int num = (((this.peasantsTrack.Value + this.archerTrack.Value) + this.pikemanTrack.Value) + this.swordsmanTrack.Value) + this.catapultTrack.Value;

            if (num > 0)
            {
                VillageMap map = GameEngine.Instance.getVillage(this.m_playerVillageID);
                if (map != null)
                {
                    RemoteServices.Instance.set_SendTroopsToVassal_UserCallBack(new RemoteServices.SendTroopsToVassal_UserCallBack(this.sendTroopsToVassalCallback));
                    RemoteServices.Instance.SendTroopsToVassal(map.VillageID, this.m_vassalVillageID, this.peasantsTrack.Value, this.archerTrack.Value, this.pikemanTrack.Value, this.swordsmanTrack.Value, this.catapultTrack.Value);
                    this.allowSliderUpdate    = false;
                    this.peasantsTrack.Value  = 0;
                    this.archerTrack.Value    = 0;
                    this.pikemanTrack.Value   = 0;
                    this.swordsmanTrack.Value = 0;
                    this.catapultTrack.Value  = 0;
                    this.updateSliderValues(0);
                    this.allowSliderUpdate = true;
                    this.btnSend.Enabled   = false;
                }
            }
        }
예제 #24
0
 public void getVillageBuildingListCallBack(GetVillageBuildingsList_ReturnType returnData)
 {
     if (returnData.Success)
     {
         if (returnData.existingArmies != null)
         {
             this.World.updateExistingArmies(returnData.existingArmies);
         }
         if (InterfaceMgr.Instance.getSelectedMenuVillage() == returnData.villageID)
         {
             int villageID = returnData.villageID;
             if (this.villages[villageID] == null)
             {
                 VillageMap map = new VillageMap(returnData.mapID, returnData.mapVariant, returnData.mapType, villageID, this.gfx);
                 this.villages[villageID] = map;
             }
             bool flag = false;
             VillageMap map2 = (VillageMap) this.villages[villageID];
             if ((villageID == InterfaceMgr.Instance.getSelectedMenuVillage()) || returnData.viewOnly)
             {
                 this.village = map2;
                 flag = true;
             }
             map2.resetMapType(returnData.mapID, returnData.mapVariant, returnData.mapType);
             if (flag)
             {
                 map2.loadBackgroundImage();
                 map2.reInitGFX(this.gfx);
             }
             map2.ViewOnly = returnData.viewOnly;
             map2.ViewHonour = returnData.viewHonour;
             map2.lastDownloadedTime = DateTime.Now;
             if (returnData.parishTaxInfo != null)
             {
                 map2.importParishTaxPeople(returnData.parishTaxInfo, returnData.currentTime);
             }
             VillageMap.setServerTime(returnData.currentTime);
             if (returnData.fullUpdate)
             {
                 map2.initClickMask();
             }
             map2.importResourcesAndStats(returnData.villageResourcesAndStats, returnData.currentTime);
             map2.importVillageBuildings(returnData.villageBuildings, returnData.fullUpdate);
             if (!returnData.viewOnly)
             {
                 map2.importTraders(returnData.traders, returnData.currentTime);
             }
             DXPanel.skipPaint = true;
             if (this.lastVillageTabID == 0)
             {
                 map2.playEnvironmentalSounds();
             }
             InterfaceMgr.Instance.villageDownloaded(returnData.villageID);
             if (!returnData.viewOnly)
             {
                 this.getCastleCallBack(returnData);
             }
             if (returnData.viewOnly)
             {
                 InterfaceMgr.Instance.getMainTabBar().selectDummyTab(50);
             }
         }
         if (!returnData.viewOnly)
         {
             this.World.importOrphanedPeople(returnData.people, returnData.currentTime, returnData.villageID);
         }
     }
     else if ((returnData.m_errorCode == ErrorCodes.ErrorCode.VILLAGE_BUILDINGS_NO_LONGER_OWNER) && !returnData.viewOnly)
     {
         this.displayedVillageLost(returnData.villageID, true);
     }
 }
 public VillageInputHandler(VillageMap villagemap)
 {
     this.village = villagemap;
 }
예제 #26
0
 public void displayedVillageLost(int villageID, bool popup)
 {
     InterfaceMgr.Instance.closeVillageTab();
     InterfaceMgr.Instance.closeCastleTab();
     this.world.updateWorldMapOwnership();
     if (popup)
     {
         MyMessageBox.Show(SK.Text("GameEngine_Lost_Control_Of_Village", "You have lost control of this village!"), SK.Text("GENERIC_Error", "Error"));
     }
     if (this.villages[villageID] != null)
     {
         this.villages[villageID] = null;
         this.village = null;
     }
     InterfaceMgr.Instance.getMainTabBar().changeTab(9);
     InterfaceMgr.Instance.getMainTabBar().changeTab(0);
 }
        public void init(MyFormBase parent, int troopType, bool isTroops, object back)
        {
            base.clearControls();
            this.imgBackground.Image = (Image)back;
            this.m_isTroops          = isTroops;
            this.m_parent            = parent;
            base.Size                   = this.m_parent.Size;
            this.BackColor              = ARGBColors.Transparent;
            this.imgBackground.Size     = base.Size;
            this.imgBackground.Position = new Point(0, 0);
            this.imgBackground.Visible  = true;
            base.addControl(this.imgBackground);
            VillageMap village = GameEngine.Instance.Village;

            this.m_troopType = troopType;
            int numPeasants = 0;

            this.lblTroopType.Text            = "";
            this.lblTroopType.Color           = ARGBColors.White;
            this.lblTroopType.DropShadowColor = ARGBColors.Black;
            this.lblTroopType.Position        = new Point(0, 10);
            this.lblTroopType.Size            = new Size(base.Width, 0x18);
            this.lblTroopType.Alignment       = CustomSelfDrawPanel.CSD_Text_Alignment.TOP_CENTER;
            this.lblTroopType.Font            = FontManager.GetFont("Arial", 10f, FontStyle.Regular);
            this.lblMax.Text = "";
            if (village != null)
            {
                switch (troopType)
                {
                case 1:
                    this.lblTroopType.Text = SK.Text("GENERIC_Monks", "Monks");
                    numPeasants            = village.calcTotalMonksAtHome();
                    break;

                case 2:
                    this.lblTroopType.Text = SK.Text("GENERIC_Merchants", "Merchants");
                    numPeasants            = village.calcTotalTradersAtHome();
                    break;

                case 3:
                    this.lblTroopType.Text = SK.Text("GENERIC_Spiese", "Spies");
                    numPeasants            = 0;
                    break;

                case 4:
                    this.lblTroopType.Text = SK.Text("GENERIC_Scouts", "Scouts");
                    numPeasants            = village.calcTotalScoutsAtHome();
                    break;

                case 70:
                    this.lblTroopType.Text = SK.Text("GENERIC_Peasants", "Peasants");
                    numPeasants            = village.m_numPeasants;
                    break;

                case 0x47:
                    this.lblTroopType.Text = SK.Text("GENERIC_Swordsmen", "Swordsmen");
                    numPeasants            = village.m_numSwordsmen;
                    break;

                case 0x48:
                    this.lblTroopType.Text = SK.Text("GENERIC_Archers", "Archers");
                    numPeasants            = village.m_numArchers;
                    break;

                case 0x49:
                    this.lblTroopType.Text = SK.Text("GENERIC_Pikemen", "Pikemen");
                    numPeasants            = village.m_numPikemen;
                    break;

                case 0x4a:
                    this.lblTroopType.Text = SK.Text("GENERIC_Catapults", "Catapults");
                    numPeasants            = village.m_numCatapults;
                    break;

                case 100:
                    this.lblTroopType.Text = SK.Text("GENERIC_Captains", "Captains");
                    numPeasants            = village.m_numCaptains;
                    break;
                }
                this.lblMax.Text = numPeasants.ToString();
            }
            this.tbTroopsDisband.Position  = new Point((base.Width / 2) - (GFXLibrary.int_slidebar_ruler.Width / 2), 40);
            this.tbTroopsDisband.Size      = new Size(base.Width - 50, 0x17);
            this.tbTroopsDisband.StepValue = 1;
            this.tbTroopsDisband.Value     = 0;
            this.tbTroopsDisband.Max       = numPeasants;
            this.tbTroopsDisband.setValueChangeDelegate(new CustomSelfDrawPanel.CSDControl.CSD_ValueChangedDelegate(this.trackMoved));
            this.tbTroopsDisband.Create((Image)GFXLibrary.int_slidebar_ruler, (Image)GFXLibrary.reinforce_slider, (Image)GFXLibrary.reinforce_slider, (Image)GFXLibrary.reinforce_slider, (Image)GFXLibrary.reinforce_slider, (Image)GFXLibrary.reinforce_slider);
            this.lblMin.Text                 = "0";
            this.lblMin.Color                = ARGBColors.White;
            this.lblMin.DropShadowColor      = ARGBColors.Black;
            this.lblMin.Position             = new Point(0, this.tbTroopsDisband.Position.Y);
            this.lblMin.Size                 = new Size(this.tbTroopsDisband.Position.X - 10, this.tbTroopsDisband.Height);
            this.lblMin.Alignment            = CustomSelfDrawPanel.CSD_Text_Alignment.TOP_RIGHT;
            this.lblMin.Font                 = FontManager.GetFont("Arial", 10f, FontStyle.Regular);
            this.lblMax.Color                = ARGBColors.White;
            this.lblMax.DropShadowColor      = ARGBColors.Black;
            this.lblMax.Position             = new Point(this.tbTroopsDisband.Rectangle.Right + 5, this.tbTroopsDisband.Position.Y);
            this.lblMax.Size                 = new Size((base.Width - this.tbTroopsDisband.Rectangle.Right) - 10, this.tbTroopsDisband.Height);
            this.lblMax.Alignment            = CustomSelfDrawPanel.CSD_Text_Alignment.TOP_LEFT;
            this.lblMax.Font                 = FontManager.GetFont("Arial", 10f, FontStyle.Regular);
            this.lblCurValue.Text            = SK.Text("GENERIC_Disband", "Disband");
            this.lblCurValue.Text            = this.lblCurValue.Text + ": 0";
            this.lblCurValue.Color           = ARGBColors.White;
            this.lblCurValue.DropShadowColor = ARGBColors.Black;
            this.lblCurValue.Position        = new Point(this.tbTroopsDisband.Position.X, this.tbTroopsDisband.Rectangle.Bottom + 10);
            this.lblCurValue.Size            = new Size(base.Width, 0x1a);
            this.lblCurValue.Alignment       = CustomSelfDrawPanel.CSD_Text_Alignment.TOP_LEFT;
            this.lblCurValue.Font            = FontManager.GetFont("Arial", 12f, FontStyle.Regular);
            this.btnDisband.Text.Text        = SK.Text("GENERIC_Disband", "Disband");
            this.btnDisband.ImageNorm        = (Image)GFXLibrary.button_132_normal;
            this.btnDisband.ImageOver        = (Image)GFXLibrary.button_132_over;
            this.btnDisband.ImageClick       = (Image)GFXLibrary.button_132_in;
            this.btnDisband.setSizeToImage();
            this.btnDisband.Position    = new Point((base.Width / 2) - (this.btnDisband.Width / 2), this.lblCurValue.Rectangle.Bottom + 10);
            this.btnDisband.Text.Font   = FontManager.GetFont("Arial", 9f, FontStyle.Regular);
            this.btnDisband.TextYOffset = -2;
            this.btnDisband.Text.Color  = ARGBColors.Black;
            this.btnDisband.setClickDelegate(new CustomSelfDrawPanel.CSDControl.CSD_ClickDelegate(this.disbandClick), "Disband_Disband");
            this.btnDisband.Enabled = true;
            this.btnEdit.ImageNorm  = (Image)GFXLibrary.faction_pen;
            this.btnEdit.ImageOver  = (Image)GFXLibrary.faction_pen;
            this.btnEdit.ImageClick = (Image)GFXLibrary.faction_pen;
            this.btnEdit.setSizeToImage();
            this.btnEdit.MoveOnClick  = true;
            this.btnEdit.OverBrighten = true;
            this.btnEdit.Position     = new Point(this.tbTroopsDisband.Rectangle.Right - this.btnEdit.Width, this.lblCurValue.Position.Y);
            this.btnEdit.Data         = 1;
            this.btnEdit.setClickDelegate(new CustomSelfDrawPanel.CSDControl.CSD_ClickDelegate(this.editValue), "Disband_EditValue");
            if (this.imgBackground.Image != null)
            {
                this.imgBackground.addControl(this.btnEdit);
                this.imgBackground.addControl(this.btnDisband);
                this.imgBackground.addControl(this.lblCurValue);
                this.imgBackground.addControl(this.lblMax);
                this.imgBackground.addControl(this.lblMin);
                this.imgBackground.addControl(this.tbTroopsDisband);
                this.imgBackground.addControl(this.lblTroopType);
            }
            else
            {
                base.addControl(this.btnEdit);
                base.addControl(this.btnDisband);
                base.addControl(this.lblCurValue);
                base.addControl(this.lblMax);
                base.addControl(this.lblMin);
                base.addControl(this.tbTroopsDisband);
                base.addControl(this.lblTroopType);
            }
        }
예제 #28
0
        public void Trade()
        {
#if DEBUG
            Log("Trade!");
#endif
            int sleep = 0;
            while (true)
            {
                try
                {
                    sleep = 8 + new Random().Next(-5, 5);

                    if (trading) // Если торгуем
                    {
                        Log("Step with \"" + listBox_ResList.SelectedItem.ToString() + "\"");
                        // Получаем ID товара из списка
                        int resID = GetID(listBox_ResList.SelectedItem.ToString());

                        int targetID = -1;
                        //List<int> villageIDs = GameEngine.Instance.World.getListOfUserVillages(); // Получаем список наших деревень

                        for (int i = 0; i < listBox_ActiveVillages.Items.Count; i++)
                        //foreach (int villageID in villageIDs) // Перебираем их
                        {
                            if (!listBox_ActiveVillages.GetSelected(i))
                            {
                                continue;
                            }
                            int villageID = GetID(listBox_ActiveVillages.Items[i].ToString());

                            // Если деревня прогружена (открывалась ее карта в текущей сессии хоть раз)
                            if (GameEngine.Instance.getVillage(villageID) != null)
                            {
                                // Получаем базовую информацию о нашей деревни
                                WorldMap.VillageData village = GameEngine.Instance.World.getVillageData(villageID);
                                VillageMap           map     = GameEngine.Instance.getVillage(villageID); // Получаем полную информацию
                                int merchantsCount           = map.calcTotalTradersAtHome();              // Кол-во торговцев в ней
                                if (merchantsCount == 0)
                                {
                                    continue;
                                }

                                int resAmount = (int)map.getResourceLevel(resID);                                                 // Кол-во ресурса на складе
                                Log("At village " + villageID + " (" + village.villageName + ") " + merchantsCount + " traders"); // Дебаг

                                int sendWithOne = int.Parse(textBox_ResCount.Text);                                               // Кол-во ресурса на торговца
                                int maxAmount   = merchantsCount * sendWithOne;                                                   // Кол-во ресурсов отправим
                                if (resAmount < maxAmount)                                                                        // Если торговцы могут увезти больше чем есть
                                {
                                    merchantsCount = (int)(resAmount / sendWithOne);                                              // Считаем сколько смогут увезти реально
                                }
                                if (merchantsCount > 0)                                                                           // Если трейдеры дома есть
                                {
                                    if (radioButton1.Checked)                                                                     // Parish
                                    {
                                        targetID = GameEngine.Instance.World.getRegionCapitalVillage(village.regionID);
                                    }
                                    else if (radioButton2.Checked) // Target
                                    {
                                        targetID = int.Parse(textBox_TradeTargetID.Text);
                                    }
                                    else if (radioButton3.Checked) // Resell
                                    {
                                        InterfaceMgr.Instance.selectStockExchange(-1);
                                        GameEngine.Instance.SkipVillageTab();
                                        InterfaceMgr.Instance.getMainTabBar().changeTab(1);
                                        InterfaceMgr.Instance.setVillageTabSubMode(3);
                                        InterfaceMgr.Instance.resetVillageReportPanelData();
                                        InterfaceMgr.Instance.selectStockExchange(int.Parse(listBox_ParishList.Items[0].ToString()));
                                    }


                                    // if target - player
                                    // GameEngine.Instance.getVillage(id).sendResources()
                                    // Вызываем высокоуровневую функцию торговли с рядом каллбеков
                                    GameEngine.Instance.getVillage(villageID).stockExchangeTrade(targetID, resID, merchantsCount * sendWithOne, false);
                                    AllVillagesPanel.travellersChanged(); // Подтверждаем изменения (ушли трейдеры) в GUI-клиента
                                }
                            }
                        }

                        Log("Again in " + sleep + " seconds - " + DateTime.Now.AddSeconds(sleep).ToString("HH:mm:ss"));
                        Console.WriteLine();
                    }
                }
                catch (Exception ex)
                {
                    WriteLog(ex);
                }

                Thread.Sleep(sleep * 1000); // Спим, чтобы не спамить. Так меньше палева.
            }
        }
 public bool updateConstructionGFX(double localBaseTime, DateTime serverBaseTime, bool initialUpdate, VillageMap vm)
 {
     if (this.baseSprite != null)
     {
         if (this.serverDeleting)
         {
             double num = (DXTimer.GetCurrentMilliseconds() - localBaseTime) / 1000.0;
             num -= 1.5;
             DateTime time = serverBaseTime.AddSeconds(num);
             if (!this.complete && (time.CompareTo(this.completionTime) >= 0))
             {
                 this.complete = true;
             }
             TimeSpan span = (TimeSpan) (this.deletionTime - time);
             int secsLeft = (int) (span.TotalSeconds - 0.5);
             if (span.TotalDays > 10.0)
             {
                 secsLeft = 0x98967f;
             }
             if ((secsLeft > 0) && (secsLeft < 0x989680))
             {
                 if (!vm.ViewOnly)
                 {
                     string text = VillageMap.createBuildTimeString(secsLeft);
                     this.baseSprite.attachText(text, new Point(0, -50), ARGBColors.White, true, true);
                 }
             }
             else
             {
                 this.baseSprite.clearText();
                 this.baseSprite.clearSecondText();
                 if (secsLeft <= 0)
                 {
                     return true;
                 }
             }
             this.baseSprite.ColorToUse = Color.FromArgb(0xff, 0xff, 0x80, 0x80);
             if (this.animSprite != null)
             {
                 this.animSprite.ColorToUse = this.baseSprite.ColorToUse;
             }
             if (this.extraAnimSprite1 != null)
             {
                 this.extraAnimSprite1.ColorToUse = this.baseSprite.ColorToUse;
             }
             if (this.extraAnimSprite2 != null)
             {
                 this.extraAnimSprite2.ColorToUse = this.baseSprite.ColorToUse;
             }
             return false;
         }
         if (this.complete)
         {
             return false;
         }
         bool flag = false;
         double num3 = (DXTimer.GetCurrentMilliseconds() - localBaseTime) / 1000.0;
         if (initialUpdate)
         {
             num3 = 0.0;
         }
         num3 -= 3.0;
         DateTime time2 = serverBaseTime.AddSeconds(num3);
         if (time2.CompareTo(this.completionTime) < 0)
         {
             flag = true;
         }
         if (this.buildingType == 0)
         {
             flag = false;
         }
         if (flag)
         {
             if (!this.highlighted)
             {
                 this.baseSprite.ColorToUse = Color.FromArgb(0x80, 0x80, 0x80, 0x80);
                 if (this.animSprite != null)
                 {
                     this.animSprite.ColorToUse = Color.FromArgb(0x80, 0x80, 0x80, 0x80);
                 }
                 if (this.extraAnimSprite1 != null)
                 {
                     this.extraAnimSprite1.ColorToUse = Color.FromArgb(0x80, 0x80, 0x80, 0x80);
                 }
                 if (this.extraAnimSprite2 != null)
                 {
                     this.extraAnimSprite2.ColorToUse = Color.FromArgb(0x80, 0x80, 0x80, 0x80);
                 }
             }
             TimeSpan span2 = (TimeSpan) (this.completionTime - time2);
             int num4 = (int) (span2.TotalSeconds - 0.5);
             if ((num4 > 0) && (num4 < 0x989680))
             {
                 int num6;
                 int num5 = num4;
                 num4 = vm.updateConstructionDisplayTime(num4, this.completionTime, out num6);
                 Color col = (num6 == 1) ? ARGBColors.White : ARGBColors.WhiteSmoke;
                 if (!vm.ViewOnly)
                 {
                     string str2 = VillageMap.createBuildTimeString(num4);
                     if ((num4 != num5) && this.showFullConstructionText)
                     {
                         this.showFullConstructionText = false;
                         string str3 = str2;
                         str2 = str3 + Environment.NewLine + "(" + VillageMap.createBuildTimeString(num5) + ")";
                     }
                     this.baseSprite.attachText(str2, new Point(0, -40), ARGBColors.White, true, true);
                     if (num6 > 0)
                     {
                         this.baseSprite.attachSecondText(num6.ToString(), new Point(0, -55), col, true, true);
                     }
                     else
                     {
                         this.baseSprite.clearSecondText();
                     }
                 }
             }
             else
             {
                 this.baseSprite.clearText();
                 this.baseSprite.clearSecondText();
             }
         }
         else
         {
             Color white = ARGBColors.White;
             this.baseSprite.ColorToUse = white;
             if (this.animSprite != null)
             {
                 this.animSprite.ColorToUse = white;
             }
             if (this.extraAnimSprite1 != null)
             {
                 this.extraAnimSprite1.ColorToUse = white;
             }
             if (this.extraAnimSprite2 != null)
             {
                 this.extraAnimSprite2.ColorToUse = white;
             }
             this.complete = true;
             if (!initialUpdate)
             {
                 this.localComplete = false;
                 return true;
             }
             this.baseSprite.clearText();
             this.baseSprite.clearSecondText();
         }
     }
     return false;
 }
예제 #30
0
        public void Trade()
        {
            Log("Торговый поток создан!");

            int Sleep = 0;

            while (true)
            {
                try
                {
                    Sleep = 60 + new Random().Next(-5, 60);

                    if (IsTrading) // Если торгуем
                    {
                        Log("Заход с \"" + listBox_ResList.SelectedItem.ToString() + "\"");
                        // Получаем ID товара из списка
                        int        ResID      = GetItemID(listBox_ResList.SelectedItem.ToString());
                        int        TargetID   = int.Parse(textBox_TradeTargetID.Text);             // Получаем ID деревни-цели
                        List <int> VillageIDs = GameEngine.Instance.World.getListOfUserVillages(); // Получаем список наших деревень

                        foreach (int VillageID in VillageIDs)                                      // Перебираем их
                        {
                            // Если деревня прогружена (открывалась ее карта в текущей сессии хоть раз)
                            if (GameEngine.Instance.getVillage(VillageID) != null)
                            {
                                // Получаем базовую информацию о нашей деревни
                                WorldMap.VillageData Village = GameEngine.Instance.World.getVillageData(VillageID);
                                VillageMap           Map     = GameEngine.Instance.getVillage(VillageID); // Получаем полную информацию
                                int ResAmount      = (int)Map.getResourceLevel(ResID);                    // Кол-во ресурса на складе
                                int MerchantsCount = Map.calcTotalTradersAtHome();                        // Кол-во торговцев в ней
                                Log("В деревне " + VillageID + " есть " + MerchantsCount + " торговцев"); // Дебаг

                                int SendWithOne = int.Parse(textBox_ResCount.Text);                       // Кол-во ресурса на торговца
                                int MaxAmount   = MerchantsCount * SendWithOne;                           // Кол-во ресурсов отправим
                                if (ResAmount < MaxAmount)                                                // Если торговцы могут увезти больше чем есть
                                {
                                    MerchantsCount = (int)(ResAmount / SendWithOne);                      // Считаем сколько смогут увезти реально
                                }
                                if (MerchantsCount > 0)                                                   // Если трейдеры дома есть
                                {
                                    TargetID = (checkBox_Parish.Checked ?
                                                GameEngine.Instance.World.getRegionCapitalVillage(Village.regionID) :
                                                int.Parse(textBox_TradeTargetID.Text));
                                    //textBox_TradeTargetID.Text = TargetID.ToString();

                                    // Вызываем высокоуровневую функцию торговли с рядом каллбеков
                                    GameEngine.Instance.getVillage(VillageID).stockExchangeTrade(TargetID, ResID, MerchantsCount * SendWithOne, false);
                                    AllVillagesPanel.travellersChanged(); // Подтверждаем изменения (ушли трейдеры) в GUI-клиента
                                }
                            }
                        }

                        Log("Повтор цикла торговли через " + Sleep + " секунд(ы) в " + DateTime.Now.AddSeconds(Sleep).ToString("HH:mm:ss"));
                        Console.WriteLine();
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine("\n======| EX INFO |======");
                    Console.WriteLine(ex);
                    Console.WriteLine("======| ======= |======\n");
                }

                Thread.Sleep(Sleep * 1000); // Спим, чтобы не спамить. Так меньше палева.
            }
        }
 public VillageInputHandler(VillageMap villagemap)
 {
     this.village = villagemap;
 }
        public void update()
        {
            this.backGround.update();
            int[]      numArray  = new int[3];
            TimeSpan[] spanArray = new TimeSpan[3];
            int        numInfos  = this.numInfos;

            this.numInfos = 0;
            int tooltipData = GameEngine.Instance.World.getParishPlagueLevel(this.m_selectedVillage);

            if (tooltipData != this.lastPlague)
            {
                if (tooltipData <= 0)
                {
                    this.backGround.updatePanelType(0x5dc);
                    this.lblPlagueValue.TextDiffOnly = "";
                }
                else if (this.lastPlague <= 0)
                {
                    this.backGround.updatePanelType(0x5e0);
                    this.lblPlagueValue.TextDiffOnly = tooltipData.ToString();
                }
                this.backGround.setTooltipData(tooltipData);
                this.lastPlague = tooltipData;
            }
            bool     visible = this.lblProtectionType.Visible;
            int      num3    = 0;
            TimeSpan span    = new TimeSpan();

            if (GameEngine.Instance.World.isVillageInterdictProtected(this.m_selectedVillage))
            {
                DateTime time  = GameEngine.Instance.World.getInterdictTime(this.m_selectedVillage);
                DateTime time2 = VillageMap.getCurrentServerTime();
                span = (TimeSpan)(time - time2);
                num3 = 1;
                spanArray[this.numInfos] = span;
                numArray[this.numInfos]  = num3;
                this.numInfos++;
            }
            if (GameEngine.Instance.World.isVillagePeaceTimeProtected(this.m_selectedVillage))
            {
                DateTime time3 = GameEngine.Instance.World.getPeaceTime(this.m_selectedVillage);
                DateTime time4 = VillageMap.getCurrentServerTime();
                TimeSpan span2 = (TimeSpan)(time3 - time4);
                if (span2 > span)
                {
                    span = span2;
                    num3 = 2;
                    spanArray[this.numInfos] = span;
                    numArray[this.numInfos]  = num3;
                    this.numInfos++;
                }
            }
            if (this.numInfos > 0)
            {
                if (this.selectedProtection < this.numInfos)
                {
                    num3 = numArray[(this.numInfos - 1) - this.selectedProtection];
                    span = spanArray[(this.numInfos - 1) - this.selectedProtection];
                }
                else
                {
                    this.selectedProtection = 0;
                }
            }
            switch (num3)
            {
            case 1:
            {
                int    totalSeconds = (int)span.TotalSeconds;
                string str          = VillageMap.createBuildTimeStringFull(totalSeconds);
                this.lblProtected.TextDiffOnly      = SK.Text("OtherVillagePanel_Cannot_Be_Attacked_For_X_Time", "Cannot be attacked for") + " : " + str;
                this.lblProtectionType.TextDiffOnly = SK.Text("OtherVillagePanel_Interdict", "Interdict");
                this.lblProtectionType.Visible      = true;
                break;
            }

            case 2:
            {
                int    secsLeft = (int)span.TotalSeconds;
                string str2     = VillageMap.createBuildTimeStringFull(secsLeft);
                this.lblProtected.TextDiffOnly      = SK.Text("OtherVillagePanel_Cannot_Be_Attacked_For_X_Time", "Cannot be attacked for") + " : " + str2;
                this.lblProtectionType.TextDiffOnly = SK.Text("OtherVillagePanel_Peace", "Peace");
                this.lblProtectionType.Visible      = true;
                break;
            }

            default:
                this.lblProtected.TextDiffOnly      = "";
                this.lblProtectionType.TextDiffOnly = "";
                this.lblProtectionType.Visible      = false;
                break;
            }
            if (visible != this.lblProtectionType.Visible)
            {
                this.updateSize();
                if (!visible)
                {
                    this.selectedProtection = 0;
                }
            }
            if (numInfos != this.numInfos)
            {
                if (this.numInfos >= 2)
                {
                    this.leftButton.Visible  = true;
                    this.rightButton.Visible = true;
                }
                else
                {
                    this.leftButton.Visible  = false;
                    this.rightButton.Visible = false;
                }
            }
        }
        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 updateInn(GraphicsMgr gfx, VillageMap vm)
 {
     if (this.baseSprite != null)
     {
         if (this.innExtension == null)
         {
             this.innExtension = new VillageMapBuildingInnExtension();
             for (int j = 0; j < 3; j++)
             {
                 this.innExtension.cell[j] = new SpriteWrapper();
                 this.innExtension.cell[j].Visible = false;
                 this.innExtension.cell[j].PosX = -80 + VillageMapBuildingInnExtension.innLayout[j * 2];
                 this.innExtension.cell[j].PosY = -44 + VillageMapBuildingInnExtension.innLayout[(j * 2) + 1];
                 this.baseSprite.AddChild(this.innExtension.cell[j]);
                 this.innExtension.showGood(gfx, j, -1, 0);
             }
         }
         for (int i = 0; i < 3; i++)
         {
             this.innExtension.showGood(gfx, i, -1, 0);
         }
         VillageMap.InnLevels levels = new VillageMap.InnLevels();
         if (vm.getInnLevels(levels))
         {
             if (levels.aleLevel == 0.0)
             {
                 if (vm.m_effectiveAleRationsLevel > 0.0)
                 {
                     this.open = true;
                 }
                 else
                 {
                     this.open = false;
                 }
             }
             else
             {
                 this.open = true;
                 int index = 0;
                 if (levels.aleLevel > 416.0)
                 {
                     index = 4;
                 }
                 else if (levels.aleLevel > 96.0)
                 {
                     index = 3;
                 }
                 else if (levels.aleLevel > 16.0)
                 {
                     index = 2;
                 }
                 else if (levels.aleLevel > 0.0)
                 {
                     index = 1;
                 }
                 else
                 {
                     index = 0;
                 }
                 if (index > 3)
                 {
                     index = 3;
                 }
                 for (int k = 0; k < index; k++)
                 {
                     if (k != (index - 1))
                     {
                         this.innExtension.showGood(gfx, k, 12, 0x10);
                     }
                     else
                     {
                         int num6 = (((int) levels.aleLevel) - this.goods16Levels[index]) / this.goodsDividers[index];
                         this.innExtension.showGood(gfx, k, 12, Math.Min(num6, 0x10));
                     }
                 }
             }
         }
     }
 }
 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));
                     }
                 }
             }
         }
     }
 }
예제 #36
0
 public void downloadCurrentVillage()
 {
     int villageID = InterfaceMgr.Instance.getSelectedMenuVillage();
     InterfaceMgr.Instance.villageChanged(villageID);
     InterfaceMgr.Instance.castleChanged();
     this.castle = null;
     this.village = null;
     this.lastLoadedVillage = villageID;
     bool needParishPeople = false;
     if ((this.villages[villageID] != null) && (this.castles[villageID] != null))
     {
         this.village = (VillageMap) this.villages[villageID];
         this.castle = (CastleMap) this.castles[villageID];
         this.village.moveMap(0, 0);
         this.castle.moveMap(0, 0);
         this.village.ViewOnly = false;
         if (this.World.isCapital(villageID) && this.village.needParishPeople())
         {
             needParishPeople = true;
         }
         TimeSpan span = (TimeSpan) (DateTime.Now - this.village.lastDownloadedTime);
         if (span.TotalMinutes < 5.0)
         {
             VillageMap.loadVillageBuildingsGFX2();
             this.village.loadBackgroundImage();
             this.village.reAddBuildingsToMap();
             this.village.updateConstructionOnCachedLoad();
             this.castle.reInitGFX();
             CastleMap.CreateMode = false;
             InterfaceMgr.Instance.villageDownloaded(villageID);
             this.castle.castleShown(true);
             return;
         }
     }
     else if (this.World.isCapital(villageID))
     {
         needParishPeople = true;
     }
     RemoteServices.Instance.GetVillageBuildingsList(villageID, true, needParishPeople);
     VillageMap.loadVillageBuildingsGFX2();
     if (this.village != null)
     {
         this.village.loadBackgroundImage();
     }
     if (this.castle != null)
     {
         this.castle.reInitGFX();
     }
     CastleMap.CreateMode = false;
 }
예제 #37
0
        private void Scout(int playerVillageID)
        {
            //int honourRange = CardTypes.adjustScoutingHonourRange(GameEngine.Instance.World.UserCardData, GameEngine.Instance.LocalWorldData.BaseScoutHonourRange);
            while (true)
            {
                if (!scout)
                {
                    Thread.Sleep(500);
                    continue;
                }

                try
                {
                    bool ok    = false;
                    int  index = 0;
                    foreach (string str in listBox_scoutFrom.Items) // Разведывать ли из этой деревни
                    {
                        int id = GetID(str);
                        if (id == playerVillageID)
                        {
                            if (listBox_scoutFrom.GetSelected(index))
                            {
                                ok = true;
                                break;
                            }
                        }
                        index++;
                    }
                    if (!ok)
                    {
                        Thread.Sleep(1000); // Нечего лаги пилить если вообще ничего не делаем
                        continue;
                    }

                    if (GameEngine.Instance.getVillage(playerVillageID) == null) // Если деревня игрока не прогружена - пропускаем
                    {
                        Thread.Sleep(3000);                                      // Чтобы не лагать, деревня то вовсе не загружена
                        continue;
                    }

                    // TODO: возможно при отправке не всех сразу инфу надо будет обновлять
                    // чтобы оно не думало что скауты еще есть в наличии
                    VillageMap map = GameEngine.Instance.getVillage(playerVillageID);
                    if (map.calcTotalScoutsAtHome() == 0)
                    {
                        Thread.Sleep(500); // Чтобы не лагать, лучше переждать лишнего
                        continue;
                    }

                    double minRange    = double.MaxValue;
                    bool   isUnscouted = false;
                    int    target      = -1;

                    bool isContinue = false;
                    for (int i = 0; i < GameEngine.Instance.World.villageList.Length; i++) // Перебираем тайники
                    {
                        int id = GameEngine.Instance.World.villageList[i].id;
                        if (!GameEngine.Instance.World.isSpecial(id)) // Если это не тайник - пропускаем
                        {
                            continue;
                        }

                        int type = GameEngine.Instance.World.getSpecial(id); // 100 - unscouted
                        //if ((type >= 100) && (type <= 0xc7))
                        if (!DataExport.IsStash(type))                       // Если не тайник с ресурсами - пропускаем
                        {
                            continue;
                        }

                        if (checkBox_Honourable.Checked && type == 100) // Если только не разведанные
                        {
                            if (!GameEngine.Instance.World.isScoutHonourOutOfRange(playerVillageID, id))
                            {
                                continue;
                            }
                        }

                        index = 0;
                        foreach (string str in listBox_resForScouting.Items) // Выбран ли тип ресурса для разведки
                        {
                            int typeID = GetID(str);
                            if (typeID == type)
                            {
                                if (!listBox_resForScouting.GetSelected(index))
                                {
                                    isContinue = true;
                                }
                                break;
                            }
                            index++;
                        }
                        if (isContinue) // Если этот тайник не выбран - пропускаем
                        {
                            isContinue = false;
                            continue;
                        }

                        // Считаем расстояние до тайника
                        Point  playerVillage = GameEngine.Instance.World.getVillageLocation(playerVillageID);
                        Point  targetStash   = GameEngine.Instance.World.getVillageLocation(id);
                        int    x             = playerVillage.X;
                        int    num7          = playerVillage.Y;
                        int    num8          = targetStash.X;
                        int    num9          = targetStash.Y;
                        double d             = ((x - num8) * (x - num8)) + ((num7 - num9) * (num7 - num9)); // Квадрат расстояния
                        d = Math.Sqrt(d);
                        if (d > int.Parse(textBox_maxRadius.Text))                                          // Дальше чем положено нас не касается
                        {
                            continue;
                        }

                        if (type == 100) // не открытые тайники в приоритете
                        {
                            isUnscouted = true;
                        }
                        else if (isUnscouted) // Если это разведанный тайник, но уже был найден не разведанный
                        {
                            continue;
                        }
                        if (d < minRange) // && ((type == 100 && isUnscouted) || !isUnscouted))
                        {
                            minRange = d;
                            target   = id;
                        }

                        //RemoteServices.Instance.set_SendScouts_UserCallBack(new RemoteServices.SendScouts_UserCallBack(this.sendScoutsCallback));
                        //d = Math.Sqrt(d) * ((GameEngine.Instance.LocalWorldData.ScoutsMoveSpeed * GameEngine.Instance.LocalWorldData.gamePlaySpeed) * ResearchData.ScoutTimes[GameEngine.Instance.World.UserResearchData.Research_Horsemanship]);
                        //d *= CardTypes.getScoutSpeed(GameEngine.Instance.World.UserCardData);
                        //string str = VillageMap.createBuildTimeString((int)d); // Time

                        //Console.WriteLine("WUT: " + id);
                        //Console.WriteLine("     | " + GameEngine.Instance.World.getVillageNameOrType(id));
                        //InterfaceMgr.Instance.SelectedVillage = id;
                        //GameEngine.Instance.World.setZooming(1, GameEngine.Instance.World.getVillageData(id).x, GameEngine.Instance.World.getVillageData(id).y);
                        //count++;
                    }

                    if (target == -1)
                    {
                        Thread.Sleep(1500); // Точек найдено не было
                        continue;
                    }

                    int numScouts = int.Parse(textBox_scoutsPerStash.Text);
                    if (numScouts == 0 || numScouts > map.calcTotalScoutsAtHome())
                    {
                        numScouts = map.calcTotalScoutsAtHome();
                    }

                    if (numScouts == 0) // вроде как непостижимый код
                    {
                        Thread.Sleep(500);
                        continue; // TODO: wait till != 0
                    }

                    RemoteServices.Instance.SendScouts(playerVillageID, target, numScouts);
                    AllVillagesPanel.travellersChanged();

                    Thread.Sleep(1500);
                }
                catch (Exception ex)
                {
                    Log(ex.ToString());
                }

                Thread.Sleep(1000);
            }

            //GameEngine.Instance.World.isScoutHonourOutOfRange(InterfaceMgr.Instance.OwnSelectedVillage, id);
            //InterfaceMgr.Instance.selectUserVillage(id)
            //InterfaceMgr.Instance.selectVillage(id)
            //int villageID = InterfaceMgr.Instance.getSelectedMenuVillage();
            //GameEngine.Instance.World.getNextUserVillage();
            //GameEngine.Instance.downloadCurrentVillage();
        }
예제 #38
0
        private void menu1Callback(int id)
        {
            string str;

            GameEngine.Instance.playInterfaceSound("WorldMapScreen_menu_item_selected");
            this.fixCommandSent = false;
            switch (id)
            {
            case 0x5207:
                castleCopyMode = true;
                return;

            case 0x5208:
            case 0x19c9:
            case 0x44f:
            case 0x450:
            case 0x451:
            case 0x452:
            case 0x453:
            case 0x454:
            case 0x259:
            case 0x25a:
            case 0xde:
            case 3:
            case 4:
            case 6:
            case 7:
            case 8:
            case 10:
            case 0x68:
            case 0x6a:
            case 110:
            case 0x6f:
            case 0x71:
            case 0x72:
            case 0x73:
            case 0x74:
            case 0x75:
            case 0x76:
            case 0x77:
            case 120:
                return;

            case 0x5209:
            {
                string fileName = (URLs.AccountInfoURL + "?u=" + RemoteServices.Instance.UserGuid.ToString().Replace("-", "") + "&s=" + RemoteServices.Instance.SessionGuid.ToString().Replace("-", "")) + "&lang=" + Program.mySettings.LanguageIdent.ToLower();
                try
                {
                    Process.Start(fileName);
                }
                catch (Exception)
                {
                    MyMessageBox.Show(SK.Text("ERROR_Browser1", "Stronghold Kingdoms encountered an error when trying to open your system's Default Web Browser. Please check that your web browser is working correctly and there are no unresponsive copies showing in task manager->Processes and then try again.") + Environment.NewLine + Environment.NewLine + SK.Text("ERROR_Browser2", "If this problem persists, please contact support."), SK.Text("ERROR_Browser3", "Error opening Web Browser"));
                }
                return;
            }

            case 0x520a:
            {
                string str4 = (URLs.InviteAFriendURL + "?u=" + RemoteServices.Instance.UserGuid.ToString().Replace("-", "") + "&s=" + RemoteServices.Instance.SessionGuid.ToString().Replace("-", "")) + "&lang=" + Program.mySettings.LanguageIdent.ToLower();
                try
                {
                    Process.Start(str4);
                }
                catch (Exception)
                {
                    MyMessageBox.Show(SK.Text("ERROR_Browser1", "Stronghold Kingdoms encountered an error when trying to open your system's Default Web Browser. Please check that your web browser is working correctly and there are no unresponsive copies showing in task manager->Processes and then try again.") + Environment.NewLine + Environment.NewLine + SK.Text("ERROR_Browser2", "If this problem persists, please contact support."), SK.Text("ERROR_Browser3", "Error opening Web Browser"));
                }
                return;
            }

            case 0x520b:
            {
                string str5 = (URLs.AccountInfoURL + "?section=codes&u=" + RemoteServices.Instance.UserGuid.ToString().Replace("-", "") + "&s=" + RemoteServices.Instance.SessionGuid.ToString().Replace("-", "")) + "&lang=" + Program.mySettings.LanguageIdent.ToLower();
                try
                {
                    Process.Start(str5);
                }
                catch (Exception)
                {
                    MyMessageBox.Show(SK.Text("ERROR_Browser1", "Stronghold Kingdoms encountered an error when trying to open your system's Default Web Browser. Please check that your web browser is working correctly and there are no unresponsive copies showing in task manager->Processes and then try again.") + Environment.NewLine + Environment.NewLine + SK.Text("ERROR_Browser2", "If this problem persists, please contact support."), SK.Text("ERROR_Browser3", "Error opening Web Browser"));
                }
                return;
            }

            case 0x5211:
                CreateVacationWindow.showVacationMode();
                return;

            case 0x2a2f:
                try
                {
                    string str2 = "http://login.strongholdkingdoms.com/support/?u=" + RemoteServices.Instance.UserGuid.ToString().Replace("-", "") + "&s=" + RemoteServices.Instance.SessionGuid.ToString().Replace("-", "") + "&lang=" + Program.mySettings.languageIdent;
                    new Process {
                        StartInfo = { FileName = str2 }
                    }.Start();
                }
                catch (Exception)
                {
                }
                return;

            case 0x23f2:
                this.nextPlaybackCountries = false;
                if (!GameEngine.Instance.World.gotPlaybackData())
                {
                    this.retrieveGameStats();
                    return;
                }
                GameEngine.Instance.World.playbackProvinces();
                return;

            case 0x23f3:
                GameEngine.Instance.World.stopPlayback();
                return;

            case 0x4b1:
                PostTutorialWindow.CreatePostTutorialWindow(false);
                return;

            case 0x8ab:
            {
                if (!GameEngine.Instance.World.MapEditing)
                {
                    GameEngine.Instance.World.MapEditing = true;
                    return;
                }
                int villageID = GameEngine.Instance.World.lastClickedVillage();
                if (GameEngine.Instance.World.isCountyCapital(villageID) && !GameEngine.Instance.World.isVillageVisible(villageID))
                {
                    RemoteServices.Instance.CompleteVillageCastle(villageID, 0x15);
                }
                GameEngine.Instance.World.MapEditing = false;
                return;
            }

            case 0x44d:
                InterfaceMgr.Instance.getMainTabBar().selectDummyTab(2);
                GameEngine.Instance.InitCastleAttackSetup();
                return;

            case 0x44e:
                GameEngine.Instance.SkipVillageTab();
                InterfaceMgr.Instance.getMainTabBar().changeTab(1);
                InterfaceMgr.Instance.getVillageTabBar().changeTab(1);
                CastleMap.CreateMode = true;
                return;

            case 0x455:
                GameEngine.Instance.playInterfaceSound("Options_resume_tutorial");
                GameEngine.Instance.World.resumeTutorial();
                return;

            case 0x456:
            case 0x457:
            case 0x458:
            case 0x459:
            case 0x45a:
            case 0x45b:
            case 0x45c:
            case 0x45d:
            case 0x45e:
            case 0x45f:
                CastleMap.FakeKeep = (id - 0x456) + 1;
                return;

            case 0x460:
            case 0x461:
            case 0x462:
            case 0x463:
                CastleMap.FakeDefensiveMode = id - 0x460;
                return;

            case 0x3e9:
                InterfaceMgr.Instance.ParentForm.Close();
                return;

            case 0xe7:
                GameEngine.Instance.World.DrawDebugNames        = !GameEngine.Instance.World.DrawDebugNames;
                GameEngine.Instance.World.DrawDebugVillageNames = false;
                return;

            case 0xe8:
                GameEngine.Instance.World.DrawDebugVillageNames = !GameEngine.Instance.World.DrawDebugVillageNames;
                GameEngine.Instance.World.DrawDebugNames        = false;
                return;

            case 300:
                InterfaceMgr.Instance.getMainTabBar().selectDummyTab(60);
                return;

            case 0xdd:
                this.createIngameMessage();
                return;

            case 0xdf:
                this.clearIngameMessage();
                return;

            case 0xd1:
            {
                MessageBoxButtons yesNo = MessageBoxButtons.YesNo;
                if (MyMessageBox.Show("This call is not entirely 'game friendly'. Only use sparingly and at quiet game times and make sure no one else is using them same function!", "Admin Warning!", yesNo, MessageBoxIcon.None, MessageBoxDefaultButton.Button2, 0) == DialogResult.Yes)
                {
                    this.fixCommandSent = true;
                    RemoteServices.Instance.set_CompleteVillageCastle_UserCallBack(new RemoteServices.CompleteVillageCastle_UserCallBack(this.CompleteVillageCastleCallBack));
                    RemoteServices.Instance.CompleteVillageCastle(InterfaceMgr.Instance.getSelectedMenuVillage(), 15);
                }
                return;
            }

            case 0x97:
                try
                {
                    new Process {
                        StartInfo = { FileName = URLs.TermsAndConditions }
                    }.Start();
                }
                catch (Exception)
                {
                }
                return;

            case 0x98:
                try
                {
                    new Process {
                        StartInfo = { FileName = URLs.PrivacyPolicy }
                    }.Start();
                }
                catch (Exception)
                {
                }
                return;

            case 0xc9:
                AdminInfoPopup.showAdminEdit();
                return;

            case 0xca:
                this.nextPlaybackCountries = true;
                if (!GameEngine.Instance.World.gotPlaybackData())
                {
                    this.retrieveGameStats();
                    return;
                }
                GameEngine.Instance.World.playbackCountries();
                return;

            case 0xcb:
                this.retrieveGameInfo();
                return;

            case 1:
                GameEngine.Instance.playInterfaceSound("Options_open");
                OptionsPopup.openSettings();
                return;

            case 2:
                InterfaceMgr.Instance.openLogoutWindow(true);
                return;

            case 5:
                InterfaceMgr.Instance.getMainTabBar().selectDummyTab(10);
                return;

            case 9:
            {
                if (!RemoteServices.Instance.Admin || !GameEngine.Instance.World.DrawDebugVillageNames)
                {
                    int ownSelectedVillage = InterfaceMgr.Instance.OwnSelectedVillage;
                    if (((ownSelectedVillage >= 0) && !GameEngine.Instance.World.isCapital(ownSelectedVillage)) && GameEngine.Instance.World.isUserVillage(ownSelectedVillage))
                    {
                        RenameVillagePopup popup2 = new RenameVillagePopup();
                        popup2.setVillageID(ownSelectedVillage, GameEngine.Instance.World.getVillageNameOnly(ownSelectedVillage));
                        popup2.Show(InterfaceMgr.Instance.ParentForm);
                        return;
                    }
                    MyMessageBox.Show(SK.Text("MENU_Cannot_Rename", "You cannot rename this village."), SK.Text("MENU_Rename_Error", "Rename Error"));
                    return;
                }
                int selectedVillage      = InterfaceMgr.Instance.SelectedVillage;
                RenameVillagePopup popup = new RenameVillagePopup();
                popup.setVillageID(selectedVillage, GameEngine.Instance.World.getVillageNameOnly(selectedVillage));
                popup.Show(InterfaceMgr.Instance.ParentForm);
                return;
            }

            case 11:
            {
                int num3 = InterfaceMgr.Instance.OwnSelectedVillage;
                if (((num3 < 0) || GameEngine.Instance.World.isCapital(num3)) || !GameEngine.Instance.World.isUserVillage(num3))
                {
                    MyMessageBox.Show(SK.Text("MENU_Cannot_Abandon", "You cannot abandon this village."), SK.Text("GENERIC_Error", "Error"));
                    return;
                }
                GameEngine.Instance.villageToAbandon = num3;
                return;
            }

            case 12:
            {
                int num4 = InterfaceMgr.Instance.OwnSelectedVillage;
                if (((num4 < 0) || GameEngine.Instance.World.isCapital(num4)) || !GameEngine.Instance.World.isUserVillage(num4))
                {
                    return;
                }
                InterfaceMgr.Instance.changeTab(1);
                VillageMap map = GameEngine.Instance.getVillage(num4);
                if ((map == null) || (map.m_nextMapTypeChange <= VillageMap.getCurrentServerTime()))
                {
                    InterfaceMgr.Instance.openBuyVillageWindow(num4, false);
                    return;
                }
                TimeSpan span = (TimeSpan)(map.m_nextMapTypeChange - VillageMap.getCurrentServerTime());
                str = "";
                if (span.Days <= 0)
                {
                    str = string.Format("{0:D1} " + SK.Text("MENU_hours_short", "hrs") + ", {1:D2} " + SK.Text("MENU_minutes_short", "mins"), span.Hours, span.Minutes);
                    break;
                }
                str = string.Format("{0:D2} " + SK.Text("MENU_days", "days") + ", {1:D2} " + SK.Text("MENU_hours_short", "hrs") + ", {2:D2} " + SK.Text("MENU_minutes_short", "mins"), span.Days, span.Hours, span.Minutes);
                break;
            }

            case 0x65:
                new Process {
                    StartInfo = { FileName = "readme.txt" }
                }.Start();
                return;

            case 0x66:
            {
                AboutPopup popup3 = new AboutPopup();
                popup3.init();
                popup3.Show();
                return;
            }

            case 0x67:
                AdminInfoPopup.showMessage();
                return;

            case 0x69:
                try
                {
                    new Process {
                        StartInfo = { FileName = URLs.FireflyHomepage }
                    }.Start();
                }
                catch (Exception)
                {
                }
                return;

            case 0x6b:
                try
                {
                    new Process {
                        StartInfo = { FileName = "http://login.strongholdkingdoms.com/forum/?u=" + RemoteServices.Instance.UserGuid.ToString().Replace("-", "") + "&s=" + RemoteServices.Instance.SessionGuid.ToString().Replace("-", "") + "&lang=" + Program.mySettings.languageIdent }
                    }.Start();
                }
                catch (Exception)
                {
                }
                return;

            case 0x6c:
                try
                {
                    new Process {
                        StartInfo = { FileName = URLs.WikiPage }
                    }.Start();
                }
                catch (Exception)
                {
                }
                return;

            case 0x6d:
                try
                {
                    new Process {
                        StartInfo = { FileName = URLs.IPSharingPage }
                    }.Start();
                }
                catch (Exception)
                {
                }
                return;

            case 0x70:
                try
                {
                    new Process {
                        StartInfo = { FileName = URLs.TechnicalFAQPage }
                    }.Start();
                }
                catch (Exception)
                {
                }
                return;

            case 0x79:
                try
                {
                    new Process {
                        StartInfo = { FileName = URLs.WikiPage }
                    }.Start();
                }
                catch (Exception)
                {
                }
                return;

            default:
                return;
            }
            MyMessageBox.Show(SK.Text("MENU_Cannot_Change_Type", "You cannot change this Village's Type for") + " : " + str, SK.Text("MENU_Change_Type_Error", "Change Village Type Error"));
        }
 public void initStorageBuilding(GraphicsMgr gfx, VillageMap vm)
 {
     if (this.buildingType == 2)
     {
         this.updateStockpile(gfx, vm);
     }
     if (this.buildingType == 3)
     {
         this.updateGranary(gfx, vm);
     }
     if (this.buildingType == 0x23)
     {
         this.updateInn(gfx, vm);
     }
 }