예제 #1
0
    private void OnButtonDown()
    {
        RaycastHit2D hit = Physics2D.GetRayIntersection(mainCamera.ScreenPointToRay(Input.mousePosition));

        if (hit.collider != null)
        {
            BoxScript hitBox = hit.collider.gameObject.GetComponent <BoxScript>();
            if (hitBox != null)
            {
                if (currentAnimal == null)
                {
                    currentAnimal = hitBox.GetAnimal();
                    if (currentAnimal != null)
                    {
                        currentAnimal.transform.SetParent(transform);
                    }
                }
                else
                {
                    if (!hitBox.IsFull())
                    {
                        hitBox.PutAnimnal(currentAnimal);
                        currentAnimal = null;
                        if (IsEnd())
                        {
                            //Debug.Log("END");
                            SummaryPopup.SummaryPopupInstance.ShowPopup();
                        }
                    }
                }
            }
        }
    }