示例#1
0
    public override void OnInspectorGUI()
    {
        base.OnInspectorGUI();

        EditorGUI.BeginChangeCheck();

        if (GUILayout.Button("Create New"))
        {
            Undo.RecordObject(creator, "Create New");
            creator.CreatePath();
            path = creator.path;
            SceneView.RepaintAll();
        }

        if (GUILayout.Button("Toggle Closed"))
        {
            Undo.RecordObject(creator, "Toggle Closed");
            path.ToggleClosed();
            SceneView.RepaintAll();
        }

        bool autoSetControlPoints = GUILayout.Toggle(path.AutoSetControlPoints, "Auto Set Control Points");

        if (autoSetControlPoints != path.AutoSetControlPoints)
        {
            Undo.RecordObject(creator, "Toggle Auto Set Controls");
            path.AutoSetControlPoints = autoSetControlPoints;
        }

        if (EditorGUI.EndChangeCheck())
        {
            SceneView.RepaintAll();
        }
    }
示例#2
0
    public override void OnInspectorGUI() //adds buttons to the GUI *IMPORTANT*
    {
        base.OnInspectorGUI();

        EditorGUI.BeginChangeCheck(); //starts checking for changes
        if (GUILayout.Button("Create new"))
        {
            Undo.RecordObject(creator, "Create new");
            creator.CreatePath();
        }

        bool isClosed = GUILayout.Toggle(Path.IsClosed, "Closed"); //create toggle for if path is closed/open

        if (isClosed != Path.IsClosed)
        {
            Undo.RecordObject(creator, "Toggle closed");
            Path.IsClosed = isClosed; //sets to this local isClosed value
        }

        bool autoSetControlPoints = GUILayout.Toggle(Path.AutoSetControlPoints, "Auto Set Control Points");

        if (autoSetControlPoints != Path.AutoSetControlPoints)
        {
            Undo.RecordObject(creator, "Toggle auto set controls");
            Path.AutoSetControlPoints = autoSetControlPoints;
        }

        if (EditorGUI.EndChangeCheck()) //ends check and sees if any changes
        {
            SceneView.RepaintAll();     //if changed, repaints the scene
        }
    }
示例#3
0
    public override void OnInspectorGUI()
    {
        base.OnInspectorGUI();

        EditorGUI.BeginChangeCheck();

        bool isClosed = EditorGUILayout.Toggle("Close Path", path.IsClosed);

        if (isClosed != path.IsClosed)
        {
            Undo.RecordObject(creator, "close path");
            path.IsClosed = isClosed;
        }

        if (GUILayout.Button("Create New Path"))
        {
            Undo.RecordObject(creator, "create new path");
            creator.CreatePath();
        }

        if (EditorGUI.EndChangeCheck())
        {
            SceneView.RepaintAll();
        }
    }
    public override void OnInspectorGUI()
    {
        DrawDefaultInspector();

        PathCreator path_creator = (PathCreator)target;

        if (GUILayout.Button("Create Path"))
        {
            path_creator.CreatePath();
        }

        if (GUILayout.Button("Clear Path"))
        {
            path_creator.ClearPath();
        }

        if (path_creator.HasPath())
        {
            if (GUILayout.Button("Create Node"))
            {
                path_creator.CreatePathNode();
            }
        }

        if (GUILayout.Button("Finish Path"))
        {
            path_creator.FinishPath();
        }
    }
示例#5
0
    public override void OnInspectorGUI()
    {
        base.OnInspectorGUI();

        EditorGUI.BeginChangeCheck();
        if (GUILayout.Button("Create new"))
        {
            Undo.RecordObject(creator, "Create new");
            creator.CreatePath();
        }

        bool isClosed = GUILayout.Toggle(Path.IsClosed, "Closed");

        if (isClosed != Path.IsClosed)
        {
            Undo.RecordObject(creator, "Toggle closed");
            Path.IsClosed = isClosed;
        }

        bool autoSetControlPoints = GUILayout.Toggle(Path.AutoSetControlPoints, "Auto set control points");

        if (autoSetControlPoints != Path.AutoSetControlPoints)
        {
            Undo.RecordObject(creator, "Toggle auto set controls");
            Path.AutoSetControlPoints = autoSetControlPoints;
        }

        if (EditorGUI.EndChangeCheck())
        {
            SceneView.RepaintAll();
        }
    }
示例#6
0
    public override void OnInspectorGUI()
    {
        base.OnInspectorGUI();

        if (GUILayout.Button("Create New Path"))
        {
            Undo.RecordObject(_creator, "Create New Path");
            _creator.CreatePath();
            _path = _creator.path;

            SceneView.RepaintAll();
        }

        if (GUILayout.Button("Toggle Closed Path"))
        {
            Undo.RecordObject(_creator, "Toggle Closed Path");
            _path.ToggleClosed();

            SceneView.RepaintAll();
        }

        if (GUILayout.Button("Auto Map"))
        {
            Undo.RecordObject(_creator, "AutoMap");
            _path.AutoMap();
            SceneView.RepaintAll();
        }
    }
示例#7
0
 void OnEnable()
 {
     creator = this.target as PathCreator;
     if (creator.path == null)
     {
         creator.CreatePath();
     }
 }
示例#8
0
 /// <summary>
 /// This function is called when the object becomes enabled and active. Create a new path (curve).
 /// </summary>
 private void OnEnable()
 {
     creator = target as PathCreator;
     if (creator.Path == null)
     {
         creator.CreatePath();
     }
 }
示例#9
0
 private void OnEnable()
 {
     creator = (PathCreator)target;
     if (creator.path == null)
     {
         creator.CreatePath();
     }
 }
示例#10
0
 void OnEnable()
 {
     pathCreator = (PathCreator)target;
     if (pathCreator.path == null)
     {
         pathCreator.CreatePath();
     }
 }
示例#11
0
 void OnEnable()
 {
     _creator = (PathCreator)target;
     if (_creator.path == null)
     {
         _creator.CreatePath();
     }
     _path = _creator.path;
 }
示例#12
0
 void OnEnable()
 {
     creator = (PathCreator)target;
     mode3D  = false;
     if (creator.path == null)
     {
         creator.CreatePath();
     }
 }
示例#13
0
    private void OnEnable()
    {
        //获取 inspector 中选中的对象
        creator = (PathCreator)target;

        if (creator.Path == null)
        {
            creator.CreatePath();
        }
    }
示例#14
0
    private void OnEnable()
    {
        creator = (PathCreator)target;
        if (creator.curvePath == null)
        {
            creator.CreatePath();
        }

        _curvePath = creator.curvePath;
    }
示例#15
0
    public override void OnInspectorGUI()
    {
        DrawDefaultInspector();
        if (manager == null)
        {
            manager = target as MultiPathManager;
        }


        showPoints = EditorGUILayout.Foldout(showPoints, "Paths");

        if (showPoints)
        {
            if (points != null)
            {
                for (int i = 0; i < points.arraySize; i++)
                {
                    DrawPathEditor(manager.GetPathAtIndex(i), i);
                }
            }

            if (GUILayout.Button("Add Path"))
            {
                Undo.RegisterCompleteObjectUndo(manager, "Add Path");

                GameObject pathObject = new GameObject("Path" + points.arraySize);
                pathObject.transform.parent        = manager.transform;
                pathObject.transform.localPosition = Vector3.zero;
                PathCreator pc = pathObject.AddComponent <PathCreator>();
                points.InsertArrayElementAtIndex(points.arraySize);
                points.GetArrayElementAtIndex(points.arraySize - 1).objectReferenceValue = pc;

                if (pc.path == null)
                {
                    pc.CreatePath();
                }
            }
        }

        if (GUI.changed)
        {
            serializedObject.ApplyModifiedProperties();
            EditorUtility.SetDirty(target);
        }

        //foreach (PathCreator pc in manager.paths)
        //{
        //    //draw a custom creation thing here
        //    for (int i = 0; i < pc.path.NumSegments; i++)
        //    {
        //        Vector2[] points = pc.path.GetPointsInSegment(i);
        //        Handles.DrawBezier(points[0], points[3], points[1], points[2], Color.green, null, 2);
        //    }
        //}
    }
    /// <summary>
    /// Set scene parameters to match scene mode
    /// </summary>
    /// <param name="mode"></param>
    void SetMode(string mode)
    {
        switch (mode)
        {
        case "Easy":
            sandboxScene.SetActive(false);
            pathCreator.numberOfPathTiles   = 5;
            pathCreator.minLineSize         = 2;
            pathCreator.maxLineSize         = 3;
            pathCreator.maxConsecutiveTurns = 1;
            mapBounds = pathCreator.CreatePath();
            break;

        case "Medium":
            sandboxScene.SetActive(false);
            pathCreator.numberOfPathTiles   = 10;
            pathCreator.minLineSize         = 3;
            pathCreator.maxLineSize         = 4;
            pathCreator.maxConsecutiveTurns = 2;
            mapBounds = pathCreator.CreatePath();
            break;

        case "Hard":
            sandboxScene.SetActive(false);
            pathCreator.numberOfPathTiles   = 20;
            pathCreator.minLineSize         = 3;
            pathCreator.maxLineSize         = 4;
            pathCreator.maxConsecutiveTurns = 2;
            mapBounds = pathCreator.CreatePath();
            break;

        case "Sandbox":
            mapBounds = sandBoxBounds;
            sandboxScene.SetActive(true);
            beTargetObject.transform.position = Vector3.zero;
            beTargetObject.transform.rotation = Quaternion.identity;
            break;

        default:
            break;
        }
    }
        public void IdentifyPath_InsertPlane_CorrectPathOutPut()
        {
            string      location = testModelLocation + "\\plane.ply";
            CVMesh      mesh     = PLYHandler.ReadMesh(location);
            BoundingBox b        = Extensions.FindBoundingBox(mesh.Vertices);

            uut.distance_length = -(b.x_max - b.x_min) / 9f;
            uut.distance_width  = -(b.y_max - b.y_min) / 9f;
            List <VertexIndex> path = uut.CreatePath(mesh.Vertices);

            path = Extensions.PruneVertices(path);
            Assert.AreEqual(path.Count, mesh.Vertices.Count);
        }
示例#18
0
    private void OnEnable()
    {
        creator = (PathCreator)target;
        if (creator.path == null)
        {
            creator.CreatePath();
            Debug.Log("Path Created");
        }
        path = creator.path;

        Debug.Log("OnEnable");
        SceneView.duringSceneGui += OnSceneViewGUI;
    }
示例#19
0
    public void LoadLevel()
    {
        if (pathCreator == null)
        {
            pathCreator = new PathCreator();
        }

        points = 0;

        playerControlls.StartGame();
        pathCreator.CreatePath(meshCreatorPool, bonusSpawner, blockPrefab, startPos, StartPlatformSize, PathWidth, PathLength);

        playerUI.RestartLevel();
    }
示例#20
0
    void OnEnable()
    {
        pathCreator = (PathCreator)target;

        if (pathCreator.Path == null)// Cria caminho caso este não exita
        {
            pathCreator.CreatePath();
        }
        path = pathCreator.Path;

        //for (int i = 0; i < path.NumberPoints; i++)
        //{
        //    Instantiate(GameObject.CreatePrimitive(PrimitiveType.Sphere), (Vector3)path[i], Quaternion.identity);
        //}
    }
示例#21
0
    public override void OnInspectorGUI()
    {
        if (GUILayout.Button("Reset"))
        {
            Undo.RecordObject(creator, "Reset");
            creator.CreatePath();
        }

        base.OnInspectorGUI();

        EditorGUILayout.Space();
        EditorGUILayout.LabelField("Path", EditorStyles.boldLabel);

        EditorGUI.BeginChangeCheck();

        if (GUILayout.Button("Add Point"))
        {
            Undo.RecordObject(creator, "Add Segment");
            Path.AddSegmentAtLast();
        }

        bool isClosed = GUILayout.Toggle(Path.IsClosed, "Closed");

        if (isClosed != Path.IsClosed)
        {
            Undo.RecordObject(creator, "Toggle Closed");
            Path.IsClosed = isClosed;
        }

        bool autoSetControlPoints = GUILayout.Toggle(Path.AutoSetControPoints, "Auto Set Control Points");

        if (autoSetControlPoints != Path.AutoSetControPoints)
        {
            Undo.RecordObject(creator, "Toggle Auto Set Controls");
            Path.AutoSetControPoints = autoSetControlPoints;
        }

        if (GUILayout.Button("Flatten"))
        {
            Undo.RecordObject(creator, "Flatten");
            Path.FlattenAllPoints();
        }

        if (EditorGUI.EndChangeCheck())
        {
            SceneView.RepaintAll();
        }
    }
示例#22
0
    public override void OnInspectorGUI()
    {
        base.OnInspectorGUI();
        EditorGUI.BeginChangeCheck();

        if (GUILayout.Button("Reset"))
        {
            Undo.RecordObject(creator, "Reset Path");
            creator.CreatePath();
            path = creator.path;
        }

        if (GUILayout.Button("Flatten"))
        {
            Undo.RecordObject(creator, "Flatten Path");
            path.Flatten();
        }

        bool isLoop = GUILayout.Toggle(path.IsLoop, "Loop");

        if (isLoop != path.IsLoop)
        {
            Undo.RecordObject(creator, "Toggle Loop");
            path.IsLoop = isLoop;
        }

        bool isSmooth = GUILayout.Toggle(path.IsSmooth, "Smooth Path");

        if (isSmooth != path.IsSmooth)
        {
            Undo.RecordObject(creator, "Toggle Smooth Path");
            path.IsSmooth = isSmooth;
        }

        int pointsBySegment = EditorGUILayout.IntField("Points by Segment", path.PointsBySegment);

        if (pointsBySegment != path.PointsBySegment)
        {
            Undo.RecordObject(creator, "Update Number of Points by Segment");
            path.PointsBySegment = pointsBySegment;
        }

        if (EditorGUI.EndChangeCheck())
        {
            SceneView.RepaintAll();
        }
    }
示例#23
0
    public override void OnInspectorGUI()
    {
        base.OnInspectorGUI();

        if (GUILayout.Button("Create new"))
        {
            creator.CreatePath();
            path = creator.path;
            SceneView.RepaintAll();
        }

        if (GUILayout.Button("Toggle closed"))
        {
            path.ToggleClosed();
            SceneView.RepaintAll();
        }
    }
示例#24
0
    public override void OnInspectorGUI()
    {
        base.OnInspectorGUI();

        EditorGUI.BeginChangeCheck();

        if (GUILayout.Button("Create New"))
        {
            Undo.RecordObject(creator, "Create new");
            creator.CreatePath();
            path = creator.path;
        }


        if (GUILayout.Button("Toggle Close"))
        {
            Undo.RecordObject(creator, "Toogle Close");
            path.ToogleClosed();
        }

        if (GUILayout.Button("Show points"))
        {
            Debug.Log(path.NumPoints);

            for (int i = 0; i < path.NumPoints; i++)
            {
                Debug.Log(path[i]);
            }
        }

        bool autoSetControl = GUILayout.Toggle(path.SetControl, "Auto set controls");

        if (autoSetControl != path.SetControl)
        {
            Undo.RecordObject(creator, "Toogle Auto set");
            path.SetControl = autoSetControl;
        }

        if (EditorGUI.EndChangeCheck())
        {
            SceneView.RepaintAll();
        }
    }
示例#25
0
        public void CreatePathTest()
        {
            var creator = new PathCreator();
            var map     = new[, ]
            {
                { true, true, true },
                { true, true, true },
                { false, false, true },
                { true, true, true }
            };

            List <Point> path = creator.CreatePath(map, new Point(0, 0), new Point(1, 3));

            Assert.AreEqual(7, path.Count);
            Assert.AreEqual(new Point(0, 0), path[0]);
            Assert.AreEqual(new Point(0, 1), path[1]);
            Assert.AreEqual(new Point(1, 1), path[2]);
            Assert.AreEqual(new Point(2, 1), path[3]);
            Assert.AreEqual(new Point(2, 2), path[4]);
            Assert.AreEqual(new Point(2, 3), path[5]);
            Assert.AreEqual(new Point(1, 3), path[6]);
        }
示例#26
0
        public GeneratedMap GenerateMap()
        {
            var random = new Random();

            int mapWidth  = random.Next(10, 20);
            int mapHeight = random.Next(10, 15);

            bool[,] map = new bool[mapHeight, mapWidth];
            for (int i = 0; i < mapHeight; i++)
            {
                for (int j = 0; j < mapWidth; j++)
                {
                    map[i, j] = true;
                }
            }

            // Make some percentage impassable.
            int totalCount           = mapWidth * mapHeight;
            int impassablePercentage = random.Next(10, 20);
            int impassableCount      = (int)Math.Ceiling(totalCount * ((float)impassablePercentage / 100));

            for (int i = 0; i < impassableCount; i++)
            {
                int x = random.Next(0, map.GetLength(0) - 1);
                int y = random.Next(0, map.GetLength(1) - 1);

                map[x, y] = false;
            }

            // Generate a start and an end.
            int start = random.Next(0, mapHeight - 1);
            int end   = random.Next(0, mapHeight - 1);

            Point startPoint = new Point(0, start);
            Point endPoint   = new Point(mapWidth - 1, end);

            // Create the final map. (with impassable tiles)
            SpriteEnum[,] spriteMap = new SpriteEnum[mapHeight, mapWidth];
            for (int h = 0; h < spriteMap.GetLength(0); h++)
            {
                for (int w = 0; w < spriteMap.GetLength(1); w++)
                {
                    spriteMap[h, w] = map[h, w] ? SpriteEnum.LandscapeGrass : SpriteEnum.LandscapeMinerals;
                }
            }

            // Generate a path.
            List <Point> path     = _pathCreator.CreatePath(map, startPoint, endPoint);
            Point        previous = Point.Empty;

            for (int i = 0; i < path.Count; i++)
            {
                SpriteDirectionEnum from;
                SpriteDirectionEnum to;

                Point next = i == path.Count - 1 ? Point.Empty : path[i + 1];

                Point current = path[i];
                if (i == 0)
                {
                    from = SpriteDirectionEnum.BottomLeft;
                    if (next.X > current.X)
                    {
                        to = SpriteDirectionEnum.TopRight;
                    }
                    else if (next.Y < current.Y)
                    {
                        to = SpriteDirectionEnum.TopLeft;
                    }
                    else if (next.Y > current.Y)
                    {
                        to = SpriteDirectionEnum.BottomRight;
                    }
                    else
                    {
                        throw new Exception("That's unexpected.");
                    }
                }
                else
                {
                    if (previous.Y == current.Y)
                    {
                        // Straight.
                        from = SpriteDirectionEnum.BottomLeft;
                    }
                    else if (previous.Y > current.Y)
                    {
                        from = SpriteDirectionEnum.BottomRight;
                    }
                    else if (previous.Y < current.Y)
                    {
                        from = SpriteDirectionEnum.TopLeft;
                    }
                    else
                    {
                        throw new Exception("That's unexpected.");
                    }

                    if (i == path.Count - 1)
                    {
                        // The last one.
                        to = SpriteDirectionEnum.TopRight;
                    }
                    else
                    {
                        if (next.X > current.X)
                        {
                            to = SpriteDirectionEnum.TopRight;
                        }
                        else if (next.Y < current.Y)
                        {
                            to = SpriteDirectionEnum.TopLeft;
                        }
                        else if (next.Y > current.Y)
                        {
                            to = SpriteDirectionEnum.BottomRight;
                        }
                        else
                        {
                            throw new Exception("That's unexpected.");
                        }
                    }
                }
                previous = path[i];

                if (from == SpriteDirectionEnum.BottomLeft && to == SpriteDirectionEnum.TopRight)
                {
                    spriteMap[current.Y, current.X] = SpriteEnum.LandscapeRoadUp;
                }
                else if (from == SpriteDirectionEnum.TopLeft && to == SpriteDirectionEnum.BottomRight ||
                         from == SpriteDirectionEnum.BottomRight && to == SpriteDirectionEnum.TopLeft)
                {
                    spriteMap[current.Y, current.X] = SpriteEnum.LandscapeRoadDown;
                }
                else if (from == SpriteDirectionEnum.BottomLeft && to == SpriteDirectionEnum.BottomRight)
                {
                    spriteMap[current.Y, current.X] = SpriteEnum.LandscapeTurnBottomLeftBottomRight;
                }
                else if (from == SpriteDirectionEnum.TopLeft && to == SpriteDirectionEnum.TopRight)
                {
                    spriteMap[current.Y, current.X] = SpriteEnum.LandscapeTurnTopLeftTopRight;
                }
                else if (from == SpriteDirectionEnum.BottomLeft && to == SpriteDirectionEnum.TopLeft)
                {
                    spriteMap[current.Y, current.X] = SpriteEnum.LandscapeTurnBottomLeftTopLeft;
                }
                else if (from == SpriteDirectionEnum.BottomRight && to == SpriteDirectionEnum.TopRight)
                {
                    spriteMap[current.Y, current.X] = SpriteEnum.LandscapeTurnBottomRightTopRight;
                }
                else
                {
                    throw new Exception("That's unexpected.");
                }
            }
            return(new GeneratedMap
            {
                Map = spriteMap,
                Path = path
            });
        }
 void OnEnable()
 {
     creator  = (PathCreator)target;
     path     = creator.path ?? creator.CreatePath();
     property = serializedObject.FindProperty("path");
 }