/// <summary>
 /// Add a gyro to the selected node and display its output
 /// </summary>
 public List <GameObject> AddGyro()
 {
     currentSensor = sensorManager.AddGyro();
     DisplayOutput();
     StartConfiguration();
     return(sensorManager.gyroList);
 }
 /// <summary>
 /// Add an ultrasonic sensor to the selected node and display its output
 /// </summary>
 public List <GameObject> AddUltrasonic()
 {
     currentSensor = sensorManager.AddUltrasonic();
     DisplayOutput();
     StartConfiguration();
     return(sensorManager.ultrasonicList);
 }
 /// <summary>
 /// Add a beam breaker sensor to the selected node and display its output
 /// </summary>
 public List <GameObject> AddBeamBreaker()
 {
     currentSensor = sensorManager.AddBeamBreaker();
     DisplayOutput();
     StartConfiguration();
     return(sensorManager.beamBreakerList);
 }
        /// <summary>
        /// Cancel the current sensor type selection and destroy the sensor game object
        /// </summary>
        public void CancelTypeSelection()
        {
            if (isAddingBeamBreaker)
            {
                isAddingBeamBreaker = false;
                addBeamBreakerButton.GetComponentInChildren <Text>().text = "Add Beam Breaker";
            }
            else if (isAddingUltrasonic)
            {
                isAddingUltrasonic = false;
                addUltrasonicButton.GetComponentInChildren <Text>().text = "Add Ultrasonic";
            }
            else if (isAddingGyro)
            {
                isAddingGyro = false;
                addGyroButton.GetComponentInChildren <Text>().text = "Add Gyro";
            }
            addUltrasonicButton.SetActive(true);
            addBeamBreakerButton.SetActive(true);
            addGyroButton.SetActive(true);

            //Remove the current sensor - can't use this in EndProcesses because of this part
            if (currentSensor != null)
            {
                //sensorManager.RemoveSensor(currentSensor.gameObject); //works if this never gets called
                //Shift the panel up for the current sensor destroyed
                ShiftOutputPanels();
                Destroy(currentSensor.gameObject);
                currentSensor = null;
            }
            cancelTypeButton.SetActive(false);
        }
 /// <summary>
 /// Similar function as the SyncNodeFunction
 /// </summary>
 public void SyncSensorSelection()
 {
     if (sensorManager.SelectedSensor == null)
     {
         currentSensor = null;
     }
     else
     {
         currentSensor = sensorManager.SelectedSensor.GetComponent <SensorBase>();
         sensorManager.ClearSelectedSensor();
     }
 }
Exemple #6
0
        /// <summary>
        /// Delete the current sensor from the robot
        /// </summary>
        public void DeleteSensor()
        {
            //Don't change the order of following lines or it won't work
            string type = currentSensor.sensorType;

            Destroy(currentSensor.gameObject);
            sensorManager.RemoveSensor(currentSensor.gameObject, type);
            ShiftOutputPanels();
            currentSensor = null;

            EndProcesses();
            tabStateMachine.FindState <SensorToolbarState>().RemoveSensorFromDropdown(type,
                                                                                      sensorManager.ultrasonicList, sensorManager.beamBreakerList, sensorManager.gyroList);
        }
        /// <summary>
        /// Delete the current sensor from the robot
        /// </summary>
        public void DeleteSensor()
        {
            //Don't change the order of following lines or it won't work
            string type = currentSensor.sensorType;

            Destroy(currentSensor.gameObject);
            sensorManager.RemoveSensor(currentSensor.gameObject, type);
            ShiftOutputPanels();
            currentSensor = null;

            AnalyticsManager.GlobalInstance.LogEventAsync(AnalyticsLedger.EventCatagory.SensorTab,
                                                          AnalyticsLedger.EventAction.Removed,
                                                          "Sensors",
                                                          AnalyticsLedger.getMilliseconds().ToString());

            EndProcesses();
            tabStateMachine.FindState <SensorToolbarState>().RemoveSensorFromDropdown(type,
                                                                                      sensorManager.ultrasonicList, sensorManager.beamBreakerList, sensorManager.gyroList);
        }
Exemple #8
0
        /// <summary>
        /// Remove the current sensor from the robot
        /// </summary>
        /// <param name="robot"></param>
        public void RemoveSensorsFromRobot(SimulatorRobot robot)
        {
            List <GameObject> sensorsOnRobot = sensorManager.GetSensorsFromRobot(robot);

            foreach (GameObject removingSensors in sensorsOnRobot)
            {
                string type = removingSensors.GetComponent <SensorBase>().sensorType;

                Destroy(removingSensors);
                sensorManager.RemoveSensor(removingSensors, type);
                ShiftOutputPanels();
                if (currentSensor != null && currentSensor.Equals(removingSensors.GetComponent <SensorBase>()))
                {
                    currentSensor = null; EndProcesses();
                }
                tabStateMachine.FindState <SensorToolbarState>().RemoveSensorFromDropdown(type,
                                                                                          sensorManager.ultrasonicList, sensorManager.beamBreakerList, sensorManager.gyroList);
            }
        }
        /// <summary>
        /// Close all window related to adding/configuring sensor, also called in SimUI
        /// </summary>
        public void EndProcesses()
        {
            isChoosingOption = false;
            if (currentSensor != null)
            {
                currentSensor.GetComponentInChildren <MoveArrows>(true).gameObject.SetActive(false);
                currentSensor.ResetConfigurationState();
                currentSensor = null;
            }
            //CancelOptionSelection();
            //CancelTypeSelection();
            ResetConfigurationWindow();
            //HideSensorOutput();

            //Switch back to the original camera state
            if (preConfigState != null)
            {
                dynamicCamera.SwitchToState(preConfigState);
                preConfigState = null;
            }

            HideInvisibleSensors();
        }
        /// <summary>
        /// Remove the current sensor from the robot
        /// </summary>
        /// <param name="robot"></param>
        public void RemoveSensorsFromRobot(SimulatorRobot robot)
        {
            List <GameObject> sensorsOnRobot = sensorManager.GetSensorsFromRobot(robot);

            foreach (GameObject removingSensors in sensorsOnRobot)
            {
                string type = removingSensors.GetComponent <SensorBase>().sensorType;

                Destroy(removingSensors);
                sensorManager.RemoveSensor(removingSensors, type);
                ShiftOutputPanels();
                if (currentSensor != null && currentSensor.Equals(removingSensors.GetComponent <SensorBase>()))
                {
                    currentSensor = null; EndProcesses();
                }
                tabStateMachine.FindState <SensorToolbarState>().RemoveSensorFromDropdown(type,
                                                                                          sensorManager.ultrasonicList, sensorManager.beamBreakerList, sensorManager.gyroList);
            }

            AnalyticsManager.GlobalInstance.LogEventAsync(AnalyticsLedger.EventCatagory.SensorTab,
                                                          AnalyticsLedger.EventAction.Removed,
                                                          "Sensors",
                                                          AnalyticsLedger.getMilliseconds().ToString());
        }
 /// <summary>
 /// Set currentSensor to a specified gyro
 /// </summary>
 /// <param name="i"></param>
 public void SetGyroAsCurrent(int i)
 {
     currentSensor = sensorManager.gyroList[i].GetComponent <SensorBase>();
 }
 /// <summary>
 /// Set currentSensor to a specified beam breaker
 /// </summary>
 /// <param name="i"></param>
 public void SetBeamBreakerAsCurrent(int i)
 {
     currentSensor = sensorManager.beamBreakerList[i].GetComponent <SensorBase>();
 }
 /// <summary>
 /// Set currentSensor to a specified ultrasonic
 /// </summary>
 /// <param name="i"></param>
 public void SetUltrasonicAsCurrent(int i)
 {
     currentSensor = sensorManager.ultrasonicList[i].GetComponent <SensorBase>();
 }