private void processControlGroupSelection(KeyCode keyCode, int i) { string unitToSelect = SettingsManager.controlGroupSettlers[i]; ALivingEntity settler = UnitManager.getInstance().playerUnits.Find(x => x.unitName == unitToSelect); if (settler == null || !settler.isAlive()) { SettingsManager.controlGroupSettlers[i] = string.Empty; return; } MonoBehaviour selectedObject = UnitManager.getInstance().controllerObj.GetComponent <ControlPlayer>().selectedObject; bool openSettlerWindow = false; if (selectedObject != null && selectedObject.gameObject.tag == "ControllableUnit" && AManager <GUIManager> .getInstance().GetComponent <HumanSettlerWindow>().entity == selectedObject) { openSettlerWindow = true; } AManager <WorldManager> .getInstance().controllerObj.GetComponent <ControlPlayer>().SelectObject(settler.transform, openSettlerWindow); if (doubleTapDelayArray[i] > 0 && numberOfTapsArray[i] == 1) { AManager <WorldManager> .getInstance().controllerObj.GetComponent <ControlPlayer>().MoveToPosition(settler.coordinate.world); } else { resetDobuleTap(i); } }
/// <summary> /// This will build a button to display a dead 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(ALivingEntity 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())) { if (settler is HumanEntity) { settler.hitpoints = settler.maxHP; settler.hunger = 0f; settler.interruptTask(); settler.faction = WorldManager.getInstance().PlayerFaction; } else { settler.Destroy(); GUIManager.getInstance().AddTextLine("Can only revive Humans"); } } }
public void equipHumanWeapons(ALivingEntity entity, bool isArcher = false) { entity.inventory.Add(ResourceId.FOOD, 5); entity.inventory.Add(ResourceId.SHORTSWORD, 1); entity.inventory.Add(ResourceId.BUCKLER, 1); if (isArcher) { entity.inventory.Add(ResourceId.SHORTBOW, 1); entity.inventory.Add(ResourceId.BROADHEAD_ARROW, 25); } }
public void equipGoblinWeapons(ALivingEntity entity, bool isArcher = false) { entity.inventory.Add(ResourceId.FOOD, 5); entity.inventory.Add(ResourceId.getRandomGoblinMeleeWeapon(), 1); entity.inventory.Add(ResourceId.getRandomGoblinShield(), 1); if (isArcher) { entity.inventory.Add(ResourceId.getRandomGoblinRangedWeapon(), 1); entity.inventory.Add(ResourceId.BROADHEAD_ARROW, 25); } }
public void equipNPCWeapons(ALivingEntity entity, bool isArcher = false) { if (entity is HumanEntity) { equipHumanWeapons(entity, isArcher); } else if (entity is GoblinEntity) { equipGoblinWeapons(entity, isArcher); } else if (entity is SkeletonEntity) { equipSkeletonWeapons(entity, isArcher); } }
private void processControlGroupDesignation(KeyCode keyCode, int i) { MonoBehaviour selectedObject = UnitManager.getInstance().controllerObj.GetComponent <ControlPlayer>().selectedObject; if (selectedObject == null) { return; } ALivingEntity settler = UnitManager.getInstance().playerUnits.Find(x => x.Equals(selectedObject)); if (settler == null || !settler.isAlive()) { return; } SettingsManager.controlGroupSettlers[i] = settler.unitName; }
public AWorkTask getWork(ALivingEntity entity, ref float metric) { Coordinate coordinate = entity.coordinate; WorkRepairDoor result = null; foreach (KeyValuePair<BuildStructure, WorkRepairDoor> current in this.pool) { if (current.Key.beingBuilt) { if (current.Value.unit.taskStackContains(current.Value)) { continue; } current.Key.beingBuilt = false; } float priority = current.Value.getPriority(entity); if (priority < metric) { if (entity.canPerformWork(current.Value)) { metric = priority; result = current.Value; } } } return result; }
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; } }
public void OnMerchantTrade(EventMerchantArrived evt) { showTradeWindow = false; merchantInHall = true; needToCreateTransaction = true; merchant = evt.getUnit(); }
public override float getPriority(ALivingEntity entity) { Coordinate coordinate = entity.coordinate; return Vector3.Distance(coordinate.absolute, this.structPos.absolute) + base.getPriorityOffset() - 50f; }
public static bool getPreference(ALivingEntity entity, String preferenceName) { if (!isPlayableEntity(entity)) return false; return entity.GetComponent<APlayableEntity>().preferences[preferenceName]; }
public static void setPreference(ALivingEntity entity, String preferenceName, bool value) { if (!isPlayableEntity(entity)) return; entity.GetComponent<APlayableEntity>().preferences[preferenceName] = value; }
public static bool isPlayableEntity(ALivingEntity entity) { return entity != null && entity is APlayableEntity; }
public void equipSkeletonWeapons(ALivingEntity entity, bool isArcher = false) { entity.inventory.Add(ResourceId.FOOD, 5); entity.inventory.Add(ResourceId.getRandomSkeletonMeleeWeapon(), 1); entity.inventory.Add(ResourceId.SKELETAL_ROUND_SHIELD, 1); if (isArcher) { entity.inventory.Add(ResourceId.SKELETAL_BOW, 1); entity.inventory.Add(ResourceId.BROADHEAD_ARROW, 25); } }
private void applyPlayerPreferences(ALivingEntity entity) { if (!UnitPreference.getPreference(entity, UnitPreference.IS_PLAYER_UNIT)) { UnitPreference.setPreference(entity, UnitPreference.IS_PLAYER_UNIT, true); UnitPreference.setPreference(entity, UnitPreference.WAIT_IN_HALL_WHILE_IDLE, true); UnitPreference.setPreference(entity, UnitPreference.TRAIN_UNDER_LEVEL_3, true); } }
private void fixUnitStatus(ALivingEntity entity) { entity.hunger = 0f; if (entity.fatigue <= .5f) entity.fatigue = 1f; if (entity.morale <= .5f) entity.morale = 1f; if (entity.hitpoints <= entity.maxHP / 2f) entity.hitpoints = entity.maxHP; }