private void UpdateTroopRequestMode()
        {
            SmartEntity smartEntity = (SmartEntity)Service.Get <BuildingLookupController>().GetCurrentSquadBuilding();

            if (smartEntity != null)
            {
                int  storage                 = smartEntity.BuildingComp.BuildingType.Storage;
                uint serverTime              = Service.Get <ServerAPI>().ServerTime;
                uint troopRequestDate        = Service.Get <SquadController>().StateManager.TroopRequestDate;
                int  troopRequestCrystalCost = SquadUtils.GetTroopRequestCrystalCost(serverTime, troopRequestDate);
                if (SquadUtils.GetDonatedTroopStorageUsedByCurrentPlayer() < storage && GameUtils.CanAffordCrystals(troopRequestCrystalCost))
                {
                    if (SquadUtils.CanSendFreeTroopRequest(serverTime, troopRequestDate))
                    {
                        this.requestTroopBtn.Visible       = true;
                        this.resendRequestTroopBtn.Visible = false;
                        return;
                    }
                    this.requestTroopBtn.Visible          = false;
                    this.resendRequestTroopBtn.Visible    = true;
                    this.resendRequestTroopCostLabel.Text = troopRequestCrystalCost.ToString();
                    return;
                }
                else
                {
                    this.resendRequestTroopBtn.Visible = false;
                    this.requestTroopBtn.Visible       = true;
                    this.requestTroopBtn.Enabled       = false;
                }
            }
        }
Ejemplo n.º 2
0
 private void UpdateRequestState()
 {
     if (this.requestResendCost != null)
     {
         uint serverTime           = Service.ServerAPI.ServerTime;
         uint troopRequestDate     = Service.SquadController.StateManager.TroopRequestDate;
         int  troopRequestTimeLeft = SquadUtils.GetTroopRequestTimeLeft(serverTime, troopRequestDate);
         bool flag = troopRequestTimeLeft <= 0;
         if (flag)
         {
             this.requestResendCost.Visible = false;
             if (this.observingClockViewTime && !Service.PostBattleRepairController.IsEntityInRepair(this.selectedBuilding))
             {
                 this.observingClockViewTime = false;
                 Service.ViewTimeEngine.UnregisterClockTimeObserver(this);
             }
         }
         else
         {
             int troopRequestCrystalCost = SquadUtils.GetTroopRequestCrystalCost(serverTime, troopRequestDate);
             this.requestResendCost.Visible = true;
             this.requestResendCost.Enabled = GameUtils.CanAffordCrystals(troopRequestCrystalCost);
             UXUtils.SetupCostElements(this, "CostResendRequest", "troop_request", 0, 0, 0, troopRequestCrystalCost, false, null);
             if (!this.observingClockViewTime)
             {
                 this.observingClockViewTime = true;
                 Service.ViewTimeEngine.RegisterClockTimeObserver(this, 1f);
             }
         }
     }
 }
Ejemplo n.º 3
0
        private void InternalOnLeaveSquadClicked(object cookie)
        {
            Service.EventManager.SendEvent(EventId.SquadEdited, null);
            SquadController    squadController      = Service.SquadController;
            SquadMemberWarData currentMemberWarData = squadController.WarManager.GetCurrentMemberWarData();
            uint serverTime = Service.ServerAPI.ServerTime;
            int  unclaimedSquadWarRewardsCount = SquadUtils.GetUnclaimedSquadWarRewardsCount(currentMemberWarData, serverTime);

            if (!SquadUtils.CanLeaveSquad())
            {
                string message = Service.Lang.Get("IN_WAR_CANT_LEAVE_SQUAD", new object[0]);
                AlertScreen.ShowModal(false, null, message, null, null, true);
                this.screen.ShowSquadSlideButton();
            }
            else if (unclaimedSquadWarRewardsCount > 0)
            {
                YesNoScreen.ShowModal(this.lang.Get("LEAVING_SQUAD_ALERT_WITH_REWARDS_TITLE", new object[0]), this.lang.Get("LEAVING_SQUAD_ALERT_WITH_REWARDS", new object[]
                {
                    unclaimedSquadWarRewardsCount
                }), false, this.lang.Get("LEAVING_SQUAD_CONFIRM", new object[0]), this.lang.Get("ACCOUNT_CONFLICT_CONFIRM_CANCEL", new object[0]), new OnScreenModalResult(this.OnAlertLeaveResult), null);
            }
            else
            {
                YesNoScreen.ShowModal(this.lang.Get("LEAVING_SQUAD_ALERT_TITLE", new object[0]), this.lang.Get("LEAVING_SQUAD_ALERT", new object[0]), false, this.lang.Get("LEAVING_SQUAD_CONFIRM", new object[0]), this.lang.Get("ACCOUNT_CONFLICT_CONFIRM_CANCEL", new object[0]), new OnScreenModalResult(this.OnAlertLeaveResult), null);
            }
        }
Ejemplo n.º 4
0
        private void RefreshSquadLevel()
        {
            Squad currentSquad = Service.SquadController.StateManager.GetCurrentSquad();

            if (currentSquad == null)
            {
                return;
            }
            this.squadLevelLabel.Text = currentSquad.Level.ToString();
            int totalRepInvested            = currentSquad.TotalRepInvested;
            int reputationReqForSquadLevel  = SquadUtils.GetReputationReqForSquadLevel(currentSquad.Level);
            int reputationReqForSquadLevel2 = SquadUtils.GetReputationReqForSquadLevel(currentSquad.Level + 1);

            if (reputationReqForSquadLevel2 < 0)
            {
                this.squadLevelProgressLabel.Text = this.lang.Get("MAX_LEVEL", new object[0]);
                this.squadLevelProgressBar.Value  = 1f;
                return;
            }
            int num  = totalRepInvested - reputationReqForSquadLevel;
            int num2 = reputationReqForSquadLevel2 - reputationReqForSquadLevel;

            this.squadLevelProgressLabel.Text = num + " / " + num2;
            this.squadLevelProgressBar.Value  = (float)num / (float)num2;
        }
Ejemplo n.º 5
0
        public override void ShowView()
        {
            EventManager eventManager = Service.EventManager;

            this.viewContainer.Visible = true;
            eventManager.SendEvent(EventId.SquadSelect, null);
            eventManager.SendEvent(EventId.UISquadScreenTabShown, "warlog");
            SquadController    squadController      = Service.SquadController;
            SquadMemberWarData currentMemberWarData = squadController.WarManager.GetCurrentMemberWarData();
            uint serverTime = Service.ServerAPI.ServerTime;

            if (SquadUtils.DoesRewardWithoutWarHistoryExist(squadController, currentMemberWarData, serverTime))
            {
                ProcessingScreen.Show();
                EventManager eventManager2 = Service.EventManager;
                eventManager2.RegisterObserver(this, EventId.SquadUpdateCompleted);
                squadController.UpdateCurrentSquad();
            }
            else
            {
                this.RefreshView();
            }
            this.tabButton.Selected = true;
            Service.ViewTimeEngine.RegisterFrameTimeObserver(this);
        }
Ejemplo n.º 6
0
 private void OnSquadDetailsUpdated(Squad squad, bool success)
 {
     ProcessingScreen.Hide();
     if (this.IsClosedOrClosing())
     {
         return;
     }
     if (success)
     {
         if (squad != null)
         {
             string detailsString;
             bool   showRequestButton = SquadUtils.CanCurrentPlayerJoinSquad(Service.CurrentPlayer, Service.SquadController.StateManager.GetCurrentSquad(), squad, Service.Lang, out detailsString);
             this.DisplaySquadInfoView(squad, showRequestButton, detailsString);
         }
         else
         {
             success = false;
         }
     }
     else
     {
         string message = this.lang.Get("GENERIC_SQUAD_INFO_ISSUE", new object[0]);
         AlertScreen.ShowModal(false, null, message, null, null);
     }
 }
Ejemplo n.º 7
0
        public void OnViewFrameTime(float dt)
        {
            List <UXElement>   elementList          = this.gridWarLog.GetElementList();
            SquadController    squadController      = Service.SquadController;
            uint               serverTime           = Service.ServerAPI.ServerTime;
            SquadMemberWarData currentMemberWarData = squadController.WarManager.GetCurrentMemberWarData();
            int i     = 0;
            int count = elementList.Count;

            while (i < count)
            {
                string             text         = elementList[i].Tag as string;
                UXLabel            subElement   = this.gridWarLog.GetSubElement <UXLabel>(text, "LabelWarlogExpires");
                SquadWarRewardData rewardForWar = SquadUtils.GetRewardForWar(text, currentMemberWarData);
                if (rewardForWar != null)
                {
                    int num = (int)(rewardForWar.ExpireDate - serverTime);
                    if (num < 0)
                    {
                        this.HideCollectButton(text);
                    }
                    else
                    {
                        string text2 = LangUtils.FormatTime((long)num);
                        subElement.Visible = true;
                        subElement.Text    = text2;
                    }
                }
                else
                {
                    this.HideCollectButton(text);
                }
                i++;
            }
        }
 public override OnCompleteAction OnFailure(uint status, object data)
 {
     if (SquadUtils.IsNotFatalServerError(status))
     {
         return(base.EatFailure(status, data));
     }
     return(base.OnFailure(status, data));
 }
Ejemplo n.º 9
0
        public void SendTroopRequest(string requestText, bool isWarRequest = false)
        {
            bool            flag            = true;
            bool            payToSkip       = false;
            uint            serverTime      = Service.ServerAPI.ServerTime;
            SquadController squadController = Service.SquadController;
            uint            troopRequestDate;

            if (isWarRequest)
            {
                troopRequestDate = squadController.StateManager.WarTroopRequestDate;
            }
            else
            {
                troopRequestDate = squadController.StateManager.TroopRequestDate;
            }
            int troopRequestCrystalCost = SquadUtils.GetTroopRequestCrystalCost(serverTime, troopRequestDate);

            if (troopRequestCrystalCost > 0)
            {
                payToSkip = true;
                flag      = GameUtils.SpendCrystals(troopRequestCrystalCost);
            }
            if (flag)
            {
                string empty     = string.Empty;
                string itemId    = "requestTroops";
                int    itemCount = 1;
                string type      = "squad_action";
                string subType   = "consumable";
                Service.DMOAnalyticsController.LogInAppCurrencyAction(-troopRequestCrystalCost, empty, itemId, itemCount, type, subType);
                if (string.IsNullOrEmpty(requestText))
                {
                    if (isWarRequest)
                    {
                        requestText = Service.Lang.Get("REQUEST_WAR_TROOPS_DEFAULT", new object[0]);
                    }
                    else
                    {
                        requestText = Service.Lang.Get("REQUEST_TROOPS_DEFAULT", new object[0]);
                    }
                }
                SquadMsg message;
                if (isWarRequest)
                {
                    message = SquadMsgUtils.CreateRequestWarTroopsMessage(payToSkip, troopRequestCrystalCost, requestText);
                    Service.EventManager.SendEvent(EventId.SquadWarTroopsRequestStartedByCurrentPlayer, null);
                }
                else
                {
                    message = SquadMsgUtils.CreateRequestTroopsMessage(payToSkip, troopRequestCrystalCost, requestText);
                }
                this.TakeAction(message);
            }
            Service.EventManager.SendEvent(EventId.SquadEdited, null);
        }
Ejemplo n.º 10
0
        public void SyncCurrentPlayerPlanet()
        {
            CurrentPlayer currentPlayer   = Service.CurrentPlayer;
            SquadMember   squadMemberById = SquadUtils.GetSquadMemberById(this.StateManager.GetCurrentSquad(), currentPlayer.PlayerId);

            if (squadMemberById != null)
            {
                squadMemberById.Planet = currentPlayer.PlanetId;
            }
        }
Ejemplo n.º 11
0
        public override bool EvaluateUpdate()
        {
            int storage = Service.BuildingLookupController.SquadBuildingNodeList.Head.BuildingComp.BuildingType.Storage;
            int donatedTroopStorageUsedByWorldOwner = SquadUtils.GetDonatedTroopStorageUsedByWorldOwner();

            Service.BotRunner.Log("Squad Center Capacity: {0} > {1} : {2}", new object[]
            {
                storage,
                donatedTroopStorageUsedByWorldOwner,
                storage >= donatedTroopStorageUsedByWorldOwner
            });
            return(storage > donatedTroopStorageUsedByWorldOwner);
        }
Ejemplo n.º 12
0
 private void OnCreateSquadClicked(UXButton button)
 {
     if (!SquadUtils.CanLeaveSquad())
     {
         string message = Service.Lang.Get("IN_WAR_CANT_LEAVE_SQUAD", new object[0]);
         AlertScreen.ShowModal(false, null, message, null, null, true);
     }
     else
     {
         Service.ScreenController.AddScreen(new SquadCreateScreen(true));
     }
     this.screen.Close(null);
 }
Ejemplo n.º 13
0
        public void SyncCurrentPlayerRole()
        {
            SquadMember squadMemberById = SquadUtils.GetSquadMemberById(this.StateManager.GetCurrentSquad(), Service.CurrentPlayer.PlayerId);

            if (squadMemberById != null)
            {
                this.StateManager.Role = squadMemberById.Role;
                if (this.StateManager.JoinDate == 0u)
                {
                    this.StateManager.JoinDate = squadMemberById.JoinDate;
                }
            }
        }
Ejemplo n.º 14
0
        private void OnViewClicked(UXButton button)
        {
            GameUtils.ExitEditState();
            Service.EventManager.SendEvent(EventId.SquadNext, null);
            SquadUtils.ForceCloseSquadWarScreen();
            Service.UXController.HUD.DestroySquadScreen();
            SquadMember squadMember = button.Tag as SquadMember;

            Service.NeighborVisitManager.VisitNeighbor(squadMember.MemberID);
            PlayerVisitTag cookie = new PlayerVisitTag(true, false, "SQUAD_MEMBERS", squadMember.MemberID);

            Service.EventManager.SendEvent(EventId.VisitPlayer, cookie);
        }
Ejemplo n.º 15
0
        private void UpdateRequestState()
        {
            uint            time            = ServerTime.Time;
            SquadController squadController = Service.SquadController;
            uint            troopRequestDate;

            if (this.isWarRequest)
            {
                troopRequestDate = squadController.StateManager.WarTroopRequestDate;
            }
            else
            {
                troopRequestDate = squadController.StateManager.TroopRequestDate;
            }
            int troopRequestTimeLeft = SquadUtils.GetTroopRequestTimeLeft(time, troopRequestDate);

            this.canSendFreeRequest = (troopRequestTimeLeft <= 0);
            this.UpdateScreenElementVisibility();
            if (this.canSendFreeRequest)
            {
                int troopRequestCooldownTime = Service.PerkManager.GetTroopRequestCooldownTime();
                this.instructionsLabel.Text = this.lang.Get("REQUEST_TIME_LIMIT_MESSAGE", new object[]
                {
                    (uint)((ulong)(GameConstants.SQUAD_TROOP_REQUEST_THROTTLE_MINUTES * 60u) - (ulong)((long)troopRequestCooldownTime)) / 60u
                });
                if (this.observingClockTime)
                {
                    this.observingClockTime = false;
                    Service.ViewTimeEngine.UnregisterClockTimeObserver(this);
                }
            }
            else
            {
                this.instructionsLabel.Text = this.lang.Get("REQUEST_TIME_LEFT_MESSAGE", new object[]
                {
                    Math.Ceiling((double)((float)troopRequestTimeLeft / 60f))
                });
                int troopRequestCrystalCost = SquadUtils.GetTroopRequestCrystalCost(time, troopRequestDate);
                this.costButton.Enabled       = GameUtils.CanAffordCrystals(troopRequestCrystalCost);
                this.requestNowCostLabel.Text = troopRequestCrystalCost.ToString();
                this.observingClockTime       = true;
                Service.ViewTimeEngine.RegisterClockTimeObserver(this, 1f);
            }
            if (this.isWarRequest)
            {
                bool flag = SquadUtils.IsPlayerSquadWarTroopsAtMaxCapacity();
                this.instructionsLabel.Visible = !flag;
            }
            this.instructionsPerksLabel.Text = this.instructionsLabel.Text;
        }
Ejemplo n.º 16
0
        public int RefreshBadge()
        {
            SquadController    squadController      = Service.SquadController;
            SquadMemberWarData currentMemberWarData = squadController.WarManager.GetCurrentMemberWarData();
            uint serverTime = Service.ServerAPI.ServerTime;
            int  unclaimedSquadWarRewardsCount = SquadUtils.GetUnclaimedSquadWarRewardsCount(currentMemberWarData, serverTime);

            if (this.warLogBadge == null)
            {
                this.warLogBadge = JewelControl.Create(this.screen, "SocialWarLog");
            }
            this.warLogBadge.Value = unclaimedSquadWarRewardsCount;
            return(unclaimedSquadWarRewardsCount);
        }
Ejemplo n.º 17
0
        public void JoinSquad(string biSource)
        {
            if (this.squad == null)
            {
                return;
            }
            Lang lang = Service.Lang;

            this.biSource = biSource;
            Squad squad = Service.CurrentPlayer.Squad;

            if (!this.button.VisuallyDisabled)
            {
                this.button.Enabled = false;
                Service.EventManager.SendEvent(EventId.SquadNext, null);
                if (this.squad.InviteType == 1)
                {
                    if (squad == null)
                    {
                        ProcessingScreen.Show();
                        this.ActualJoinSquad();
                    }
                    else if (!SquadUtils.CanLeaveSquad())
                    {
                        string message = Service.Lang.Get("IN_WAR_CANT_LEAVE_SQUAD", new object[0]);
                        AlertScreen.ShowModal(false, null, message, null, null, true);
                    }
                    else
                    {
                        YesNoScreen.ShowModal(lang.Get("ALERT", new object[0]), lang.Get("JOIN_LEAVE_SQUAD_ALERT", new object[]
                        {
                            squad.SquadName,
                            this.squad.SquadName
                        }), false, lang.Get("JOIN_CTA", new object[0]), lang.Get("ACCOUNT_CONFLICT_CONFIRM_CANCEL", new object[0]), new OnScreenModalResult(this.OnLeaveAndJoinSquad), this.squad);
                        Service.EventManager.SendEvent(EventId.UISquadLeaveConfirmation, squad.SquadID + "|join|" + this.squad.SquadID);
                    }
                }
                else
                {
                    Service.ScreenController.AddScreen(new SquadJoinRequestScreen(this.squad, new SquadController.ActionCallback(this.OnApplyToSquadComplete), this.button));
                }
            }
            else
            {
                string msg;
                SquadUtils.CanCurrentPlayerJoinSquad(Service.CurrentPlayer, Service.SquadController.StateManager.GetCurrentSquad(), this.squad, Service.Lang, out msg);
                this.ShowInfoText(msg);
            }
        }
Ejemplo n.º 18
0
        private void InitFullView()
        {
            Lang   lang = Service.Lang;
            string text;

            if (!SquadUtils.CanCurrentPlayerJoinSquad(Service.CurrentPlayer, Service.SquadController.StateManager.GetCurrentSquad(), this.squad, lang, out text))
            {
                this.primaryButton.VisuallyDisableButton();
            }
            else if (this.squad.InviteType == 0 && Service.SquadController.StateManager.SquadJoinRequestsPending.Contains(this.squad.SquadID))
            {
                this.primaryButton.Enabled = false;
            }
            this.primaryButton.OnClicked = new UXButtonClickedDelegate(this.OnJoinClicked);
            this.joinModule = new SquadJoinActionModule(this.squad, this.screen, this.primaryButton);
            this.secondaryButton.OnClicked = new UXButtonClickedDelegate(this.screen.ViewSquadInfoClicked);
            this.secondaryButton.Tag       = this.squad.SquadID;
            this.secondaryButton.Visible   = true;
            this.secondaryButtonLabel.Text = lang.Get("context_Info", new object[0]);
            if (this.squad.InviteType == 1)
            {
                this.primaryButtonLabel.Text = lang.Get("JOIN", new object[0]);
                this.typeLabel.Text          = lang.Get("SQUAD_OPEN_TO_ALL", new object[0]);
            }
            else
            {
                this.primaryButtonLabel.Text = lang.Get("APPLY", new object[0]);
                this.typeLabel.Text          = lang.Get("SQUAD_INVITE_ONLY", new object[0]);
            }
            this.playerFactionSprite.Visible = false;
            this.memberNumberLabel.Text      = lang.Get("SQUAD_MEMBERS", new object[0]) + " " + lang.Get("FRACTION", new object[]
            {
                this.squad.MemberCount,
                this.squad.MemberMax
            });
            this.activeMemberNumberLabel.Text = lang.Get("SQUAD_ACTIVE_MEMBERS", new object[0]) + " " + lang.Get("FRACTION", new object[]
            {
                this.squad.ActiveMemberCount,
                this.squad.MemberMax
            });
            this.squadLevelGroup.Visible = true;
            this.squadLevelLabel.Text    = this.squad.Level.ToString();
            this.friendTexture.Visible   = false;
            this.planetLabel.Visible     = false;
            this.planetBgTexture.Visible = false;
            Squad currentSquad = Service.SquadController.StateManager.GetCurrentSquad();

            base.ToggleHighlight(currentSquad != null && currentSquad.SquadID == this.squad.SquadID);
        }
Ejemplo n.º 19
0
        private void UpdateMembers()
        {
            SquadController squadController = Service.SquadController;
            Squad           currentSquad    = squadController.StateManager.GetCurrentSquad();

            if (currentSquad == null)
            {
                return;
            }
            bool             flag        = false;
            List <UXElement> elementList = this.squadMemberGrid.GetElementList();

            for (int i = 0; i < elementList.Count; i++)
            {
                SquadMember squadMember = elementList[i].Tag as SquadMember;
                if (!SquadUtils.IsPlayerInSquad(squadMember.MemberID, currentSquad))
                {
                    UXElement uXElement = elementList[i];
                    this.squadMemberGrid.RemoveItem(uXElement);
                    this.screen.DestroyElement(uXElement);
                    i--;
                    flag = true;
                }
            }
            int j     = 0;
            int count = currentSquad.MemberList.Count;

            while (j < count)
            {
                if (this.CheckAndCreateMemberEntry(currentSquad.MemberList[j]))
                {
                    flag = true;
                }
                j++;
            }
            int k      = 0;
            int count2 = currentSquad.MemberList.Count;

            while (k < count2)
            {
                this.UpdateSquadMember(currentSquad.MemberList[k]);
                k++;
            }
            if (flag)
            {
                this.squadMemberGrid.RepositionItems();
            }
        }
Ejemplo n.º 20
0
        public void OnPlayerActionFailure(SquadMsg actionMsg, uint status)
        {
            SquadAction type = actionMsg.ActionData.Type;

            if (type == SquadAction.RequestTroops || type == SquadAction.RequestWarTroops)
            {
                SqmRequestData requestData = actionMsg.RequestData;
                if (requestData.PayToSkip && requestData.ResendCrystalCost > 0)
                {
                    Service.CurrentPlayer.Inventory.ModifyCrystals(requestData.ResendCrystalCost);
                }
            }
            string messageForServerActionFailure = SquadUtils.GetMessageForServerActionFailure(type, status);

            AlertScreen.ShowModal(false, null, Service.Lang.Get(messageForServerActionFailure, new object[0]), null, null);
        }
Ejemplo n.º 21
0
        private void UpdateHousingSpace()
        {
            int     donatedTroopStorageUsedByWorldOwner = SquadUtils.GetDonatedTroopStorageUsedByWorldOwner();
            int     storage      = this.buildingInfo.Storage;
            UXLabel currentLabel = this.sliders[1].CurrentLabel;

            currentLabel.Text = this.lang.Get("FRACTION", new object[]
            {
                this.lang.ThousandsSeparated(donatedTroopStorageUsedByWorldOwner),
                this.lang.ThousandsSeparated(storage)
            });
            UXSlider currentSlider = this.sliders[1].CurrentSlider;
            float    value         = (storage != 0) ? ((float)donatedTroopStorageUsedByWorldOwner / (float)storage) : 0f;

            currentSlider.Value = value;
        }
Ejemplo n.º 22
0
        protected void InitTroopGrid()
        {
            base.InitGrid();
            GamePlayer worldOwner = GameUtils.GetWorldOwner();
            List <SquadDonatedTroop> worldOwnerSquadBuildingTroops = SquadUtils.GetWorldOwnerSquadBuildingTroops();
            int count = worldOwnerSquadBuildingTroops.Count;

            if (count > 0)
            {
                Dictionary <string, string> dictionary = null;
                if (worldOwner.Squad != null)
                {
                    dictionary = new Dictionary <string, string>();
                    List <SquadMember> memberList = worldOwner.Squad.MemberList;
                    int i      = 0;
                    int count2 = memberList.Count;
                    while (i < count2)
                    {
                        SquadMember squadMember = memberList[i];
                        dictionary.Add(squadMember.MemberID, squadMember.MemberName);
                        i++;
                    }
                }
                StaticDataController staticDataController = Service.StaticDataController;
                for (int j = 0; j < count; j++)
                {
                    SquadDonatedTroop squadDonatedTroop = worldOwnerSquadBuildingTroops[j];
                    TroopTypeVO       troopTypeVO       = staticDataController.Get <TroopTypeVO>(squadDonatedTroop.TroopUid);
                    int totalAmount = squadDonatedTroop.GetTotalAmount();
                    if (totalAmount > 0)
                    {
                        string tooltipString = this.GetTooltipString(troopTypeVO, squadDonatedTroop, dictionary);
                        base.AddTroopItem(troopTypeVO, totalAmount, tooltipString);
                    }
                }
            }
            if (!this.inVisitMode && worldOwner.Squad != null && SquadUtils.GetDonatedTroopStorageUsedByWorldOwner() < this.buildingInfo.Storage)
            {
                this.AddTroopRequestItem();
            }
            else
            {
                this.requestResendCost = null;
            }
            base.RepositionGridItems();
        }
Ejemplo n.º 23
0
        public ISerializable FromObject(object obj)
        {
            Dictionary <string, object> dictionary = obj as Dictionary <string, object>;

            if (dictionary.ContainsKey("id"))
            {
                this.SquadMemberId = Convert.ToString(dictionary["id"], CultureInfo.InvariantCulture);
            }
            if (dictionary.ContainsKey("name"))
            {
                this.SquadMemberName = Convert.ToString(dictionary["name"], CultureInfo.InvariantCulture);
            }
            if (dictionary.ContainsKey("victoryPoints"))
            {
                this.VictoryPointsLeft = Convert.ToInt32(dictionary["victoryPoints"], CultureInfo.InvariantCulture);
            }
            if (dictionary.ContainsKey("warMap") && dictionary["warMap"] != null)
            {
                this.BaseMap = new Map();
                this.BaseMap.FromObject(dictionary["warMap"]);
                this.BaseMap.InitializePlanet();
            }
            if (dictionary.ContainsKey("donatedTroops"))
            {
                this.WarTroops = SquadUtils.GetSquadDonatedTroopsFromObject(dictionary["donatedTroops"]);
            }
            if (dictionary.ContainsKey("rewards"))
            {
                Dictionary <string, object> dictionary2 = dictionary["rewards"] as Dictionary <string, object>;
                if (dictionary2 != null)
                {
                    this.WarRewards.Clear();
                    foreach (object current in dictionary2.Values)
                    {
                        SquadWarRewardData squadWarRewardData = new SquadWarRewardData();
                        squadWarRewardData.FromObject(current);
                        if (squadWarRewardData.ExpireDate > Service.Get <ServerAPI>().ServerTime)
                        {
                            this.WarRewards.Add(squadWarRewardData);
                        }
                    }
                    this.WarRewards.Sort(new Comparison <SquadWarRewardData>(this.CompareExpirationDates));
                }
            }
            return(this);
        }
        private void UpdateSquadRank()
        {
            SquadController squadController = Service.Get <SquadController>();
            Squad           currentSquad    = squadController.StateManager.GetCurrentSquad();

            if (currentSquad == null)
            {
                return;
            }
            this.squadRankLabel.Text        = this.lang.ThousandsSeparated(currentSquad.Rank);
            this.squadHighestRankLabel.Text = this.lang.ThousandsSeparated(currentSquad.HighestRank);
            if (SquadUtils.CanLeaveSquad())
            {
                this.leaveButton.VisuallyEnableButton();
                return;
            }
            this.leaveButton.VisuallyDisableButton();
        }
Ejemplo n.º 25
0
        private void OnNextButtonClicked(UXButton button)
        {
            this.Close(null);
            SquadController          squadController          = Service.SquadController;
            bool                     flag                     = squadController.StateManager.GetCurrentSquad() != null;
            BuildingLookupController buildingLookupController = Service.BuildingLookupController;
            int  highestLevelHQ = buildingLookupController.GetHighestLevelHQ();
            bool flag2          = SquadUtils.CanStartMatchmakingPrep(squadController, buildingLookupController);

            if (!flag)
            {
                Service.BILoggingController.TrackGameAction(highestLevelHQ.ToString(), "UI_squadwar_joinsquad", ServerTime.Time.ToString(), null);
                Service.ScreenController.AddScreen(new SquadJoinScreen());
            }
            else if (flag2)
            {
                squadController.WarManager.StartMatchMakingPreparation();
            }
        }
Ejemplo n.º 26
0
        protected void InitTroopGrid()
        {
            this.storageItemGrid = base.GetElement <UXGrid>("GridCurrentTroops");
            this.storageItemGrid.SetTemplateItem("CardCurrentTroops");
            this.storageItemGrid.Clear();
            this.troopList = new List <TroopUpgradeTag>();
            int        num        = 0;
            GamePlayer worldOwner = GameUtils.GetWorldOwner();
            List <SquadDonatedTroop> list;
            int squadStorageCapacity;

            if (this.isWarRequest)
            {
                SquadMemberWarData currentMemberWarData = Service.SquadController.WarManager.GetCurrentMemberWarData();
                list = currentMemberWarData.WarTroops;
                squadStorageCapacity = currentMemberWarData.BaseMap.GetSquadStorageCapacity();
            }
            else
            {
                list = SquadUtils.GetWorldOwnerSquadBuildingTroops();
                squadStorageCapacity = worldOwner.Map.GetSquadStorageCapacity();
            }
            int count = list.Count;

            if (count > 0)
            {
                StaticDataController staticDataController = Service.StaticDataController;
                for (int i = 0; i < count; i++)
                {
                    SquadDonatedTroop squadDonatedTroop = list[i];
                    TroopTypeVO       troopTypeVO       = staticDataController.Get <TroopTypeVO>(squadDonatedTroop.TroopUid);
                    int totalAmount = squadDonatedTroop.GetTotalAmount();
                    if (totalAmount > 0)
                    {
                        this.AddTroopItem(troopTypeVO, totalAmount);
                        num += totalAmount * troopTypeVO.Size;
                    }
                }
            }
            this.canRequestTroops = (num < squadStorageCapacity);
            this.UpdateScreenElementVisibility();
            this.storageItemGrid.RepositionItems();
        }
        private void OnTroopRequestClicked(UXButton btn)
        {
            SquadController squadController  = Service.Get <SquadController>();
            uint            serverTime       = Service.Get <ServerAPI>().ServerTime;
            uint            troopRequestDate = squadController.StateManager.TroopRequestDate;
            bool            flag             = !SquadUtils.CanSendFreeTroopRequest(serverTime, troopRequestDate);
            string          text             = this.requestInputBox.Text;

            if (!Service.Get <ProfanityController>().IsValid(text, false))
            {
                AlertScreen.ShowModal(false, null, this.lang.Get("INVALID_TEXT", new object[0]), null, null);
                return;
            }
            if (flag)
            {
                squadController.ShowTroopRequestScreen(text, false);
                return;
            }
            squadController.SendTroopRequest(text, false);
        }
Ejemplo n.º 28
0
        public override OnCompleteAction OnFailure(uint status, object data)
        {
            if (SquadUtils.IsNotFatalServerError(status))
            {
                return(base.EatFailure(status, data));
            }
            string text = null;

            if (status == 2414u)
            {
                text = "WAR_ERROR_ENDED";
                Service.SquadController.WarManager.EndSquadWar();
            }
            if (text != null)
            {
                OnScreenModalResult onModalResult = new OnScreenModalResult(Service.UXController.HUD.OnSquadWarAttackResultCallback);
                AlertScreen.ShowModal(false, null, Service.Lang.Get(text, new object[0]), onModalResult, null);
                return(OnCompleteAction.Ok);
            }
            return(OnCompleteAction.Desync);
        }
        public override OnCompleteAction OnFailure(uint status, object data)
        {
            if (SquadUtils.IsNotFatalServerError(status))
            {
                return(base.EatFailure(status, data));
            }
            string text = null;

            switch (status)
            {
            case 2402u:
                text = "WAR_ERROR_BUFF_BASE_OWNED";
                break;

            case 2403u:
                text = "WAR_ERROR_BUFF_BASE_IN_BATTLE";
                break;

            case 2404u:
                text = "WAR_ERROR_OPPONENT_IN_BATTLE";
                break;

            default:
                if (status == 2414u)
                {
                    text = "WAR_ERROR_ENDED";
                    Service.Get <SquadController>().WarManager.EndSquadWar();
                }
                break;
            }
            if (text != null)
            {
                OnScreenModalResult onModalResult = new OnScreenModalResult(Service.Get <UXController>().HUD.OnSquadWarAttackResultCallback);
                AlertScreen.ShowModal(false, null, Service.Get <Lang>().Get(text, new object[0]), onModalResult, null);
                return(OnCompleteAction.Ok);
            }
            return(OnCompleteAction.Desync);
        }
Ejemplo n.º 30
0
        public override ISerializable FromObject(object obj)
        {
            Dictionary <string, object> dictionary = obj as Dictionary <string, object>;

            if (dictionary.ContainsKey("player"))
            {
                Dictionary <string, object> dictionary2 = dictionary["player"] as Dictionary <string, object>;
                this.Name = (dictionary2["name"] as string);
                if (dictionary2.ContainsKey("scalars"))
                {
                    Dictionary <string, object> dictionary3 = dictionary2["scalars"] as Dictionary <string, object>;
                    if (dictionary3.ContainsKey("attackRating"))
                    {
                        this.AttackRating = Convert.ToInt32(dictionary3["attackRating"], CultureInfo.InvariantCulture);
                    }
                    if (dictionary3.ContainsKey("defenseRating"))
                    {
                        this.DefenseRating = Convert.ToInt32(dictionary3["defenseRating"], CultureInfo.InvariantCulture);
                    }
                    if (dictionary3.ContainsKey("attacksWon"))
                    {
                        this.AttacksWon = Convert.ToInt32(dictionary3["attacksWon"], CultureInfo.InvariantCulture);
                    }
                    if (dictionary3.ContainsKey("defensesWon"))
                    {
                        this.DefensesWon = Convert.ToInt32(dictionary3["defensesWon"], CultureInfo.InvariantCulture);
                    }
                }
                if (dictionary2.ContainsKey("playerModel"))
                {
                    Dictionary <string, object> dictionary4 = dictionary2["playerModel"] as Dictionary <string, object>;
                    if (dictionary4.ContainsKey("map"))
                    {
                        this.MapData = new Map();
                        this.MapData.FromObject(dictionary4["map"]);
                        this.MapData.InitializePlanet();
                    }
                    Dictionary <string, object> dictionary5 = dictionary4["inventory"] as Dictionary <string, object>;
                    if (dictionary5.ContainsKey("capacity") && dictionary5["capacity"] != null)
                    {
                        this.InventoryData = new Inventory();
                        this.InventoryData.FromObject(dictionary4["inventory"]);
                    }
                    this.Faction = StringUtils.ParseEnum <FactionType>(dictionary4["faction"].ToString());
                    if (dictionary4.ContainsKey("guildInfo"))
                    {
                        Dictionary <string, object> dictionary6 = dictionary4["guildInfo"] as Dictionary <string, object>;
                        if (dictionary6 != null && dictionary6.ContainsKey("guildId"))
                        {
                            string squadID = dictionary6["guildId"] as string;
                            this.Squad = Service.Get <LeaderboardController>().GetOrCreateSquad(squadID);
                            this.Squad.FromVisitNeighborObject(dictionary6);
                        }
                    }
                    if (dictionary4.ContainsKey("donatedTroops"))
                    {
                        this.SquadTroops = SquadUtils.GetSquadDonatedTroopsFromObject(dictionary4["donatedTroops"]);
                    }
                    if (dictionary4.ContainsKey("upgrades"))
                    {
                        this.UpgradesData = new UnlockedLevelData();
                        this.UpgradesData.FromObject(dictionary4["upgrades"]);
                    }
                }
                return(this);
            }
            Service.Get <StaRTSLogger>().Error("Unable to parse response for neighbor.visit");
            return(null);
        }