예제 #1
0
        /// <summary>
        /// Tries to rotate the tile that is behind mouse position.
        /// </summary>
        /// <param name="degrees">the degree value the tile will be rotated by.</param>
        private void TryToRotateTile(int degrees)
        {
            GameObject hitObject = VMEGlobal.GetTileAtMousePosition();

            if (hitObject != null)
            {
                hitObject.transform.Rotate(new Vector3(0, degrees, 0));
            }
        }
예제 #2
0
        /// <summary>
        /// Handles editor input.
        /// </summary>
        public void Input(SceneView view)
        {
            Event e = Event.current;

            if (e.isKey)
            {
                if (e.type == EventType.KeyDown)
                {
                    if (e.keyCode == settings.APPLY_SINGLE)
                    {
                        if (state == SelectState.Two)
                        {
                            state = SelectState.None;
                            GetSelectionOfObjects();
                        }
                    }
                }
            }

            if (e.type == EventType.MouseDown)
            {
                Vector3 tar = VMEGlobal.GetPositionNextToHoveredTile();

                if (e.button == 0)
                {
                    if (tar == new Vector3(0, 9000, 0))
                    {
                        firstTarget.transform.position  = new Vector3(0, 9000, 0);
                        secondTarget.transform.position = new Vector3(0, 9000, 0);
                        state = SelectState.None;
                    }
                    else
                    {
                        if (state == SelectState.None)
                        {
                            firstTarget.transform.position = tar;
                            state = SelectState.One;
                        }
                        else if (state == SelectState.One)
                        {
                            secondTarget.transform.position = tar;
                            state = SelectState.Two;
                        }
                    }
                }
            }
        }
예제 #3
0
        public override void Input(SceneView sceneView)
        {
            base.Input(sceneView);
            searchWindow.Input(sceneView);

            Event e = Event.current;

            if (e.isKey)
            {
                if (e.keyCode == KeyCode.I)
                {
                    GameObject target = VMEGlobal.GetTileAtMousePosition();

                    if (target != null)
                    {
                        SetSwatchSelection(target);
                    }
                }
            }
        }
예제 #4
0
        public void PaintAtHoverPosition()
        {
            //Get GameObject that we hovered over to check if we can paint,
            //also use its rotation for the new tile.
            GameObject hoveredTile = VMEGlobal.GetTileAtMousePosition();

            //if theres none.
            if (hoveredTile == null)
            {
                Debug.LogWarning("[Paint Mode]: Not hovered over a tile, thereby can't paint a tile.");
            }
            else
            {
                //Get selected item in Swatch.
                GameObject selectedSwatchItem = voxelSwatchReference.GetSelectedTile();

                //Get position next to hovered tile.
                Vector3 newPosition = VMEGlobal.GetPositionNextToHoveredTile();

                //Paint the tile.
                VMEMainWindow.Instance.tileAddControls.PaintTIle(selectedSwatchItem, hoveredTile, newPosition);
            }
        }
예제 #5
0
        /// <summary>
        /// Tries to switch the tile to another style of that tile.
        /// </summary>
        private void TryToSwitchTileStyle()
        {
            //Get the tile i'm pointing at.
            GameObject target = VMEGlobal.GetTileAtMousePosition();

            if (target == null)
            {
                Debug.LogWarning("[Edit Mode - SwapStyle]: No target selected.");
            }
            else
            {
                VSTileGroup group = voxelSwatchReference.GetSwatch().GetGroupByName(target.name);

                if (group == null)
                {
                    Debug.LogWarning("[Edit Mode - SwapStyle]: This tile is not a item from the VoxelSwatch. Style swap not possible.");
                }
                else
                {
                    GameObject[] itemsInGroup = group.styles.ToArray();

                    if (itemsInGroup.Length == 1)
                    {
                        Debug.LogWarning("[Edit Mode - SwapStyle]: The Tile of type: " + target.name + " Only has one variation.");
                    }
                    else
                    {
                        int currentIndexInGroup = -1;
                        Debug.Log("Items in the group: " + itemsInGroup.Length);
                        for (int i = 0; i < itemsInGroup.Length; i++)
                        {
                            if (target.name == itemsInGroup[i].name)
                            {
                                currentIndexInGroup = i;
                                Debug.Log(currentIndexInGroup);
                            }
                        }


                        int newIndex = -1;

                        if (currentIndexInGroup != -1)
                        {
                            Debug.Log(currentIndexInGroup + " : " + itemsInGroup.Length);
                            if (currentIndexInGroup + 1 == itemsInGroup.Length)
                            {
                                newIndex = 0;
                            }
                            else
                            {
                                newIndex = currentIndexInGroup + 1;
                            }

                            if (currentIndexInGroup != newIndex)
                            {
                                VMEMainWindow.Instance.tileAddControls.EditTile(itemsInGroup[newIndex].gameObject, target);
                            }
                        }
                    }
                }
            }
        }