Exemple #1
0
        /// <summary>
        /// This method handles the undo and delete functionality
        /// Removes the waypoint from the scene and from the drone's path
        /// </summary>
        public void Undo() /// TODO: add undo for moving around
        {
            Drone currentlySelectedDrone = WorldProperties.GetSelectedDrone();

            if (currentlySelectedDrone != null)
            {
                // Make sure the currently selected drone has waypoints
                if (currentlySelectedDrone.WaypointsCount() >= 2)
                {
                    // Otherwise we default to removing the last waypoint (UNDO)
                    Debug.Log("Removing most recently placed waypoint");

                    Waypoint lastWaypoint = currentlySelectedDrone.PopWaypoint();

                    // Remove from collisions list
                    //currentCollisions.RemoveAll(collision => collision.waypoint == lastWaypoint &&
                    //                       collision.type == CollisionType.WAYPOINT);
                    // currentCollisions.RemoveAll(collision => collision.waypoint == lastWaypoint &&
                    //                       collision.type == CollisionType.LINE);

                    // Catching edge case in which most recent collision was the last waypoint
                    //if (lastWaypoint == mostRecentCollision.waypoint)
                    //{
                    //   mostRecentCollision.type = CollisionType.NOTHING;
                    //  mostRecentCollision.waypoint = null;
                    // }
                }
            }
        }
Exemple #2
0
        public void Redo()
        {
            Drone currentlySelectedDrone = WorldProperties.GetSelectedDrone();

            if (currentlySelectedDrone != null)
            {
                currentlySelectedDrone.RestoreLastDeletedWaypoint();
            }
        }
Exemple #3
0
        // Fixed update is called n times per frame, where n is the physics step (and can be different from the progression of video frames).
        void FixedUpdate()
        {
            // Query for the controller state, determined by user input.
            switch (controllerState)
            {
            // If nothing is held down, default to the idle state.
            case ControllerState.IDLE:
            {
                if (controllerInput.RightIsTouchingWaypoint())
                {
                    controllerInput.HideWaypointPlacementVisualizer();
                }
                else
                {
                    controllerInput.ShowWaypointPlacementVisualizer();
                }

                if (controllerInput.BothGrip())
                {
                    controllerState = ControllerState.SCALING;

                    controllerInput.DisableBothUIs();
                    controllerInput.DisableRightPointer();

                    ScaleWorld();
                    break;
                }

                if (controllerInput.RightGrip())
                {
                    controllerState = ControllerState.AIMING_SELECTOR;
                    controllerInput.DisableRightUI();
                    break;
                }

                if (controllerInput.RightTrigger())
                {
                    controllerState = ControllerState.PLACING_WAYPOINT;
                    controllerInput.DisableRightPointer();
                    /// TODO: start linecollider
                    break;
                }

                if (controllerInput.RightA())
                {
                    controllerState = ControllerState.UNDOING;
                    controllerInput.DisableRightPointer();
                    /// TODO: make waypoint slightly fade
                    break;
                }

                if (controllerInput.RightB())
                {
                    controllerState = ControllerState.REDOING;
                    controllerInput.DisableRightPointer();
                    /// TODO: make waypoint slightly appear
                    break;
                }

                if (controllerInput.RightStickMoved())     /// Rotate the world
                {
                    RotateWorld();
                }

                if (controllerInput.LeftStickMoved())     /// Move the world
                {
                    MoveWorld();
                }

                if (controllerInput.LeftX())     /// Cycle through drones
                {
                    controllerState = ControllerState.SELECTING_DRONE;
                }

                if (controllerInput.LeftY())     /// Cycle through sensors
                {
                    controllerState = ControllerState.SELECTING_SENSOR;
                }

                break;
            }

            case ControllerState.SCALING:
            {
                if (controllerInput.BothGrip())
                {
                    ScaleWorld();
                }
                else
                {
                    controllerState = ControllerState.IDLE;
                    controllerInput.EnableBothUIs();
                    controllerInput.EnableRightPointer();
                }
                break;
            }

            case ControllerState.SELECTING_DRONE:
            {
                if (!controllerInput.LeftX())
                {
                    controllerState = ControllerState.IDLE;
                    WorldProperties.SelectNextDrone();
                }
                break;
            }

            case ControllerState.SELECTING_SENSOR:
            {
                if (!controllerInput.LeftY())
                {
                    controllerState = ControllerState.IDLE;
                    WorldProperties.sensorManager.ShowNextSensor();
                }
                break;
            }

            case ControllerState.AIMING_SELECTOR:
            {
                /// TODO: set wp height if GetRightIndex()
                if (controllerInput.BothGrip())
                {
                    controllerState = ControllerState.SCALING;
                    controllerInput.DisableBothUIs();
                    controllerInput.DisableRightPointer();
                    ScaleWorld();
                    break;
                }
                if (!controllerInput.RightGrip())
                {
                    controllerState = ControllerState.IDLE;
                    controllerInput.EnableRightUI();
                }
                break;
            }

            case ControllerState.SETTING_WAYPOINT_HEIGHT:
            {
                break;
            }

            case ControllerState.PLACING_WAYPOINT:
            {
                if (controllerInput.RightIsGrabbingWaypoint())
                {
                    controllerState = ControllerState.MOVING_WAYPOINT;
                    break;
                }

                if (controllerInput.RightGrip())     /// Cancel waypoint placement
                {
                    /// TODO: stop showing line
                    controllerState = ControllerState.IDLE;
                    controllerInput.EnableRightPointer();
                    break;
                }

                if (!controllerInput.RightTrigger())
                {
                    controllerState = ControllerState.IDLE;
                    Drone currentlySelectedDrone = WorldProperties.GetSelectedDrone();
                    currentlySelectedDrone.AddWaypoint(controllerInput.RightUITransform().position);
                    controllerInput.EnableRightPointer();
                }
                else
                {
                    /// TODO: continue line showing and slightly faded wp
                }
                break;
            }

            case ControllerState.MOVING_WAYPOINT:
            {
                if (!controllerInput.RightIsGrabbingWaypoint())
                {
                    controllerState = ControllerState.IDLE;
                    controllerInput.EnableRightPointer();
                    break;
                }
                break;
            }

            case ControllerState.UNDOING:
            {
                if (!controllerInput.RightA())
                {
                    controllerState = ControllerState.IDLE;
                    Undo();
                    break;
                }
                if (controllerInput.RightGrip())
                {
                    controllerState = ControllerState.IDLE;
                    controllerInput.EnableRightPointer();
                    /// TODO: make waypoint disappear
                    break;
                }
                break;
            }

            case ControllerState.REDOING:
            {
                if (!controllerInput.RightB())
                {
                    controllerState = ControllerState.IDLE;
                    Redo();
                    break;
                }
                if (controllerInput.RightGrip())
                {
                    controllerState = ControllerState.IDLE;
                    controllerInput.EnableRightPointer();
                    /// TODO: make waypoint disappear
                    break;
                }
                break;
            }
            }
        }