Ejemplo n.º 1
0
    public void MeleeAttack(float x, float y, bool saveLastDirection)
    {
        if (!saveLastDirection)
        {
            AttackPoint.localPosition = new Vector3(x, y);
        }

        damagePoints = playerProperties.GetDamagePoints();

        Collider2D[] hitEnemies = Physics2D.OverlapCircleAll(AttackPoint.position, AttackSize, EnemyLayer);
        foreach (Collider2D hitEnemy in hitEnemies)
        {
            if (hitEnemy.isTrigger)
            {
                hitEnemy.GetComponent <EnemyProperties>().TakeDamage(damagePoints);
            }
        }
        AnimationMelee();

        if (!MeleeAttackSound.isPlaying)
        {
            MeleeAttackSound.Play();
        }
    }