Ejemplo n.º 1
0
    private void OnTriggerEnter2D(Collider2D collision)
    {
        Health targetHealth = collision.GetComponent <Health>();
        PlayerSidescrollController player = collision.GetComponent <PlayerSidescrollController>();
        SidescrollEnemy            enemy  = collision.GetComponent <SidescrollEnemy>();

        if (targetHealth)
        {
            if (player == null || !player.isBlocking)
            {
                /*if(player)
                 * {
                 *  player.ShowDamage();
                 * }
                 * if(enemy)
                 * {
                 *  enemy.ShowDamage();
                 * }*/
                targetHealth.DealDamage(damage);
                if (knockBack)
                {
                    if (player)
                    {
                        if (transform.position.x > collision.transform.position.x)
                        {
                            player.KnockBack(horizontalKnockback * -1, verticalKnockBack);
                        }
                        else if (transform.position.x <= collision.transform.position.x)
                        {
                            player.KnockBack(horizontalKnockback, verticalKnockBack);
                        }
                    }
                }
            }
        }
    }
Ejemplo n.º 2
0
 private void Start()
 {
     playerRigidBody = GetComponentInParent <Rigidbody2D>();
     player          = GetComponentInParent <PlayerSidescrollController>();
 }