private bool Allow(Collider2D incomingCollider) { //Debug.Log("<color=yellow>RingFilter | Check if " + incomingCollider.gameObject.name + " is allowed on a pin</color>"); if (incomingCollider == null) { // We only want to run checks for valid colliders return(false); } // Determine if the ring falling down is of a smaller size compared to the topmost // ring placed on this pin. RaycastHit2D hit = Physics2D.Raycast(raycastOrigin.position, Vector2.down, Mathf.Infinity, checkLayer); if (hit.collider != null) { //Debug.Log("<color=yellow>RingFilter | Hit a collider " + hit.collider.gameObject.name + "</color>"); Ring incomingRing = GameSystems.GetService <RingRegistry>().Get(incomingCollider.gameObject.GetInstanceID()); Ring hitRing = GameSystems.GetService <RingRegistry>().Get(hit.collider.gameObject.GetInstanceID()); if (incomingRing == null || hitRing == null) { return(false); } if (incomingRing.Size == hitRing.Size) { return(true); } //Debug.Log("<color=yellow>RingFilter | Hit a ring with size: " + hitRing.Size.ToString() + " (compared to incoming collider with size: " + incomingRing.Size.ToString() + ")</color>"); return(incomingRing.Size < hitRing.Size); } // No rings hit, pin is empty, so we allow // the incoming ring to fall down this pin return(true); }
private void DisableDragDropOnRing(int instanceID) { Ring ring = GameSystems.GetService <RingRegistry>().Get(instanceID); if (ring != null) { ring.DisableDragDropControls(); } }
private void PlaySFX(AudioClip clip) { GameSystems.GetService <IAudioHandler>().PlayOneShot(clip); }
void Start() { // We register this Ring object on Start instead of Awake to // ensure that the RingRegistry util has been properly instantiated. GameSystems.GetService <RingRegistry>().Register(this); }
private void TriggerSFX() { // Play the sfx for not allowing larger rings to drop GameSystems.GetService <IAudioHandler>().PlayOneShot(sfxClip); }