void Update() { if (!GameOver) { if (inRecycleBin != null) { if (!inRecycleBin.IsClickedOn) { inRecycleBin.HoverOverBin = false; iconPool.ReturnGameObjectToPool(inRecycleBin.gameObject); inRecycleBin = null; recycleSound.Play(); shakeGameObject(gameObject, 0.3f, 0.1f); score++; } } if ((float)iconPool.NumberOfActiveObjects / (float)iconPool.MaxNumberOfObjects > 0.85) { GameOver = true; resetPanel.SetActive(true); resetButton.Init(); if (!errorSoundPlayed) { errorPopUp.Play(); errorSoundPlayed = true; } } } }
public void Reset() { score = 0; if (inRecycleBin != null) { inRecycleBin.HoverOverBin = false; } inRecycleBin = null; GameOver = false; }
private void OnTriggerExit2D(Collider2D other) { if (!GameOver) { if (inRecycleBin != null) { inRecycleBin.HoverOverBin = false; } inRecycleBin = null; } }
void OnTriggerEnter2D(Collider2D other) { if (!GameOver) { inRecycleBin = other.gameObject.GetComponent <InteractableIcon>(); if (inRecycleBin != null) { inRecycleBin.HoverOverBin = true; } } }
InteractableIcon CheckForIcon() { RaycastHit2D hit = Physics2D.Raycast(transform.position, Vector2.zero); if (hit.collider != null) { InteractableIcon temp = hit.collider.gameObject.GetComponent <InteractableIcon>(); return(temp); } return(null); }
void UpdateMouseInteraction() { if (inputManager.IsClicked) { clickSound.Stop(); clickSound.Play(); if (currentInteractingIcon == null) { CheckForButtons(); } if (RecycleBin.GameOver) { if (currentInteractingIcon != null) { PlaceIcon(); renderer.enabled = true; } } else { if (currentInteractingIcon == null) { currentInteractingIcon = CheckForIcon(); if (currentInteractingIcon != null) { currentInteractingIcon.OnClick(); } } else { PlaceIcon(); renderer.enabled = true; } } } if (currentInteractingIcon != null) { DragIcon(); renderer.enabled = false; } }
protected virtual void Awake() { CurrentUser = null; Icon = InteractableIcon.Create(this); }
void PlaceIcon() { currentInteractingIcon.OnClick(); currentInteractingIcon = currentInteractingIcon.IsClickedOn ? currentInteractingIcon : null; }