public void executeBehavior() { sterilizeEngagedEnemies(); if (currentlyBlocking < heroStats.getBlock()) { List <GameObject> enemiesInRange = Utils.getEnemiesInRange(transform.position, heroStats.getRange()); if (enemiesInRange.Any()) { tryToBlockEnemy(enemiesInRange); } } }
void FixedUpdate() { //clean out enemies that have been killed by other units sterilizeEngagedEnemies(); //fetch and block enemies in range List <GameObject> enemiesInRange = Utils.getEnemiesInRange(transform.position, heroStats.getRange()); if (enemiesInRange.Count > 0 && currentlyBlocking < heroStats.getBlock()) { tryToBlockEnemy(enemiesInRange); } //try to attack enemies if (engagedEnemies.Count > 0 && Time.time > nextAttackTime) { nextAttackTime = Time.time + attackSpeed; attackEngagedEnemies(); } }
public void updateUI() { currentHp.text = "" + selectedHeroHealthBar.getCurrentHealth() + " / " + selectedHeroHealthBar.getMaxHealth(); currentAttackSpeed.text = "" + Utils.calculateAttackRate(selectedHeroStats.getUnitType(), selectedHeroStats.getAgility()); unitType.text = "" + Enum.GetName(typeof(Utils.UnitType), selectedHeroStats.getUnitType()); currentExperience.text = "" + selectedHeroStats.getExperience(); Level.text = "" + selectedHeroStats.getLevel(); nextLevelXP.text = "" + selectedHeroStats.getNextLevelExperience(); Health.text = "" + selectedHeroStats.getHealth(); Attack.text = "" + selectedHeroStats.getAttack(); Magic.text = "" + selectedHeroStats.getMagic(); Defense.text = "" + selectedHeroStats.getDefense(); Resistance.text = "" + selectedHeroStats.getResistance(); Agility.text = "" + selectedHeroStats.getAgility(); Block.text = "" + selectedHeroStats.getBlock(); refundButtonText.text = "REFUND\n +" + (int)(selectedHeroStats.getCost() * .66f) + " REQ"; updateAbilityButtonValidity(); }