//***************************************************************************************** //add a new random postive trait to unit private bool addPositiveTrait(APlayableEntity unit) { Dbg.trc(Dbg.Grp.Units, 5); List<string> posPrefs = new List<string> {"trait.hardworker","trait.goodvision","trait.charismatic","trait.courageous","trait.athletic","trait.quicklearner","trait.strongback"}; List<string> notHasPrefs = new List<string>(); foreach(string pref in posPrefs) { if(unit.preferences[pref] != true) { notHasPrefs.Add(pref); } } if(notHasPrefs.Count >= 1) { Dictionary<string,string> traitsChangedStrings = new Dictionary<string,string>{ {"trait.hardworker","is a hard worker"}, {"trait.goodvision","has good vision"}, {"trait.charismatic","is charismatic"}, {"trait.courageous","is courageous"}, {"trait.athletic","is athletic"}, {"trait.quicklearner","is a quick learner"}, {"trait.strongback","has a strong back"}, }; int add = UnityEngine.Random.Range(0, notHasPrefs.Count - 1); unit.preferences[notHasPrefs[add]] = true; string outString; traitsChangedStrings.TryGetValue(notHasPrefs[add], out outString); UI.print("All this training paid off! " + unit.unitName + " now " + outString + "!"); return true; } return false; }
public static void setBestTraits(APlayableEntity entity) { foreach (UnitTrait trait in UnitTrait.List) { entity.preferences[trait.Name] = trait.Type == UnitTraitType.GOOD; } }
/// <summary> /// This will check are settings and decide to include or exculde certain settlers based on those settings. /// </summary> /// <param name="settler">The settler to check if we want to include or exclude them</param> /// <returns>Should the settler be excluded or included.</returns> private bool passProfessionCheck(APlayableEntity settler) { bool checkPassed = true; AProfession profession = settler.getProfession(); if (SettingsManager.boolSettings[(int)Preferences.excludeArcher]) { if (profession.getProfessionName().Equals("Archer")) { checkPassed = false; } } if (SettingsManager.boolSettings[(int)Preferences.excludeInfantry]) { if (profession.getProfessionName().Equals("Infantry")) { checkPassed = false; } } if (SettingsManager.boolSettings[(int)Preferences.excludeTrader]) { if (profession.getProfessionName().Equals("Trader")) { checkPassed = false; } } if (SettingsManager.boolSettings[(int)Preferences.excludeHerder]) { if (profession.getProfessionName().Equals("Herder")) { checkPassed = false; } } return(checkPassed); }
public void equipPlayerUnit(APlayableEntity entity) { entity.inventory.Add(ResourceId.FOOD, 5); AProfession profession = entity.getProfession(); if (profession is Archer) { equipHumanWeapons(entity, true); } else if (profession is Infantry) { equipHumanWeapons(entity); } else if (profession is Blacksmith) { entity.inventory.Add(ResourceId.STRONG_HAMMER, 1); entity.inventory.Add(ResourceId.STRONG_TONGS, 1); } else if (profession is Builder || profession is Carpenter || profession is StoneMason || profession is Engineer) { entity.inventory.Add(ResourceId.STRONG_HAMMER, 1); } else if (profession is Farmer) { entity.inventory.Add(ResourceId.STRONG_HOE, 1); entity.inventory.Add(ResourceId.CARROT_SEED, 5); entity.inventory.Add(ResourceId.CORN_SEED, 5); entity.inventory.Add(ResourceId.COTTON_SEED, 5); entity.inventory.Add(ResourceId.FLAX_SEED, 5); entity.inventory.Add(ResourceId.POTATO_SEED, 5); entity.inventory.Add(ResourceId.PUMPKIN_SEED, 5); entity.inventory.Add(ResourceId.TURNIP_SEED, 5); entity.inventory.Add(ResourceId.WHEAT_SEED, 5); } else if (profession is Fisherman) { entity.inventory.Add(ResourceId.STRONG_FISHING_ROD, 1); } else if (profession is Forager) { entity.inventory.Add(ResourceId.SHARP_KNIFE, 1); } else if (profession is Herder) { entity.inventory.Add(ResourceId.HERDING_CROOK, 1); } else if (profession is Miner) { entity.inventory.Add(ResourceId.SHARP_PICK, 1); } else if (profession is Tailor) { entity.inventory.Add(ResourceId.SHARP_SHEARS, 1); } else if (profession is WoodChopper) { entity.inventory.Add(ResourceId.SHARP_AXE, 1); } }
public static void setAllProfessionsMax(APlayableEntity entity) { foreach (KeyValuePair<Type, AProfession> key in entity.professions) { key.Value.setExperience(AProfession.maxExperience); key.Value.setLevel(AProfession.maxLevel); } }
public static void setPlayerUnitSettings(PlayerUnitSettings playerUnitSettings, APlayableEntity entity, IUnitSettingCollectionItem[] collection) { if (playerUnitSettings != null) { foreach (IUnitSettingCollectionItem item in collection) { UnitPreference.setPreference(entity, item.Name, playerUnitSettings.getSetting(item).Enabled); } } }
public static void updatePlayerUnitSettings(ref PlayerUnitSettings playerUnitSettings, APlayableEntity entity, IUnitSettingCollectionItem[] collection) { if (UnitPreference.isPlayableEntity(entity)) { playerUnitSettings = PlayerUnitSettings.fromEntity(entity, collection); } else { playerUnitSettings = null; } }
public static PlayerUnitSettings fromEntity(APlayableEntity entity, IUnitSettingCollectionItem[] collection) { List<UnitSetting> tempSettings = new List<UnitSetting>(); UnitSetting tempSetting; foreach (IUnitSettingCollectionItem item in collection) { tempSetting = new UnitSetting(); tempSetting.Item = item; tempSetting.Enabled = UnitPreference.getPreference(entity, item.Name); tempSettings.Add(tempSetting); } PlayerUnitSettings playerUnitSettings = new PlayerUnitSettings(); playerUnitSettings.UnitSettings = tempSettings; return playerUnitSettings; }
/// <summary> /// This will build a button to display a idle settler. /// It also has the logic in it to handle moving to and selecting a settler. /// </summary> /// <param name="settler">The settler that needs to be displayed</param> /// <param name="buttonAboveHeight">The y coord needed relative to all the views above it</param> /// <param name="isOdd">Is this a odd button.</param> private void buildLabel(APlayableEntity settler, float buttonAboveHeight, bool isOdd) { Rect viewRect; if (isOdd) { viewRect = new Rect((leftRightMargin) + ((windowRect.width - leftRightMargin * 2) / 2 - (inbetweenMargin / 2)) + inbetweenMargin, buttonAboveHeight, (windowRect.width - leftRightMargin * 2) / 2 - (inbetweenMargin / 2), buttonHeight); } else { viewRect = new Rect(leftRightMargin, buttonAboveHeight, (windowRect.width - leftRightMargin * 2) / 2 - (inbetweenMargin / 2), buttonHeight); } if (guiMgr.DrawButton(viewRect, settler.unitName.Split(' ').FirstOrDefault())) { settlerToSelect = settler; selectSettler = true; } }
private void UpdateGameVariables(object sender, ElapsedEventArgs e) { if (!SettingsManager.BoolSettings[(int)Preferences.ToggleNewTradeMenu]) return; totalTransactionCost = CalculateTransactionCost(); CalculateStorageNeeded(); playerCoin = WorldManager.getInstance().PlayerFaction.storage[Resource.FromID(55)]; if (merchant != null) { if (merchant.taskStackContains(typeof(TaskExitMapViaRoads))) { tradeOnGoing = false; merchantInHall = false; merchant = null; trader = null; } } trader = GetTrader(); if (merchant != null && trader != null && merchantInHall) { tradeOnGoing = true; if (needToCreateTransaction) { merchantCoin = 0; resourcesBought.Clear(); resourcesSold.Clear(); TradeWindowBuyList.Clear(); TradeWindowSellList.Clear(); CreateRandomTransaction(); needToCreateTransaction = false; } } else { tradeOnGoing = false; } }
//***************************************************************************************** //find all negative traits on unit and randomly remove one, return false if no negs found private bool removeNegativeTrait(APlayableEntity unit) { Dbg.trc(Dbg.Grp.Units, 5); List<string> negPrefs = new List<string> {"trait.weakback","trait.cowardly","trait.clumsy","trait.sluggish","trait.overeater","trait.disloyal","trait.badvision","trait.lazy"}; List<string> hasPrefs = new List<string>(); foreach(string pref in negPrefs) { if(unit.preferences[pref] == true) { hasPrefs.Add(pref); } } if(hasPrefs.Count >= 1) { Dictionary<string,string> traitsChangedStrings = new Dictionary<string,string>{ {"trait.weakback","has a weak back"}, {"trait.cowardly","is a coward"}, {"trait.clumsy","is clumsy"}, {"trait.sluggish","is sluggish"}, {"trait.overeater","is an overeater"}, {"trait.disloyal","is disloyal"}, {"trait.badvision","has bad vision"}, {"trait.lazy","is lazy"} }; int remove = UnityEngine.Random.Range(0, hasPrefs.Count - 1); unit.preferences[hasPrefs[remove]] = false; string outString; traitsChangedStrings.TryGetValue(hasPrefs[remove], out outString); UI.print("All this training paid off! " + unit.unitName + " no longer " + outString + "!"); return true; } return false; }
/// <summary> /// This will check are settings and decide to include or exculde certain settlers based on those settings. /// </summary> /// <param name="settler">The settler to check if we want to include or exclude them</param> /// <returns>Should the settler be excluded or included.</returns> private bool PassProfessionCheck(APlayableEntity settler) { bool checkPassed = true; AProfession profession = settler.getProfession(); if (SettingsManager.BoolSettings[(int)Preferences.ExcludeArcher]) { if (profession.getProfessionName().Equals("Archer")) { checkPassed = false; } } if (SettingsManager.BoolSettings[(int)Preferences.ExcludeInfantry]) { if (profession.getProfessionName().Equals("Infantry")) { checkPassed = false; } } if (SettingsManager.BoolSettings[(int)Preferences.ExcludeTrader]) { if (profession.getProfessionName().Equals("Trader")) { checkPassed = false; } } if (SettingsManager.BoolSettings[(int)Preferences.ExcludeHerder]) { if (profession.getProfessionName().Equals("Herder")) { checkPassed = false; } } return checkPassed; }
/// <summary> /// This will build a button to display a idle settler. /// It also has the logic in it to handle moving to and selecting a settler. /// </summary> /// <param name="settler">The settler that needs to be displayed</param> /// <param name="buttonAboveHeight">The y coord needed relative to all the views above it</param> /// <param name="isOdd">Is this a odd button.</param> private void BuildLabel(APlayableEntity settler, float buttonAboveHeight, bool isOdd) { Rect viewRect; if (isOdd) { viewRect = new Rect((LeftRightMargin) + ((windowRect.width - LeftRightMargin * 2) / 2 - (InbetweenMargin / 2)) + InbetweenMargin, buttonAboveHeight, (windowRect.width - LeftRightMargin * 2) / 2 - (InbetweenMargin / 2), ButtonHeight); } else { viewRect = new Rect(LeftRightMargin, buttonAboveHeight, (windowRect.width - LeftRightMargin * 2) / 2 - (InbetweenMargin / 2), ButtonHeight); } if (guiMgr.DrawButton(viewRect, settler.unitName.Split(' ').FirstOrDefault())) { _settlerToSelect = settler; _selectSettler = true; } }
public static void setCurrentProfessionMax(APlayableEntity entity) { entity.getProfession().setExperience(AProfession.maxExperience); entity.getProfession().setLevel(AProfession.maxLevel); }
public static UnitPreference[] getPreferences(APlayableEntity entity) { return getPreferences(UnitHuman.valueOf(entity.getProfession().getProfessionName())).ToArray(); }