示例#1
0
        public void Update()
        {
            if (Input.GetMouseButtonDown(0))
            {
                Vector3        mousePosition = Input.mousePosition;
                Vector2        worldPosition = GridBuilderUtils.ScreenToWorld(root, mousePosition);
                PointyHexPoint hexPoint      = map[worldPosition];

                if (grid.Contains(hexPoint))
                {
                    grid[hexPoint].HighlightOn = !grid[hexPoint].HighlightOn;
                }
            }
        }
示例#2
0
        public bool IsClosed(PointyHexPoint point)
        {
            var  neighbors = grid.GetAllNeighbors(point).ToList();
            bool isClosed  = true;

            //We use for loop so that we can use the index in the access operation below
            for (int i = 0; i < neighbors.Count(); i++)
            {
                if (grid.Contains(neighbors[i]))
                {
                    //(i + 3) % 6 is the opposite neighbor
                    //Here we abuse the fact that neighbors are returned in (anti-clockwise) order.
                    if (grid[point].EdgeData[i] != grid[neighbors[i]].EdgeData[(i + 3) % 6])
                    {
                        isClosed = false;
                    }
                }
            }

            return(isClosed);
        }
示例#3
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.
                PointyHexPoint 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;
                }
            }
        }
示例#4
0
        public void Update()
        {
            if (Input.GetMouseButtonDown(0))
            {
                Vector3        worldPosition = GridBuilderUtils.ScreenToWorld(Input.mousePosition);
                PointyHexPoint hexPoint      = map[worldPosition];

                if (grid.Contains(hexPoint))
                {
                    if (grid[hexPoint] != null)
                    {
                        grid[hexPoint].gameObject.SetActive(!grid[hexPoint].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;
            }
        }