Beispiel #1
0
        public MagicIceTest()
        {
            map                    = new CastleMap();
            map.TileSet            = new TileSet();
            map.TileSet.TileGroups = new List <TileGroup>();

            mapExtender        = new CastleExtender();
            mapExtender.TheMap = map;

            GameState.MapExtender = mapExtender;

            GameState.Map.TileSet.TileGroups.Add(
                new TileGroup
            {
                Tiles = new List <int> {
                    1, 2, 3
                },
                GroupType = GroupType.Water
            });
            GameState.Map.TileSet.TileGroups.Add(
                new TileGroup()
            {
                Tiles = new List <int> {
                    4, 5, 6
                },
                GroupType = GroupType.Special1
            });
        }
 public void getCastleCallBack(GetVillageBuildingsList_ReturnType returnData)
 {
     if (returnData.Success)
     {
         int villageID = returnData.villageID;
         if (this.castles[villageID] == null)
         {
             CastleMap map = new CastleMap(villageID, this.gfx, 0);
             this.castles[villageID] = map;
         }
         CastleMap map2 = (CastleMap) this.castles[villageID];
         if (villageID == InterfaceMgr.Instance.getSelectedMenuVillage())
         {
             this.castle = map2;
         }
         CastleMap.setServerTime(returnData.currentTime);
         map2.importElements(returnData.elements);
         map2.castleShown(true);
     }
 }
 public CastleInputHandler(CastleMap castlemap, GameEngine.GameDisplaySubModes castleSubMode)
 {
     this.castle = castlemap;
     this.gameDisplayModeSubMode = castleSubMode;
 }
 public void manageInput()
 {
     this.inputState.getInput();
     InterfaceMgr.Instance.runTooltips();
     if (this.WindowActive)
     {
         if (f11Pressed)
         {
             f11Pressed = false;
             if ((InterfaceMgr.Instance.ParentForm != null) && InterfaceMgr.Instance.ParentForm.Visible)
             {
                 if (InterfaceMgr.Instance.ParentForm.FormBorderStyle == FormBorderStyle.Sizable)
                 {
                     InterfaceMgr.Instance.ParentForm.FormBorderStyle = FormBorderStyle.None;
                 }
                 else if (InterfaceMgr.Instance.ParentForm.WindowState == FormWindowState.Maximized)
                 {
                     InterfaceMgr.Instance.ParentForm.Visible = false;
                     InterfaceMgr.Instance.ParentForm.WindowState = FormWindowState.Normal;
                     Program.DoEvents();
                     Thread.Sleep(100);
                     InterfaceMgr.Instance.ParentForm.FormBorderStyle = FormBorderStyle.Sizable;
                     Program.DoEvents();
                     InterfaceMgr.Instance.ParentForm.WindowState = FormWindowState.Maximized;
                     InterfaceMgr.Instance.ParentForm.Visible = true;
                     Program.DoEvents();
                     InterfaceMgr.Instance.ParentForm.Invalidate();
                 }
                 else
                 {
                     InterfaceMgr.Instance.ParentForm.FormBorderStyle = FormBorderStyle.Sizable;
                 }
             }
         }
         else
         {
             if (InterfaceMgr.Instance.getDXBasePanel().Visible)
             {
                 if (this.GameDisplayMode == GameDisplays.DISPLAY_VILLAGE)
                 {
                     new VillageInputHandler(this.village).handleInput(this.inputState);
                 }
                 else if (this.GameDisplayMode == GameDisplays.DISPLAY_WORLD)
                 {
                     new WorldMapInputHandler(this.world).handleInput(this.inputState);
                 }
                 else if (this.GameDisplayMode == GameDisplays.DISPLAY_CASTLE)
                 {
                     CastleMap castle = this.castle;
                     if (this.gameDisplayModeSubMode == GameDisplaySubModes.SUBMODE_CASTLE_ATTACKER_SETUP)
                     {
                         castle = this.castle_AttackerSetup;
                     }
                     else if (this.gameDisplayModeSubMode == GameDisplaySubModes.SUBMODE_BATTLE)
                     {
                         castle = this.castle_Battle;
                     }
                     new CastleInputHandler(castle, this.gameDisplayModeSubMode).handleInput(this.inputState);
                 }
             }
             this.gfx.clearInput();
         }
     }
 }
 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;
 }
 public void InitCastleView(byte[] compressedCastleMap, byte[] compressedDefenderMap, int keepType, int campMode, int defencesResearch, int villageID, int landType)
 {
     InterfaceMgr.Instance.clearControls();
     this.castle_Battle = new CastleMap(-1, this.gfx, 3);
     this.castle_Battle.castleShown(false);
     this.castle_Battle.reInitGFX();
     this.castle_Battle.setCampMode(campMode);
     this.castle_Battle.clearTempAttackers();
     CastleResearchData defenderResearchData = new CastleResearchData {
         defences = defencesResearch
     };
     this.castle_Battle.launchBattle(compressedCastleMap, null, compressedDefenderMap, null, keepType, defenderResearchData, new CastleResearchData(), campMode, -1, -1, -1, landType, true, false);
     this.castle_Battle.returnToReports();
     this.castle_Battle.setRealBattleMode(false);
     this.GameDisplayMode = GameDisplays.DISPLAY_CASTLE;
     this.gameDisplayModeSubMode = GameDisplaySubModes.SUBMODE_BATTLE;
     this.gfx.BGColor = ARGBColors.Black;
     InterfaceMgr.Instance.initCastleBattleTab(false, villageID, false);
 }
        public void InitCastleAttackSetup(byte[] castleMap, byte[] defenderMap, int keepLevel, int numPeasants, int numArchers, int numPikemen, int numSwordsmen, int numCatapults, int attackingVillage, int targetVillage, int attackType, int pillagePercent, int captainsCommand, int parentOfAttackingVillage, int numPeasantsInCastle, int numArchersInCastle, int numPikemenInCastle, int numSwordsmenInCastle, int targetUserID, string targetUserName, BattleHonourData honourData, int numCaptainsInCastle, int numCaptains, int landType, double capitalAttackRate)
        {
            try
            {
                InterfaceMgr.Instance.clearControls();
                if (this.castle_AttackerSetup == null)
                {
                    this.castle_AttackerSetup = new CastleMap(-1, this.gfx, 1);
                }
                this.castle_AttackerSetup.castleShown(false);
                this.castle_AttackerSetup.reInitGFX();
                int mode = 0;
                switch (this.World.getSpecial(targetVillage))
                {
                    case 3:
                        mode = 1;
                        break;

                    case 5:
                        mode = 2;
                        break;
                }
                this.castle_AttackerSetup.setCampMode(mode);
                this.castle_AttackerSetup.importDefenderSnapshot(castleMap, defenderMap, keepLevel, true, landType);
                this.castle_AttackerSetup.initRealSetup(attackingVillage, targetVillage, numPeasants, numArchers, numPikemen, numSwordsmen, numCatapults, attackType, pillagePercent, captainsCommand, parentOfAttackingVillage, numPeasantsInCastle, numArchersInCastle, numPikemenInCastle, numSwordsmenInCastle, targetUserID, targetUserName, honourData, numCaptainsInCastle, numCaptains, capitalAttackRate);
                this.GameDisplayMode = GameDisplays.DISPLAY_CASTLE;
                this.gameDisplayModeSubMode = GameDisplaySubModes.SUBMODE_CASTLE_ATTACKER_SETUP;
                this.gfx.BGColor = ARGBColors.Black;
                InterfaceMgr.Instance.initCastleAttackerSetupTab();
            }
            catch (Exception exception)
            {
                UniversalDebugLog.Log(string.Concat(new object[] {
                    exception.ToString(), " values = ", castleMap, defenderMap, keepLevel, numPeasants, numArchers, numPikemen, numSwordsmen, numCatapults, attackingVillage, targetVillage, attackType, pillagePercent, captainsCommand, parentOfAttackingVillage,
                    numPeasantsInCastle, numArchersInCastle
                 }));
            }
        }
 public void InitCastleAttackSetup()
 {
     InterfaceMgr.Instance.clearControls();
     if (this.castle_AttackerSetup == null)
     {
         this.castle_AttackerSetup = new CastleMap(-1, this.gfx, 1);
     }
     this.castle_AttackerSetup.castleShown(false);
     this.castle_AttackerSetup.reInitGFX();
     if (this.castle == null)
     {
         this.castle_AttackerSetup.importDefenderSnapshot(null, null, 0, false, 0);
     }
     else
     {
         this.castle_AttackerSetup.importDefenderSnapshot(this.castle.generateCastleMapSnapshot(), this.castle.generateCastleTroopsSnapshot(), 0, false, 0);
     }
     this.castle_AttackerSetup.initFakeSetup();
     this.GameDisplayMode = GameDisplays.DISPLAY_CASTLE;
     this.gameDisplayModeSubMode = GameDisplaySubModes.SUBMODE_CASTLE_ATTACKER_SETUP;
     this.gfx.BGColor = ARGBColors.Black;
     InterfaceMgr.Instance.initCastleAttackerSetupTab();
 }
 public void InitBattle(byte[] compressedCastleMap, byte[] compressedCastleDamageMap, byte[] compressedDefenderMap, byte[] compressedAttackerMap, int keepType, CastleResearchData defenderResearchData, CastleResearchData attackerResearchData, int campMode, int pillageInfo, int ransackCount, int raidCount, int attackType, int villageID, GetReport_ReturnType reportReturnData, int landType)
 {
     InterfaceMgr.Instance.clearControls();
     this.castle_Battle = new CastleMap(villageID, this.gfx, 3);
     this.castle_Battle.castleShown(false);
     this.castle_Battle.reInitGFX();
     this.castle_Battle.setCampMode(campMode);
     bool oldReport = false;
     if ((reportReturnData != null) && (reportReturnData.reportTime < CastlesCommon.PRE_FOREST_CHANGE_DATE))
     {
         oldReport = true;
     }
     this.castle_Battle.setReportData(reportReturnData);
     this.castle_Battle.launchBattle(compressedCastleMap, compressedCastleDamageMap, compressedDefenderMap, compressedAttackerMap, keepType, defenderResearchData, attackerResearchData, campMode, pillageInfo, ransackCount, raidCount, landType, false, oldReport);
     this.castle_Battle.returnToReports();
     this.GameDisplayMode = GameDisplays.DISPLAY_CASTLE;
     this.gameDisplayModeSubMode = GameDisplaySubModes.SUBMODE_BATTLE;
     this.gfx.BGColor = ARGBColors.Black;
     bool aIAttack = true;
     if (reportReturnData != null)
     {
         aIAttack = this.World.isSpecial(reportReturnData.attackingVillage);
     }
     InterfaceMgr.Instance.initCastleBattleTab(true, attackType, aIAttack);
 }
        public void InitBattle(int keepType, int fakeDefensiveMode)
        {
            CastleResearchData defenderResearchData = new CastleResearchData();
            CastleResearchData attackerResearchData = new CastleResearchData();
            if (fakeDefensiveMode >= 0)
            {
                switch (fakeDefensiveMode)
                {
                    case 0:
                        defenderResearchData.catapult = 0;
                        defenderResearchData.conscription = 0;
                        defenderResearchData.longBow = 0;
                        defenderResearchData.pike = 0;
                        defenderResearchData.sword = 0;
                        keepType = 1;
                        break;

                    case 1:
                        defenderResearchData.defences = 4;
                        keepType = 3;
                        defenderResearchData.catapult = 2;
                        defenderResearchData.conscription = 2;
                        defenderResearchData.longBow = 2;
                        defenderResearchData.pike = 2;
                        defenderResearchData.sword = 2;
                        break;

                    case 2:
                        defenderResearchData.defences = 8;
                        defenderResearchData.sallyForth = 2;
                        keepType = 5;
                        defenderResearchData.catapult = 4;
                        defenderResearchData.conscription = 4;
                        defenderResearchData.longBow = 4;
                        defenderResearchData.pike = 4;
                        defenderResearchData.sword = 4;
                        break;

                    case 3:
                        defenderResearchData.defences = 10;
                        defenderResearchData.sallyForth = 4;
                        keepType = 10;
                        defenderResearchData.catapult = 6;
                        defenderResearchData.conscription = 6;
                        defenderResearchData.longBow = 6;
                        defenderResearchData.pike = 6;
                        defenderResearchData.sword = 6;
                        defenderResearchData.tunnel = 6;
                        break;
                }
            }
            attackerResearchData.defences = this.World.UserResearchData.Research_Defences;
            attackerResearchData.catapult = this.World.UserResearchData.Research_Catapult;
            attackerResearchData.sword = this.World.UserResearchData.Research_Sword;
            attackerResearchData.pike = this.World.UserResearchData.Research_Pike;
            attackerResearchData.longBow = this.World.UserResearchData.Research_LongBow;
            attackerResearchData.conscription = this.World.UserResearchData.Research_Conscription;
            attackerResearchData.sallyForth = this.World.UserResearchData.Research_SallyForth;
            attackerResearchData.vaults = this.World.UserResearchData.Research_Vaults;
            InterfaceMgr.Instance.clearControls();
            this.castle_Battle = new CastleMap(-1, this.gfx, 3);
            this.castle_Battle.castleShown(false);
            this.castle_Battle.reInitGFX();
            this.castle_Battle.setCampMode(0);
            if (keepType < 0)
            {
                keepType = 1;
            }
            this.castle_Battle.launchBattle(this.castle_AttackerSetup.generateCastleMapSnapshot(), null, this.castle_AttackerSetup.generateCastleTroopsSnapshot(), null, keepType, defenderResearchData, attackerResearchData, 0, -1, -1, -1, 0, false, false);
            this.GameDisplayMode = GameDisplays.DISPLAY_CASTLE;
            this.gameDisplayModeSubMode = GameDisplaySubModes.SUBMODE_BATTLE;
            this.gfx.BGColor = ARGBColors.Black;
            InterfaceMgr.Instance.initCastleBattleTab(true, -1, false);
        }