Esempio n. 1
0
    void EditionKeyboard()
    {
        Grid grid = (Grid)target;

        #region Grid editing shortcuts
        if (!Event.current.shift)
        {
            if (Event.current.type == EventType.KeyDown)
            {
                if ((Event.current.character == 'a' || Event.current.character == 'A') && grid.Edition != 1)
                {
                    ChangeEdition(1, target);
                }
                else if ((Event.current.character == 's' || Event.current.character == 'S') && grid.Edition != 2)
                {
                    ChangeEdition(2, target);
                }
                else if ((Event.current.character == 'd' || Event.current.character == 'D') && grid.Edition != 3)
                {
                    ChangeEdition(3, target);
                }
                else if ((Event.current.character == 'v' || Event.current.character == 'V') && grid.Edition != 3)
                {
                    ChangeEdition(0, target);
                }

                else if (Event.current.character == 'c' || Event.current.character == 'C')
                {
                    if (grid.EditionType == 1)
                    {
                        ChangeEditionType(2, target);
                    }
                    else if (grid.EditionType == 2)
                    {
                        ChangeEditionType(1, target);
                    }
                }

                else if (Event.current.character == 'z' || Event.current.character == 'Z')
                {
                    ChangeEdition(4, target);
                    PathUtility.UpdatePathLines(target);
                }

                else if (Event.current.character == 'x' || Event.current.character == 'X')
                {
                    ChangeEdition(5, target);
                    PathUtility.UpdatePathLines(target);
                }
            }
        }
        #endregion

        #region Increase/ Decrease grid shortcuts
        if (Event.current.type == EventType.KeyDown)
        {
            if (Event.current.character == 'q' || Event.current.character == 'Q')
            {
                GridEditorUtility.IncreaseGrid(target, 1);
            }
            else if (Event.current.character == 'w' || Event.current.character == 'W')
            {
                GridEditorUtility.IncreaseGrid(target, 2);
            }
            else if (Event.current.character == 'e' || Event.current.character == 'E')
            {
                GridEditorUtility.IncreaseGrid(target, 3);
            }
            else if (Event.current.character == 'r' || Event.current.character == 'R')
            {
                GridEditorUtility.IncreaseGrid(target, 4);
            }

            else if (Event.current.character == 'y' || Event.current.character == 'Y')
            {
                GridEditorUtility.DecreaseGrid(target, 1);
            }
            else if (Event.current.character == 'u' || Event.current.character == 'U')
            {
                GridEditorUtility.DecreaseGrid(target, 2);
            }
            else if (Event.current.character == 'i' || Event.current.character == 'I')
            {
                GridEditorUtility.DecreaseGrid(target, 3);
            }
            else if (Event.current.character == 'o' || Event.current.character == 'O')
            {
                GridEditorUtility.DecreaseGrid(target, 4);
            }
        }
        #endregion
    }