Exemplo n.º 1
0
    private void handleInput()
    {
        //handle input through the OnMouseDown of ColumnSelect
        //        if (Input.GetMouseButtonDown(0)) {
        gamemanager.board.unhoverAll();


        Ray        ray = Camera.main.ScreenPointToRay(Input.mousePosition);
        RaycastHit raycasthit;

        Physics.Raycast(ray, out raycasthit);
        if (raycasthit.collider != null)
        {
            ColumnSelect columnselect = raycasthit.collider.GetComponent <ColumnSelect>();
            if (columnselect != null)
            {
                if (Input.GetMouseButtonDown(0))
                {
                    gamemanager.playColumn(columnselect.iCol);
                }
                else
                {
                    columnselect.setHovered(true, gamemanager.matDiscs[iPlayerIndex]);
                }
            }

            LightSwitch lightswitch = raycasthit.collider.GetComponent <LightSwitch>();
            if (lightswitch != null && Input.GetMouseButtonDown(0))
            {
                Debug.Log("lightswitch clicked");
                lightswitch.toggleLights();
            }

            SwitchDoorbell switchdoorbell = raycasthit.collider.GetComponent <SwitchDoorbell>();
            if (switchdoorbell != null && Input.GetMouseButtonDown(0))
            {
                Debug.Log("doorbell pressed");
                switchdoorbell.playDoorbell();
            }

            Painting painting = raycasthit.collider.GetComponent <Painting>();
            if (painting != null && Input.GetMouseButtonDown(0))
            {
                painting.doChangePainting();
            }
        }
    }