Пример #1
0
    /// <summary>
    /// Find ALL the GUI stuff needed for the sensor GUI to work
    /// </summary>
    private void FindElements()
    {
        canvas        = GameObject.Find("Canvas");
        simUI         = gameObject.GetComponent <SimUI>();
        sensorManager = GameObject.Find("SensorManager").GetComponent <SensorManager>();
        dynamicCamera = GameObject.Find("Main Camera").GetComponent <DynamicCamera>();

        sensorOptionPanel     = AuxFunctions.FindObject(canvas, "SensorOptionPanel");
        sensorTypePanel       = AuxFunctions.FindObject(canvas, "SensorTypePanel");
        configureSensorButton = AuxFunctions.FindObject(canvas, "ConfigureSensorButton");

        //For sensor option panel
        addSensorButton      = AuxFunctions.FindObject(sensorOptionPanel, "AddNewSensor");
        selectExistingButton = AuxFunctions.FindObject(sensorOptionPanel, "ConfigureExistingSensor");
        cancelOptionButton   = AuxFunctions.FindObject(sensorOptionPanel, "CancelButton");
        sensorOptionToolTip  = AuxFunctions.FindObject(sensorOptionPanel, "ToolTipPanel");

        //For choosing sensor type
        addUltrasonicButton  = AuxFunctions.FindObject(sensorTypePanel, "AddUltrasonic");
        addBeamBreakerButton = AuxFunctions.FindObject(sensorTypePanel, "AddBeamBreaker");
        addGyroButton        = AuxFunctions.FindObject(sensorTypePanel, "AddGyro");
        cancelTypeButton     = AuxFunctions.FindObject(sensorTypePanel, "CancelButton");

        //For Sensor position and attachment configuration
        configureSensorPanel          = AuxFunctions.FindObject(canvas, "SensorConfigurationPanel");
        changeSensorNodeButton        = AuxFunctions.FindObject(configureSensorPanel, "ChangeNodeButton");
        sensorConfigurationModeButton = AuxFunctions.FindObject(configureSensorPanel, "ConfigurationMode");
        sensorNodeText            = AuxFunctions.FindObject(configureSensorPanel, "NodeText").GetComponent <Text>();
        cancelNodeSelectionButton = AuxFunctions.FindObject(configureSensorPanel, "CancelNodeSelectionButton");
        deleteSensorButton        = AuxFunctions.FindObject(configureSensorPanel, "DeleteSensorButton");

        //For Sensor angle configuration
        sensorAnglePanel = AuxFunctions.FindObject(canvas, "SensorAnglePanel");
        xAngleEntry      = AuxFunctions.FindObject(sensorAnglePanel, "xAngleEntry");
        yAngleEntry      = AuxFunctions.FindObject(sensorAnglePanel, "yAngleEntry");
        zAngleEntry      = AuxFunctions.FindObject(sensorAnglePanel, "zAngleEntry");
        showAngleButton  = AuxFunctions.FindObject(configureSensorPanel, "ShowSensorAngleButton");
        editAngleButton  = AuxFunctions.FindObject(sensorAnglePanel, "EditButton");

        //For range configuration
        sensorRangePanel = AuxFunctions.FindObject(canvas, "SensorRangePanel");
        RangeEntry       = AuxFunctions.FindObject(sensorRangePanel, "RangeEntry");
        showRangeButton  = AuxFunctions.FindObject(configureSensorPanel, "ShowSensorRangeButton");
        editRangeButton  = AuxFunctions.FindObject(sensorRangePanel, "EditButton");

        lockPositionButton = AuxFunctions.FindObject(configureSensorPanel, "LockPositionButton");
        lockAngleButton    = AuxFunctions.FindObject(configureSensorPanel, "LockAngleButton");
        lockRangeButton    = AuxFunctions.FindObject(configureSensorPanel, "LockRangeButton");

        hideOutputPanelsButton = AuxFunctions.FindObject(canvas, "HideOutputButton");
    }
Пример #2
0
    /// <summary>
    /// FInds all the gameobjects and stores them in variables for efficiency
    /// </summary>
    void Start()
    {
        canvas            = GameObject.Find("Canvas");
        multiplayerWindow = AuxFunctions.FindObject(canvas, "MultiplayerPanel");
        addRobotWindow    = AuxFunctions.FindObject(canvas, "AddRobotPanel");

        for (int i = 0; i < robotButtons.Length; i++)
        {
            robotButtons[i] = AuxFunctions.FindObject(canvas, "Robot" + (i + 1) + "Button");
        }

        simUI     = StateMachine.Instance.gameObject.GetComponent <SimUI>();
        highlight = AuxFunctions.FindObject(canvas, "HighlightActiveRobot");
    }
Пример #3
0
    /// <summary>
    /// FInds all the gameobjects and stores them in variables for efficiency
    /// </summary>
    private void Start()
    {
        canvas            = GameObject.Find("Canvas");
        multiplayerWindow = Auxiliary.FindObject(canvas, "MultiplayerPanel");
        addRobotWindow    = Auxiliary.FindObject(canvas, "AddRobotPanel");

        for (int i = 0; i < robotButtons.Length; i++)
        {
            robotButtons[i] = Auxiliary.FindObject(canvas, "Robot" + (i + 1) + "Button");
        }

        simUI            = StateMachine.SceneGlobal.gameObject.GetComponent <SimUI>();
        highlight        = Auxiliary.FindObject(canvas, "HighlightActiveRobot");
        mixAndMatchPanel = Auxiliary.FindObject(canvas, "MixAndMatchPanel");
    }
Пример #4
0
    /// <summary>
    /// Find all robot camera related GUI elements in the canvas
    /// </summary>
    public void FindGUIElements()
    {
        canvas           = GameObject.Find("Canvas");
        simUI            = GameObject.Find("StateMachine").GetComponent <SimUI>();
        sensorManagerGUI = GameObject.Find("StateMachine").GetComponent <SensorManagerGUI>();
        //For robot camera view window
        robotCameraView       = Resources.Load("Images/RobotCameraView") as RenderTexture;
        robotCameraViewWindow = AuxFunctions.FindObject(canvas, "RobotCameraPanel");
        robotCameraViewWindow = AuxFunctions.FindObject(canvas, "RobotCameraPanelBorder");

        //For camera indicator
        robotCameraListObject = GameObject.Find("RobotCameraList");
        robotCameraManager    = robotCameraListObject.GetComponent <RobotCameraManager>();

        if (CameraIndicator == null)
        {
            CameraIndicator = AuxFunctions.FindObject(robotCameraListObject, "CameraIndicator");
        }
        showCameraButton = AuxFunctions.FindObject(canvas, "ShowCameraButton");

        //For camera position and attachment configuration
        configureRobotCameraButton    = AuxFunctions.FindObject(canvas, "CameraConfigurationButton");
        changeCameraNodeButton        = AuxFunctions.FindObject(canvas, "ChangeNodeButton");
        configureCameraPanel          = AuxFunctions.FindObject(canvas, "CameraConfigurationPanel");
        cameraConfigurationModeButton = AuxFunctions.FindObject(canvas, "ConfigurationMode");
        cameraNodeText            = AuxFunctions.FindObject(canvas, "NodeText").GetComponent <Text>();
        cancelNodeSelectionButton = AuxFunctions.FindObject(canvas, "CancelNodeSelectionButton");

        //For camera angle configuration
        cameraAnglePanel = AuxFunctions.FindObject(canvas, "CameraAnglePanel");
        xAngleEntry      = AuxFunctions.FindObject(cameraAnglePanel, "xAngleEntry");
        yAngleEntry      = AuxFunctions.FindObject(cameraAnglePanel, "yAngleEntry");
        zAngleEntry      = AuxFunctions.FindObject(cameraAnglePanel, "zAngleEntry");
        showAngleButton  = AuxFunctions.FindObject(configureCameraPanel, "ShowCameraAngleButton");
        editAngleButton  = AuxFunctions.FindObject(cameraAnglePanel, "EditButton");

        //For field of view configuration
        cameraFOVPanel = AuxFunctions.FindObject(canvas, "CameraFOVPanel");
        FOVEntry       = AuxFunctions.FindObject(cameraFOVPanel, "FOVEntry");
        showFOVButton  = AuxFunctions.FindObject(configureCameraPanel, "ShowCameraFOVButton");
        editFOVButton  = AuxFunctions.FindObject(cameraFOVPanel, "EditButton");

        lockPositionButton = AuxFunctions.FindObject(configureCameraPanel, "LockPositionButton");
        lockAngleButton    = AuxFunctions.FindObject(configureCameraPanel, "LockAngleButton");
        lockFOVButton      = AuxFunctions.FindObject(configureCameraPanel, "LockFOVButton");
    }
Пример #5
0
    void FindElements()
    {
        canvas = GameObject.Find("Canvas");
        simUI  = GetComponent <SimUI>();

        dpmWindow    = AuxFunctions.FindObject(canvas, "DPMPanel");
        configWindow = AuxFunctions.FindObject(canvas, "ConfigurationPanel");

        enableDPMText = AuxFunctions.FindObject(canvas, "EnableDPMText").GetComponent <Text>();

        primaryGamepieceText   = AuxFunctions.FindObject(canvas, "PrimaryGamepieceText").GetComponent <Text>();
        secondaryGamepieceText = AuxFunctions.FindObject(canvas, "SecondaryGamepieceText").GetComponent <Text>();

        configuringText  = AuxFunctions.FindObject(canvas, "ConfiguringText").GetComponent <Text>();
        configHeaderText = AuxFunctions.FindObject(canvas, "ConfigHeaderText").GetComponent <Text>();

        releaseVelocityPanel = AuxFunctions.FindObject(canvas, "ReleaseVelocityPanel");

        xOffsetEntry           = AuxFunctions.FindObject(canvas, "XOffsetEntry");
        yOffsetEntry           = AuxFunctions.FindObject(canvas, "YOffsetEntry");
        zOffsetEntry           = AuxFunctions.FindObject(canvas, "ZOffsetEntry");
        releaseSpeedEntry      = AuxFunctions.FindObject(canvas, "ReleaseSpeedEntry");
        releaseVerticalEntry   = AuxFunctions.FindObject(canvas, "ReleaseVerticalEntry");
        releaseHorizontalEntry = AuxFunctions.FindObject(canvas, "ReleaseHorizontalEntry");

        releaseMechanismText = AuxFunctions.FindObject(canvas, "ReleaseMechanismText").GetComponent <Text>();
        intakeMechanismText  = AuxFunctions.FindObject(canvas, "IntakeMechanismText").GetComponent <Text>();

        defineIntakeWindow    = AuxFunctions.FindObject(canvas, "DefineIntakePanel");
        defineReleaseWindow   = AuxFunctions.FindObject(canvas, "DefineReleasePanel");
        defineGamepieceWindow = AuxFunctions.FindObject(canvas, "DefineGamepiecePanel");
        setSpawnWindow        = AuxFunctions.FindObject(canvas, "SetGamepieceSpawnPanel");

        intakeControlText  = AuxFunctions.FindObject(canvas, "IntakeInputButton").GetComponentInChildren <Text>();
        releaseControlText = AuxFunctions.FindObject(canvas, "ReleaseInputButton").GetComponentInChildren <Text>();
        spawnControlText   = AuxFunctions.FindObject(canvas, "SpawnInputButton").GetComponentInChildren <Text>();

        primaryCountText   = AuxFunctions.FindObject(canvas, "PrimaryCountText").GetComponent <Text>();
        secondaryCountText = AuxFunctions.FindObject(canvas, "SecondaryCountText").GetComponent <Text>();

        lockPanel = AuxFunctions.FindObject(canvas, "DPMLockPanel");
    }
Пример #6
0
        public override void Start()
        {
            canvas = GameObject.Find("Canvas");
            camera = GameObject.Find("Main Camera").GetComponent <DynamicCamera>();

            tabs         = Auxiliary.FindObject(canvas, "Tabs");
            toolbar      = Auxiliary.FindObject(canvas, "MainToolbar");
            helpMenu     = Auxiliary.FindObject(canvas, "Help");
            overlay      = Auxiliary.FindObject(canvas, "Overlay");
            helpBodyText = Auxiliary.FindObject(canvas, "BodyText").GetComponent <Text>();

            changeRobotPanel = Auxiliary.FindObject(canvas, "ChangeRobotPanel");
            robotListPanel   = Auxiliary.FindObject(changeRobotPanel, "RobotListPanel");
            changePanel      = Auxiliary.FindObject(canvas, "ChangePanel");
            addPanel         = Auxiliary.FindObject(canvas, "AddPanel");
            changeFieldPanel = Auxiliary.FindObject(canvas, "ChangeFieldPanel");

            resetDropdown    = GameObject.Find("ResetRobotDropdown");
            multiplayerPanel = Auxiliary.FindObject(canvas, "MultiplayerPanel");

            stopwatchWindow = Auxiliary.FindObject(canvas, "StopwatchPanel");
            statsWindow     = Auxiliary.FindObject(canvas, "StatsPanel");
            rulerWindow     = Auxiliary.FindObject(canvas, "RulerPanel");

            inputManagerPanel = Auxiliary.FindObject(canvas, "InputManagerPanel");
            bindedKeyPanel    = Auxiliary.FindObject(canvas, "BindedKeyPanel");
            checkSavePanel    = Auxiliary.FindObject(canvas, "CheckSavePanel");

            // To access instatiate classes within a state, use the StateMachine.SceneGlobal
            toolkit          = StateMachine.SceneGlobal.GetComponent <Toolkit>();
            multiplayer      = StateMachine.SceneGlobal.GetComponent <LocalMultiplayer>();
            simUI            = StateMachine.SceneGlobal.GetComponent <SimUI>();
            robotCameraGUI   = StateMachine.SceneGlobal.GetComponent <RobotCameraGUI>();
            sensorManagerGUI = StateMachine.SceneGlobal.GetComponent <SensorManagerGUI>();

            State = StateMachine.SceneGlobal.CurrentState as MainState;

            Button helpButton = Auxiliary.FindObject(helpMenu, "CloseHelpButton").GetComponent <Button>();

            helpButton.onClick.RemoveAllListeners();
            helpButton.onClick.AddListener(CloseHelpMenu);
        }
Пример #7
0
    /// <summary>
    /// Finds all the necessary UI elements that need to be updated/modified
    /// </summary>
    private void FindElements()
    {
        canvas = GameObject.Find("Canvas");

        mixAndMatchPanel = AuxFunctions.FindObject(canvas, "MixAndMatchPanel");
        wheelPanel       = AuxFunctions.FindObject(canvas, "WheelPanel");
        driveBasePanel   = AuxFunctions.FindObject(canvas, "DriveBasePanel");
        manipulatorPanel = AuxFunctions.FindObject(canvas, "ManipulatorPanel");

        addRobotPanel = AuxFunctions.FindObject("MultiplayerPanel");


        changeRobotPanel = AuxFunctions.FindObject(canvas, "ChangeRobotPanel");


        inputManagerPanel = AuxFunctions.FindObject(canvas, "InputManagerPanel");

        exitPanel    = AuxFunctions.FindObject(canvas, "ExitPanel");
        loadingPanel = AuxFunctions.FindObject(canvas, "LoadingPanel");

        simUI = StateMachine.Instance.gameObject.GetComponent <SimUI>();
    }
Пример #8
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;
            }
        }
Пример #9
0
        public override void End()
        {
            base.End();

            SimUI.getSimUI().CloseNavigationTooltip();
        }
Пример #10
0
        /// <summary>
        /// Return the robot to robotStartPosition and destroy extra game pieces
        /// </summary>
        /// <param name="resetTransform"></param>
        public void BeginReset()
        {
            //GetDriverPractice().DestroyAllGamepieces();

            InputControl.freeze = true;
            if (canvas == null)
            {
                canvas = GameObject.Find("Canvas");
            }
            if (resetCanvas == null)
            {
                resetCanvas = Auxiliary.FindObject(UnityEngine.Camera.main.gameObject, "ResetRobotSpawnpointUI");
            }
            canvas.GetComponent <Canvas>().enabled = false;
            resetCanvas.SetActive(true);

            #region init
            if (toolbar == null)
            {
                toolbar = Auxiliary.FindObject(resetCanvas, "ResetStateToolbar");
            }
            #endregion

            Button resetButton = Auxiliary.FindObject(resetCanvas, "ResetButton").GetComponent <Button>();
            resetButton.onClick.RemoveAllListeners();
            resetButton.onClick.AddListener(BeginRevertSpawnpoint);
            Button returnButton = Auxiliary.FindObject(resetCanvas, "ReturnButton").GetComponent <Button>();
            returnButton.onClick.RemoveAllListeners();
            returnButton.onClick.AddListener(EndReset);

            DynamicCamera dynamicCamera = UnityEngine.Camera.main.transform.GetComponent <DynamicCamera>();
            lastCameraState = dynamicCamera.ActiveState;
            dynamicCamera.SwitchCameraState(new DynamicCamera.OrbitState(dynamicCamera));

            foreach (SimulatorRobot robot in state.SpawnedRobots)
            {
                foreach (BRigidBody rb in robot.GetComponentsInChildren <BRigidBody>())
                {
                    if (rb != null && !rb.GetCollisionObject().IsActive)
                    {
                        rb.GetCollisionObject().Activate();
                    }
                }
            }

            if (!state.DynamicCameraObject.GetComponent <DynamicCamera>().ActiveState.GetType().Equals(typeof(DynamicCamera.ConfigurationState)))
            {
                IsResetting = true;

                BeginRobotReset();
                OnBeginReset();

                //Where "save orientation" works
                RotateRobot(robotStartOrientation);

                AttachMoveArrows();
            }
            else
            {
                UserMessageManager.Dispatch("Please don't reset robot during configuration!", 5f);
            }

            SimUI.getSimUI().OpenNavigationTooltip();
        }
Пример #11
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;

            //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);
        }
Пример #12
0
        // Use this for initialization
        public override void Start()
        {
            //create indicator
            if (goalIndicator != null)
            {
                GameObject.Destroy(goalIndicator);
            }
            if (goalIndicator == null)
            {
                goalIndicator      = GameObject.CreatePrimitive(PrimitiveType.Cube); // Create cube to show goal region
                goalIndicator.name = "GoalIndicator";
                Renderer render = goalIndicator.GetComponentInChildren <Renderer>();
                render.material.shader = Shader.Find("Transparent/Diffuse");
                Color newColor = new Color(0, 0.88f, 0, 0.6f);
                render.material.color = newColor;
            }

            GameObject goal = color.Equals("Red") ? gm.redGoals[gamepieceIndex][goalIndex] : gm.blueGoals[gamepieceIndex][goalIndex];

            goalIndicator.transform.position    = goal.GetComponent <Goal>().position;
            goalIndicator.transform.eulerAngles = goal.GetComponent <Goal>().rotation;
            goalIndicator.transform.localScale  = goal.GetComponent <Goal>().scale;

            settingGamepieceGoalVertical = false;

            //move arrow attachment
            GameObject moveArrows = GameObject.Instantiate(Resources.Load <GameObject>("Prefabs\\MoveArrows"));

            moveArrows.name                    = "IndicatorMoveArrows";
            moveArrows.transform.parent        = goalIndicator.transform;
            moveArrows.transform.localPosition = UnityEngine.Vector3.zero;

            if (move)
            {
                moveArrows.GetComponent <MoveArrows>().Translate = (translation) => goalIndicator.transform.Translate(translation, Space.World);
            }
            else
            {
                moveArrows.GetComponent <MoveArrows>().Translate = (translation) => goalIndicator.transform.localScale += translation;
            }

            StateMachine.SceneGlobal.Link <GoalState>(moveArrows);

            //camera stuff
            DynamicCamera dynamicCamera = UnityEngine.Camera.main.transform.GetComponent <DynamicCamera>();

            lastCameraState = dynamicCamera.ActiveState;
            dynamicCamera.SwitchCameraState(new DynamicCamera.ConfigurationState(dynamicCamera, goalIndicator));

            //UI callbacks
            Button resetButton = GameObject.Find("ResetButton").GetComponent <Button>();

            resetButton.onClick.RemoveAllListeners();
            resetButton.onClick.AddListener(Reset);
            Button returnButton = GameObject.Find("ReturnButton").GetComponent <Button>();

            returnButton.onClick.RemoveAllListeners();
            returnButton.onClick.AddListener(ReturnToMainState);

            if (move)
            {
                SimUI.getSimUI().OpenNavigationTooltip();
            }
        }
Пример #13
0
        /// <summary>
        /// Prepares the goal display to show descriptions and buttons for a set of goals.
        /// </summary>
        /// <param name="descriptions">Descriptions of the goals.</param>
        /// <param name="points">Point value of the goals.</param>
        public void InitializeDisplay()
        {
            GameObject[] goals = color.Equals("Red") ? redGoals[gamepieceIndex].ToArray() : blueGoals[gamepieceIndex].ToArray();
            if (goalDisplay != null)
            {
                if (goalElements == null)
                {
                    goalElements = new List <GameObject>();
                }

                while (goalElements.Count > 0)
                {
                    Destroy(goalElements[0]);
                    goalElements.RemoveAt(0);
                }

                for (int i = 0; i < goals.Length; i++)
                {
                    int id = i;

                    var goal = goals[i].GetComponent <Goal>();

                    GameObject newGoalElement = Instantiate(goalElementPrefab);
                    newGoalElement.transform.parent = goalDisplay;
                    newGoalElement.name             = "Goal" + i.ToString();
                    #region Goal buttons
                    InputField descText = Auxiliary.FindObject(newGoalElement, "DescriptionText").GetComponent <InputField>();
                    descText.text = goal.description;
                    descText.onValueChanged.AddListener(delegate { SetGoalDescription(id, descText.text); });

                    descText.onEndEdit.AddListener(delegate { InputControl.freeze = false; });

                    InputField pointValue = Auxiliary.FindObject(newGoalElement, "PointValue").GetComponent <InputField>();
                    pointValue.text = goal.pointValue.ToString();
                    pointValue.onValueChanged.AddListener(delegate {
                        int value       = int.TryParse(pointValue.text, out value) ? int.Parse(pointValue.text) : 0;
                        pointValue.text = value.ToString();
                        SetGoalPoints(id, value);
                    });
                    pointValue.onEndEdit.AddListener(delegate { InputControl.freeze = false; });

                    Toggle keepScoredToggle = Auxiliary.FindObject(newGoalElement, "KeepScoredToggle").GetComponent <Toggle>();
                    keepScoredToggle.isOn = goal.KeepScored;
                    keepScoredToggle.onValueChanged.AddListener((value) => { SetGoalKeepScored(id, value); });

                    Toggle stickyToggle = Auxiliary.FindObject(newGoalElement, "Sticky").GetComponent <Toggle>();
                    stickyToggle.isOn = goal.Sticky;
                    stickyToggle.onValueChanged.AddListener(value => {
                        if (!goal.KeepScored)
                        {
                            goal.SetKeepScored(true); keepScoredToggle.isOn = true;
                        }
                        goal.Sticky = value;
                        if (goal.Sticky)
                        {
                            SimUI.getSimUI().DisplayBetaWarning();
                        }
                    });

                    Button moveButton = Auxiliary.FindObject(newGoalElement, "MoveButton").GetComponent <Button>();
                    moveButton.onClick.AddListener(delegate { MoveGoal(id); });

                    Button scaleButton = Auxiliary.FindObject(newGoalElement, "ScaleButton").GetComponent <Button>();
                    scaleButton.onClick.AddListener(delegate { ScaleGoal(id); });

                    Button deleteButton = Auxiliary.FindObject(newGoalElement, "DeleteButton").GetComponent <Button>();
                    deleteButton.onClick.AddListener(delegate { DeleteGoal(id); });
                    #endregion
                    goalElements.Add(newGoalElement);
                }
            }
            else
            {
                Debug.Log("Could not initialize goal display, display not found");
            }
        }
Пример #14
0
        // Use this for initialization
        public override void Start()
        {
            Gamepiece gamepiece = FieldDataHandler.gamepieces[gamepieceIndex];

            //gamepiece indicator
            if (spawnIndicator != null)
            {
                GameObject.Destroy(spawnIndicator);
            }
            if (spawnIndicator == null)
            {
                spawnIndicator = GameObject.Instantiate(Auxiliary.FindGameObject(gamepiece.name), new UnityEngine.Vector3(0, 3, 0), UnityEngine.Quaternion.identity);
                spawnIndicator.SetActive(true);
                spawnIndicator.name = "SpawnIndicator";
                GameObject.Destroy(spawnIndicator.GetComponent <BRigidBody>());
                GameObject.Destroy(spawnIndicator.GetComponent <BCollisionShape>());
                GameObject.Destroy(spawnIndicator.GetComponent <Tracker>());
                if (spawnIndicator.transform.GetChild(0) != null)
                {
                    spawnIndicator.transform.GetChild(0).name = "SpawnIndicatorMesh";
                }
                Renderer render = spawnIndicator.GetComponentInChildren <Renderer>();
                render.material.shader = Shader.Find("Transparent/Diffuse");
                Color newColor = render.material.color;
                newColor.a            = 0.6f;
                render.material.color = newColor;
            }
            spawnIndicator.transform.position    = gamepiece.spawnpoint;
            spawnIndicator.transform.eulerAngles = gamepiece.spawnorientation;

            //move arrow attachment
            GameObject moveArrows = GameObject.Instantiate(Resources.Load <GameObject>("Prefabs\\MoveArrows"));

            moveArrows.name                    = "IndicatorMoveArrows";
            moveArrows.transform.parent        = spawnIndicator.transform;
            moveArrows.transform.localPosition = UnityEngine.Vector3.zero;

            //IMPORTANT
            moveArrows.GetComponent <MoveArrows>().Translate = (translation) =>
                                                               spawnIndicator.transform.Translate(translation, Space.World);

            StateMachine.SceneGlobal.Link <GamepieceSpawnState>(moveArrows);

            //camera stuff
            DynamicCamera dynamicCamera = UnityEngine.Camera.main.transform.GetComponent <DynamicCamera>();

            lastCameraState = dynamicCamera.ActiveState;
            dynamicCamera.SwitchCameraState(new DynamicCamera.ConfigurationState(dynamicCamera, spawnIndicator));

            //help menu
            Button resetButton = GameObject.Find("ResetButton").GetComponent <Button>();

            resetButton.onClick.RemoveAllListeners();
            resetButton.onClick.AddListener(ResetSpawn);
            Button returnButton = GameObject.Find("ReturnButton").GetComponent <Button>();

            returnButton.onClick.RemoveAllListeners();
            returnButton.onClick.AddListener(ReturnToMainState);

            SimUI.getSimUI().OpenNavigationTooltip();
        }