Exemplo n.º 1
0
    void Start()
    {
        m_collider = GetComponent <Collider>();
        // m_cubeMeshRenderer = transform.Find("Cube").gameObject.GetComponent<MeshRenderer>();
        m_cubeMeshRenderer         = subCube.GetComponent <MeshRenderer>();
        m_scoreZoneSimSceneManager = GameObject.Find("StateMachine").GetComponent <ScoreZoneSimSceneManager>();
        m_dpmRobot = GameObject.Find("StateMachine").GetComponent <DriverPracticeMode>().dpmRobot;
        m_dpm      = GameObject.Find("StateMachine").GetComponent <DriverPracticeMode>();

        this.GetComponent <BBoxShape>().Extents = transform.localScale * 0.5f;
    }
Exemplo n.º 2
0
    private void Update()
    {
        if (main == null)
        {
            main = StateMachine.Instance.FindState <MainState>();
        }
        else if (dpm == null)
        {
            camera = GameObject.Find("Main Camera").GetComponent <DynamicCamera>();

            toolkit          = GetComponent <Toolkit>();
            dpm              = GetComponent <DriverPracticeMode>();
            multiplayer      = GetComponent <LocalMultiplayer>();
            sensorManagerGUI = GetComponent <SensorManagerGUI>();

            FindElements();
        }
        else if (camera == null)
        {
            camera = GameObject.Find("Main Camera").GetComponent <DynamicCamera>();
        }
        else
        {
            UpdateWindows();

            if (Input.GetKeyDown(KeyCode.Escape))
            {
                if (StateMachine.Instance.CurrentState.GetType().Equals(typeof(MainState)))
                {
                    if (!exitPanel.activeSelf)
                    {
                        MainMenuExit("open");
                    }
                    else
                    {
                        MainMenuExit("cancel");
                    }
                }
            }

            if (Input.GetKey(KeyCode.LeftControl) && Input.GetKeyDown(KeyCode.H))
            {
                TogglePanel(toolbar);
            }
        }
    }
Exemplo n.º 3
0
    private void Update()
    {
        if (main == null)
        {
            main = transform.GetComponent <StateMachine>().CurrentState as MainState;
        }
        else if (dpm == null)
        {
            camera = GameObject.Find("Main Camera").GetComponent <DynamicCamera>();

            toolkit = GetComponent <Toolkit>();
            dpm     = GetComponent <DriverPracticeMode>();
            FindElements();
        }
        else if (camera == null)
        {
            camera = GameObject.Find("Main Camera").GetComponent <DynamicCamera>();
        }
        else
        {
            UpdateWindows();

            if (Input.GetKeyDown(KeyCode.Escape))
            {
                if (StateMachine.Instance.CurrentState.GetType().Equals(typeof(MainState)))
                {
                    if (!exitPanel.activeSelf)
                    {
                        MainMenuExit("open");
                    }
                    else
                    {
                        MainMenuExit("cancel");
                    }
                }
            }
        }
    }
Exemplo n.º 4
0
    /// <summary>
    /// Loads a robot from file into the simulator.
    /// </summary>
    private void TryLoadRobot()
    {
        //resets rotation for new robot
        rotation = Quaternion.identity;
        if (activeRobot != null)
        {
            skeleton = null;
            UnityEngine.Object.Destroy(activeRobot);
        }
        if (filePath != null && skeleton == null)
        {
            //Debug.Log (filePath);
            List <Collider> meshColliders = new List <Collider>();
            activeRobot = new GameObject("Robot");
            activeRobot.transform.parent = transform;

            List <RigidNode_Base> names = new List <RigidNode_Base>();
            RigidNode_Base.NODE_FACTORY = delegate(Guid guid)
            {
                return(new UnityRigidNode(guid));
            };

            skeleton = BXDJSkeleton.ReadSkeleton(filePath + "skeleton.bxdj");
            //Debug.Log(filePath + "skeleton.bxdj");
            skeleton.ListAllNodes(names);
            foreach (RigidNode_Base node in names)
            {
                UnityRigidNode uNode = (UnityRigidNode)node;

                uNode.CreateTransform(activeRobot.transform);

                if (!uNode.CreateMesh(filePath + uNode.ModelFileName))
                {
                    UserMessageManager.Dispatch(node.ModelFileName + " has been modified and cannot be loaded.", 6f);
                    skeleton = null;
                    UnityEngine.Object.Destroy(activeRobot);
                    return;
                }

                uNode.CreateJoint();

                Debug.Log("Joint");

                meshColliders.AddRange(uNode.unityObject.GetComponentsInChildren <Collider>());
            }

            {                                                                                // Add some mass to the base object
                UnityRigidNode uNode = (UnityRigidNode)skeleton;
                uNode.unityObject.transform.rigidbody.mass += 20f * PHYSICS_MASS_MULTIPLIER; // Battery'
            }

            //finds main node of robot to use its rigidbody
            mainNode = GameObject.Find("node_0.bxda");

            if (DriverPracticeMode.CheckRobot(PlayerPrefs.GetString("dpmSelectedRobot") + "\\dpmConfiguration.txt"))
            {
                driverPracticeMode = activeRobot.AddComponent <DriverPracticeMode>();
                driverPracticeMode.Initialize();
                driverPraticeOn = true;
            }
            else
            {
                UserMessageManager.Dispatch("No DPM Configuration found!", 5);
            }

            //Debug.Log ("HELLO AMIREKA: " + mainNode);
            auxFunctions.IgnoreCollisionDetection(meshColliders);
            resetRobot();
        }
        else
        {
            Debug.Log("unityWheelData is null...");
        }
        HideGuiSidebar();
    }