/// <summary> /// Called after Awake() when the script instance is enabled. /// Initializes variables then loads the field and robot as well as setting up replay features. /// </summary> public override void Start() { AppModel.ClearError(); //getting bullet physics information physicsWorld = BPhysicsWorld.Get(); ((DynamicsWorld)physicsWorld.world).SetInternalTickCallback(BPhysicsTickListener.Instance.PhysicsTick); //setting up raycast robot tick callback BPhysicsTickListener.Instance.OnTick -= BRobotManager.Instance.UpdateRaycastRobots; BPhysicsTickListener.Instance.OnTick += BRobotManager.Instance.UpdateRaycastRobots; //starts a new instance of unity packet which receives packets from the driver station unityPacket = new UnityPacket(); unityPacket.Start(); SpawnedRobots = new List <NetworkRobot>(); //loads all the controls Controls.Load(); //initializes the dynamic camera DynamicCameraObject = GameObject.Find("Main Camera"); dynamicCamera = DynamicCameraObject.AddComponent <DynamicCamera>(); DynamicCamera.ControlEnabled = true; IsMetric = PlayerPrefs.GetString("Measure").Equals("Metric") ? true : false; Network = GameObject.Find("NetworkManager").GetComponent <MultiplayerNetwork>(); Network.State = this; }
/// <summary> /// Switches to the error screen and its respective UI elements. /// </summary> public void SwitchErrorScreen() { currentTab = Tab.ErrorScreen; navigationPanel.SetActive(false); homeTab.SetActive(false); optionsTab.SetActive(false); simTab.SetActive(false); errorText.text = AppModel.ErrorMessage; errorScreen.SetActive(true); AppModel.ClearError(); }
/// <summary> /// Initailizes references to requried <see cref="GameObject"/>s and sets the error message text. /// </summary> public override void Start() { string error = AppModel.ErrorMessage; if (error == null) { throw new System.Exception("Missing error message - don't start error scene directly"); } string error_type = error.Contains("|") ? error.Split('|')[0] : ""; string error_mesage = error.Contains("|") ? error.Split('|')[1] : error; if (error_type.Equals("ROBOT_SELECT")) { AppModel.ClearError(); StateMachine.ChangeState(new LoadRobotState()); if (error_mesage.Equals("FIRST")) { Auxiliary.FindGameObject("ErrorNote").GetComponent <Text>().text = ""; } else { Auxiliary.FindGameObject("ErrorNote").GetComponent <Text>().text = error_mesage; } PlayerPrefs.SetString("simSelectedRobot", ""); PlayerPrefs.SetString("simSelectedRobotName", ""); } /* * else if (error_type.Equals("FIELD_SELECT")) * { * AppModel.ClearError(); * StateMachine.ChangeState(new LoadFieldState()); * if (error_mesageEquals("FIRST")) Auxiliary.FindGameObject("ErrorNote").GetComponent<Text>().text = ""; * else Auxiliary.FindGameObject("ErrorNote").GetComponent<Text>().text = error_mesage; * PlayerPrefs.SetString("simSelectedField", ""); * PlayerPrefs.SetString("simSelectedFieldName", ""); * } */ else { if (error_type.Equals("FIELD_SELECT")) { PlayerPrefs.SetString("simSelectedField", ""); PlayerPrefs.SetString("simSelectedFieldName", ""); } Auxiliary.FindGameObject("ErrorScreen").SetActive(true); Auxiliary.FindGameObject("ErrorText").GetComponent <Text>().text = error_mesage; AppModel.ClearError(); } }
/// <summary> /// Initailizes references to requried <see cref="GameObject"/>s and sets the error message text. /// </summary> public override void Start() { Auxiliary.FindGameObject("ErrorText").GetComponent <Text>().text = AppModel.ErrorMessage; AppModel.ClearError(); }
/// <summary> /// Called after Awake() when the script instance is enabled. /// Initializes variables then loads the field and robot as well as setting up replay features. /// </summary> public override void Start() { AppModel.ClearError(); //getting bullet physics information physicsWorld = BPhysicsWorld.Get(); ((DynamicsWorld)physicsWorld.world).SetInternalTickCallback(BPhysicsTickListener.Instance.PhysicsTick); lastFrameCount = physicsWorld.frameCount; //setting up raycast robot tick callback BPhysicsTickListener.Instance.OnTick -= BRobotManager.Instance.UpdateRaycastRobots; BPhysicsTickListener.Instance.OnTick += BRobotManager.Instance.UpdateRaycastRobots; //starts a new instance of unity packet which receives packets from the driver station unityPacket.Start(); //If a replay has been selected, load the replay. Otherwise, load the field and robot. string selectedReplay = PlayerPrefs.GetString("simSelectedReplay"); if (string.IsNullOrEmpty(selectedReplay)) { Tracking = true; if (!LoadField(PlayerPrefs.GetString("simSelectedField"))) { AppModel.ErrorToMenu("Could not load field: " + PlayerPrefs.GetString("simSelectedField") + "\nHas it been moved or deleted?)"); return; } if (!LoadRobot(PlayerPrefs.GetString("simSelectedRobot"), RobotTypeManager.IsMixAndMatch)) { AppModel.ErrorToMenu("Could not load robot: " + PlayerPrefs.GetString("simSelectedRobot") + "\nHas it been moved or deleted?)"); return; } reset = FieldDataHandler.robotSpawn == new Vector3(99999, 99999, 99999); if (RobotTypeManager.IsMixAndMatch && RobotTypeManager.HasManipulator) { Debug.Log(LoadManipulator(RobotTypeManager.ManipulatorPath) ? "Load manipulator success" : "Load manipulator failed"); } } else { awaitingReplay = true; LoadReplay(selectedReplay); } //initializes the dynamic camera DynamicCameraObject = GameObject.Find("Main Camera"); dynamicCamera = DynamicCameraObject.AddComponent <DynamicCamera>(); DynamicCamera.ControlEnabled = true; sensorManager = GameObject.Find("SensorManager").GetComponent <SensorManager>(); sensorManagerGUI = StateMachine.gameObject.GetComponent <SensorManagerGUI>(); simUI = StateMachine.SceneGlobal.GetComponent <SimUI>(); robotCameraManager = GameObject.Find("RobotCameraList").GetComponent <RobotCameraManager>(); IsMetric = PlayerPrefs.GetString("Measure").Equals("Metric") ? true : false; StateMachine.Link <MainState>(GameObject.Find("Main Camera").transform.GetChild(0).gameObject); StateMachine.Link <MainState>(GameObject.Find("Main Camera").transform.GetChild(1).gameObject, false); StateMachine.Link <ReplayState>(Auxiliary.FindGameObject("ReplayUI")); StateMachine.Link <SaveReplayState>(Auxiliary.FindGameObject("SaveReplayUI")); StateMachine.Link <GamepieceSpawnState>(Auxiliary.FindGameObject("ResetGamepieceSpawnpointUI")); StateMachine.Link <DefineNodeState>(Auxiliary.FindGameObject("DefineNodeUI")); StateMachine.Link <GoalState>(Auxiliary.FindGameObject("GoalStateUI")); StateMachine.Link <SensorSpawnState>(Auxiliary.FindGameObject("ResetSensorSpawnpointUI")); StateMachine.Link <DefineSensorAttachmentState>(Auxiliary.FindGameObject("DefineSensorAttachmentUI")); string defaultDirectory = (Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + @"Autodesk\Synthesis\Emulator"); string directoryPath = ""; if (Directory.Exists(defaultDirectory)) { directoryPath = defaultDirectory; isEmulationDownloaded = true; } }
/// <summary> /// Called after Awake() when the script instance is enabled. /// Initializes variables then loads the field and robot as well as setting up replay features. /// </summary> public override void Start() { AppModel.ClearError(); //getting bullet physics information physicsWorld = BPhysicsWorld.Get(); ((DynamicsWorld)physicsWorld.world).SetInternalTickCallback(BPhysicsTickListener.Instance.PhysicsTick); lastFrameCount = physicsWorld.frameCount; //setting up raycast robot tick callback BPhysicsTickListener.Instance.OnTick -= BRobotManager.Instance.UpdateRaycastRobots; BPhysicsTickListener.Instance.OnTick += BRobotManager.Instance.UpdateRaycastRobots; //setting up replay CollisionTracker = new CollisionTracker(this); //starts a new instance of unity packet which receives packets from the driver station unityPacket = new UnityPacket(); unityPacket.Start(); //loads all the controls Controls.Load(); //If a replay has been selected, load the replay. Otherwise, load the field and robot. string selectedReplay = PlayerPrefs.GetString("simSelectedReplay"); SpawnedRobots = new List <Robot>(); if (string.IsNullOrEmpty(selectedReplay)) { Tracking = true; if (!LoadField(PlayerPrefs.GetString("simSelectedField"))) { AppModel.ErrorToMenu("Could not load field: " + PlayerPrefs.GetString("simSelectedField") + "\nHas it been moved or deleted?)"); return; } if (!LoadRobot(PlayerPrefs.GetString("simSelectedRobot"), RobotTypeManager.IsMixAndMatch)) { AppModel.ErrorToMenu("Could not load robot: " + PlayerPrefs.GetString("simSelectedRobot") + "\nHas it been moved or deleted?)"); return; } if (RobotTypeManager.IsMixAndMatch && RobotTypeManager.HasManipulator) { Debug.Log(LoadManipulator(RobotTypeManager.ManipulatorPath) ? "Load manipulator success" : "Load manipulator failed"); } } else { awaitingReplay = true; LoadReplay(selectedReplay); } //initializes the dynamic camera DynamicCameraObject = GameObject.Find("Main Camera"); dynamicCamera = DynamicCameraObject.AddComponent <DynamicCamera>(); DynamicCamera.MovingEnabled = true; sensorManager = GameObject.Find("SensorManager").GetComponent <SensorManager>(); sensorManagerGUI = GameObject.Find("StateMachine").GetComponent <SensorManagerGUI>(); robotCameraManager = GameObject.Find("RobotCameraList").GetComponent <RobotCameraManager>(); IsMetric = PlayerPrefs.GetString("Measure").Equals("Metric") ? true : false; StateMachine.Instance.Link <MainState>(GameObject.Find("Main Camera").transform.GetChild(0).gameObject); StateMachine.Instance.Link <ReplayState>(Resources.FindObjectsOfTypeAll <GameObject>().First(x => x.name.Equals("ReplayUI"))); StateMachine.Instance.Link <SaveReplayState>(Resources.FindObjectsOfTypeAll <GameObject>().First(x => x.name.Equals("SaveReplayUI"))); }
/// <summary> /// Called after Awake() when the script instance is enabled. /// Initializes variables then loads the field and robot as well as setting up replay features. /// </summary> public override void Start() { AppModel.ClearError(); //getting bullet physics information physicsWorld = BPhysicsWorld.Get(); ((DynamicsWorld)physicsWorld.world).SetInternalTickCallback(BPhysicsTickListener.Instance.PhysicsTick); lastFrameCount = physicsWorld.frameCount; //setting up raycast robot tick callback BPhysicsTickListener.Instance.OnTick -= BRobotManager.Instance.UpdateRaycastRobots; BPhysicsTickListener.Instance.OnTick += BRobotManager.Instance.UpdateRaycastRobots; //If a replay has been selected, load the replay. Otherwise, load the field and robot. string selectedReplay = PlayerPrefs.GetString("simSelectedReplay"); if (PlayerPrefs.GetString("simSelectedRobot", "").Equals("")) { AppModel.ErrorToMenu("ROBOT_SELECT|FIRST"); return; } if (string.IsNullOrEmpty(selectedReplay)) { Tracking = true; if (!LoadField(PlayerPrefs.GetString("simSelectedField"))) { //AppModel.ErrorToMenu("FIELD_SELECT|FIRST"); AppModel.ErrorToMenu("FIELD_SELECT|Could not load field: " + PlayerPrefs.GetString("simSelectedField") + "\nHas it been moved or deleted?)"); return; } else { MovePlane(); } bool result = false; try { result = LoadRobot(PlayerPrefs.GetString("simSelectedRobot"), false); } catch (Exception e) { MonoBehaviour.Destroy(GameObject.Find("Robot")); } if (!result) { AppModel.ErrorToMenu("ROBOT_SELECT|Could not find the selected robot"); return; } reset = FieldDataHandler.robotSpawn == new Vector3(99999, 99999, 99999); if (RobotTypeManager.IsMixAndMatch && RobotTypeManager.HasManipulator) { Debug.Log(LoadManipulator(RobotTypeManager.ManipulatorPath) ? "Load manipulator success" : "Load manipulator failed"); } } else { awaitingReplay = true; PlayerPrefs.SetString("simSelectedReplay", ""); LoadReplay(selectedReplay); } //initializes the dynamic camera DynamicCameraObject = GameObject.Find("Main Camera"); dynamicCamera = DynamicCameraObject.AddComponent <DynamicCamera>(); DynamicCamera.ControlEnabled = true; sensorManager = GameObject.Find("SensorManager").GetComponent <SensorManager>(); sensorManagerGUI = StateMachine.gameObject.GetComponent <SensorManagerGUI>(); simUI = StateMachine.SceneGlobal.GetComponent <SimUI>(); robotCameraManager = GameObject.Find("RobotCameraList").GetComponent <RobotCameraManager>(); IsMetric = PlayerPrefs.GetString("Measure").Equals("Metric"); StateMachine.Link <MainState>(GameObject.Find("Main Camera").transform.GetChild(0).gameObject); StateMachine.Link <MainState>(GameObject.Find("Main Camera").transform.GetChild(1).gameObject, false); StateMachine.Link <ReplayState>(Auxiliary.FindGameObject("ReplayUI")); StateMachine.Link <SaveReplayState>(Auxiliary.FindGameObject("SaveReplayUI")); StateMachine.Link <GamepieceSpawnState>(Auxiliary.FindGameObject("ResetGamepieceSpawnpointUI")); StateMachine.Link <DefineNodeState>(Auxiliary.FindGameObject("DefineNodeUI")); StateMachine.Link <GoalState>(Auxiliary.FindGameObject("GoalStateUI")); StateMachine.Link <SensorSpawnState>(Auxiliary.FindGameObject("ResetSensorSpawnpointUI")); StateMachine.Link <DefineSensorAttachmentState>(Auxiliary.FindGameObject("DefineSensorAttachmentUI")); MediaManager.getInstance(); Controls.Load(); Controls.UpdateFieldControls(); Controls.Save(true); }
/// <summary> /// Called after Awake() when the script instance is enabled. /// Initializes variables then loads the field and robot as well as setting up replay features. /// </summary> public override void Start() { AppModel.ClearError(); //getting bullet physics information physicsWorld = BPhysicsWorld.Get(); ((DynamicsWorld)physicsWorld.world).SetInternalTickCallback(BPhysicsTickListener.Instance.PhysicsTick); lastFrameCount = physicsWorld.frameCount; //setting up raycast robot tick callback BPhysicsTickListener.Instance.OnTick += BRobotManager.Instance.UpdateRaycastRobots; //setting up replay CollisionTracker = new CollisionTracker(this); //starts a new instance of unity packet which receives packets from the driver station unityPacket = new UnityPacket(); unityPacket.Start(); //loads all the controls Controls.Load(); //If a replay has been selected, load the replay. Otherwise, load the field and robot. string selectedReplay = PlayerPrefs.GetString("simSelectedReplay"); SpawnedRobots = new List <Robot>(); if (string.IsNullOrEmpty(selectedReplay)) { Tracking = true; fieldPath = PlayerPrefs.GetString("simSelectedField"); robotPath = PlayerPrefs.GetString("simSelectedRobot"); Debug.Log(RobotFieldLoader.LoadField(fieldPath) ? "Load field success!" : "Load field failed."); Debug.Log(LoadRobot(robotPath) ? "Load robot success!" : "Load robot failed."); if (!LoadRobot(PlayerPrefs.GetString("simSelectedRobot"))) { AppModel.ErrorToMenu("Could not load robot: " + PlayerPrefs.GetString("simSelectedRobot") + "\nHas it been moved or deleted?)"); return; } int isMixAndMatch = PlayerPrefs.GetInt("mixAndMatch", 0); // 0 is false, 1 is true int hasManipulator = PlayerPrefs.GetInt("hasManipulator"); if (isMixAndMatch == 1 && hasManipulator == 1) { Debug.Log(LoadManipulator(PlayerPrefs.GetString("simSelectedManipulator")) ? "Load manipulator success" : "Load manipulator failed"); } } else { awaitingReplay = true; LoadReplay(selectedReplay); } //initializes the dynamic camera dynamicCameraObject = GameObject.Find("Main Camera"); dynamicCamera = dynamicCameraObject.AddComponent <DynamicCamera>(); DynamicCamera.MovingEnabled = true; sensorManager = GameObject.Find("SensorManager").GetComponent <SensorManager>(); sensorManagerGUI = GameObject.Find("StateMachine").GetComponent <SensorManagerGUI>(); robotCameraManager = GameObject.Find("RobotCameraList").GetComponent <RobotCameraManager>(); ScoreZoneSimSceneManager scoreZoneSimSceneManager = GameObject.Find("StateMachine").GetComponent <ScoreZoneSimSceneManager>(); scoreZoneSimSceneManager.LoadScoreZones(); }