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; } } }
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); }