public void StartClearingSelectedBuilding() { Entity selectedBuilding = this.buildingSelector.SelectedBuilding; BuildingTypeVO buildingType = selectedBuilding.Get <BuildingComponent>().BuildingType; if (buildingType.Type == BuildingType.Clearable) { int credits = buildingType.Credits; int materials = buildingType.Materials; int contraband = buildingType.Contraband; string text = StringUtils.ToLowerCaseUnderscoreSeperated(buildingType.Type.ToString()); StringBuilder stringBuilder = new StringBuilder(); stringBuilder.Append(text); stringBuilder.Append("|"); stringBuilder.Append(buildingType.BuildingID); stringBuilder.Append("|"); stringBuilder.Append(buildingType.SizeX * buildingType.SizeY); if (PayMeScreen.ShowIfNotEnoughCurrency(credits, materials, contraband, stringBuilder.ToString(), new OnScreenModalResult(this.OnPayMeForCurrencyResult))) { return; } if (PayMeScreen.ShowIfNoFreeDroids(new OnScreenModalResult(this.OnPayMeForDroidResult), selectedBuilding)) { return; } this.ConfirmClearingBuilding(selectedBuilding); } }
public void StartChampionRepair(SmartEntity building) { BuildingTypeVO buildingType = building.BuildingComp.BuildingType; this.repairChampionType = this.FindChampionTypeIfPlatform(buildingType); if (this.repairChampionType == null) { return; } int credits = this.repairChampionType.Credits; int materials = this.repairChampionType.Materials; int contraband = this.repairChampionType.Contraband; if (credits != 0 || materials != 0 || contraband != 0) { string purchaseContext = string.Format("{0}|{1}|{2}|{3}", new object[] { StringUtils.ToLowerCaseUnderscoreSeperated(this.repairChampionType.Type.ToString()), this.repairChampionType.TroopID, this.repairChampionType.Lvl, "repair" }); if (PayMeScreen.ShowIfNotEnoughCurrency(credits, materials, contraband, purchaseContext, new OnScreenModalResult(this.OnPayMeForCurrencyResult))) { return; } } if (PayMeScreen.ShowIfNoFreeDroids(new OnScreenModalResult(this.OnPayMeForDroidResult), null)) { return; } this.ConfirmRepair(); }
private void OnPayMeForCurrencyResult(object result, object cookie) { Entity selectedBuilding = this.buildingSelector.SelectedBuilding; if (GameUtils.HandleSoftCurrencyFlow(result, cookie) && !PayMeScreen.ShowIfNoFreeDroids(new OnScreenModalResult(this.OnPayMeForDroidResult), selectedBuilding)) { this.ConfirmClearingBuilding(selectedBuilding); } }
private void OnPayMeForCurrencyResult(object result, object cookie) { if (GameUtils.HandleSoftCurrencyFlow(result, cookie)) { if (!PayMeScreen.ShowIfNoFreeDroids(new OnScreenModalResult(this.OnPayMeForDroidResult), null)) { this.ConfirmRepair(); } } else { this.repairChampionType = null; } }
private void OnPayMeForCurrencyResult(object result, object cookie) { bool flag = GameUtils.HandleSoftCurrencyFlow(result, cookie); if (flag) { Entity selectedBuilding = this.buildingSelector.SelectedBuilding; BuildingTypeVO buildingType = selectedBuilding.Get <BuildingComponent>().BuildingType; if (buildingType.Type != BuildingType.DroidHut && PayMeScreen.ShowIfNoFreeDroids(new OnScreenModalResult(this.OnPayMeForDroidResult), null)) { return; } } UXController uXController = Service.UXController; uXController.HUD.ToggleExitEditModeButton(true); this.LowerLiftedBuilding((!flag) ? DropKind.CancelPurchase : DropKind.ConfirmPurchase, true, this.lifted, true, true); }
private void LowerLiftedBuilding(DropKind dropKind, bool affectBoard, bool sendLoweredEvent, bool playLoweredSound, bool showContextButtons) { SmartEntity selectedBuilding = this.buildingSelector.SelectedBuilding; if (selectedBuilding == null) { this.lifted = false; this.moved = false; return; } UXController uXController = Service.UXController; if (dropKind != DropKind.JustDrop) { uXController.MiscElementsManager.HideConfirmGroup(); } if (affectBoard && dropKind == DropKind.ConfirmPurchase) { BuildingTypeVO buildingType = selectedBuilding.BuildingComp.BuildingType; int credits = buildingType.Credits; int materials = buildingType.Materials; int contraband = buildingType.Contraband; string value = StringUtils.ToLowerCaseUnderscoreSeperated(buildingType.Type.ToString()); StringBuilder stringBuilder = new StringBuilder(); stringBuilder.Append(value); stringBuilder.Append("|"); stringBuilder.Append(buildingType.BuildingID); stringBuilder.Append("|"); stringBuilder.Append(buildingType.Lvl); if (PayMeScreen.ShowIfNotEnoughCurrency(credits, materials, contraband, stringBuilder.ToString(), new OnScreenModalResult(this.OnPayMeForCurrencyResult))) { return; } if (buildingType.Type != BuildingType.DroidHut && PayMeScreen.ShowIfNoFreeDroids(new OnScreenModalResult(this.OnPayMeForDroidResult), null)) { return; } if (buildingType.Type == BuildingType.NavigationCenter && buildingType.Lvl == 1) { Service.UXController.HUD.InitialNavigationCenterPlanetSelect(selectedBuilding, buildingType, new OnScreenModalResult(this.OnPickPlanetResult)); return; } } BuildingTypeVO buildingType2 = selectedBuilding.Get <BuildingComponent>().BuildingType; if (buildingType2.Time == 0 && dropKind != DropKind.JustDrop) { showContextButtons = false; } if (dropKind != DropKind.JustDrop) { uXController.HUD.ToggleExitEditModeButton(true); } this.canOccupy = this.EntireSelectionIsPlaceable(); if (!this.canOccupy) { this.LiftSelectedBuilding(selectedBuilding, false, false); int i = 0; int count = this.buildingSelector.AdditionalSelectedBuildings.Count; while (i < count) { this.LiftSelectedBuilding(this.buildingSelector.AdditionalSelectedBuildings[i], false, false); i++; } } bool flag = !this.LowerLiftedBuildingHelper(selectedBuilding, dropKind, affectBoard, sendLoweredEvent, playLoweredSound, showContextButtons, string.Empty); int j = 0; int count2 = this.buildingSelector.AdditionalSelectedBuildings.Count; while (j < count2) { this.LowerLiftedBuildingHelper(this.buildingSelector.AdditionalSelectedBuildings[j], dropKind, affectBoard, false, false, false, string.Empty); j++; } if (sendLoweredEvent) { for (int k = 0; k < this.buildingSelector.AdditionalSelectedBuildings.Count; k++) { Service.EventManager.SendEvent(EventId.UserLoweredBuilding, this.buildingSelector.AdditionalSelectedBuildings[k]); } Service.EventManager.SendEvent(EventId.UserLoweredBuilding, flag ? null : selectedBuilding); } if (affectBoard && dropKind == DropKind.JustDrop && this.ShouldSaveAfterEveryMove()) { BuildingMultiMoveRequest buildingMultiMoveRequest = new BuildingMultiMoveRequest(); buildingMultiMoveRequest.PositionMap = new PositionMap(); Position position = new Position(); position.X = selectedBuilding.Get <TransformComponent>().X; position.Z = selectedBuilding.Get <TransformComponent>().Z; buildingMultiMoveRequest.PositionMap.AddPosition(selectedBuilding.Get <BuildingComponent>().BuildingTO.Key, position); for (int l = 0; l < this.buildingSelector.AdditionalSelectedBuildings.Count; l++) { Entity entity = this.buildingSelector.AdditionalSelectedBuildings[l]; position = new Position(); position.X = entity.Get <TransformComponent>().X; position.Z = entity.Get <TransformComponent>().Z; buildingMultiMoveRequest.PositionMap.AddPosition(entity.Get <BuildingComponent>().BuildingTO.Key, position); } BuildingMultiMoveCommand command = new BuildingMultiMoveCommand(buildingMultiMoveRequest); Service.ServerAPI.Sync(command); } if (dropKind == DropKind.ConfirmPurchase || dropKind == DropKind.CancelPurchase) { Service.EventManager.SendEvent(EventId.BuildingPurchaseModeEnded, null); } }