// Animation event when guard attacks player public void attackVampire() { if (guardControl == null) { guardControl = GetComponentInParent <GuardControl>(); } guardControl.hurtVampire(); }
private void OnCollisionEnter2D(Collision2D collision) { GuardControl gc = collision.collider.GetComponent <GuardControl>(); if ((gc != null) || collision.collider.name.Equals("rightHand") || collision.collider.name.Equals("leftHand")) { aliveCount--; if (aliveCount == 1) { rigidbody2D.transform.Rotate(0, 0, 180); Vector2 temp = new Vector2(-forceV.x, forceV.y); rigidbody2D.AddForce(temp); } else { Destroy(gameObject); } /*Vector2 temp = new Vector2(-forceV.x, forceV.y); * rigidbody2D.AddForce(temp);*/ Debug.Log("Collision with Guard:" + collision.collider.name); return; } HitControl hc = collision.collider.GetComponent <HitControl>(); if (hc != null) { hc.hitted(); Destroy(gameObject); Debug.Log("Collision with Other:" + collision.collider.name); return; } Debug.Log("Collision!!!" + collision.collider.name); Destroy(gameObject); }