示例#1
0
 /// <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);
 }
示例#2
0
 /// <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);
 }
示例#3
0
 /// <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);
 }
示例#4
0
        /// <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);
        }
示例#5
0
 /// <summary>
 /// Similar function as the SyncNodeFunction
 /// </summary>
 public void SyncSensorSelection()
 {
     if (sensorManager.SelectedSensor == null)
     {
         currentSensor = null;
     }
     else
     {
         currentSensor = sensorManager.SelectedSensor.GetComponent <SensorBase>();
         sensorManager.ClearSelectedSensor();
     }
 }
示例#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);
        }
示例#7
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;

            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);
        }
示例#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);
            }
        }
示例#9
0
        /// <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();
        }
示例#10
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);
            }

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