/// <summary> /// Mage player's secondary attack /// </summary> protected override void SecondaryAttack() { // Ensure player has enough mana to perform this attack if (AttackCooldown > 0 || (Stats as PlayerStatsController).mana.CurrentValue < secondaryAttackManaDepletion) { return; } StartCoroutine(VfxHelper.CreateVFX(secondaryVFX, transform.position + new Vector3(0, 0.01f, 0), Quaternion.identity, PlayerManager.colours.GetColour(Stats.characterColour))); // Check all enemies within attack radius of the player List <Transform> enemies = GetSurroundingEnemies(secondaryAttackRadius); // Attack any enemies within the AOE range foreach (var enemy in enemies) { StartCoroutine(PerformExplosiveDamage(enemy.GetComponent <EntityStatsController>(), secondaryAttackMaxDamage, secondaryAttackStunTime, secondaryAttackExplosionForce, transform.position, secondaryAttackRadius, secondaryAttackDamageDelay)); } // Trigger secondary attack animation Anim.SetTrigger("SecondaryAttack"); // Play the attack audio StartCoroutine(AudioHelper.PlayAudioOverlap(WeaponAudio, secondaryAttackWeaponSFX)); // Reset attack timeout and deplete mana AttackCooldown = secondaryAttackTimeout; (Stats as PlayerStatsController).mana.Subtract(secondaryAttackManaDepletion); // Apply movement speed modifier StartCoroutine(Motor.ApplyTimedMovementModifier(secondaryAttackMovementModifier, secondaryAttackTimeout)); }
/// <summary> /// Healer's primary attack /// </summary> protected override void PrimaryAttack() { if (AttackCooldown > 0 || (Stats as PlayerStatsController).mana.CurrentValue < primaryAttackManaDepletion) { return; } // Check all enemies within attack radius of the player List <Transform> enemies = GetSurroundingEnemies(primaryAttackRadius); float baseDamage = Stats.damage.GetValue(); // Attack any enemies within the attack sweep and range foreach (var enemy in enemies.Where(enemy => CanDamageTarget(enemy, primaryAttackRadius, primaryAttackSweepAngle))) { // Calculate and perform damage float damageValue = Random.Range(primaryAttackMinDamage + baseDamage, primaryAttackMaxDamage + baseDamage); StartCoroutine(PerformDamage(enemy.GetComponent <EntityStatsController>(), damageValue, primaryAttackDamageDelay)); } // Trigger primary attack animation StartCoroutine(TriggerTimeAttackAnimation("PrimaryAttack", primaryAttackTimeout)); // Play the attack audio StartCoroutine(AudioHelper.PlayAudioOverlap(WeaponAudio, primaryAttackWeaponSFX)); // Reset attack timeout and deplete mana AttackCooldown = primaryAttackTimeout; (Stats as PlayerStatsController).mana.Subtract(primaryAttackManaDepletion); // Apply movement speed modifier StartCoroutine(Motor.ApplyTimedMovementModifier(primaryAttackMovementModifier, primaryAttackTimeout)); }
/// <summary> /// Healer's secondary attack /// </summary> protected override void SecondaryAttack() { if (AttackCooldown > 0 || (Stats as PlayerStatsController).mana.CurrentValue < secondaryAttackManaDepletion) { return; } float baseDamage = Stats.damage.GetValue(); float damageValue = Random.Range(secondaryAttackMinDamage + baseDamage, secondaryAttackMaxDamage + baseDamage); float healingValue = Random.Range(secondaryAttackMinHealing, secondaryAttackMaxHealing); // Launch projectile in the direction the player is facing StartCoroutine(LaunchProjectile(projectilePrefab, transform.forward, secondaryAttackLaunchForce, secondaryAttackRange, damageValue, healingValue, secondaryAttackLaunchDelay)); // Trigger secondary attack animation Anim.SetTrigger("SecondaryAttack"); // Play the attack audio StartCoroutine(AudioHelper.PlayAudioOverlap(WeaponAudio, secondaryAttackWeaponSFX)); // Reset attack timeout and deplete mana AttackCooldown = secondaryAttackTimeout; (Stats as PlayerStatsController).mana.Subtract(secondaryAttackManaDepletion); // Apply movement speed modifier StartCoroutine(Motor.ApplyTimedMovementModifier(secondaryAttackMovementModifier, secondaryAttackTimeout)); }
/// <summary> /// Melee's secondary attack /// </summary> protected override void SecondaryAttack() { // Ensure player has enough mana to perform this attack if (AttackCooldown > 0 || (Stats as PlayerStatsController).mana.CurrentValue < secondaryAttackManaDepletion) { return; } StartCoroutine(VfxHelper.CreateVFX(secondaryVFX, transform.position + new Vector3(0, 0.01f, 0), transform.rotation, PlayerManager.colours.GetColour(Stats.characterColour), secondaryAttackDamageDelay)); // Check all enemies within attack radius of the player List <Transform> enemies = GetSurroundingEnemies(secondaryAttackRadius); // Attack any enemies within the attack sweep and range foreach (var enemy in enemies.Where(enemy => CanDamageTarget(enemy, secondaryAttackRadius, secondaryAttackSweepAngle))) { // Calculate and perform damage float damageValue = Random.Range(secondaryAttackMinDamage, secondaryAttackMaxDamage + Stats.damage.GetValue()); StartCoroutine(PerformDamage(enemy.GetComponent <EntityStatsController>(), damageValue, secondaryAttackDamageDelay)); } // Trigger secondary attack animation Anim.SetTrigger("SecondaryAttack"); // Play the attack audio StartCoroutine(AudioHelper.PlayAudioOverlap(WeaponAudio, secondaryAttackWeaponSFX)); // Reset attack timeout and deplete mana AttackCooldown = secondaryAttackTimeout; (Stats as PlayerStatsController).mana.Subtract(secondaryAttackManaDepletion); // Apply movement speed modifier StartCoroutine(Motor.ApplyTimedMovementModifier(secondaryAttackMovementModifier, secondaryAttackTimeout)); }
/// <summary> /// Ranger's secondary attack /// </summary> protected override void SecondaryAttack() { if (AttackCooldown > 0 || (Stats as PlayerStatsController).mana.CurrentValue < secondaryAttackManaDepletion) { return; } // Place explosive trap StartCoroutine(PlaceTrap(secondaryAttackTrapPrefab, secondaryAttackSpawnDelay)); // Trigger secondary attack animation Anim.SetTrigger("SecondaryAttack"); // Play the attack audio StartCoroutine(AudioHelper.PlayAudioOverlap(WeaponAudio, secondaryAttackWeaponSFX)); // Reset attack timeout and deplete mana AttackCooldown = secondaryAttackTimeout; (Stats as PlayerStatsController).mana.Subtract(secondaryAttackManaDepletion); // Apply movement speed modifier StartCoroutine(Motor.ApplyTimedMovementModifier(secondaryAttackMovementModifier, secondaryAttackTimeout)); }