Example #1
0
        /// <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;
        }
Example #2
0
    /// <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()
    {
        //getting bullet physics information
        physicsWorld = BPhysicsWorld.Get();
        ((DynamicsWorld)physicsWorld.world).SetInternalTickCallback(BRobotManager.Instance.UpdateRaycastRobots);
        lastFrameCount = physicsWorld.frameCount;

        //setting up replay
        Trackers         = new List <Tracker>();
        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;
            Debug.Log(LoadField(PlayerPrefs.GetString("simSelectedField")) ? "Load field success!" : "Load field failed.");
            Debug.Log(LoadRobot(PlayerPrefs.GetString("simSelectedRobot")) ? "Load robot success!" : "Load robot failed.");

            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>();
    }
Example #3
0
    // Use this for initialization
    void Start()
    {
        unityPacket = new UnityPacket();
        unityPacket.Start();

        Debug.Log(LoadField(PlayerPrefs.GetString("Field")) ? "Load field success!" : "Load field failed.");
        Debug.Log(LoadRobot(PlayerPrefs.GetString("Robot")) ? "Load robot success!" : "Load robot failed.");

        dynamicCamera = GameObject.Find("Main Camera").AddComponent <DynamicCamera>();

        extraElements = new List <GameObject>();

        random = new System.Random();

        resetting = false;
    }
Example #4
0
    /// <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()
    {
        //getting bullet physics information
        physicsWorld   = BPhysicsWorld.Get();
        lastFrameCount = physicsWorld.frameCount;

        //setting up replay
        Trackers      = new List <Tracker>();
        contactPoints = new FixedQueue <List <ContactDescriptor> >(Tracker.Length);

        //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;
            Debug.Log(LoadField(PlayerPrefs.GetString("simSelectedField")) ? "Load field success!" : "Load field failed.");
            Debug.Log(LoadRobot(PlayerPrefs.GetString("simSelectedRobot")) ? "Load robot success!" : "Load robot failed.");

            int isMixAndMatch = PlayerPrefs.GetInt("MixAndMatch", 1); //0 is true, 1 is false
            if (isMixAndMatch == 0 && MixAndMatchMode.hasManipulator)
            {
                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;
    }
Example #5
0
        /// <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;
            }
        }
Example #6
0
    /// <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")));
    }