Example #1
0
    protected void WeaponAttackEnemies( )
    {
        foreach (GameObject enemy in allEnemies)
        {
            EnemyCharacter e = enemy.GetComponent <EnemyCharacter>( );

            float distance = Vector3.Distance(e.transform.position, transform.position);

            Vector3 dir = (e.transform.position - transform.position).normalized;

            float direction = Vector3.Dot(transform.forward, dir);

            if (direction > 0 && distance < attribute.attackDistance)
            {
                e.BeAttacked( );
                //if ( !isShaking ) StartCoroutine(Shake(0.1f));
            }
            else
            {
                //e.BeAttacked(false);
            }
        }
        return;
    }