public void DoDamage(int damage, IDestroyable target)
 {
     if (target != null)
     {
         target.ReceiveDamage(damage);
     }
 }
Ejemplo n.º 2
0
    private void OnTriggerEnter2D(Collider2D other)
    {
        IDestroyable go = other.GetComponent <IDestroyable>();

        if (go != null && !hasCollided)
        {
            //Debug.Log("Hit enemy:" + other.name);

            go.ReceiveDamage(damage);

            GameObject hitPS = PoolManager.instance.GetObject(onHitPS);
            hitPS.transform.position = transform.position;
            hitPS.transform.rotation = transform.rotation;
            hitPS.SetActive(true);
            ParticleSystem ps = hitPS.GetComponent <ParticleSystem>();
            ps.Emit(3);

            hasCollided = true;

            gameObject.SetActive(false);
        }
    }