private void OnCollisionEnter2D(Collision2D collision) { int collisionId = 0; if (collision.gameObject.tag == "Wall") { collisionId = collision.gameObject.GetComponent <Wall>().GetId(); SoundManager.instance.PlayBounceSFX(); if (id != collisionId) { changeOwnerNextUpdate = true; } else { } } else if (collision.gameObject.tag == "Grey Wall") { SoundManager.instance.PlayBounceSFX(); } else if (collision.gameObject.tag == "Puck") { if (!idle) { SoundManager.instance.PlayPengouinBounceSFX(); } Puck collidedpuck = collision.gameObject.GetComponent <Puck>(); collisionId = collidedpuck.GetId(); //PHYSICS collidedpuck.PuckCollision(idle); // if (id != collisionId) { changeOwnerNextUpdate = true; } else { } } else { return; } }
private void OnTriggerEnter2D(Collider2D collision) { if (collision.gameObject.tag == "Puck") { Puck puck = collision.gameObject.GetComponent <Puck>(); int puckId = puck.GetId(); //TODO If puck is different color from triggerOwner if (id != puckId) { GameManager.Instance.AddScore(puckId, puck.GetValue()); if (!puck.specialPuck) { SoundManager.instance.PlayGoalSFX(); } else { SoundManager.instance.PlayMaskedGoalSFX(); } } GameObject.Destroy(collision.gameObject); GameManager.Instance.SpawnPuck(puckId); } }