Пример #1
0
    public void setupBoard(int iRows, int iCols, int in_ConnectToWin)
    {
        int i, j;

        for (i = 0; i < iRows; i++)
        {
            for (j = 0; j < iCols; j++)
            {
                Cell cell = Instantiate(CellPrefab, Vector3.zero, Quaternion.identity).GetComponent <Cell>();
                cell.iRow  = i;
                cell.iCol  = j;
                cell.board = this;
                cell.updatePosition();
                cell.transform.SetParent(transform);
                cells.Add(cell);
            }
        }


        for (j = 0; j < iCols; j++)
        {
            ColumnSelect columnselect = Instantiate(ColumnSelectPrefab, Vector3.zero, Quaternion.identity).GetComponent <ColumnSelect>();
            columnselect.iCol = j;
            columnselect.transform.SetParent(transform);
            columnselect.board       = this;
            columnselect.gamemanager = gamemanager;
            columnselect.updatePosition();
        }


        iConnectToWin = in_ConnectToWin;
    }
Пример #2
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();
            }
        }
    }