Example #1
0
        /// <summary>
        /// Use this to remove a waypoint from the path and from the scene
        /// </summary>
        /// <param name="deletedWaypoint"> The waypoint which is to be deleted </param>
        public void DeleteWaypoint(Waypoint deletedWaypoint)
        {
            //Sending a ROS DELETE Update
            string curr_id           = deletedWaypoint.id;
            string prev_id           = deletedWaypoint.prevPathPoint.id;
            float  x                 = deletedWaypoint.gameObjectPointer.transform.localPosition.x;
            float  y                 = deletedWaypoint.gameObjectPointer.transform.localPosition.y;
            float  z                 = deletedWaypoint.gameObjectPointer.transform.localPosition.z;
            UserpointInstruction msg = new UserpointInstruction(curr_id, prev_id, x, y, z, "DELETE");

            WorldProperties.worldObject.GetComponent <ROSDroneConnection>().PublishWaypointUpdateMessage(msg);

            // Removing the new waypoint from the dictionary, waypoints array and placement order
            waypointsDict.Remove(deletedWaypoint.id);
            waypoints.Remove(deletedWaypoint);
            waypointsOrder.Remove(deletedWaypoint);

            // Removing from the path linked list by adjusting the next and previous pointers of the surrounding waypoints
            deletedWaypoint.prevPathPoint.nextPathPoint = deletedWaypoint.nextPathPoint;
            // Need to check if this is the last waypoint in the list -- if it has a next or not
            if (deletedWaypoint.nextPathPoint != null)
            {
                deletedWaypoint.nextPathPoint.prevPathPoint = deletedWaypoint.prevPathPoint;
            }

            // Removing line collider
            WaypointProperties tempProperties = deletedWaypoint.gameObjectPointer.GetComponent <WaypointProperties>();

            tempProperties.DeleteLineCollider();

            // Deleting the waypoint gameObject
            Object.Destroy(deletedWaypoint.gameObjectPointer);
        }
        /// <summary>
        /// Use this to remove a waypoint from the path and from the scene
        /// </summary>
        /// <param name="deletedWaypoint"> The waypoint which is to be deleted </param>
        public void DeleteWaypoint(Waypoint deletedWaypoint)
        {
            // Removing the new waypoint from the dictionary, waypoints array and placement order
            waypoints.Remove(deletedWaypoint);
            deletedWaypoints.Add(deletedWaypoint);

            // Removing from the path linked list by adjusting the next and previous pointers of the surrounding waypoints. Check if first waypoint in the list.
            if (deletedWaypoint.prevPathPoint != null)
            {
                deletedWaypoint.prevPathPoint.nextPathPoint = deletedWaypoint.nextPathPoint;
            }

            // Need to check if this is the last waypoint in the list -- if it has a next or not
            if (deletedWaypoint.nextPathPoint != null)
            {
                deletedWaypoint.nextPathPoint.prevPathPoint = deletedWaypoint.prevPathPoint;
            }

            // Removing line collider
            WaypointProperties tempProperties = deletedWaypoint.gameObjectPointer.GetComponent <WaypointProperties>();

            tempProperties.DeleteLineCollider();

            // Deleting the waypoint gameObject
            Object.Destroy(deletedWaypoint.gameObjectPointer);
        }
 /// <summary>
 /// Removes all waypoints from this drone (including the first one).
 /// </summary>
 // TODO: Fix @apollo do we still need to fix this?
 public void DeleteAllWaypoints()
 {
     if (!isEmptyWaypointList(waypoints))
     {
         foreach (Waypoint waypoint in waypoints)
         {
             deletedWaypoints.Add(waypoint);
             WaypointProperties tempProperties = waypoint.gameObjectPointer.GetComponent <WaypointProperties>();
             tempProperties.DeleteLineCollider();
             Object.Destroy(waypoint.gameObjectPointer);
         }
         waypoints.Clear();
     }
 }