예제 #1
0
    public void CheckClick(bool editMode)
    {
        if (EventSystem.current.IsPointerOverGameObject())
        {
            return;
        }
        if (Input.GetMouseButtonDown(0))
        {
            Debug.Log(TAG + "Mouse clicked");
            RaycastHit hit;
            Vector3    dir = transform.TransformDirection(-Vector3.up);
            Ray        ray = mainCamera.ScreenPointToRay(Input.mousePosition);
            //check if hits a tool button
            if (Physics.Raycast(ray, out hit, 30.0f))
            {
                if (hit.collider.tag == "button")
                {
                    Debug.Log(TAG + "hit a button");
                    ButtonTool t = hit.collider.GetComponentInParent <ButtonTool>();
                    toolManager.SetCurTool(t);

                    return;
                }
                if (hit.collider.tag == "tool")
                {
                    Debug.Log(TAG + "hit a tool.");
                    return;                     //taking out this functionallity for now

                    Tool tool = hit.collider.GetComponentInParent <Tool>();

                    tool.EndUse();
                    toolManager.ClearCurTool();
                    return;
                }
                if (hit.collider.tag == "menuButton")
                {
                    Debug.Log(TAG + "menu button pressed");
                    MenuButton menuButton = hit.collider.GetComponentInParent <MenuButton>();
                    menuManager.MenuButtonPress(menuButton.Press());
                }
            }
            //if it is over a hex, press it
            if (curHex != null)
            {
                MouseClick(editMode);
                return;
            }

            //if it does not hit a hex
        }
    }