public static void OnDrawSceneGizmo(WaypointNode waypoint, GizmoType gizmoType)
        {
            if ((gizmoType & GizmoType.Selected) != 0)
            {
                Gizmos.color = Color.green;
            }
            else
            {
                Gizmos.color = Color.grey * 0.25f;
            }

            Gizmos.DrawSphere(waypoint.transform.position, 0.25f);

            Gizmos.color = Color.white;
            Gizmos.DrawWireSphere(waypoint.transform.position, waypoint.width * 0.5f);

            if (waypoint.prev != null)
            {
                Gizmos.color = Color.red;
                Gizmos.DrawLine(waypoint.transform.position, waypoint.prev.transform.position);
            }

            if (waypoint.next != null)
            {
                Gizmos.color = Color.red;
                Gizmos.DrawLine(waypoint.transform.position, waypoint.next.transform.position);
            }
        }
        public void UpdateNavigation()
        {
            currentNode = currentNode.GetNextNode();

            hasNode = currentNode != null;
            if (hasNode)
            {
                OnNavigationUpdated?.Invoke(currentNode);
            }
        }
        private void OnScannerEnter(Collider pCollider)
        {
            if (!hasNode)
            {
                currentNode = pCollider.transform.GetComponent <WaypointNode>();

                hasNode = true;

                OnNavigationStarted?.Invoke(currentNode);
            }
        }
Ejemplo n.º 4
0
        void RemoveWaypoint()
        {
            WaypointNode selectedNode = Selection.activeGameObject.GetComponent <WaypointNode>();

            if (selectedNode.next != null)
            {
                selectedNode.next.prev = selectedNode.prev;
            }

            if (selectedNode.prev != null)
            {
                selectedNode.prev.next = selectedNode.next;

                Selection.activeGameObject = selectedNode.prev.gameObject;
            }

            DestroyImmediate(selectedNode.gameObject);
        }
Ejemplo n.º 5
0
        private void CloseLoop()
        {
            if (root.childCount > 1)
            {
                WaypointNode first = root.GetChild(0).GetComponent <WaypointNode>();
                WaypointNode last  = root.GetChild(root.childCount - 1).GetComponent <WaypointNode>();

                if (closeLoop)
                {
                    first.prev = last;
                    last.next  = first;
                }
                else
                {
                    first.prev = null;
                    last.next  = null;
                }
            }
        }
Ejemplo n.º 6
0
        void CreateWaypoint()
        {
            string     name           = "Waypoint(" + root.childCount + ")";
            GameObject waypointObject = new GameObject(name, typeof(WaypointNode));

            waypointObject.transform.SetParent(root, false);

            waypointObject.AddComponent <SphereCollider>();
            waypointObject.GetComponent <SphereCollider>().isTrigger = true;

            WaypointNode node = waypointObject.GetComponent <WaypointNode>();

            if (root.childCount > 1)
            {
                node.prev      = root.GetChild(root.childCount - 2).GetComponent <WaypointNode>();
                node.prev.next = node;

                node.transform.position = node.prev.transform.position;

                CloseLoop();
            }

            Selection.activeGameObject = node.gameObject;
        }
Ejemplo n.º 7
0
        private void OnNavigationUpdated(WaypointNode pWaypointNode)
        {
            unitState = UnitState.MOVING;

            navMeshAgent.SetDestination(pWaypointNode.GetPosition());
        }