Exemple #1
0
        private void ProcessMouse()
        {
            Vector3   worldPosition = GridBuilderUtils.ScreenToWorld(uiRoot, Input.mousePosition);
            RectPoint rectPosition  = map[worldPosition];

            if (tileGrid.Contains(rectPosition))
            {
                if (blocksGrid[rectPosition] != null)
                {
                    SetHighlight(currentBlock, false);
                    currentBlock = blocksGrid[rectPosition];
                    SetHighlight(currentBlock, true);
                }
            }
        }
Exemple #2
0
    public void Update()
    {
        if (Input.GetMouseButtonDown(0))
        {
            // If you use a different GUI system, you will probably need a
            // custom version of this function.
            // This assumes your camera is orthographic. For perspective cameras,
            // you must use a ray casting method instead.
            Vector3 worldPosition = GridBuilderUtils.ScreenToWorld(root, Input.mousePosition);

            // Calculates the grid point that corresponds to the given world coordinate.
            RectPoint point = map[worldPosition];

            // The point may in fact lie outside the grid as we defined it when we built it.
            // So we first check whether the grid contains the point...
            if (grid.Contains(point))
            {
                //... and toggle the highlight of the cell
                grid[point].HighlightOn = !grid[point].HighlightOn;
            }
        }
    }
        public void Update()
        {
            if (Input.GetMouseButtonDown(0))
            {
                var worldPosition = GridBuilderUtils.ScreenToWorld(Input.mousePosition);
                var gridPoint     = map[worldPosition];

                if (grid.Contains(gridPoint))
                {
                    if (grid[gridPoint] != null)
                    {
                        grid[gridPoint].gameObject.SetActive(!grid[gridPoint].gameObject.activeInHierarchy);
                    }
                }
            }

            if (Input.GetKey(KeyCode.UpArrow))
            {
                cam.transform.position = cam.transform.position + Vector3.up * 10f;
            }

            if (Input.GetKey(KeyCode.DownArrow))
            {
                cam.transform.position = cam.transform.position + Vector3.down * 10f;
            }

            if (Input.GetKey(KeyCode.LeftArrow))
            {
                cam.transform.position = cam.transform.position + Vector3.left * 10f;
            }

            if (Input.GetKey(KeyCode.RightArrow))
            {
                cam.transform.position = cam.transform.position + Vector3.right * 10f;
            }
        }