public void ReceiveReinforcementUnits(List <TroopsInformation> reinforcements) { if (troopsStationed != null && troopsStationed.Count > 0) { for (int i = 0; i < reinforcements.Count; i++) { TroopsInformation tmp = null; tmp = troopsStationed.Find(x => x.unitInformation.unitName == reinforcements[i].unitInformation.unitName); if (tmp != null) { tmp.totalUnitCount += reinforcements[i].totalUnitCount; } else { tmp = new TroopsInformation(); tmp = reinforcements[i]; troopsStationed.Add(tmp); } } } else { troopsStationed = new List <TroopsInformation>(); troopsStationed.AddRange(reinforcements); } }
// BUTTON public void SendUnits() { for (int i = 0; i < subOptionsList.Count; i++) { unitsToSend[i] = subOptionsList[i].amountToSell; } if (leaderHandler.IsHeroChosen()) { Debug.Log("A Hero Is Chosen and is now Added!"); heroesSent = new List <BaseHeroInformationData>(); BaseHeroInformationData tmp = new BaseHeroInformationData(); tmp = leaderHandler.availableHeroes[leaderHandler.idx]; heroesSent.Add(tmp); } else { heroesSent.Clear(); } List <TroopsInformation> troopsToSend = new List <TroopsInformation>(); for (int i = 0; i < curPlayerUnits.Count; i++) { TroopsInformation tmp = new TroopsInformation(); tmp.unitInformation = new UnitInformationData(); tmp.unitInformation = curPlayerUnits[i].unitInformation; tmp.totalUnitCount = unitsToSend[i]; troopsToSend.Add(tmp); } Debug.Log("Clicekd Send Units"); if (myController.currentMapPoint.myPointInformation.ownedBy != TerritoryOwners.Player) { PlayerGameManager.GetInstance.SendThisUnits(troopsToSend, heroesSent, true); myController.SendTroopsToBattle(); } else { Debug.Log("Sending Units As Reinforcement!"); myController.currentMapPoint.myPointInformation.ReceiveReinforcementUnits(troopsToSend); for (int i = 0; i < troopsToSend.Count; i++) { PlayerGameManager.GetInstance.RemoveTroops(troopsToSend[i].totalUnitCount, troopsToSend[i].unitInformation.unitName); } ResourceInformationController.GetInstance.UpdateCurrentPanel(); myController.UpdateShownPointInformation(myController.currentMapPoint); StartCoroutine(myPanel.WaitAnimationForAction(myPanel.closeAnimationName, myWindow.CloseWindow)); if (SaveData.SaveLoadManager.GetInstance != null) { SaveData.SaveLoadManager.GetInstance.SaveCurrentCampaignData(); } } }
public List <TroopsInformation> GenerateBasicWarband(int unitCount) { List <int> troopTypes = new List <int>(); troopTypes.Add(0); troopTypes.Add(0); troopTypes.Add(0); troopTypes.Add(0); for (int i = 0; i < unitCount; i++) { int rand = UnityEngine.Random.Range(0, troopTypes.Count); troopTypes[rand] += 1; } TroopsInformation recruit = TroopsInformation.ConvertToTroopsInformation(GetUnitInformation("Recruit"), troopTypes[0]); TroopsInformation swordsman = TroopsInformation.ConvertToTroopsInformation(GetUnitInformation("Swordsman"), troopTypes[1]); TroopsInformation spearman = TroopsInformation.ConvertToTroopsInformation(GetUnitInformation("Spearman"), troopTypes[2]); TroopsInformation archer = TroopsInformation.ConvertToTroopsInformation(GetUnitInformation("Archer"), troopTypes[3]); List <TroopsInformation> tmp = new List <TroopsInformation>(); tmp.Add(recruit); tmp.Add(swordsman); tmp.Add(spearman); tmp.Add(archer); return(tmp); }
public void SetupBasicCommander() { if (BattlefieldSceneManager.GetInstance == null) { return; } unitsCarried = new List <TroopsInformation>(); heroesCarried = new List <BaseHeroInformationData>(); TroopsInformation tmp = new TroopsInformation(); tmp.unitInformation = BattlefieldSceneManager.GetInstance.spawnManager.unitStorage.basicUnitStorage.Find(x => x.unitName == "Recruit"); tmp.totalUnitCount = 10; TroopsInformation tmp1 = new TroopsInformation(); tmp1.unitInformation = BattlefieldSceneManager.GetInstance.spawnManager.unitStorage.basicUnitStorage.Find(x => x.unitName == "Swordsman"); tmp1.totalUnitCount = 10; TroopsInformation tmp2 = new TroopsInformation(); tmp2.unitInformation = BattlefieldSceneManager.GetInstance.spawnManager.unitStorage.basicUnitStorage.Find(x => x.unitName == "Spearman"); tmp2.totalUnitCount = 10; TroopsInformation tmp3 = new TroopsInformation(); tmp3.unitInformation = BattlefieldSceneManager.GetInstance.spawnManager.unitStorage.basicUnitStorage.Find(x => x.unitName == "Archer"); tmp3.totalUnitCount = 10; unitsCarried.Add(tmp); unitsCarried.Add(tmp1); unitsCarried.Add(tmp2); unitsCarried.Add(tmp3); //heroesCarried.Add(BattlefieldSceneManager.GetInstance.spawnManager.unitStorage.heroStorage[0]); }
public void RecruitTroops() { if (curPlayer.coins < GetRecruitCoins && curPlayer.population < 1) { Debug.LogWarning("Trying to recruit a troop but you seem to be lacking in resources [ Coins:" + curPlayer.coins + "] [Pop:" + curPlayer.population + "]"); return; } curPlayer.coins -= GetRecruitCoins; curPlayer.SetPopulation(-1); int idx = -1; if (curPlayer.troopsList == null) { curPlayer.troopsList = new List <TroopsInformation>(); } if (curPlayer.troopsList.Find(x => x.unitInformation.unitName == "Recruit") != null) { idx = curPlayer.troopsList.FindIndex(x => x.unitInformation.unitName == "Recruit"); } if (idx != -1) { curPlayer.troopsList[idx].totalUnitCount += 1; } else { curPlayer.troopsList.Add(TroopsInformation.ConvertToTroopsInformation(TransitionManager.GetInstance.unitStorage.GetUnitInformation("Recruit"), 0)); curPlayer.troopsList[curPlayer.troopsList.Count - 1].totalUnitCount += 1; } }
public void SetupInitialData() { temporaryKingdom.foods = initialFood; temporaryKingdom.safeFood = 50; temporaryKingdom.population = initialPopulation; temporaryKingdom.safePopulation = 20; TroopsInformation tmp = new TroopsInformation(); tmp.unitInformation = new Characters.UnitInformationData(); tmp.unitInformation = TransitionManager.GetInstance.unitStorage.GetUnitInformation("Recruit"); tmp.totalUnitCount = initialTroops; temporaryKingdom.troopsList = new List <TroopsInformation>(); temporaryKingdom.troopsList.Add(tmp); recruitIdx = temporaryKingdom.troopsList.Count - 1; temporaryKingdom.barracksCapacity = 20; temporaryKingdom.coins = initialCoins; temporaryKingdom.coinsCapacity = 30; UpdatePlayerHero(); for (int i = 0; i < resourcePagesList.Count; i++) { resourcePagesList[i].UpdateResourceCount(); } }
public TroopsInformation ObtainMercenaryInformation(string unitName) { if (troopsMercList == null || troopsMercList.Count <= 0) { TroopsInformation tmp = new TroopsInformation(); tmp.totalUnitCount = 0; return(tmp); } return(troopsMercList.Find(x => x.unitInformation.unitName == unitName)); }
public void SendTroopsToBattle() { if (myMap.selectedMapPoint.myPointInformation.ownedBy == TerritoryOwners.Player) { // REINFORCE LOCATION if (!myMap.selectedMapPoint.myPointInformation.isBeingAttacked) { List <TroopsInformation> tmp = new List <TroopsInformation>(); tmp.AddRange(myMap.selectedMapPoint.myPointInformation.troopsStationed); if (PlayerGameManager.GetInstance != null) { List <TroopsInformation> tmpUnitsSent = PlayerGameManager.GetInstance.unitsToSend.troopsCarried; for (int i = 0; i < tmpUnitsSent.Count; i++) { TroopsInformation tempTroop = tmp.Find(x => x.unitInformation.unitName == tmpUnitsSent[i].unitInformation.unitName); if (tempTroop != null) { tempTroop.totalUnitCount += tmpUnitsSent[i].totalUnitCount; } // New Type of Troop Sent else { tempTroop = new TroopsInformation(); tempTroop = tmpUnitsSent[i]; tmp.Add(tempTroop); } } } myMap.selectedMapPoint.myPointInformation.troopsStationed = new List <TroopsInformation>(); myMap.selectedMapPoint.myPointInformation.troopsStationed = tmp; } else { // SEND TROOPS TO BATTLE WITH THE SAID UNITS TO BE ADDED TO THE MAPS CURRENT STATIONED UNITS. if (TransitionManager.GetInstance != null) { TransitionManager.GetInstance.FaceMapPoint(myMap.selectedMapPoint.myPointInformation, false); myController.myWindow.CloseWindow(); } } } // JUST ATTACK WITH THE SAID UNITS THE ONLY UNITS ON PLAYER MANAGER else if (myMap.selectedMapPoint.myPointInformation.ownedBy != TerritoryOwners.Player) { if (TransitionManager.GetInstance != null) { TransitionManager.GetInstance.FaceMapPoint(myMap.selectedMapPoint.myPointInformation, true); myController.myWindow.CloseWindow(); } } }
public static TroopsInformation ConvertToTroopsInformation(UnitInformationData unitData, int availableCount) { TroopsInformation tmp = new TroopsInformation(); tmp.unitInformation = new UnitInformationData(); tmp.unitInformation = unitData; tmp.totalUnitsAvailableForDeployment = availableCount; tmp.totalUnitCount = availableCount; return(tmp); }
public void ReturnUnitsToPlayerData() { BattlefieldCommander playerUnits = new BattlefieldCommander(); if (TransitionManager.GetInstance.isPlayerAttacker) { playerUnits = BattlefieldSpawnManager.GetInstance.attackingCommander; } else { playerUnits = BattlefieldSpawnManager.GetInstance.defendingCommander; } // CHANGE PLAYER DATA COUNT STUFF TO UNITS CARRIED (SO PLAYER CAN USE OTHER UNITS LATER ON). for (int i = 0; i < playerUnits.unitsCarried.Count; i++) { TroopsInformation tmp = PlayerGameManager.GetInstance.playerData.troopsList.Find(x => x.unitInformation.unitName == playerUnits.unitsCarried[i].unitInformation.unitName); tmp.totalReturningUnitCount = playerUnits.CheckUnitCount(playerUnits.unitsCarried[i].unitInformation.unitName); tmp.totalUnitCount -= (tmp.totalReturningUnitCount + playerUnits.CheckUnitDeathCount(playerUnits.unitsCarried[i].unitInformation.unitName)); } SaveLoadManager.GetInstance.SaveCurrentData(); }
public void ReceiveMercenary(int amount, string unitName) { int idx = playerData.troopsMercList.FindIndex(x => x.unitInformation.unitName == unitName); if (idx != -1) { playerData.troopsMercList[idx].totalUnitCount += amount; } else { if (TransitionManager.GetInstance != null) { TroopsInformation tmp = new TroopsInformation(); tmp.unitInformation = new UnitInformationData(); tmp.unitInformation = TransitionManager.GetInstance.unitStorage.GetUnitInformation(unitName); tmp.totalUnitCount += amount; if (tmp.unitInformation != null && !string.IsNullOrEmpty(tmp.unitInformation.unitName)) { playerData.troopsMercList.Add(tmp); } } } }
public BaseTravellerData GenerateRandomWarbandTraveller(int unitCount, float newRelationship) { BaseTravellerData tmp = new BaseTravellerData(); tmp.weekSpawned = ObtainPlayerWeeklyCount(); tmp.troopsCarried = new List <TroopsInformation>(); if (newRelationship < 0) { tmp.affiliatedTeam = Maps.TerritoryOwners.FurKhan; } else { tmp.affiliatedTeam = Maps.TerritoryOwners.Neutral; } int randLdrIdx = UnityEngine.Random.Range(0, unitStorage.heroStorage.Count); tmp.leaderUnit = new List <BaseHeroInformationData>(); BaseHeroInformationData newLeader = new BaseHeroInformationData(); newLeader = TransitionManager.GetInstance.unitStorage.ObtainHeroBaseInformation(WieldedWeapon.Bow); // TODO : CHANGE ON NEW HERO PREFABS newLeader.unitInformation.prefabDataPath = "Assets/Resources/Prefabs/Unit and Items/Player.prefab"; tmp.leaderUnit.Add(newLeader); tmp.UpdateRelationship(newRelationship); // TroopTypes List <int> troopTypes = new List <int>(); troopTypes.Add(0); troopTypes.Add(0); troopTypes.Add(0); troopTypes.Add(0); for (int i = 0; i < unitCount; i++) { int rand = UnityEngine.Random.Range(0, troopTypes.Count); troopTypes[rand] += 1; } TroopsInformation recruit = TroopsInformation.ConvertToTroopsInformation(unitStorage.GetUnitInformation("Recruit"), troopTypes[0]); TroopsInformation swordsman = TroopsInformation.ConvertToTroopsInformation(unitStorage.GetUnitInformation("Swordsman"), troopTypes[1]); TroopsInformation spearman = TroopsInformation.ConvertToTroopsInformation(unitStorage.GetUnitInformation("Spearman"), troopTypes[2]); TroopsInformation archer = TroopsInformation.ConvertToTroopsInformation(unitStorage.GetUnitInformation("Archer"), troopTypes[3]); tmp.troopsCarried.Add(recruit); tmp.troopsCarried.Add(swordsman); tmp.troopsCarried.Add(spearman); tmp.troopsCarried.Add(archer); TravellerFlavourPhrase flavourTmp = new TravellerFlavourPhrase(); flavourTmp.relationshipGauge = -50; flavourTmp.flavourText = "100 coins is not enough, we know you're hiding more there!"; TravellerFlavourPhrase flavourTmp1 = new TravellerFlavourPhrase(); flavourTmp1.relationshipGauge = -30; flavourTmp1.flavourText = "100 coins, you should give more!"; TravellerFlavourPhrase flavourTmp2 = new TravellerFlavourPhrase(); flavourTmp2.relationshipGauge = 0; flavourTmp2.flavourText = "100 coins might make us stay a week or two.."; tmp.flavourTexts = new List <TravellerFlavourPhrase>(); tmp.flavourTexts.Add(flavourTmp); tmp.flavourTexts.Add(flavourTmp1); tmp.flavourTexts.Add(flavourTmp2); return(tmp); }