예제 #1
0
    void Update()
    {
        if (Input.GetKey(KeyCode.LeftAlt))
        {
            return;
        }

        BaseButtonInputs();

        if (Input.GetKeyDown(KeyCode.F))
        {
            myCamera.Focus(selectionController.selectionPivot.position);
        }

        RaycastHit hit;

        ray = Camera.main.ScreenPointToRay(Input.mousePosition);

        if (slotManager.selectedSlot.slotInfo.itemType != ItemType.move || selectionController.selectedList.Count == 0)
        {
            selectionController.controlPoint.gameObject.SetActive(false);
        }
        else
        {
            selectionController.controlPoint.gameObject.SetActive(true);
        }

        if (Physics.Raycast(ray, out hit, Mathf.Infinity, buttonMask))
        {
            switch (slotManager.selectedSlot.slotInfo.itemType)
            {
            case ItemType.block:
                if (Input.GetMouseButtonUp(0))
                {
                    blockController.Do(hit);
                }
                break;

            case ItemType.axe:
                if (Input.GetMouseButtonUp(0))
                {
                    //if it is selected, remove from lists
                    if (selectionController.selectedDict.ContainsKey(hit.transform))
                    {
                        selectionController.Deselect(hit.transform);
                    }

                    Destroy(hit.transform.parent.gameObject);
                }
                break;

            case ItemType.paintBucket:
                if (Input.GetMouseButton(0))
                {
                    paintManager.Paint(hit.transform.GetComponent <FaceButton>(), ColorPickerController.singletonInstance.GetSelectedColor());
                }

                break;

            case ItemType.select:
            case ItemType.move:

                if (hit.transform.tag == "EditHandle")
                {
                    break;
                }

                if (Input.GetKey(KeyCode.LeftShift) && Input.GetMouseButtonDown(0))
                {
                    selectionController.OnSelect(hit);
                }
                else
                {
                    if (Input.GetMouseButtonDown(0))
                    {
                        selectionController.OnDeselectAll();
                        selectionController.OnSelect(hit);
                    }
                }
                break;
            }
        }
        else
        {
            if (Input.GetMouseButtonDown(0))
            {
                selectionController.OnDeselectAll();
            }
        }
    }