Beispiel #1
0
    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;
                }
            }
        }
    }
Beispiel #2
0
 public void Reset()
 {
     score = 0;
     if (inRecycleBin != null)
     {
         inRecycleBin.HoverOverBin = false;
     }
     inRecycleBin = null;
     GameOver     = false;
 }
Beispiel #3
0
 private void OnTriggerExit2D(Collider2D other)
 {
     if (!GameOver)
     {
         if (inRecycleBin != null)
         {
             inRecycleBin.HoverOverBin = false;
         }
         inRecycleBin = null;
     }
 }
Beispiel #4
0
 void OnTriggerEnter2D(Collider2D other)
 {
     if (!GameOver)
     {
         inRecycleBin = other.gameObject.GetComponent <InteractableIcon>();
         if (inRecycleBin != null)
         {
             inRecycleBin.HoverOverBin = true;
         }
     }
 }
Beispiel #5
0
    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);
    }
Beispiel #6
0
    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);
 }
Beispiel #8
0
 void PlaceIcon()
 {
     currentInteractingIcon.OnClick();
     currentInteractingIcon = currentInteractingIcon.IsClickedOn ? currentInteractingIcon : null;
 }