public void openSaleMenu(GameManager.Kingdom kingdom) { gameManager.currentlyBuyingFrom = kingdom.ToString(); canvas.GetComponent <ConfirmSaleMenu>().setMaxValues(kingdom); confirmSale.SetActive(true); infoTextConfirm.text = "You are currently trading with " + kingdom.ToString() + "."; int woodCost = gameManager.getCost(GameManager.Type.Wood, kingdom); int stoneCost = gameManager.getCost(GameManager.Type.Stone, kingdom); int leatherCost = gameManager.getCost(GameManager.Type.Leather, kingdom); relationNo.text = gameManager.getRelations(kingdom) + "%"; }
public void onClick(string k) { GameManager.Kingdom kingdom = (GameManager.Kingdom)Enum.Parse(typeof(GameManager.Kingdom), k); spoils.SetActive(true); raidObject.SetActive(false); actionMenu.setTask(true); actionMenu.openObjects.Remove(raidObject); actionMenu.openObjects.Add(spoils); int wood = UnityEngine.Random.Range(40, 70); int stone = UnityEngine.Random.Range(30, 50); int leather = UnityEngine.Random.Range(10, 20); int gold = UnityEngine.Random.Range(200, 350); int relations = UnityEngine.Random.Range(20, 35); // make each random number relate to each kingdoms specific resources int failChance = 65 + ((int)(gameManager.soldierStrength - 1) * 100) + (int)((gameManager.soldierCount / 100) * 2); // so soldier strength helps raid chances int roll = UnityEngine.Random.Range(1, 100); gameManager.decreaseRelations(kingdom, relations); int modifier = UnityEngine.Random.Range(3, 7); gameManager.soldierCount -= ((gameManager.soldierCount / 100) * modifier); relationText.text = "(-" + relations + " relations with " + kingdom.ToString() + ")"; if (gameManager.getRelations(kingdom) <= 10) { gameManager.setAtWar(kingdom); gameManager.isAtWar = true; warTextObj.SetActive(true); warText.text = "You are now at war with " + kingdom + "."; } if (roll >= failChance) { setIconStatus(false); title.text = "Defeat!"; failed = true; return; } gameManager.gold += gold; gameManager.wood += wood; gameManager.stone += stone; gameManager.leather += leather; canvas.GetComponent <ResourceUI>().updateResourceText(); woodText.text = wood.ToString(); stoneText.text = stone.ToString(); leatherText.text = leather.ToString(); coinText.text = gold.ToString(); }
public void onClick(string k) { GameManager.Kingdom kingdom = (GameManager.Kingdom)Enum.Parse(typeof(GameManager.Kingdom), k); gameManager.setAtWar(kingdom); int chance = -10; gameManager.invadePause = true; float modifier = gameManager.soldierCount; modifier = (gameManager.soldierCount * gameManager.soldierStrength); chance += (int)((modifier / 100) * invadeModifier); int roll = UnityEngine.Random.Range(1, 100); invade.SetActive(false); if (chance >= roll) { gameManager.puppetStates++; if (gameManager.puppetStates != 4) { invadeSuccess.SetActive(true); } gameManager.conqueredStatus[kingdom] = true; gameManager.warStatus[kingdom] = false; textS.text = "Your forces have stormed the keep of " + kingdom.ToString() + ", and have taken the land. Your subjects congratulate you on your victory. " + "There is a cost in victory though, as you have lost good men to claim these lands."; bool war = false; foreach (GameManager.Kingdom kin in gameManager.warStatus.Keys) { if (gameManager.warStatus[kin]) { war = true; } } if (!war) { gameManager.isAtWar = false; } float loss = ((gameManager.soldierCount / 100) * UnityEngine.Random.Range(30, 55)); if (gameManager.ownsGarrison || gameManager.ownsBarracks) { loss -= (loss * ((gameManager.soldierStrength - 1))); } gameManager.soldierCount -= loss; } else { invadeFail.SetActive(true); textF.text = "Your forces were unable to overcome " + kingdom.ToString() + " 's defenses. You have lost a large majority of soldiers, and your people's happiness has dropped."; gameManager.soldierCount = ((gameManager.soldierCount / 100) * UnityEngine.Random.Range(15, 25)); // keep 15 to 25% gameManager.decreaseRelations(kingdom, 100); } if (tradeListener == null) { tradeListener = GameObject.FindGameObjectWithTag("Canvas").transform.Find("Trade").GetComponentInChildren <TradeListener>(); } tradeListener.updateRelationsText(kingdom); gameManager.updateTradeStatus(kingdom); if (gameManager.puppetStates == 4) { gameManager.won = true; win.SetActive(true); actionMenu.setTask(true); actionMenu.openObjects.Add(win); } }