public void adjustDevelopmentPriorityInLightOfPotential(Nation player) { if (player.getIP() < 1 && State.era == MyEnum.Era.Early) { if (PlayerCalculator.canMakeDevelopmentAction(player)) { PlayerPayer.payForDevelopmentAction(player, 1); player.addIP(2); } else { this.progressPriorities[MyEnum.progressPriorities.investment]++; } } if (player.getIP() < 2 && State.era != MyEnum.Era.Early) { if (PlayerCalculator.canMakeDevelopmentAction(player)) { PlayerPayer.payForDevelopmentAction(player, 1); player.addIP(2); } else { this.progressPriorities[MyEnum.progressPriorities.investment]++; } } }
private void updateSelfProvinceButtons(Nation player, assemblyCsharp.Province province) { if (PlayerCalculator.checkUpgradeDevelopment(province, player)) { upgradeDevelopment.interactable = true; } else { upgradeDevelopment.interactable = false; } if (PlayerCalculator.canUpgradeRailRoad(province, player)) { upgradeRailway.interactable = true; } else { upgradeRailway.interactable = false; } if (PlayerCalculator.canUpgradeFort(province, player)) { upgradeFort.interactable = true; } else { upgradeFort.interactable = false; } }
private static void manageCoalShortage(Nation player) { float deficit = Math.Abs(player.getNumberResource(MyEnum.Resources.coal)); player.decreasePrestige(1); player.setNumberResource(MyEnum.Resources.coal, 0); float totalCoalNeed = PlayerCalculator.coalNeededForRailRoads(player); int numRailRoads = (int)totalCoalNeed * 5; int numRailsNotWorking = (int)deficit*5; int count = Math.Min(numRailsNotWorking, numRailRoads); List<int> provs = player.getProvinces(); System.Random rnd = new System.Random(); for (int i = 0; i < count; i++) { bool flag = false; while(flag == false) { int r = rnd.Next(provs.Count); Province prov = State.getProvinces()[r]; if(prov.getDevelopmentLevel() >= 1) { flag = true; prov.addRailNotWorking(); } } } }
public void updateUI() { App app = UnityEngine.Object.FindObjectOfType <App>(); int playerIndex = app.GetHumanIndex(); Nation player = State.getNations()[playerIndex]; Debug.Log("Updating UI_______________"); turn.text = State.turn.ToString(); updateDevelopmentPanel(player); updateInventoryPanel(player); updateInformationPanel(player); if (ProductionPanel.activeSelf) { updateProductionPanel(player); } if (doctrineTab.activeSelf) { updateDoctrinePanel(player); } if (PlayerCalculator.canBuildTrain(player)) { addTrain.interactable = true; } else { addTrain.interactable = false; } }
public void FetchTechnology() { App app = UnityEngine.Object.FindObjectOfType <App>(); Nation player = State.getNations()[app.GetHumanIndex()]; string realName = transform.Find("TechName").GetComponent <Text>().text; string techName = thisTechButton.name; Technology tech = State.GetTechnologies()[techName]; TechName.text = realName; HiddenName.text = tech.GetTechName(); TechPrestige.text = "Prestige: " + tech.GetPrestige().ToString(); Payment.text = "Payment: " + tech.GetPayment().ToString(); TechCost.text = "Cost: " + tech.GetCost().ToString(); if (tech.GetDiscovered()) { Nation discoverer = State.getNations()[tech.GetDiscoveredBy()]; DiscoveredBy.text = discoverer.getName(); } else { DiscoveredBy.text = "None"; } string description = tech.GetDescription()[0] + Environment.NewLine + tech.GetDescription()[1] + Environment.NewLine + "Requirements: " + Environment.NewLine; foreach (string item in tech.GetPreRequisites()) { description = description + item + ","; } description = description + Environment.NewLine; description = description.Remove(description.Length - 1); techDescriptionText.text = description; TechImage.sprite = Resources.Load <Sprite>("TechImages/" + techName); if (PlayerCalculator.hasTechPreRequisites(player, techName) && PlayerCalculator.canAffordTech(player, techName)) { ResearchButton.interactable = true; // PressToResearch.text = "Press to \n Research"; } else if (player.GetTechnologies().Contains(techName)) { ResearchButton.interactable = false; // PressToResearch.text = "Already \n researched"; } else { Debug.Log("Cannot be researched"); ResearchButton.interactable = false; // PressToResearch.text = "Cannot \n research"; } }
public bool warOverRejection(Nation nation, Nation otherNation, Province prov) { int otherStrength = 0; int selfStrength = PlayerCalculator.CalculateArmyScore(nation); int roll = Random.Range(1, 100); if (State.mapUtilities.shareLandBorder(nation, otherNation)) { otherStrength = PlayerCalculator.CalculateArmyScore(otherNation); } else { otherStrength = PlayerCalculator.CalculateNavalProjection(otherNation); } if (selfStrength * 1.5 > otherStrength) { return(true); } else if (selfStrength * 1.33 > otherStrength) { if (roll < 60) { return(true); } else { return(false); } } else if (selfStrength * 1.25 > otherStrength) { if (roll < 35) { return(true); } else { return(false); } } else if (selfStrength * 1.15 > otherStrength) { if (roll < 20) { return(true); } else { return(false); } } return(false); }
private void changeTransportSlider() { App app = UnityEngine.Object.FindObjectOfType <App>(); Nation player = State.getNations()[app.GetHumanIndex()]; int oldFlow = PlayerCalculator.calculateTransportFlow(player); // int oldFlow = player.industry.getTransportFlow(); updateFlow(player); int newFlow = PlayerCalculator.calculateTransportFlow(player); //If slider was reduced new flow will be less than old flow - return coal to player int difference = Math.Abs(oldFlow - newFlow); int totalNumberOfProvinces = PlayerCalculator.getTotalNumberOfProvinces(player); // In case we reduced the flow if (newFlow < oldFlow) { if (oldFlow <= totalNumberOfProvinces) { // do nothing } else if (oldFlow > totalNumberOfProvinces) { if (newFlow >= totalNumberOfProvinces) { player.collectResource(MyEnum.Resources.coal, difference * 0.2f); } else { player.collectResource(MyEnum.Resources.coal, (oldFlow - totalNumberOfProvinces) * 0.2f); } } } else // The case where we have increased the amount of flow { if (newFlow <= totalNumberOfProvinces) { // do nothing } else if (newFlow > totalNumberOfProvinces) { // The case where we were already making use of some coal for transport if (oldFlow >= totalNumberOfProvinces) { player.consumeResource(MyEnum.Resources.coal, difference * 0.2f); } else { player.consumeResource(MyEnum.Resources.coal, (newFlow - player.getProvinces().Count) * 0.2f); } } } updateTransportPanel(); }
public float determineCanProduce(MyEnum.Goods good, Nation player) { Dictionary <string, float> costs = ProductionCosts.GetCosts(good); float bottleNeck = 1000f; float nextComponent = 0.0f; float ratio; float materialMod = DetermineMaterialMod(player); foreach (string item in costs.Keys) { if (Enum.IsDefined(typeof(MyEnum.Goods), item)) { MyEnum.Goods itemType = (MyEnum.Goods)System. Enum.Parse(typeof(MyEnum.Goods), item); nextComponent = player.getNumberGood(itemType) * materialMod; ratio = nextComponent / costs[item]; } else { MyEnum.Resources itemType = (MyEnum.Resources)System. Enum.Parse(typeof(MyEnum.Resources), item); nextComponent = player.getNumberResource(itemType) * materialMod; ratio = nextComponent / costs[item]; } if (ratio < bottleNeck) { bottleNeck = ratio; } } int value = 0; int factoryLevel = getFactoryLevel(good); if (factoryLevel == 0) { value = 0; } if (factoryLevel == 1) { value = (int)Math.Min(4, bottleNeck); } if (factoryLevel == 2) { value = (int)Math.Min(8, bottleNeck); } float corruptionFactor = PlayerCalculator.getCorruptionFactor(player); float industrialExpFactor = PlayerCalculator.getIndustrialExperienceFactor(player); /*Later additional modifiers will affect this including: * Corruptuon, happiness, management level, and perhaps some * technologies */ value = (int)(value * corruptionFactor * industrialExpFactor); return(value); }
public void drawRailRoadsFromScratch(Nation player) { HashSet <int> allProvinces = PlayerCalculator.getAllProvinces(player); foreach (int provIndex in allProvinces) { assemblyCsharp.Province prov = State.getProvinces()[provIndex]; if (prov.railroad) { drawRailroadOnMap(prov, player); } } }
public bool demandReferendum(Nation responder, Nation cracker, Province prov) { // sanity check: make sure responder and prov share same culture if (!responder.culture.Equals(cracker.culture)) { return(false); } responder.adjustRelation(cracker, -15); int relations = responder.Relations[cracker.getIndex()]; if (relations > 50) { return(false); } int selfStrength = 0; int otherStrength = PlayerCalculator.CalculateArmyScore(cracker); if (State.mapUtilities.shareLandBorder(responder, cracker)) { selfStrength = PlayerCalculator.CalculateArmyScore(responder); } else { selfStrength = PlayerCalculator.CalculateNavalProjection(responder); } if (selfStrength * 1 > otherStrength) { if (selfStrength * 1.2 < otherStrength) { int roll = Random.Range(1, 100); if (roll < 35) { return(true); } else { return(false); } } else { return(true); } } else { return(false); } }
private void updatePanel() { App app = UnityEngine.Object.FindObjectOfType <App>(); Nation player = State.getNations()[app.GetHumanIndex()]; currentResearchPoints.text = player.Research.ToString(); numberPattents.text = player.getPatents().Count.ToString(); researchLevel.text = player.getResearchLevel().ToString(); bool able = PlayerCalculator.canDoResearch(player); if (able) { conductResearch.interactable = true; } conductResearch.interactable = false; }
public static void payMaintenance(Nation player) { if(player.IsColonyOf() > -1) { return; } int population = (int)player.getTotalPOP(); float wheatNeeded = population * 0.1f; float meatNeeded = population * 0.05f; float fruitNeeded = population * 0.05f; player.consumeResource(MyEnum.Resources.wheat, wheatNeeded); player.consumeResource(MyEnum.Resources.meat, meatNeeded); player.consumeResource(MyEnum.Resources.fruit, fruitNeeded); float coalNeeded = PlayerCalculator.coalNeededForRailRoads(player); player.consumeResource(MyEnum.Resources.coal, coalNeeded); float oilNeeded = player.getOilNeeded(); player.consumeResource(MyEnum.Resources.oil, oilNeeded); if (player.getNumberResource(MyEnum.Resources.wheat) < 0) { manageFoodShortage(MyEnum.Resources.wheat, MyEnum.Resources.meat, MyEnum.Resources.fruit, player); } if (player.getNumberResource(MyEnum.Resources.meat) < 0) { manageFoodShortage(MyEnum.Resources.meat, MyEnum.Resources.wheat, MyEnum.Resources.fruit, player); } if (player.getNumberResource(MyEnum.Resources.fruit) < 0) { manageFoodShortage(MyEnum.Resources.fruit, MyEnum.Resources.meat, MyEnum.Resources.wheat, player); } if(player.getNumberResource(MyEnum.Resources.coal) < 0) { manageCoalShortage(player); } if(player.getNumberResource(MyEnum.Resources.oil) < 0) { manageOilShortage(player); } player.ChangeCorruption(0.1f); }
private void updateDevelopmentPanel(Nation player) { currentAP.text = player.getAP().ToString(); currentPP.text = player.getDP().ToString(); currentResearch.text = player.Research.ToString(); currentInvestment.text = player.IP.ToString(); currentStability.text = player.Stability.ToString(); if (PlayerCalculator.canAddAP(player)) { addAPButton.interactable = true; } else { addAPButton.interactable = false; } if (PlayerCalculator.canAddDP(player)) { addDPButton.interactable = true; } else { addDPButton.interactable = false; } if (PlayerCalculator.canMakeDevelopmentAction(player) == true) { Debug.Log("Can Make Development Action"); fundResearch.interactable = true; fundCulture.interactable = true; capitalInvestment.interactable = true; increaseStability.interactable = true; } else { Debug.Log("Cannot Make Development Action"); fundResearch.interactable = false; fundCulture.interactable = false; capitalInvestment.interactable = false; increaseStability.interactable = false; } }
public void drawRailroadOnMap(assemblyCsharp.Province prov, Nation player) { WorldMapStrategyKit.Province mapProvince = map.provinces[prov.getIndex()]; Vector2 provCenter = mapProvince.center; for (int i = 0; i < prov.Neighbours.Count; i++) { if (PlayerCalculator.getAllProvinces(player).Contains(prov.Neighbours[i])) { // draw rail segment from prv to neighbourProv assemblyCsharp.Province neighbourProvince = State.getProvinces()[prov.Neighbours[i]]; if (neighbourProvince.railroad && !neighbourProvince.Linked.Contains(prov.getIndex()) && !prov.Linked.Contains(neighbourProvince.getIndex())) { WorldMapStrategyKit.Province mapNeighbourProvince = map.provinces[prov.Neighbours[i]]; Vector2 neighbourCenter = mapNeighbourProvince.center; Cell startCell = map.GetCell(provCenter); Cell endCell = map.GetCell(neighbourCenter); List <int> cellIndices = map.FindRoute(startCell, endCell, TERRAIN_CAPABILITY.OnlyGround); if (cellIndices == null) { return; } int positionsCount = cellIndices.Count; Debug.Log("Number of positions: " + positionsCount); Vector2[] positions = new Vector2[positionsCount]; for (int k = 0; k < positionsCount; k++) { positions[k] = map.cells[cellIndices[k]].center; } // Build a railroad along the map coordinates LineMarkerAnimator lma = map.AddLine(positions, Color.white, 0.0f, 0.15f); Texture2D railwayMatt = Resources.Load("Sprites/GUI/railRoad", typeof(Texture2D)) as Texture2D; lma.lineMaterial.mainTexture = railwayMatt; lma.lineMaterial.mainTextureScale = new Vector2(16f, 2f); neighbourProvince.Linked.Add(prov.getIndex()); prov.Linked.Add(neighbourProvince.getIndex()); } } } }
private void updatePanel() { App app = UnityEngine.Object.FindObjectOfType <App>(); Nation player = State.getNations()[app.GetHumanIndex()]; string numCards = player.getCultureCards().Count.ToString(); // numberCultureCards.text = numCards; cultureLevel.text = player.getCulureLevel().ToString(); bool able = PlayerCalculator.canGetCulture(player); if (able) { drawCultureCard.interactable = true; } else { drawCultureCard.interactable = false; } }
public int determineCreditLimit(Nation player) { float assetsToDeptFactor = 2f; if (player.Bankrupt == true) { assetsToDeptFactor = 1f; } int baseAssets = PlayerCalculator.caclulateBaseAssets(player); int amount = (int)(baseAssets * assetsToDeptFactor / bondSize); if (amount < 1) { return(1); } else { return(amount); } }
private void updateInventoryPanel() { App app = UnityEngine.Object.FindObjectOfType <App>(); int playerIndex = app.GetHumanIndex(); Nation player = State.getNations()[playerIndex]; if (PlayerCalculator.canUpgradeWarehouse(player)) { expandWarehouseButton.interactable = true; } else { expandWarehouseButton.interactable = false; } storageCapacity.text = player.numberOfResourcesAndGoods().ToString() + "/" + player.GetCurrentWarehouseCapacity().ToString(); int numResources = 11; Transform storage = inventoryContent.GetComponent <Transform>(); for (int i = 0; i < numResources; i++) { string name = storage.GetChild(i).name; MyEnum.Resources res = (MyEnum.Resources)System.Enum.Parse(typeof(MyEnum.Resources), name); Text amount = storage.GetChild(i).GetComponentInChildren <Text>(); amount.text = player.getNumberResource(res).ToString(); } int beginGoods = 11; int endOfStoragePanel = 23; for (int i = beginGoods; i < endOfStoragePanel; i++) { string name = storage.GetChild(i).name; MyEnum.Goods good = (MyEnum.Goods)System. Enum.Parse(typeof(MyEnum.Goods), name); Text amount = storage.GetChild(i).GetComponentInChildren <Text>(); amount.text = player.getNumberGood(good).ToString(); } }
public void controlToolTip() { toolTipTrigger = this.GetComponent <TooltipTrigger>(); Debug.Log("Mouse Over Here"); Debug.Log(toolTipTrigger.name); App app = UnityEngine.Object.FindObjectOfType <App>(); int playerIndex = app.GetHumanIndex(); Nation player = State.getNations()[playerIndex]; if (PlayerCalculator.canAddDP(player)) { toolTipTrigger.SetText("BodyText", "Press to gain more Development Points (DP)"); } else { string message = "You requre "; if (player.getNumberResource(MyEnum.Resources.spice) < 1) { message += " 1 more spice "; } if (player.getNumberGood(MyEnum.Goods.paper) < 1) { message += " 1 more paper "; } if (player.getNumberGood(MyEnum.Goods.furniture) < 1) { message += " 1 more furniture "; } // StringBuilder requirements = new StringBuilder(); message += "."; toolTipTrigger.SetText("BodyText", message); } }
private void updateDoctrinePanel(Nation player) { int rowIndex = 0; LandForces landForces = player.landForces; foreach (MyEnum.ArmyDoctrines doctrine in Enum.GetValues(typeof(MyEnum.ArmyDoctrines))) { TableRow row = doctrineTable.Rows[rowIndex]; Button addButton = row.Cells[3].GetComponentInChildren <Button>(); if (landForces.hasDoctrine(doctrine)) { Toggle toggle = row.GetComponentInChildren <Toggle>(); toggle.isOn = true; addButton.interactable = false; } if (PlayerCalculator.canMakeDevelopmentAction(player) == false) { addButton.interactable = false; } rowIndex++; } }
void CreateTable() { App app = UnityEngine.Object.FindObjectOfType <App>(); int playerIndex = app.GetHumanIndex(); Debug.Log(playerIndex); Nation player = State.getNations()[playerIndex]; Market market = State.market; tableLayout.ClearRows(); int turn = State.turn; High.interactable = false; Medium.interactable = false; Low.interactable = false; plus.interactable = false; minus.interactable = false; foreach (MyEnum.Resources resource in Enum.GetValues(typeof(MyEnum.Resources))) { if (resource == MyEnum.Resources.gold) { continue; } if (resource == MyEnum.Resources.rubber && !player.GetTechnologies().Contains("electricity")) { continue; } if (resource == MyEnum.Resources.oil && !player.GetTechnologies().Contains("oil_drilling")) { continue; } TableRow newRow = Instantiate <TableRow>(testRow); // var fieldGameObject = new GameObject("Field", typeof(RectTransform)); newRow.gameObject.SetActive(true); newRow.preferredHeight = 30; newRow.name = resource.ToString(); tableLayout.AddRow(newRow); scrollviewContent.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, (tableLayout.transform as RectTransform).rect.height); Transform res = newRow.Cells[0].transform.GetChild(0); Image resImg = res.GetComponent <Image>(); resImg.preserveAspect = true; resImg.sprite = Resources.Load("Resource/" + resource.ToString(), typeof(Sprite)) as Sprite; Text resText = newRow.Cells[0].GetComponentInChildren <Text>(); resText.text = resource.ToString(); //newRow.Cells[0].GetComponentInChildren<Image>().sprite = Resources.Load("Resource/" + resource.ToString(), typeof(Sprite)) as Sprite; newRow.Cells[1].GetComponentInChildren <Text>().text = player.getNumberResource(resource).ToString(); if (turn == 1) { newRow.Cells[2].GetComponentInChildren <Text>().text = "3"; } else { newRow.Cells[2].GetComponentInChildren <Text>().text = market.getPriceOfResource(resource).ToString(); } Transform chg = newRow.Cells[3].transform.GetChild(0); Image chgImg = chg.GetComponent <Image>(); Text chgText = newRow.Cells[3].GetComponentInChildren <Text>(); chgText.text = "flat"; chgImg.preserveAspect = true; if (turn < 2) { chgImg.sprite = Resources.Load("Sprites/flat", typeof(Sprite)) as Sprite; } else { float currentTurnPrice = market.getPriceOfResource(resource); float lastTurnPrice = market.getResourcePriceHistory(resource)[State.turn - 1]; if (currentTurnPrice > lastTurnPrice) { chgImg.sprite = Resources.Load("Sprites/greenUp", typeof(Sprite)) as Sprite; chgText.text = "up"; } else if (currentTurnPrice < lastTurnPrice) { chgImg.sprite = Resources.Load("Sprites/redDown", typeof(Sprite)) as Sprite; chgText.text = "down"; } } float producing = PlayerCalculator.getResourceProducing(player, resource); newRow.Cells[4].GetComponentInChildren <Text>().text = producing.ToString("F2"); } foreach (MyEnum.Goods good in Enum.GetValues(typeof(MyEnum.Goods))) { if (good == MyEnum.Goods.chemicals && !player.GetTechnologies().Contains("chemistry")) { continue; } if (good == MyEnum.Goods.gear && !player.GetTechnologies().Contains("electricity")) { continue; } if (good == MyEnum.Goods.telephone && !player.GetTechnologies().Contains("telephone")) { continue; } if (good == MyEnum.Goods.auto && !player.GetTechnologies().Contains("automobile")) { continue; } if (good == MyEnum.Goods.fighter && !player.GetTechnologies().Contains("flight")) { continue; } if (good == MyEnum.Goods.tank && !player.GetTechnologies().Contains("mobile_warfare")) { continue; } TableRow newRow = Instantiate <TableRow>(testRow); newRow.gameObject.SetActive(true); newRow.preferredHeight = 30; newRow.name = good.ToString(); tableLayout.AddRow(newRow); scrollviewContent.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, (tableLayout.transform as RectTransform).rect.height); List <TableCell> cells = newRow.Cells; Transform res = newRow.Cells[0].transform.GetChild(0); Image resImg = res.GetComponent <Image>(); resImg.preserveAspect = true; resImg.sprite = Resources.Load("FinishedGoods/" + good.ToString(), typeof(Sprite)) as Sprite; newRow.Cells[1].GetComponentInChildren <Text>().text = player.getNumberGood(good).ToString(); if (turn == 1) { newRow.Cells[2].GetComponentInChildren <Text>().text = "5"; } else { newRow.Cells[2].GetComponentInChildren <Text>().text = market.getPriceOfGood(good).ToString(); } Transform chg = newRow.Cells[3].transform.GetChild(0); Image chgImg = chg.GetComponent <Image>(); chgImg.preserveAspect = true; if (turn < 2) { chgImg.sprite = Resources.Load("Sprites/flat", typeof(Sprite)) as Sprite; } else { float currentTurnPrice = market.getPriceOfGood(good); float lastTurnPrice = market.getGoodPriceHistory(good)[turn - 1]; if (currentTurnPrice > lastTurnPrice) { chgImg.sprite = Resources.Load("Sprites/greenUp", typeof(Sprite)) as Sprite; } else if (currentTurnPrice < lastTurnPrice) { chgImg.sprite = Resources.Load("Sprites/redDown", typeof(Sprite)) as Sprite; } } float producing = player.industry.getGoodProducing(good); newRow.Cells[4].GetComponentInChildren <Text>().text = producing.ToString(); } itemImage.sprite = Resources.Load("Resources/" + currentItem, typeof(Sprite)) as Sprite; if (State.turn > 1) { offeredLastTurn.text = "Offered Last Turn: " + market.getNumberOfResourcesOffered(MyEnum.Resources.wheat).ToString(); soldLastTurn.text = "Sold Last Turn: " + market.getNumberResourcesSold(MyEnum.Resources.wheat).ToString(); priceHistory = market.getResourcePriceHistory(MyEnum.Resources.wheat); } else { offeredLastTurn.text = "Offered Last Turn: 0"; soldLastTurn.text = "Sold Last Turn: 0"; } }
public int getNavelProjection(Nation player) { int capacity = getNavalUnitCapacity(player); float strength = 0; float infantryMod = 0.6f; float cavalryMod = 0.75f; float fighterMod = 1.0f; if (player.GetTechnologies().Contains("flintlock")) { infantryMod = 1f; cavalryMod = 1.1f; } if (player.GetTechnologies().Contains("breech_loaded_arms")) { infantryMod = 1.2f; cavalryMod = 1.2f; } if (player.GetTechnologies().Contains("machine_guns")) { infantryMod = 1.5f; cavalryMod = 1.3f; } if (player.GetTechnologies().Contains("bolt_action_rifles")) { infantryMod = 1.8f; cavalryMod = 1.4f; } float artMod = 1.0f; float tankMod = 2.0f; if (player.GetTechnologies().Contains("breech_loaded_arms")) { artMod = 1.15f; } if (player.GetTechnologies().Contains("indirect_fire")) { artMod = 1.45f; } if (player.GetTechnologies().Contains("heavy_armament")) { artMod = 1.8f; tankMod = 1.22f; } if (player.GetTechnologies().Contains("bombers")) { fighterMod = 1.25f; } if (player.GetTechnologies().Contains("radar")) { fighterMod = 1.5f; } int numInf = PlayerCalculator.getTotalNumberInfantry(player); int numCav = PlayerCalculator.getTotalNumberCavalry(player); int numArt = PlayerCalculator.getTotalNumberArtillery(player); int numTank = PlayerCalculator.getTotalNumberTanks(player); int numFighter = PlayerCalculator.getTotalNumberFighters(player); strength += fighterMod * 2.8f * numFighter; for (int i = 0; i < numInf; i++) { strength += infantryMod; capacity -= 1; if (capacity < 1) { return((int)strength); } } for (int i = 0; i < numTank; i++) { strength += tankMod * 3.5f; capacity -= 3; if (capacity < 1) { return((int)strength); } } for (int i = 0; i < numArt; i++) { strength += artMod * 1.33f; capacity -= 2; if (capacity < 1) { return((int)strength); } } for (int i = 0; i < numArt; i++) { strength += cavalryMod * 1.22f; capacity -= 2; if (capacity < 1) { return((int)strength); } } return((int)strength); }
private void showCheatSheet() { cheatSheetPanel.SetActive(true); // int otherIndex = Int32.Parse(SelectionButton.transform.parent.parent.name); //State.setCurrentSelectedNationDiplomacy(otherIndex); Nation chosenNation = State.getNations()[State.getCurrentSlectedNationDiplomacy()]; nationName.text = chosenNation.nationName.ToString(); AP.text = chosenNation.getAP().ToString(); PP.text = chosenNation.getDP().ToString(); IP.text = chosenNation.getIP().ToString(); railroads.text = PlayerCalculator.getNumberProvRailRoads(chosenNation).ToString(); trains.text = chosenNation.industry.getNumberOfTrains().ToString(); units.text = chosenNation.landForces.Strength.ToString(); numberProvDevelopments.text = PlayerCalculator.getNumberProvDevelopments(chosenNation).ToString(); shipyard.text = chosenNation.GetShipyardLevel().ToString(); fort.text = chosenNation.getFortLevel().ToString(); warehouse.text = chosenNation.GetCurrentWarehouseCapacity().ToString(); colonialPoints.text = chosenNation.ColonialPoints.ToString(); infulencePoints.text = chosenNation.InfulencePoints.ToString(); wheat.text = chosenNation.getNumberResource(MyEnum.Resources.wheat).ToString("0,0"); meat.text = chosenNation.getNumberResource(MyEnum.Resources.meat).ToString("0,0"); fruit.text = chosenNation.getNumberResource(MyEnum.Resources.fruit).ToString("0,0"); iron.text = chosenNation.getNumberResource(MyEnum.Resources.iron).ToString("0,0"); cotton.text = chosenNation.getNumberResource(MyEnum.Resources.cotton).ToString("0,0");; wood.text = chosenNation.getNumberResource(MyEnum.Resources.wood).ToString("0,0"); coal.text = chosenNation.getNumberResource(MyEnum.Resources.coal).ToString("0,0"); spice.text = chosenNation.getNumberResource(MyEnum.Resources.spice).ToString("0,0"); dyes.text = chosenNation.getNumberResource(MyEnum.Resources.dyes).ToString("0,0"); rubber.text = chosenNation.getNumberResource(MyEnum.Resources.rubber).ToString("0,0"); oil.text = chosenNation.getNumberResource(MyEnum.Resources.oil).ToString("0,0"); steel.text = chosenNation.getNumberGood(MyEnum.Goods.steel).ToString("0,0"); lumber.text = chosenNation.getNumberGood(MyEnum.Goods.lumber).ToString("0,0"); fabric.text = chosenNation.getNumberGood(MyEnum.Goods.fabric).ToString("0,0"); parts.text = chosenNation.getNumberGood(MyEnum.Goods.parts).ToString("0,0"); arms.text = chosenNation.getNumberGood(MyEnum.Goods.arms).ToString("0,0"); clothing.text = chosenNation.getNumberGood(MyEnum.Goods.clothing).ToString("0,0"); furniture.text = chosenNation.getNumberGood(MyEnum.Goods.furniture).ToString("0,0"); paper.text = chosenNation.getNumberGood(MyEnum.Goods.paper).ToString("0,0"); chemicals.text = chosenNation.getNumberGood(MyEnum.Goods.chemicals).ToString("0,0"); telephone.text = chosenNation.getNumberGood(MyEnum.Goods.telephone).ToString("0,0"); auto.text = chosenNation.getNumberGood(MyEnum.Goods.auto).ToString("0,0"); gear.text = chosenNation.getNumberGood(MyEnum.Goods.gear).ToString("0.0"); AdminAI admin = chosenNation.getAI().GetAdmin(); ap_adds.text = admin.ApAdds.ToString(); pp_adds.text = admin.PpAdds.ToString(); ip_adds.text = admin.IpAdds.ToString(); rp_adds.text = admin.IpAdds.ToString(); turns.text = chosenNation.getAI().numberOfTurns.ToString(); WorldBank bank = State.bank; int chosenNationIndex = chosenNation.getIndex(); int bondSize = bank.BondSize; savings.text = (bank.getDeposits(chosenNation) * bondSize).ToString(); debt.text = (bank.getDebt(chosenNation) * bondSize).ToString(); }
private void UpdateNavyTable() { App app = UnityEngine.Object.FindObjectOfType <App>(); Nation player = State.getNations()[app.GetHumanIndex()]; MilitaryForm militaryForm = player.GetMilitaryForm(); Text frigateAttack = navyTable.Rows[1].Cells[1].GetComponentInChildren <Text>(); Debug.Log("frigate attack " + militaryForm.frigate.Attack.ToString()); frigateAttack.text = militaryForm.frigate.Attack.ToString(); Text ironcladAttack = navyTable.Rows[1].Cells[2].GetComponentInChildren <Text>(); ironcladAttack.text = militaryForm.ironclad.Attack.ToString(); Text dreadnoughtAttack = navyTable.Rows[1].Cells[3].GetComponentInChildren <Text>(); dreadnoughtAttack.text = militaryForm.dreadnought.Attack.ToString(); Text frigateMaxStrength = navyTable.Rows[2].Cells[1].GetComponentInChildren <Text>(); frigateMaxStrength.text = militaryForm.frigate.GetStrength().ToString(); Text ironcladMaxStrength = navyTable.Rows[2].Cells[2].GetComponentInChildren <Text>(); ironcladMaxStrength.text = militaryForm.ironclad.GetStrength().ToString(); Text dreadnoughtMaxStrength = navyTable.Rows[2].Cells[3].GetComponentInChildren <Text>(); dreadnoughtMaxStrength.text = militaryForm.dreadnought.GetStrength().ToString(); Text frigateMan = navyTable.Rows[3].Cells[1].GetComponentInChildren <Text>(); frigateMan.text = militaryForm.frigate.Maneuver.ToString(); Text ironcladMan = navyTable.Rows[3].Cells[2].GetComponentInChildren <Text>(); ironcladMan.text = militaryForm.ironclad.Maneuver.ToString(); Text dreadnoughtMan = navyTable.Rows[3].Cells[3].GetComponentInChildren <Text>(); dreadnoughtMan.text = militaryForm.dreadnought.Maneuver.ToString(); Text frigateAmmo = navyTable.Rows[4].Cells[1].GetComponentInChildren <Text>(); frigateAmmo.text = militaryForm.frigate.AmmoUse.ToString(); Text ironcladAmmo = navyTable.Rows[4].Cells[2].GetComponentInChildren <Text>(); ironcladAmmo.text = militaryForm.ironclad.AmmoUse.ToString(); Text dreadnoughtAmmo = navyTable.Rows[4].Cells[3].GetComponentInChildren <Text>(); dreadnoughtAmmo.text = militaryForm.dreadnought.AmmoUse.ToString(); Text frigateOil = navyTable.Rows[5].Cells[1].GetComponentInChildren <Text>(); frigateOil.text = militaryForm.frigate.OilUse.ToString(); Text ironcladOil = navyTable.Rows[5].Cells[2].GetComponentInChildren <Text>(); ironcladOil.text = militaryForm.ironclad.OilUse.ToString(); Text dreadnoughtOil = navyTable.Rows[5].Cells[3].GetComponentInChildren <Text>(); dreadnoughtOil.text = militaryForm.dreadnought.OilUse.ToString(); Text frigateCap = navyTable.Rows[6].Cells[1].GetComponentInChildren <Text>(); frigateCap.text = militaryForm.frigate.Capacity.ToString(); Text ironcladCap = navyTable.Rows[6].Cells[2].GetComponentInChildren <Text>(); ironcladCap.text = militaryForm.ironclad.Capacity.ToString(); Text dreadnoughtCap = navyTable.Rows[6].Cells[3].GetComponentInChildren <Text>(); dreadnoughtCap.text = militaryForm.dreadnought.Capacity.ToString(); Text frigateMov = navyTable.Rows[7].Cells[1].GetComponentInChildren <Text>(); frigateMov.text = militaryForm.frigate.Movement.ToString(); Text ironcladMov = navyTable.Rows[7].Cells[2].GetComponentInChildren <Text>(); ironcladMov.text = militaryForm.ironclad.Movement.ToString(); Text dreadnoughtMov = navyTable.Rows[7].Cells[3].GetComponentInChildren <Text>(); dreadnoughtMov.text = militaryForm.dreadnought.Movement.ToString(); Text NumFrig = navyTable.Rows[9].Cells[1].GetComponentInChildren <Text>(); Text NumIC = navyTable.Rows[9].Cells[2].GetComponentInChildren <Text>(); Text NumDN = navyTable.Rows[9].Cells[3].GetComponentInChildren <Text>(); float frigCount = 0; float ICCount = 0; float DNCount = 0; for (int i = 0; i < player.GetFleets().Count; i++) { frigCount += player.GetFleet(i).GetFrigate(); ICCount += player.GetFleet(i).GetIronClad(); DNCount += player.GetFleet(i).GetDreadnought(); } NumFrig.text = frigCount.ToString(); NumIC.text = ICCount.ToString(); NumDN.text = DNCount.ToString(); Text recFrig = navyTable.Rows[10].Cells[1].GetComponentInChildren <Text>(); Text recIC = navyTable.Rows[10].Cells[2].GetComponentInChildren <Text>(); Text recDN = navyTable.Rows[10].Cells[3].GetComponentInChildren <Text>(); recFrig.text = player.getNavyProducing(MyEnum.NavyUnits.frigates).ToString(); recIC.text = player.getNavyProducing(MyEnum.NavyUnits.ironclad).ToString(); recDN.text = player.getNavyProducing(MyEnum.NavyUnits.dreadnought).ToString(); Button recruitFrigateButton = navyTable.Rows[11].Cells[1].GetComponentInChildren <Button>(); if (PlayerCalculator.canBuildFrigate(player)) { recruitFrigateButton.interactable = true; } else { recruitFrigateButton.interactable = false; } Button recruitIroncladButton = navyTable.Rows[11].Cells[2].GetComponentInChildren <Button>(); if (PlayerCalculator.canBuildIronclad(player)) { recruitIroncladButton.interactable = true; } else { recruitIroncladButton.interactable = false; } Button recruitDreadnoughtButton = navyTable.Rows[11].Cells[3].GetComponentInChildren <Button>(); if (PlayerCalculator.canBuildDreadnought(player)) { recruitDreadnoughtButton.interactable = true; } else { upgradeShipyard.interactable = false; } TextMeshProUGUI _shipyardLevel = shipyardLevel.GetComponent <TextMeshProUGUI>(); _shipyardLevel.SetText("Shipyard Level: " + player.GetShipyardLevel().ToString()); if (PlayerCalculator.canUpgradeShipyard(player) == true) { upgradeShipyard.interactable = true; } else { upgradeShipyard.interactable = false; } }
public void UpdateDevelopmentPriorities(Nation player) { AdminAI admin = player.getAI().GetAdmin(); int turn = State.turn; int numFactories = PlayerCalculator.getNumberOfFactories(player); // int d = 5 - this.metaProgressPriorities[MyEnum.progressPriorities.investment]; int possFact = admin.getPotentialFactoryUpgradeOptions(player).Count; if (possFact > 0) { adjustDevelopmentPriorityInLightOfPotential(player); } else { this.developmentPriorities[MyEnum.developmentPriorities.buildFactory]--; } if (numFactories / turn > 5 && possFact > 0) { this.developmentPriorities[MyEnum.developmentPriorities.buildFactory]++; this.metaPriorities[MyEnum.metaPriorities.development]++; } int provDevOpts = admin.getProviceDevelopmentOptions(player).Count; if (provDevOpts > 0) { adjustDevelopmentPriorityInLightOfPotential(player); this.developmentPriorities[MyEnum.developmentPriorities.developProvince]++; this.metaPriorities[MyEnum.metaPriorities.development]++; if (this.topPriority == MyEnum.staticPriorities.industry) { this.developmentPriorities[MyEnum.developmentPriorities.developProvince]++; } else if (this.secondPriory == MyEnum.staticPriorities.industry) { this.developmentPriorities[MyEnum.developmentPriorities.developProvince]++; } } else { this.developmentPriorities[MyEnum.developmentPriorities.developProvince]--; } if (PlayerCalculator.canUpgradeFort(player)) { { this.developmentPriorities[MyEnum.developmentPriorities.fortification]++; this.metaPriorities[MyEnum.metaPriorities.development]++; } } else { this.developmentPriorities[MyEnum.developmentPriorities.fortification]--; } if (player.GetTechnologies().Contains("steam_locomotive")) { adjustDevelopmentPriorityInLightOfPotential(player); int numberRailroads = PlayerCalculator.getNumberProvRailRoads(player); if (numberRailroads < (player.getProvinces().Count + player.getColonies().Count)) { this.metaPriorities[MyEnum.metaPriorities.development]++; } { this.developmentPriorities[MyEnum.developmentPriorities.railroad]++; if (this.topPriority == MyEnum.staticPriorities.industry) { this.developmentPriorities[MyEnum.developmentPriorities.railroad]++; } else if (this.secondPriory == MyEnum.staticPriorities.industry) { this.developmentPriorities[MyEnum.developmentPriorities.railroad]++; } } } if (PlayerCalculator.canUpgradeShipyard(player)) { this.developmentPriorities[MyEnum.developmentPriorities.shipyard]++; if (this.topPriority == MyEnum.staticPriorities.colonies) { this.developmentPriorities[MyEnum.developmentPriorities.shipyard]++; } } if ((PlayerCalculator.calculateTotalResourceProduction(player) - (player.getProvinces().Count + player.getColonies().Count)) > player.industry.getNumberOfTrains()) { this.developmentPriorities[MyEnum.developmentPriorities.trains]++; if (this.topPriority == MyEnum.staticPriorities.industry) { this.developmentPriorities[MyEnum.developmentPriorities.trains]++; } else if (this.secondPriory == MyEnum.staticPriorities.industry) { this.developmentPriorities[MyEnum.developmentPriorities.trains]++; } } if (player.numberOfResourcesAndGoods() + PlayerCalculator.calculateTotalResourceProduction(player) > player.GetCurrentWarehouseCapacity()) { this.developmentPriorities[MyEnum.developmentPriorities.warehouse] += 3; } else { this.developmentPriorities[MyEnum.developmentPriorities.warehouse]--; } }
public bool acceptRefDemand(Nation owner, Nation demander, Province prov) { Debug.Log("Will AI accept refferendum demand?"); int roll = Random.Range(0, 100); Debug.Log(roll); int otherStrength = 0; int selfStrength = PlayerCalculator.CalculateArmyScore(owner); Debug.Log("Self strength: " + selfStrength); if (State.mapUtilities.shareLandBorder(owner, demander)) { Debug.Log("By land"); otherStrength = PlayerCalculator.CalculateArmyScore(demander); } else { Debug.Log("By sea"); otherStrength = PlayerCalculator.CalculateNavalProjection(demander); } Debug.Log("Other strength: " + otherStrength); if (otherStrength < selfStrength * 1.15) { Debug.Log("Here"); return(false); } else if (otherStrength < selfStrength * 1.25) { Debug.Log("Here"); if (roll < 50) { return(false); } else { return(true); } } else if (otherStrength < selfStrength * 1.35) { Debug.Log("Here"); if (roll < 25) { return(false); } else { return(true); } } else { Debug.Log("Here"); return(true); } }
public void standardProvinceResponse(Nation nation, Province prov, int otherNationIndex, int minorNationIndex) { Debug.Log("Standard Province Response"); App app = UnityEngine.Object.FindObjectOfType <App>(); int humanIndex = app.GetHumanIndex(); Nation human = State.getNations()[humanIndex]; int numberOfDisruptedProvinces = PlayerCalculator.getNumberOfDisrputedProvinces(nation); EventRegister eventLogic = State.eventRegister; // if (numberOfDisruptedProvinces > 0) // { if (otherNationIndex > -1) { Debug.Log("Crack down"); Nation otherNation = State.getNation(otherNationIndex); //crack down on riots nation.InfulencePoints--; prov.adjustDiscontentment(1); nation.adjustRelation(otherNation, -10); if (otherNationIndex == humanIndex) { DecisionEvent newEvent = new DecisionEvent(); if (minorNationIndex == -1) { eventLogic.initalizeInformedOfCrackdownEvent(newEvent, human, nation, prov); } else { eventLogic.initalizeInformedOfCrackdownEvent(newEvent, human, nation, prov, minorNationIndex); } eventLogic.DecisionEvents.Enqueue(newEvent); } } // } else { int roll = Random.Range(1, 100); Debug.Log("Roll: " + roll); if (roll < 50) { nation.InfulencePoints--; prov.adjustDiscontentment(1); if (otherNationIndex > -1) { Nation otherNation = State.getNation(otherNationIndex); //crack down on riots nation.InfulencePoints--; prov.adjustDiscontentment(1); nation.adjustRelation(otherNation, -10); if (otherNationIndex == humanIndex) { DecisionEvent newEvent = new DecisionEvent(); if (minorNationIndex == -1) { eventLogic.initalizeInformedOfCrackdownEvent(newEvent, human, nation, prov); } else { eventLogic.initalizeInformedOfCrackdownEvent(newEvent, human, nation, prov, minorNationIndex); } eventLogic.DecisionEvents.Enqueue(newEvent); } } } else { prov.setRioting(true); } } }
public void respondToProvinceRiots(Nation nation, Province prov) { Debug.Log("Respond to Province Riots"); int numberOfDisruptedProvinces = PlayerCalculator.getNumberOfDisrputedProvinces(nation); bool sameCulture = true; int nationWithSameCulture = nation.getIndex(); EventRegister eventLogic = State.eventRegister; App app = UnityEngine.Object.FindObjectOfType <App>(); int humanIndex = app.GetHumanIndex(); Nation human = State.getNations()[humanIndex]; if (!nation.culture.Equals(prov.getCulture())) { sameCulture = false; nationWithSameCulture = Utilities.findNationWithThisCulture(prov.getCulture()); } if (prov.isColony) { if (nation.GetColonialPoints() > 0) { //crack down on riots nation.SpendColonialPoints(1); } else { prov.setRioting(true); } } else if (!prov.isColony) { if (sameCulture) { if (nation.InfulencePoints > 0) { standardProvinceResponse(nation, prov, -1, -1); } else { prov.setRioting(true); } } // Now consider cases where the prov is not a colony and does not share the same culture as its owner else if (!prov.isColony && !sameCulture) { if (nation.InfulencePoints > 0) { Debug.Log("Not colony and not same culture"); //Consider who might get angry with the crackdown int otherNationIndex = Utilities.findNationWithThisCulture(prov.getCulture()); Nation otherNation = State.getNation(otherNationIndex); Debug.Log("Other Nation is: " + otherNation.getName()); int minorNationIndex = -1; Nation minorNation = new Nation(); if (otherNation.getType() == MyEnum.NationType.minor) { minorNationIndex = otherNation.getIndex(); minorNation = otherNation; otherNationIndex = PlayerCalculator.getMostFavouredMajorNation(otherNation); // The other nation is the guardian, not the owner of the nation otherNation = State.getNation(otherNationIndex); } int otherStrength = 0; int selfStrength = PlayerCalculator.CalculateArmyScore(nation); // Will anger another great power int relations = nation.Relations[otherNationIndex]; //This value is just for tests if (relations < 85) { Debug.Log("here"); standardProvinceResponse(nation, prov, otherNationIndex, minorNationIndex); } else { if (State.mapUtilities.shareLandBorder(nation, otherNation)) { otherStrength = PlayerCalculator.CalculateArmyScore(otherNation); } else { otherStrength = PlayerCalculator.CalculateNavalProjection(otherNation); } if (otherStrength * 1.15 < selfStrength) { //Not too afraid standardProvinceResponse(nation, prov, otherNationIndex, minorNationIndex); if (demandReferendum(otherNation, nation, prov)) { if (acceptRefDemand(nation, otherNation, prov)) { referendum(nation, otherNation, prov); } else { //nation refuses to hold a referendum if (warOverRejection(otherNation, nation, prov)) { War war = new War(otherNation, nation, prov.getIndex(), minorNationIndex); war.warBetweenAI(otherNation, nation); } else if (boycottOverRefDemandRejection(otherNation)) { otherNation.addBoycott(nation.getIndex()); //.................... } else { // Backdown PlayerPayer.loseFace(otherNation); } } } } if (otherStrength * 1.3 < selfStrength) { // Prefer not to provicate other nation, but might do so if situation calls for it int roll = Random.Range(1, 100); if (roll < 50) { nation.InfulencePoints--; prov.adjustDiscontentment(1); if (otherNation.getIndex() == humanIndex) { DecisionEvent newEvent = new DecisionEvent(); if (minorNationIndex == -1) { eventLogic.initalizeInformedOfCrackdownEvent(newEvent, human, nation, prov); } else { eventLogic.initalizeInformedOfCrackdownEvent(newEvent, human, nation, prov, minorNationIndex); } eventLogic.DecisionEvents.Enqueue(newEvent); } else if (demandReferendum(otherNation, nation, prov)) { if (acceptRefDemand(nation, otherNation, prov)) { referendum(nation, otherNation, prov); } else { if (warOverRejection(otherNation, nation, prov)) { War war = new War(otherNation, nation, prov.getIndex(), minorNationIndex); war.warBetweenAI(otherNation, nation); } } } else { prov.setRioting(true); } } else { prov.setRioting(true); } } else { // Don't want to f**k with these guys prov.setRioting(true); } } } else { Debug.Log("No Influence Points"); prov.setRioting(true); // Just for now nation.InfulencePoints++; } } } }
private void updateTransportPanel() { Debug.Log("Begin Updating Transport Panel"); App app = UnityEngine.Object.FindObjectOfType <App>(); Nation player = State.getNations()[app.GetHumanIndex()]; int transportFlow = PlayerCalculator.calculateTransportFlow(player); int totalNumberProv = PlayerCalculator.getTotalNumberOfProvinces(player); int realTransportCapacity = PlayerCalculator.calculateMaxTransportFlow(player); Debug.Log("Transport Flow: " + transportFlow); Debug.Log("Current Transport Capacity: " + realTransportCapacity); // player.industry.setTransportFlow(PlayerCalculator.calculateTransportFlow(player)); float coalUsedForTransport = (transportFlow - totalNumberProv) * 0.2f; transportCapacity.text = transportFlow.ToString() + "/" + realTransportCapacity.ToString(); coalCapacity.text = player.getNumberResource(MyEnum.Resources.coal).ToString(); int remainingFlow = realTransportCapacity - transportFlow; Debug.Log("Remaining Flow Capacity: " + remainingFlow); if (PlayerCalculator.canBuildTrain(player)) { addTransportCapacityButton.interactable = true; } else { addTransportCapacityButton.interactable = false; } // Counter used for switching from first to second table in Production GUI int counter = 0; foreach (MyEnum.Resources res in Enum.GetValues(typeof(MyEnum.Resources))) { int producing = PlayerCalculator.getResourceProducing(player, res); int currentFlow = player.getResTransportFlow(res); Debug.Log("Resource is: " + res + "---------------------------------------------"); Debug.Log("Producing: " + producing); Debug.Log("Current Flow: " + currentFlow); //int systemFlow = player.industry.getTransportFlow(); int capacity = Math.Min(producing - currentFlow, remainingFlow); Debug.Log("Remaining " + res + " capacity: " + capacity); int max = currentFlow + capacity; Debug.Log("Max: " + max); if (counter <= 5) { Debug.Log("check 2553"); Text resFlow = resourceTableA.Rows[counter].Cells[1].GetComponentInChildren <Text>(); Slider resSlider = resourceTableA.Rows[counter].Cells[2].GetComponentInChildren <Slider>(); resFlow.text = currentFlow + "/" + producing; if (max == currentFlow && max < producing) { Debug.Log("poop"); resFlow.color = new Color32(170, 12, 12, 255); } else { resFlow.color = new Color32(0, 0, 0, 255); } resSlider.maxValue = max; resSlider.minValue = 0; resSlider.value = currentFlow; Debug.Log("check 2569"); } else { Debug.Log("check 2573"); Text resFlow = resourceTableB.Rows[counter % 6].Cells[1].GetComponentInChildren <Text>(); Slider resSlider = resourceTableB.Rows[counter % 6].Cells[2].GetComponentInChildren <Slider>(); resFlow.text = currentFlow + "/" + producing; if (max == currentFlow && max < producing) { Debug.Log("poop"); resFlow.color = new Color32(170, 12, 12, 255); } else { resFlow.color = new Color32(0, 0, 0, 255); } resSlider.maxValue = max; resSlider.minValue = 0; resSlider.value = currentFlow; } counter++; Debug.Log("Counter: " + counter); } }
private void UpdateNavyTable() { App app = UnityEngine.Object.FindObjectOfType <App>(); Nation player = State.getNations()[app.GetHumanIndex()]; SeaForces seaForces = player.seaForces; Text frigateAttack = navyTable.Rows[1].Cells[1].GetComponentInChildren <Text>(); Debug.Log("frigate attack " + seaForces.frigate.Attack.ToString()); frigateAttack.text = seaForces.frigate.Attack.ToString(); Text ironcladAttack = navyTable.Rows[1].Cells[2].GetComponentInChildren <Text>(); ironcladAttack.text = seaForces.ironclad.Attack.ToString(); Text dreadnoughtAttack = navyTable.Rows[1].Cells[3].GetComponentInChildren <Text>(); dreadnoughtAttack.text = seaForces.dreadnought.Attack.ToString(); Text frigateMaxStrength = navyTable.Rows[2].Cells[1].GetComponentInChildren <Text>(); frigateMaxStrength.text = seaForces.frigate.HitPoints.ToString(); Text ironcladMaxStrength = navyTable.Rows[2].Cells[2].GetComponentInChildren <Text>(); ironcladMaxStrength.text = seaForces.ironclad.HitPoints.ToString(); Text dreadnoughtMaxStrength = navyTable.Rows[2].Cells[3].GetComponentInChildren <Text>(); dreadnoughtMaxStrength.text = seaForces.dreadnought.HitPoints.ToString(); Text frigateMan = navyTable.Rows[3].Cells[1].GetComponentInChildren <Text>(); frigateMan.text = seaForces.frigate.Capacity.ToString(); Text ironcladMan = navyTable.Rows[3].Cells[2].GetComponentInChildren <Text>(); ironcladMan.text = seaForces.ironclad.Capacity.ToString(); Text dreadnoughtMan = navyTable.Rows[3].Cells[3].GetComponentInChildren <Text>(); dreadnoughtMan.text = seaForces.dreadnought.Capacity.ToString(); Text frigateAmmo = navyTable.Rows[4].Cells[1].GetComponentInChildren <Text>(); frigateAmmo.text = seaForces.frigate.Colonial.ToString(); Text ironcladAmmo = navyTable.Rows[4].Cells[2].GetComponentInChildren <Text>(); ironcladAmmo.text = seaForces.ironclad.Colonial.ToString(); Text dreadnoughtAmmo = navyTable.Rows[4].Cells[3].GetComponentInChildren <Text>(); dreadnoughtAmmo.text = seaForces.dreadnought.Colonial.ToString(); Text NumFrig = navyTable.Rows[6].Cells[1].GetComponentInChildren <Text>(); Text NumIC = navyTable.Rows[6].Cells[2].GetComponentInChildren <Text>(); Text NumDN = navyTable.Rows[6].Cells[3].GetComponentInChildren <Text>(); NumFrig.text = player.seaForces.frigate.getNumber().ToString(); NumIC.text = player.seaForces.ironclad.getNumber().ToString(); NumDN.text = player.seaForces.dreadnought.getNumber().ToString(); Text recFrig = navyTable.Rows[7].Cells[1].GetComponentInChildren <Text>(); Text recIC = navyTable.Rows[7].Cells[2].GetComponentInChildren <Text>(); Text recDN = navyTable.Rows[7].Cells[3].GetComponentInChildren <Text>(); recFrig.text = player.getNavyProducing(MyEnum.NavyUnits.frigates).ToString(); recIC.text = player.getNavyProducing(MyEnum.NavyUnits.ironclad).ToString(); recDN.text = player.getNavyProducing(MyEnum.NavyUnits.dreadnought).ToString(); shipyardLevelValue.SetText(player.GetShipyardLevel().ToString()); if (PlayerCalculator.canUpgradeShipyard(player) == true) { upgradeShipyardButton.interactable = true; } else { upgradeShipyardButton.interactable = false; } if (PlayerCalculator.canBuildFrigate(player) && State.GerEra() != MyEnum.Era.Late) { recruitFrigateButton.interactable = true; } else { recruitFrigateButton.interactable = false; } if (PlayerCalculator.canBuildIronclad(player)) { recruitIroncladButton.interactable = true; } else { recruitIroncladButton.interactable = false; } if (PlayerCalculator.canBuildDreadnought(player)) { recruitBattleshipButton.interactable = true; } else { recruitBattleshipButton.interactable = false; } if (player.GetShipyardLevel() == 1) { shipyardUpgradeCostOne.SetActive(true); shipyardUpgradeCostTwo.SetActive(false); } else if (player.GetShipyardLevel() == 2) { shipyardUpgradeCostOne.SetActive(false); shipyardUpgradeCostTwo.SetActive(true); } else { shipyardUpgradeCostOne.SetActive(false); shipyardUpgradeCostTwo.SetActive(false); } }