private IEnumerator ChargeTowards(Transform other) { charging = true; attackSounds.PlayEffect((attackSounds.ChargeActive)); var direction = transform.position.x > other.transform.position.x ? Direction.Left : Direction.Right; var vector = (direction == Direction.Left ? Vector2.left : Vector2.right) * Velocity; while (charging) { if (direction == Direction.Left ? transform.position.x <other.transform.position.x : transform.position.x> other.transform.position.x) { FinishCharge(); } else { rb.AddForce(vector, ForceMode2D.Force); } yield return(null); } }
/// <summary> /// Shoots a <seealso cref="Projectile"/> in the given direction /// </summary> /// <param name="direction">The direction in wich the proyectile should shooted</param> public virtual void Shoot(Vector2 direction) { if (CanShoot()) { sounds.PlayEffect(sounds.cast); ShootWork(direction); } }
public void SwitchMode() { sounds.PlayEffect(sounds.changeMode); CurrentMode = (Mode)((int)++CurrentMode % 2); cursor.ChangueCursor((int)CurrentMode); aura.gameObject.SetActive(CurrentMode == Mode.MAGE); }
protected override void CastAnimator(Vector2 dir) { attackSounds.PlayEffect(attackSounds.cast); base.CastAnimator(dir); if (effectAnim) { effectAnim.SetTrigger("Casting"); } }
/// <summary> /// Heal health points /// </summary> private void HealingEffects(bool active) { if (active) { attackSounds.PlayEffect(attackSounds.healingEffect); } healingAnim.SetBool("Healing", active); playerAnim.SetBool("Healing", active); }
/// <summary> /// Make an attack on all game objects between the game object that has this component /// and the vector it is aiming to inside a range that has no obstacle between both. /// </summary> /// <param name="direction">The vector director the game object is aiming to. Must be normalized</param> public void MakeAttack(Vector2 direction) { if (!cooldown.CanUse()) { return; } sounds.PlayEffect(sounds.meleeAttack); AttackAnimator(); var targets = FindGameObjects(direction); foreach (var target in targets) { target.OnAttack(damage); } //if UNITY_EDITOR var hit = targets.Count > 0; Debug.DrawRay(transform.position, direction * range, hit ? Color.green : Color.red); //#endif }
private void DoubleJumpAnimation() { doubleJump.SetTrigger("Double"); sounds.PlayEffect(sounds.doubleJump); }