Beispiel #1
0
 public PathwayMovementAction(
     PathwayConfigSO config, NavMeshAgent agent)
 {
     _agent         = agent;
     _isActiveAgent = _agent != null && _agent.isActiveAndEnabled && _agent.isOnNavMesh;
     _wayPointIndex = -1;         //Initialized to -1 so we don't skip the first element from the waypoint list
     _roamingSpeed  = config.Speed;
     _wayppoints    = config.Waypoints;
 }
Beispiel #2
0
 public PathwayMovementAction(
     PathwayConfigSO config, NavMeshAgent agent)
 {
     _agent         = agent;
     _isActiveAgent = _agent != null && _agent.isActiveAndEnabled && _agent.isOnNavMesh;
     _wayPointIndex = 0;
     _roamingSpeed  = config.Speed;
     _wayppoints    = config.Waypoints;
 }
Beispiel #3
0
    private static void DrawLabel(PathwayConfigSO pathway, Vector3 path, int index)
    {
        GUIStyle style      = new GUIStyle();
        Vector3  textHeight = Vector3.up;

        style.normal.textColor = pathway.TextColor;
        style.fontSize         = pathway.TextSize;

        Handles.Label(path + textHeight, index.ToString(), style);
    }
Beispiel #4
0
    public static void DrawGizmosSelected(PathwayConfigSO pathway)
    {
        if (!pathway.ToggledNavMeshDisplay)
        {
            DrawHandlesPath(pathway);
        }
        else
        {
            DrawNavMeshPath(pathway);
        }

        DrawHitPoints(pathway);
    }
Beispiel #5
0
    private static void DrawNavMeshPath(PathwayConfigSO pathway)
    {
        Handles.color = pathway.LineColor;

        for (int i = 0; i < pathway.Path.Count - 1; i++)
        {
            Handles.DrawLine(pathway.Path[i], pathway.Path[i + 1]);

            if (i < pathway.Waypoints.Count)
            {
                DrawLabel(pathway, pathway.Waypoints[i].waypoint, i);
            }
        }
    }
Beispiel #6
0
 private void OnEnable()
 {
     Undo.undoRedoPerformed += DoUndo;
     _reorderableList        = new ReorderableList(serializedObject, serializedObject.FindProperty("Waypoints"), true, true, true, true);
     _reorderableList.drawHeaderCallback  += DrawHeader;
     _reorderableList.drawElementCallback += DrawElement;
     _reorderableList.onAddCallback       += AddItem;
     _reorderableList.onRemoveCallback    += RemoveItem;
     _reorderableList.onChangedCallback   += ListModified;
     _reorderableList.onMouseDragCallback += DragItem;
     _pathway                  = (target as PathwayConfigSO);
     _pathWayNavMeshUI         = new PathWayNavMeshUI(_pathway);
     _pathwayHandles           = new PathwayHandles(_pathway);
     _currentListModification  = LIST_MODIFICATION.OTHER;
     SceneView.duringSceneGui += this.OnSceneGUI;
 }
Beispiel #7
0
    private static void DrawHitPoints(PathwayConfigSO pathway)
    {
        if (pathway.DisplayProbes)
        {
            float sphereRadius = pathway.ProbeRadius;

            for (int i = 0; i < pathway.Hits.Count; i++)
            {
                if (pathway.Hits[i])
                {
                    Handles.color = new Color(0, 255, 0, 0.1f);
                    Handles.SphereHandleCap(0, pathway.Waypoints[i].waypoint, Quaternion.identity, sphereRadius, EventType.Repaint);
                }
                else
                {
                    Handles.color = new Color(255, 0, 0, 0.1f);
                    Handles.SphereHandleCap(0, pathway.Waypoints[i].waypoint, Quaternion.identity, sphereRadius, EventType.Repaint);
                }
            }
        }
    }
Beispiel #8
0
    private static void DrawHandlesPath(PathwayConfigSO pathway)
    {
        Handles.color = pathway.LineColor;

        if (pathway.Waypoints.Count != 0)
        {
            DrawLabel(pathway, pathway.Waypoints[0].waypoint, 0);

            if (pathway.Waypoints.Count > 1)
            {
                for (int i = 1; i < pathway.Waypoints.Count; i++)
                {
                    DrawLabel(pathway, pathway.Waypoints[i].waypoint, i);
                    Handles.DrawDottedLine(pathway.Waypoints[i - 1].waypoint, pathway.Waypoints[i].waypoint, 2);
                }

                if (pathway.Waypoints.Count > 2)
                {
                    Handles.DrawDottedLine(pathway.Waypoints[0].waypoint, pathway.Waypoints[pathway.Waypoints.Count - 1].waypoint, 2);
                }
            }
        }
    }
Beispiel #9
0
 public PathwayHandles(PathwayConfigSO pathway)
 {
     _pathway = pathway;
 }
Beispiel #10
0
 public PathwayNavMesh(PathwayConfigSO pathway)
 {
     _pathway      = pathway;
     _pathway.Hits = new List <bool>();
 }
 public PathWayNavMeshUI(PathwayConfigSO pathway)
 {
     _pathway        = pathway;
     _pathwayNavMesh = new PathwayNavMesh(pathway);
     RestorePath();
 }