예제 #1
0
    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);
        }
    }
예제 #2
0
 /// <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);
     }
 }
예제 #3
0
    public void SwitchMode()
    {
        sounds.PlayEffect(sounds.changeMode);
        CurrentMode = (Mode)((int)++CurrentMode % 2);

        cursor.ChangueCursor((int)CurrentMode);

        aura.gameObject.SetActive(CurrentMode == Mode.MAGE);
    }
예제 #4
0
 protected override void CastAnimator(Vector2 dir)
 {
     attackSounds.PlayEffect(attackSounds.cast);
     base.CastAnimator(dir);
     if (effectAnim)
     {
         effectAnim.SetTrigger("Casting");
     }
 }
예제 #5
0
    /// <summary>
    /// Heal health points
    /// </summary>
    private void HealingEffects(bool active)
    {
        if (active)
        {
            attackSounds.PlayEffect(attackSounds.healingEffect);
        }

        healingAnim.SetBool("Healing", active);
        playerAnim.SetBool("Healing", active);
    }
예제 #6
0
    /// <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
    }
예제 #7
0
 private void DoubleJumpAnimation()
 {
     doubleJump.SetTrigger("Double");
     sounds.PlayEffect(sounds.doubleJump);
 }