示例#1
0
 public void confirmAvailableSpace()
 {
     if (!this.m_awaitingResponse)
     {
         if (!this.m_AppleChecked && (this.m_questDef.reward_apples > 0))
         {
             this.m_buildingType = 0x12;
             this.checkResource();
         }
         else if (!this.m_WoodChecked && (this.m_questDef.reward_wood > 0))
         {
             this.m_buildingType = 6;
             this.checkResource();
         }
         else if (!this.m_StoneChecked && (this.m_questDef.reward_stone > 0))
         {
             this.m_buildingType = 7;
             this.checkResource();
         }
         else if (((this.m_AppleAvailable && this.m_WoodAvailable) && this.m_StoneAvailable) || (MyMessageBox.Show(SK.Text("Quest_Reward_Insufficient_Space", "You do not have enough room to store all of the reward at this village. Are you sure you want to send the reward to this village?"), SK.Text("Quest_Reward_Insufficient_Space_header", "Insufficient Space"), MessageBoxButtons.YesNo) != DialogResult.No))
         {
             this.CompleteQuest();
         }
     }
 }
        public void CompleteQuestCallback(CompleteQuest_ReturnType returnData)
        {
            if (returnData.Success)
            {
                GameEngine.Instance.World.setTutorialInfo(returnData.m_tutorialInfo);
                this.completedActiveQuests = returnData.m_preCompletedQuests;
                if (GameEngine.Instance.GameDisplayMode == GameEngine.GameDisplays.DISPLAY_QUESTS)
                {
                    this.rebuild();
                }
                if (returnData.questCompleted >= 0)
                {
                    List <Quests.QuestReward> list = Quests.getQuestRewards(returnData.questCompleted, false, null);
                    foreach (Quests.QuestReward reward in list)
                    {
                        List <int>             list2;
                        CardTypes.PremiumToken token;
                        switch (reward.type)
                        {
                        case 0x4e20:
                        {
                            list2 = GameEngine.Instance.World.getUserVillageIDList();
                            if (list2.Count == 1)
                            {
                                break;
                            }
                            GameEngine.Instance.flushVillages();
                            if (GameEngine.Instance.GameDisplayMode == GameEngine.GameDisplays.DISPLAY_VILLAGE)
                            {
                                GameEngine.Instance.downloadCurrentVillage();
                            }
                            continue;
                        }

                        case 0x4e21:
                        {
                            GameEngine.Instance.World.addGold((double)reward.amount);
                            continue;
                        }

                        case 0x4e22:
                        {
                            GameEngine.Instance.World.addHonour((double)reward.amount);
                            continue;
                        }

                        case 0x4e23:
                        {
                            GameEngine.Instance.World.addResearchPoints(reward.amount);
                            continue;
                        }

                        case 0x4e24:
                        {
                            if (returnData.cardAdded >= 0)
                            {
                                if (reward.data == 0x1011)
                                {
                                    goto Label_01D0;
                                }
                                GameEngine.Instance.World.addProfileCard(returnData.cardAdded, CardTypes.getStringFromCard(reward.data));
                            }
                            continue;
                        }

                        case 0x4e25:
                        {
                            continue;
                        }

                        case 0x4e26:
                        {
                            WorldMap world = GameEngine.Instance.World;
                            world.FakeCardPoints += reward.amount;
                            continue;
                        }

                        default:
                        {
                            continue;
                        }
                        }
                        if (list2.Count == 1)
                        {
                            VillageMap map = GameEngine.Instance.getVillage(list2[0]);
                            if (map != null)
                            {
                                map.addResources(reward.data, reward.amount);
                            }
                        }
                        continue;
Label_01D0:
                        token                    = new CardTypes.PremiumToken();
                        token.Reward             = 1;
                        token.UserPremiumTokenID = returnData.cardAdded;
                        token.WorldID            = RemoteServices.Instance.ProfileWorldID;
                        token.Type               = 0x1011;
                        bool flag = false;
                        if (GameEngine.Instance.World.UserCardData.premiumCard <= 0)
                        {
                            XmlRpcCardsProvider provider = XmlRpcCardsProvider.CreateForEndpoint(URLs.ProfileProtocol, URLs.ProfileServerAddressCards, URLs.ProfileServerPort, URLs.ProfileCardPath);
                            XmlRpcCardsRequest  req      = new XmlRpcCardsRequest(RemoteServices.Instance.UserGuid.ToString().Replace("-", ""))
                            {
                                WorldID    = RemoteServices.Instance.ProfileWorldID.ToString(),
                                UserCardID = returnData.cardAdded.ToString()
                            };
                            if (token.Type == 0x1010)
                            {
                                req.CardString = "CARDTYPE_PREMIUM";
                            }
                            if (token.Type == 0x1011)
                            {
                                req.CardString = "CARDTYPE_PREMIUM2";
                            }
                            if (token.Type == 0x1012)
                            {
                                req.CardString = "CARDTYPE_PREMIUM30";
                            }
                            XmlRpcCardsResponse response = provider.playPremium(req, 0x1770);
                            if (response.SuccessCode != 1)
                            {
                                flag = true;
                                MyMessageBox.Show(response.Message, "Error playing premium");
                            }
                            else
                            {
                                GameEngine.Instance.World.CardPlayed(-1, token.Type, -1);
                            }
                        }
                        else
                        {
                            flag = true;
                        }
                        if (flag)
                        {
                            GameEngine.Instance.World.ProfilePremiumTokens.Add(returnData.cardAdded, token);
                        }
                    }
                    bool flag2 = false;
                    foreach (Quests.QuestReward reward2 in list)
                    {
                        if ((reward2.type == 0x4e24) || (reward2.type == 0x4e26))
                        {
                            flag2 = true;
                        }
                    }
                    if (flag2)
                    {
                        PlayCardsWindow.resetRewardCardTimer();
                    }
                }
            }
            this.inCompleteQuest = false;
        }
示例#3
0
 public void sendScoutsCallback(SendScouts_ReturnType returnData)
 {
     CursorManager.SetCursor(CursorManager.CursorType.Default, base.ParentForm);
     this.inLaunch = false;
     if (!returnData.Success && (returnData.m_errorCode == ErrorCodes.ErrorCode.ATTACKING_VILLAGE_INTERDICT_PROTECTED))
     {
         MessageBoxButtons yesNo = MessageBoxButtons.YesNo;
         if (MyMessageBox.Show(SK.Text("GameEngine_Currently_Interdited", "You are currently Interdiction protected") + "\n" + SK.Text("GameEngine_CancelProtection", "Do you wish to cancel this protection?"), SK.Text("GENERIC_Protected", "You Are Protected"), yesNo) == DialogResult.Yes)
         {
             RemoteServices.Instance.set_CancelInterdiction_UserCallBack(new RemoteServices.CancelInterdiction_UserCallBack(this.cancelInterdictionCallback));
             RemoteServices.Instance.CancelInterdiction(-returnData.sourceVillage);
         }
         else
         {
             if (returnData.numScoutsNotTaken > 0)
             {
                 VillageMap map = GameEngine.Instance.getVillage(returnData.sourceVillage);
                 if (map != null)
                 {
                     map.addTroops(0, 0, 0, 0, 0, returnData.numScoutsNotTaken);
                 }
             }
             InterfaceMgr.Instance.closeScoutPopupWindow();
             InterfaceMgr.Instance.getMainTabBar().changeTab(9);
             InterfaceMgr.Instance.getMainTabBar().changeTab(0);
         }
     }
     else
     {
         this.closeButton.Enabled = true;
         if (returnData.Success)
         {
             ArmyReturnData[] armyReturnData = new ArmyReturnData[] { returnData.armyData };
             GameEngine.Instance.World.doGetArmyData(armyReturnData, null, false);
             GameEngine.Instance.World.addExistingArmy(returnData.armyData.armyID);
             InterfaceMgr.Instance.displaySelectedVillagePanel(this.m_ownVillage, false, false, false, false);
             InterfaceMgr.Instance.closeScoutPopupWindow();
             if (returnData.cardData != null)
             {
                 GameEngine.Instance.World.UserCardData = returnData.cardData;
             }
             AttackTargetsPanel.addRecent(returnData.targetVillage);
         }
         if (returnData.numScoutsNotTaken > 0)
         {
             VillageMap map2 = GameEngine.Instance.getVillage(returnData.sourceVillage);
             if (map2 != null)
             {
                 map2.addTroops(0, 0, 0, 0, 0, returnData.numScoutsNotTaken);
             }
             if (!returnData.Success)
             {
                 this.launchButton.Enabled = false;
             }
         }
         if (returnData.Success)
         {
             InterfaceMgr.Instance.displaySelectedVillagePanel(this.m_selectedVillage, false, true, false, false);
             InterfaceMgr.Instance.closeScoutPopupWindow();
         }
     }
 }