/// <summary> /// Gets the abilities by type /// </summary> /// <returns>The abilities by type.</returns> /// <param name="type">Type.</param> private List <Ability> GetAbilitiesByType(Ability.AbilityType type) { // Create tmp dictionary for filtering by type var tmpAbilityDict = new Dictionary <int, Ability>(); foreach (var ability in _abilities) { if (ability.Value.Type == type) { tmpAbilityDict.Add(ability.Key, ability.Value); } } // Sort by id var sortedList = tmpAbilityDict.Keys.ToList(); sortedList.Sort(); // Create final sorted ability list var abilityList = new List <Ability>(); foreach (var id in sortedList) { abilityList.Add(_abilities [id]); } return(abilityList); }
/* * Set the focus on the enemy or the ally team * and on a single or multi target */ private void SetFocus(Ability.AbilityTarget target, Ability.AbilityType type) { // Wait for player enemy target choice playerUI.SetActive(false); if (_choosedAbility.target == Ability.AbilityTarget.MULTI) { if (_choosedAbility.type == Ability.AbilityType.ATTACK) { _fighters.FindAll(e => e.player != _activeFighter.player && e.dead == false).Select(e => { e.ForceSelect(); return(e); }).ToList(); } else { _fighters.FindAll(e => e.player == _activeFighter.player && e.dead == false).Select(e => { e.ForceSelect(); return(e); }).ToList(); } } else { if (_choosedAbility.type == Ability.AbilityType.ATTACK) { // Set enemies focusable _fighters.FindAll(e => e.player != _activeFighter.player && e.dead == false).Select(e => { e.ChangeFocus(true); return(e); }).ToList(); // Set first ally as focused EventSystem.current.SetSelectedGameObject(_fighters.First(e => e.player != _activeFighter.player && e.dead == false).gameObject); } else { // Set allies focusable _fighters.FindAll(e => e.player == _activeFighter.player && e.dead == false).Select(e => { e.ChangeFocus(true); return(e); }).ToList(); // Set first ally as focused EventSystem.current.SetSelectedGameObject(_fighters.First(e => e.player == _activeFighter.player && e.dead == false).gameObject); } } }
public void AddDamage(PlayerStats attacker, int damage, Ability.AbilityType type) { //Debug.Log(Stats.Health); // reset the damage counter timer everytime I take damage m_RecentDamageTimer = m_TimeForRecentDamage + Time.time; m_RecentDamage += damage; // check if my recent damage is above the threshold if (m_RecentDamage >= m_AmountOfDamageAllowed) { // find a random teleport location and switch my state to teleport there SwitchState(new BossTeleportAIState(this, TeleportLocations[Random.Range(0, 4)])); m_RecentDamage = 0; } m_PlayerDamages[attacker] += damage; m_NeedNewTarget = CheckIfNeedNewTarget(); if (m_NeedNewTarget) { m_CurrentTargetAbilityType = type; } float tenPercentOfMaxHealth = Stats.MaxHealth * 0.1f; float maxHealthMinusTenPercent = Stats.MaxHealth - tenPercentOfMaxHealth; float currentHealthMinusTenPercent = Stats.Health - tenPercentOfMaxHealth; float AbilityTimerCoolDownMultiplier = ((currentHealthMinusTenPercent / maxHealthMinusTenPercent) + 1) / 2f; m_GroundShockCoolDownTime *= AbilityTimerCoolDownMultiplier; m_EnergyMineCoolDownTime *= AbilityTimerCoolDownMultiplier; m_KnockbackCoolDownTime *= AbilityTimerCoolDownMultiplier; }
public Skill(string name, Ability.AbilityType asset, string descr) : this() { this.name = name; this.asset = asset; this.description = descr; }
public Ability GetAbility(Ability.AbilityType type) { if (registry.TryGetValue(type, out AbilitySettings item)) { return(item.ability); } return(null); }
public void NewActivity(Ability.AbilityType activityType, float castTime, int castTimes, float range, bool move) { currentActivityType = activityType; AbilityCastTime = castTime; AbilityCastTimes = castTimes; TargetAbilityRange = range; CanMove = move; TargetGameObject = Hit.collider.gameObject; TargetPosition = new Vector3(Hit.point.x, transform.position.y, Hit.point.z); }
public void SetVars(int damage_, float range, Effect.AbilityEffect effect_, GameObject owner, Ability.AbilityType aType) { damage = damage_; maxRange = range; effect = effect_; _owner = owner; abilityType = aType; startPosition = transform.position; }
public int GetAbilityLevel(Ability.AbilityType type) { if (abilities.TryGetValue(type, out int currentLevel)) { return(currentLevel); } else { return(abilityRegistry.GetAbility(type).initialLevel); } }
//public float m_ExplosionCountdown = 1.0f; //public float m_GracePeriod = 2.0f; public override void Initialize(CharacterStats attacker, Ability.AbilityType type, int abilityDamage, float lifetime) { Attacker = attacker; Type = type; AbilityDamage = abilityDamage; ExplosionDamage += attacker.Damage; m_LifeTime = lifetime + Time.time; //m_ExplosionCountdown = lifetime + Time.time; //m_GracePeriod += Time.time; }
public void ExecuteAbility(string abilityName, Target target) { Ability ability = this.GetAbility(abilityName); Ability.AbilityType abilityType = ability.GetAbilityType(); if (abilityType == Ability.AbilityType.Major) { --this.numMajorAbilities; } if (abilityType == Ability.AbilityType.Minor) { --this.numMinorAbilities; } ability.Execute(target); }
public bool IncreaseAbilityLevel(Ability.AbilityType type) { Ability ability = abilityRegistry.GetAbility(type); int currentLevel; if (!abilities.TryGetValue(type, out currentLevel)) { currentLevel = ability.initialLevel; } if (currentLevel < ability.maximumLevel) { abilities[type] = currentLevel + 1; onAbilityLevelChange?.Invoke(new AbilityLevelChangeArg(gameObject, ability, abilities[type])); return(true); } return(false); }
/// <summary> /// Add the specified ability. /// </summary> /// <param name="ability">Ability.</param> public void Add(Ability ability) { _abilities.Add(ability.Id, ability); // Set ability type flags based on passed in abilities Ability.AbilityType type = ability.Type; if (type == Ability.AbilityType.TALENT) { if (!HasTalent) { HasTalent = true; } } else if (type == Ability.AbilityType.MAGIC) { if (!HasMagic) { HasMagic = true; } } }
/// <summary> /// Plays the attack animations. /// </summary> /// <returns>The attack animations.</returns> /// <param name="attacker">Attacker.</param> /// <param name="direction">Direction.</param> protected IEnumerator PlayAttackAnimations(Unit attacker, Vector3 direction) { Ability.AbilityType abilityType = attacker.Action.Ability.Type; if (abilityType == Ability.AbilityType.ATTACK || attacker.Action.Ability.Id == AbilityConstants.MEASURED_STRIKE) { //determine which way to swing, dependent on the direction the enemy is Unit.TileDirection facing = attacker.GetDirectionToTarget(direction); UnitAnimationController animationController = attacker.GetAnimationController(); switch (facing) { case Unit.TileDirection.NORTH: animationController.AttackNorth(); break; case Unit.TileDirection.EAST: animationController.AttackEast(); break; case Unit.TileDirection.SOUTH: animationController.AttackSouth(); break; case Unit.TileDirection.WEST: animationController.AttackWest(); break; } } else if (attacker.Action.Ability.Id == AbilityConstants.WHIRLWIND_SLASH) { UnitAnimationController animationController = attacker.GetAnimationController(); animationController.WhirlwindSlash(); } else if (attacker.Action.Ability.Id == AbilityConstants.LEAPING_SLICE) { UnitAnimationController animationController = attacker.GetAnimationController(); animationController.LeapingSlice(); } yield return(null); }
public bool IsAbilityExecutable(string abilityName) { Ability ability = this.GetAbility(abilityName); bool result = false; Ability.AbilityType abilityType = ability.GetAbilityType(); if (ability.uses > 0) { if (abilityType == Ability.AbilityType.Major && this.numMajorAbilities > 0) { result = true; } if (abilityType == Ability.AbilityType.Minor && this.numMinorAbilities > 0) { result = true; } } return(result); }
public override void Initialize(CharacterStats attacker, Ability.AbilityType type, int abilityDamage, float lifetime) { base.Initialize(attacker, type, abilityDamage, lifetime); }
public int GetAbilityValueInt(Ability.AbilityType type) { return(Mathf.FloorToInt(GetAbilityValue(type))); }
/// <summary> /// Performs the action of the attacker against their targets. /// </summary> /// <returns>The action.</returns> /// <param name="attacker">Attacker.</param> protected IEnumerator PerformAbilityAction(Unit attacker) { if (attacker.Action.Item != null) { // Lower music so you can hear ability SFX yield return(StartCoroutine(controller.MusicController.LowerCombatMusic())); // Show name of ability being used attacker.TileHighlighter.RemoveHighlightedTiles(); Item item = attacker.Action.Item; controller.ActionController.Activate(item.Name); yield return(new WaitForSeconds(0.5f)); // Spawn VFX on all targets List <Unit> targets = attacker.Action.Targets; List <GameObject> vfxGameObjects = ApplyVFXToTargets(item.VFXPath, targets); // Iterate over all effects, apply them, and if there is something to display, show it PopupTextController.Initialize(attacker.GetCanvas()); List <Effect> effects = ConsumableEffectCalculator.GetConsumableEffects(item); yield return(StartCoroutine(ApplyEffects(targets, effects))); attacker.UpdateHealthbar(); // Show XP floaty text ShowXPFloatyText(new ExperienceManager().AwardConsumableExperience(attacker), attacker); yield return(new WaitForSeconds(1.0f)); // Destroy VFX's DestroyVFX(vfxGameObjects); // Remove name of used ability controller.ActionController.Deactivate(); // Bring music back up to normal volume yield return(StartCoroutine(controller.MusicController.RaiseCombatMusic())); controller.ChangeState <TurnOverState> (); } // If the ability takes more than x turns, defer the ability action else if (!attacker.HasDeferredAbility && attacker.Action.Ability.Turns > 1) { attacker.HasDeferredAbility = true; yield return(null); controller.ChangeState <TurnOverState> (); } else { // Reset bool flags depending on if a deferred attack is being executed if (attacker.HasDeferredAbility) { attacker.HasDeferredAbility = false; attacker.HasExecutedDeferredAbility = true; } // Lower music so you can hear ability SFX yield return(StartCoroutine(controller.MusicController.LowerCombatMusic())); // Show name of ability being used attacker.TileHighlighter.RemoveHighlightedTiles(); Ability ability = attacker.Action.Ability; controller.ActionController.Activate(ability.Name); yield return(new WaitForSeconds(0.5f)); // Spawn VFX on all targets List <Unit> targets = attacker.Action.Targets; List <GameObject> vfxGameObjects = ApplyVFXToTargets(ability.VFXPath, targets); // Start Combat Combat combat = new Combat(controller.HighlightedUnit); combat.Begin(); // Play weapon sound effect Ability.AbilityType abilityType = attacker.Action.Ability.Type; if (abilityType == Ability.AbilityType.ATTACK || abilityType == Ability.AbilityType.TALENT) { attacker.PlayWeaponSound(); } // Show target(s) being damaged ShowDamagedColorOnTargets(true, targets); // Play animations yield return(StartCoroutine(PlayAttackAnimations(attacker, targets [0].Tile))); // Iterate over all effects, apply them, and if there is something to display, show it PopupTextController.Initialize(attacker.GetCanvas()); yield return(StartCoroutine(ApplyEffectsByUnit(attacker.Action.GetEffectsByUnit()))); yield return(new WaitForSeconds(1.0f)); // Stop showing target(s) being damaged ShowDamagedColorOnTargets(false, targets); // Show XP floaty text ShowXPFloatyText(combat.GetAwardedExperience(), attacker); yield return(new WaitForSeconds(1.0f)); // Destroy VFX's DestroyVFX(vfxGameObjects); // Remove name of used ability controller.ActionController.Deactivate(); // Bring music back up to normal volume yield return(StartCoroutine(controller.MusicController.RaiseCombatMusic())); controller.ChangeState <TurnOverState> (); } }
/// <summary> /// Internal Function. Finds the correct "Equipped Abilities" slot to put the newly equipped ability in, /// inserts it and removes what was there before. /// <para> Hybrid abilities can be equipped in either slot of their category, thus the function can be told which of the two slots the /// player wants to equip the ability to. </para> /// </summary> /// <param name="equippedAbility">The ability to be equipped.</param> /// <param name="equippedAbilityType">Which slot the ability should be equipped in. Either Primary, Secondary or Synnergised.</param> void ProcessNewAbility(Ability newAbility, Ability.AbilityType newAbilityType) { // first we check if the new ability is a primary or secondary ability. if (newAbilityType == Ability.AbilityType.Primary) // deals with all the primary abilities { // Then we must check the ability's category - this tells us where to put it in the UI and arrays. switch (newAbility.abilityCategory) { case Ability.AbilityCategory.Jump: // This ability is a Primary Jump { AddAbility(newAbility, (int)AbilityNameIndex.PrimaryJump); } break; case Ability.AbilityCategory.Melee: // This ability is a Primary Attack { AddAbility(newAbility, (int)AbilityNameIndex.PrimaryAttack); } break; case Ability.AbilityCategory.Defense: // This ability is a Primary Defense { AddAbility(newAbility, (int)AbilityNameIndex.PrimaryDefense); } break; case Ability.AbilityCategory.Ranged: // This ability is a Primary Ranged { AddAbility(newAbility, (int)AbilityNameIndex.PrimaryRanged); } break; } } else if (newAbilityType == Ability.AbilityType.Secondary) // Deals with all the secondary abilities { // We must check the ability's category - this tells us where to put it in the UI and arrays. switch (newAbility.abilityCategory) { case Ability.AbilityCategory.Jump: // This ability is a Secondary Jump { AddAbility(newAbility, (int)AbilityNameIndex.SecondaryJump); } break; case Ability.AbilityCategory.Melee: // This ability is a Secondary Attack { AddAbility(newAbility, (int)AbilityNameIndex.SecondaryAttack); } break; case Ability.AbilityCategory.Defense: // This ability is a Secondary Defense { AddAbility(newAbility, (int)AbilityNameIndex.SecondaryDefense); } break; case Ability.AbilityCategory.Ranged: // This ability is a Secondary Ranged { AddAbility(newAbility, (int)AbilityNameIndex.SecondaryRanged); } break; } } else if (newAbilityType == Ability.AbilityType.Synergised) // Ability is a synnergised ability - arising from special { // ability combinations. Will implement later. Debug.LogWarning("Synnergy Functionality not implemented yet." + " Cannot equip " + newAbility.name + "."); } else if (newAbilityType == Ability.AbilityType.Hybrid) // Ability entered was a Hybrid ability - which shouldn't have happened. { // The user must choose to treat this as either primary or secondary. Debug.LogWarning("Player choice for hybrid's usage not defined. Please choose either primary or secondary type" + " to equip " + newAbility.name + "."); return; } // I would have used nested switch statements, but that was far harder to read than this - so for the // sake of understanding I used if statements. }
/// <summary> /// Adds this ability to the correct 'Equipped Abilities' slot and unequips what was initially there. /// <para>Use this overloaded version for Hybrid abilities, as they require the user to choose whether they want to use the /// ability as a primary or secondary ability.</para> /// </summary> /// <param name="newAbility">Ability to be equipped.</param> /// <param name="newAbilityType">The type of ability the user wants to treat this as. Either Primary or Secondary.</param> public void EquipAbility(Ability newAbility, Ability.AbilityType newAbilityType) { ProcessNewAbility(newAbility, newAbilityType); }
public float GetAbilityValue(Ability.AbilityType type) { return(abilityRegistry.GetAbility(type).ValueAtLevel(GetAbilityLevel(type))); }