예제 #1
0
        public void Update()
        {
            Ray ray = Camera.main.ScreenPointToRay(Mouse.current.position.ReadValue());

            if (hexGrid.TryRaycastHexGrid(ray, out Vector3 worldPosition) && flyingBuilding != null)
            {
                flyingBuilding.gameObject.SetActive(true);
                Vector3 CoordsOfCenter = HexMetrics.CalcCenterCoordXZFromHexCoordXZ(HexMetrics.CalcHexCoordXZFromDefault(worldPosition, hexGrid.MapData.cellSize), hexGrid.MapData);

                isAvailable = IsPossibleToBuild(flyingBuilding, HexMetrics.CalcHexCoordXZFromDefault(CoordsOfCenter, hexGrid.MapData.cellSize));

                #region syncing data with building
                flyingBuilding.HexCoords          = HexMetrics.CalcHexCoordXZFromDefault(CoordsOfCenter, hexGrid.MapData.cellSize);
                flyingBuilding.transform.position = CoordsOfCenter;
                flyingBuilding.SetTransparent(isAvailable);
                #endregion
            }
        }
예제 #2
0
        void Update()
        {
            if (hexGrid.TryRaycastHexGrid(Camera.main.ScreenPointToRay(Input.mousePosition), out Vector3 center))
            {
                if (Input.GetKey(KeyCode.LeftShift) && Input.GetMouseButton(0))
                {
                    worldEditor.TryUpdateCellHeight(HexMetrics.CalcHexCoordXZFromDefault(center, hexGrid.MapData.cellSize), .5f);
                }
                if (Input.GetKey(KeyCode.LeftShift) && Input.GetMouseButton(1))
                {
                    worldEditor.TryUpdateCellHeight(HexMetrics.CalcHexCoordXZFromDefault(center, hexGrid.MapData.cellSize), -.5f);
                }

                if (Input.GetKey(KeyCode.LeftAlt) && Input.GetMouseButton(0))
                {
                    worldEditor.TryUpdateCellHeightInRadius(HexMetrics.CalcHexCoordXZFromDefault(center, hexGrid.MapData.cellSize), .5f, radiusToChange);
                }
                if (Input.GetKey(KeyCode.LeftAlt) && Input.GetMouseButton(1))
                {
                    worldEditor.TryUpdateCellHeightInRadius(HexMetrics.CalcHexCoordXZFromDefault(center, hexGrid.MapData.cellSize), -.5f, radiusToChange);
                }

                if (Input.GetKey(KeyCode.LeftControl) && Input.GetMouseButton(0))
                {
                    worldEditor.TryUpdateCellHeight(HexMetrics.CalcHexCoordXZFromDefault(center, hexGrid.MapData.cellSize), .5f, targetHeight);
                }
                if (Input.GetKey(KeyCode.LeftControl) && Input.GetMouseButton(1))
                {
                    worldEditor.TryUpdateCellHeightInRadius(HexMetrics.CalcHexCoordXZFromDefault(center, hexGrid.MapData.cellSize), .5f, radiusToChange, targetHeight);
                }

                if (Input.GetKey(KeyCode.P) && Input.GetMouseButton(0))
                {
                    worldEditor.TryUpdateCellColor(HexMetrics.CalcHexCoordXZFromDefault(center, hexGrid.MapData.cellSize), curColor);
                }
            }
        }