private void attemptAbilityFire(int index) { Ability ability = main_unit.GetComponent <unit_control_script>().GetAbility(index); if (ability.GetLevel() < 1) { return; } if (main_unit.GetMana() < ability.GetCost() || ability.OnCooldown()) { return; } //if the ability is a point target spell see if there is a target under neath the player and that the enemy is in range if (ability.ActivationType == AbilityActivationType.Cast) { if (ability._TargetType == TargetType.PointTarget) { //see if there is an enemy under the player cursor RaycastHit hit; if (Physics.Raycast(GameObject.FindObjectOfType <Camera>().ScreenPointToRay(Input.mousePosition), out hit)) { enemy_controller enemy = hit.transform.gameObject.GetComponent <enemy_controller>(); if (hit.transform.CompareTag("Enemy") && UtilityHelper.InRange(main_unit.GetPosition(), enemy.GetPosition(), (ability.GetCastRange() + main_unit.GetCastRange()) / 100.0f)) { ability.ActivateAbility(hit.transform.gameObject); //reduce the players mana main_unit.AddMana(-ability.GetCost()); } } } if (ability._TargetType == TargetType.Self) { //check to see if ability is on cooldown if (!ability.OnCooldown()) { ability.ActivateAbility(); } } } }
protected void UpdateUiInfo() { //set the ability icons if (active_unit == null) { return; } AbilityIcons[0].texture = active_unit.GetAbility(0).GetIcon(); AbilityIcons[1].texture = active_unit.GetAbility(1).GetIcon(); AbilityIcons[2].texture = active_unit.GetAbility(2).GetIcon(); AbilityIcons[3].texture = active_unit.GetAbility(3).GetIcon(); //update the health bar health_text.text = (int)active_unit.GetHp() + "/" + (int)active_unit.GetMaxHp() + " + " + (int)(active_unit.GetHpRegen() + active_unit.GetAddedHpRegen()); hp_bar.rectTransform.sizeDelta = new Vector2(health_bar_length * active_unit.GetHp() / active_unit.GetMaxHp(), hp_bar.rectTransform.sizeDelta.y); //update the mana bar mana_text.text = (int)active_unit.GetMana() + "/" + (int)active_unit.GetMaxMana() + " + " + (int)(active_unit.GetManaRegen() + active_unit.GetAddedManaRegen()); mana_bar.rectTransform.sizeDelta = new Vector2(mana_bar_length * active_unit.GetMana() / active_unit.GetMaxMana(), mana_bar.rectTransform.sizeDelta.y); //update gold text gold_text.text = "Gold: " + player_script.GetGold(); //get pther stats StringBuilder str = new StringBuilder(); str.Append("Strength: " + active_unit.GetStrength() + "\n"); str.Append("Agility: " + active_unit.GetAgility() + "\n"); str.Append("Intelligence: " + active_unit.GetIntelligence() + "\n"); str.Append("Attack damage: " + (int)active_unit.GetBaseDamage() + " + " + (int)active_unit.GetAddedDamage() + "\n"); str.Append("Attack speed: " + (int)active_unit.GetAttackSpeed() + " + " + (int)active_unit.GetAddedAttackSpeed() + " Total Attack Time: " + active_unit.GetAttackTime() + "\n"); str.Append("Move speed: " + (int)active_unit.GetMovespeed() + " + " + (int)active_unit.GetAddedMovespeed() + "\n"); str.Append("Ability amp: " + active_unit.GetSpellamp() + " + " + active_unit.GetAddedSpellAmp() + "\n"); stat_text.text = str.ToString(); //display the amount of skill points SkillPointText.text = "Skill points: " + active_unit.GetSkillPoints(); //set the level text LevelText.text = "Level: " + active_unit.GetLevel(); //set the lives text LivesText.text = "X" + player_script.GetLives(); //update the cooldowns UpdateCooldowns(); //update the extra stats text str.Clear(); str.Append("Armor: " + active_unit.GetBaseArmor() + "+" + active_unit.GetAddedArmor()); str.Append("\nMagic resistance: " + active_unit.GetMagicResist()); str.Append("\nCastspeed reduction: " + active_unit.GetCastSpeedReduction()); str.Append("\nCooldown reduction: " + active_unit.GetCooldownReduction()); str.Append("\nCast range: " + active_unit.GetCastRange()); str.Append("\nSpell lifesteal: " + active_unit.GetSpellLifesteal()); str.Append("\nLifesteal: " + active_unit.GetLifesteal()); str.Append("\n Attack range: " + active_unit.GetAttackRange()); str.Append("\n Pure damage: " + active_unit.GetPureDamage()); str.Append("\n Splash damage: " + active_unit.GetSplash()); str.Append("\n Cleave damage: " + active_unit.GetCleave()); str.Append("\n Crit damage: " + active_unit.GetCriticalDamage()); str.Append("\n Crit chance: " + active_unit.GetCriticalChance()); str.Append("\n Status resist: " + active_unit.GetStatusResist()); ExtraStatsText.text = str.ToString(); //check to see if the player has clicked on a level if (Input.GetMouseButtonDown(0) && leveling_mode) { //check to see if the ability can be leveled for (int i = 0; i < AbilityIcons.Length; i++) { if (AbilityIcons[i].GetComponent <MouseOverDetector>().MouseIsOver() && active_unit.GetAbility(i).CanLevel()) { active_unit.GetAbility(i).Level(); level_indicators[i][active_unit.GetAbility(i).GetLevel() - 1].texture = LeveledTexture; //reduce the ability points active_unit.AddSkillPoints(-1); ExitLevelStatus(); } } } //update the level objective text LevelObjectiveText.text = level_manager.GetLevelManager().GetDescription(); }