Beispiel #1
0
        private void OnEnable()
        {
            Instance = this;

            LoadEditorModeOptions();

            visual = new EditorViewGridVisualisation();

            SceneView.onSceneGUIDelegate -= onSceneGUI;
            SceneView.onSceneGUIDelegate += onSceneGUI;

            EditorApplication.update -= onEditorApplicationUpdate;
            EditorApplication.update += onEditorApplicationUpdate;
        }
Beispiel #2
0
        public override void OnSceneViewGUI(SceneView view, MazeCreationWorkflowBackEnd backend, EditorViewGridVisualisation visual)
        {
            base.OnSceneViewGUI(view, backend, visual);

            if (backend.selectedMaze != null)
            {
                EditorVisualUtils.HandlesDrawGrid(backend.selectedMaze);
            }
        }
Beispiel #3
0
        private bool CheckIfTileIsValidPathElement(MazeCreationWorkflowBackEnd backend, EditorViewGridVisualisation visual)
        {
            var tilePosition = visual.currentTilePosition;

            if (!backend.selectedMaze.Units.Any((u) => u.GridID.Equals(tilePosition)))
            {
                return(false);
            }

            if (pathToEdit.PathAsLinkedList != null && pathToEdit.PathAsLinkedList.Count == 0)
            {
                return(true);
            }

            var lastElement = pathToEdit.PathAsLinkedList.Last;

            var gridIdOfLastElement = lastElement.Value.Unit.GridID;

            if (tilePosition == gridIdOfLastElement)
            {
                return(false);
            }

            if (lastElement.Previous != null)
            {
                var gridIdOfPreviousElement = lastElement.Previous.Value.Unit.GridID;

                if (gridIdOfPreviousElement == tilePosition)
                {
                    return(false);
                }
            }

            var deltaBetweenLastAndCurrent = tilePosition - gridIdOfLastElement;
            var absDelta = deltaBetweenLastAndCurrent.SqrMagnitude();

            if (absDelta > 1)
            {
                return(false);
            }

            return(true);
        }
Beispiel #4
0
        public override void OnSceneViewGUI(SceneView view, MazeCreationWorkflowBackEnd backend, EditorViewGridVisualisation visual)
        {
            if (pathToEdit == null)
            {
                return;
            }

            tilePositionIsValid = CheckIfTileIsValidPathElement(backend, visual);
        }
Beispiel #5
0
 public override void OnSceneViewGUI(SceneView view, MazeCreationWorkflowBackEnd backend, EditorViewGridVisualisation visual)
 {
     base.OnSceneViewGUI(view, backend, visual);
 }
Beispiel #6
0
        public virtual void ProcessEvent(Event evt, MazeCreationWorkflowBackEnd backend, EditorViewGridVisualisation visual)
        {
            if (backend == null)
            {
                Debug.Log("backend null");
            }

            this.backend = backend;

            controlId = GUIUtility.GetControlID(FocusType.Passive);

            if (evt.type == EventType.MouseDown)
            {
                if (dragging)
                {
                    DragEnds();
                }

                Click(evt, evt.button);
            }

            if (evt.type == EventType.MouseDrag)
            {
                Drag(evt, evt.button);
            }

            if (evt.type == EventType.MouseUp)
            {
                if (dragging)
                {
                    DragEnds();
                }

                Click(evt, evt.button);
            }
        }
Beispiel #7
0
        public virtual void OnSceneViewGUI(SceneView view, MazeCreationWorkflowBackEnd backend, EditorViewGridVisualisation visual)
        {
            visual.pushHandleColor();

            Handles.color = tileHighlighting;

            visual.popHandleColor();
        }