Example #1
0
        // Use this for initialization
        public override void Start()
        {
            #region init
            ui       = GameObject.Find("GoalStateUI");
            helpMenu = Auxiliary.FindObject(ui, "Help");
            toolbar  = Auxiliary.FindObject(ui, "ResetStateToolbar");
            overlay  = Auxiliary.FindObject(ui, "Overlay");
            #endregion

            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;
            }
            goalIndicator.transform.position   = color.Equals("Red") ? gm.redGoals[gamepieceIndex][goalIndex].GetComponent <Goal>().position : gm.blueGoals[gamepieceIndex][goalIndex].GetComponent <Goal>().position;
            goalIndicator.transform.localScale = color.Equals("Red") ? gm.redGoals[gamepieceIndex][goalIndex].GetComponent <Goal>().scale : gm.blueGoals[gamepieceIndex][goalIndex].GetComponent <Goal>().scale;

            settingGamepieceGoalVertical = false;

            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;//goalIndicator.transform.localScale.Scale(translation);
            }
            StateMachine.SceneGlobal.Link <GoalState>(moveArrows);

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

            dynamicCamera.SwitchCameraState(new DynamicCamera.ConfigurationState(dynamicCamera, goalIndicator));

            Button resetButton = GameObject.Find("ResetButton").GetComponent <Button>();
            resetButton.onClick.RemoveAllListeners();
            resetButton.onClick.AddListener(Reset);
            Button helpButton = GameObject.Find("HelpButton").GetComponent <Button>();
            helpButton.onClick.RemoveAllListeners();
            helpButton.onClick.AddListener(HelpMenu);
            Button returnButton = GameObject.Find("ReturnButton").GetComponent <Button>();
            returnButton.onClick.RemoveAllListeners();
            returnButton.onClick.AddListener(ReturnToMainState);
            Button closeHelp = Auxiliary.FindObject(helpMenu, "CloseHelpButton").GetComponent <Button>();
            closeHelp.onClick.RemoveAllListeners();
            closeHelp.onClick.AddListener(CloseHelpMenu);
        }
Example #2
0
    //New keywords is used to hide the default Unity camera keyword for this one.

    void Start()
    {
        state            = 0;
        round            = 1;
        timer            = 90f;
        scores[0]        = 0;
        scores[1]        = 0;
        currPlayer       = 0;
        currCreator      = 1;
        ranTwice         = false;
        playerReachedEnd = false;
        roundStarted     = false;

        if (maxRounds <= 0)
        {
            maxRounds = 5;
        }

        spawnedContainer = transform.FindChild("spawnedContainer").gameObject;
        camera           = GameObject.Find("Main Camera").GetComponent <DynamicCamera>();
        scoreboardCanvas = Instantiate(scoreboardCanvas);
        scoreboard       = scoreboardCanvas.transform.FindChild("Scoreboard").GetComponent <Scoreboard>();
        scoreboardCanvas.SetActive(false);
        MatchSettingsHolder SettingsManager = GameObject.Find("ColorHolder").GetComponent <MatchSettingsHolder> ();

        player1Color = SettingsManager.player1Color;
        player2Color = SettingsManager.player2Color;

        //SpriteRenderer SprRen = new SpriteRenderer ();
        //SprRen.sprite = scoreboardSprites [0];
        //SprRen.color = player1Color;
        //SpriteRenderer SprRen2 = new SpriteRenderer ();
        //SprRen2.sprite = scoreboardSprites [1];
        //SprRen2.color = player2Color;
    }
Example #3
0
    private void Update()
    {
        //Make sure main state and dynamic camera get initialized
        if (main == null)
        {
            main          = StateMachine.Instance.FindState <MainState>();
            dynamicCamera = main.DynamicCameraObject.GetComponent <DynamicCamera>();
        }
        //Update gui about robot camera once main and dynamic camera is ready
        else if (main != null && dynamicCamera != null)
        {
            UpdateCameraWindow();
            if (indicatorActive)
            {
                UpdateCameraAnglePanel();
                UpdateCameraFOVPanel();
                UpdateNodeAttachment();
                UpdateIndicatorTransform();
            }
        }

        //Allows users to save their configuration using enter
        if (isEditingAngle && Input.GetKeyDown(KeyCode.Return))
        {
            ToggleEditAngle();
        }
        if (isEditingFOV && Input.GetKeyDown(KeyCode.Return))
        {
            ToggleEditFOV();
        }
    }
Example #4
0
        /// <summary>
        /// Find ALL the GUI stuff needed for the sensor GUI to work
        /// </summary>
        private void FindElements()
        {
            tabStateMachine = Auxiliary.FindGameObject("Tabs").GetComponent <StateMachine>();

            canvas        = GameObject.Find("Canvas");
            sensorManager = GameObject.Find("SensorManager").GetComponent <SensorManager>();
            dynamicCamera = GameObject.Find("Main Camera").GetComponent <DynamicCamera>();
            toolkit       = GetComponent <Toolkit>();

            //For Sensor position and attachment configuration
            configureSensorPanel = Auxiliary.FindObject(canvas, "SensorConfigurationPanel");
            sensorConfigHeader   = Auxiliary.FindObject(configureSensorPanel, "SensorConfigHeader");

            //For Sensor angle configuration
            sensorAnglePanel = Auxiliary.FindObject(canvas, "SensorAnglePanel");
            xAngleEntry      = Auxiliary.FindObject(sensorAnglePanel, "xAngleEntry");
            yAngleEntry      = Auxiliary.FindObject(sensorAnglePanel, "yAngleEntry");
            zAngleEntry      = Auxiliary.FindObject(sensorAnglePanel, "zAngleEntry");

            //For range configuration
            sensorRangePanel = Auxiliary.FindObject(canvas, "RangePanel");
            RangeEntry       = Auxiliary.FindObject(sensorRangePanel, "RangeEntry");

            sensorOutputPanel = Auxiliary.FindObject(canvas, "SensorOutputBorder");
            robotCameraGUI    = GetComponent <RobotCameraGUI>();
        }
Example #5
0
    private void Update()
    {
        if (main == null)
        {
            main = GameObject.Find("StateMachine").GetComponent <StateMachine>().CurrentState as MainState;
        }
        else if (dynamicCamera == null && main.dynamicCameraObject != null)
        {
            dynamicCamera = main.dynamicCameraObject.GetComponent <DynamicCamera>();
        }
        else if (main != null && dynamicCamera != null)
        {
            UpdateCameraWindow();
            UpdateCameraAnglePanel();
            UpdateCameraFOVPanel();
            UpdateNodeAttachment();
        }

        if (CameraIndicator.activeSelf)
        {
            CameraIndicator.transform.position = robotCamera.CurrentCamera.transform.position;
            CameraIndicator.transform.rotation = robotCamera.CurrentCamera.transform.rotation;

            CameraIndicator.transform.parent = robotCamera.CurrentCamera.transform;
        }
    }
Example #6
0
        /// <summary>
        /// End the reset process and puts the robot back down
        /// </summary>
        public void EndReset()
        {
            IsResetting = false;

            EndRobotReset();

            if (lastCameraState != null)
            {
                DynamicCamera dynamicCamera = UnityEngine.Camera.main.transform.GetComponent <DynamicCamera>();
                dynamicCamera.SwitchCameraState(lastCameraState);
                lastCameraState = null;
            }

            OnEndReset();

            Destroy(resetMoveArrows);
            resetMoveArrows = null;

            foreach (Tracker t in GetComponentsInChildren <Tracker>())
            {
                t.Clear();
            }

            InputControl.freeze = false;
            canvas.GetComponent <Canvas>().enabled = true;
            resetCanvas.SetActive(false);

            SimUI.getSimUI().CloseNavigationTooltip();
        }
Example #7
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 #8
0
        // Use this for initialization
        public override void Start()
        {
            moveArrows                         = GameObject.Instantiate(Resources.Load <GameObject>("Prefabs\\MoveArrows"));
            moveArrows.name                    = "IndicatorMoveArrows";
            moveArrows.transform.parent        = sensor.transform;
            moveArrows.transform.rotation      = sensor.transform.rotation;
            moveArrows.transform.localPosition = UnityEngine.Vector3.zero;

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

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

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

            lastCameraState = dynamicCamera.ActiveState;

            dynamicCamera.SwitchCameraState(new DynamicCamera.ConfigurationState(dynamicCamera, sensor));

            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);
        }
Example #9
0
    private void Update()
    {
        if (main == null)
        {
            main = StateMachine.Instance.FindState <MainState>();
        }
        //Find the dynamic camera
        if (dynamicCamera == null)
        {
            dynamicCamera = GameObject.Find("Main Camera").GetComponent <DynamicCamera>();
        }
        //When the current sensor is ready to be configured, call its UpdateTransformFunction and update its angle, range & node text in the corresponding panels
        if (currentSensor != null && currentSensor.IsChangingPosition)
        {
            currentSensor.UpdateTransform();
            UpdateSensorAnglePanel();
            UpdateSensorRangePanel();
        }
        showSensorButton.SetActive(sensorManager.GetActiveSensors().Count > 0 && isHidingOutput);

        //Allows users to save their configuration using enter
        if (isEditingAngle && Input.GetKeyDown(KeyCode.Return))
        {
            ToggleEditAngle();
        }
        if (isEditingRange && Input.GetKeyDown(KeyCode.Return))
        {
            ToggleEditRange();
        }
    }
Example #10
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");

            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");
            pointImpulsePanel = Auxiliary.FindObject(canvas, "PointImpulsePanel");

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

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

            // 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>();
            menuUI           = StateMachine.SceneGlobal.GetComponent <MenuUI>();
            robotCameraGUI   = StateMachine.SceneGlobal.GetComponent <RobotCameraGUI>();
            sensorManagerGUI = StateMachine.SceneGlobal.GetComponent <SensorManagerGUI>();

            State = StateMachine.SceneGlobal.CurrentState as MainState;

            cameraViewDropdown = Auxiliary.FindObject(canvas, "CameraDropdown").GetComponent <Dropdown>();
            dynamicCamera      = UnityEngine.Camera.main.transform.GetComponent <DynamicCamera>();
        }
Example #11
0
        public override void Update()
        {
            bool newFocued = false;

            if (pointImpulsePanel.activeSelf)
            {
                newFocued = GameObject.Find("ImpulseInputField").GetComponent <InputField>().isFocused;
                if (UnityEngine.Input.GetKey(KeyCode.LeftControl))
                {
                    if (UnityEngine.Input.GetKeyDown(KeyCode.Mouse0))
                    {
                        ApplyForce();
                    }
                }
            }
            if (lastImpulseInputFocused != newFocued)
            {
                InputControl.freeze     = newFocued;
                lastImpulseInputFocused = newFocued;
            }
            if (DynamicCamera.StateToInt(dynamicCamera.ActiveState) != cameraViewDropdown.value)
            {
                cameraViewDropdown.value = DynamicCamera.StateToInt(dynamicCamera.ActiveState);
                cameraViewDropdown.RefreshShownValue();
            }
        }
Example #12
0
    void Start()
    {
        helpButtonContent       = new GUIContent("");
        helpButtonContent.image = Resources.Load("Images/halp") as Texture2D;

        Physics.gravity = new Vector3(0, -9.8f, 0);
        Physics.solverIterationCount     = 30;
        Physics.minPenetrationForPenalty = 0.001f;

        cameraObject = new GameObject("Camera");
        cameraObject.AddComponent <Camera> ();
        cameraObject.GetComponent <Camera> ().backgroundColor = new Color(.3f, .3f, .3f);
        dynamicCamera = cameraObject.AddComponent <DynamicCamera> ();

        light = new GameObject("Light");
        Light lightComponent = light.AddComponent <Light> ();

        lightComponent.type      = LightType.Spot;
        lightComponent.intensity = 1.5f;
        lightComponent.range     = 30f;
        lightComponent.spotAngle = 135;
        light.transform.position = new Vector3(0f, 10f, 0f);
        light.transform.Rotate(90f, 0f, 0f);

        chuteMaterial = new PhysicMaterial("chuteMaterial");
        chuteMaterial.dynamicFriction = 0f;
        chuteMaterial.staticFriction  = 0f;
        chuteMaterial.frictionCombine = PhysicMaterialCombine.Minimum;

        totes = new List <GameObject> ();

        filePath = Application.dataPath + "\\resources\\FieldOutput\\";

        reloadRobotInFrames = -1;
    }
Example #13
0
        public override void Load()
        {
            gunner1 = new Gunner
            {
                PadIndex = PlayerIndex.One,
                Color = Color.Red,
                Location = new Vector2(200, 0),
                Speed = 0.5f
            };

            gunner2 = new Gunner
            {
                PadIndex = PlayerIndex.Two,
                Color = Color.Blue,
                Location = new Vector2(400, 0),
                Speed = 0.5f
            };

            powerGenerator1 = new PowerGenerator();
            powerGenerator2 = new PowerGenerator();

            players.Add (gunner1);
            players.Add (gunner2);

            Size screenSize = new Size (Moxy.ScreenWidth, Moxy.ScreenHeight);
            camera = new DynamicCamera ();
            //camera.Targets.AddRange (new Player[] {gunner1, gunner2});
        }
Example #14
0
        public void Contain(DynamicCamera camera)
        {
            var cameraPosition = camera.transform.position;

            cameraPosition.x          = Mathf.Clamp(cameraPosition.x, leftLimit, rightLimit);
            cameraPosition.y          = Mathf.Clamp(cameraPosition.y, bottomLimit, topLimit);
            camera.transform.position = cameraPosition;
        }
Example #15
0
        private void ReturnToMainState()
        {
            DynamicCamera dynamicCamera = UnityEngine.Camera.main.transform.GetComponent <DynamicCamera>();

            dynamicCamera.SwitchCameraState(lastCameraState);
            GameObject.Destroy(moveArrows);
            StateMachine.PopState();
        }
Example #16
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>();
        toolkit       = GameObject.Find("StateMachine").GetComponent <Toolkit>();

        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");
        hideSensorButton          = AuxFunctions.FindObject(configureSensorPanel, "HideSensorButton");

        //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");
        rangeUnit        = AuxFunctions.FindObject(sensorRangePanel, "RangeUnit").GetComponent <Text>();

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

        showSensorButton  = AuxFunctions.FindObject(canvas, "ShowOutputButton");
        sensorOutputPanel = AuxFunctions.FindObject(canvas, "SensorOutputBorder");
        robotCameraGUI    = GameObject.Find("StateMachine").GetComponent <RobotCameraGUI>();
    }
Example #17
0
    // Use this for initialization
    void Start()
    {
        playSpeed = 1;

        dynCam = Camera.main.GetComponent <DynamicCamera>();

        originalPos = dynCam.CamPos;

        gm = GameObject.Find("GameManager").GetComponent <GameManager>();
    }
Example #18
0
 // Update is called once per frame
 void Update()
 {
     if (dynamicCamera == null)
     {
         dynamicCamera = GameObject.Find("Main Camera").GetComponent <DynamicCamera>();
     }
     if (mainState == null)
     {
         mainState = stateMachine.GetComponent <StateMachine>().CurrentState as MainState;
     }
 }
Example #19
0
 private void Start()
 {
     FindGUIElements();
     try
     {
         dynamicCamera = State.DynamicCameraObject.GetComponent <DynamicCamera>();
     }
     catch (System.Exception)
     {
         dynamicCamera = null;
     }
 }
        private void ReturnToMainState()
        {
            if (helpMenu.activeSelf)
            {
                CloseHelpMenu();
            }
            DynamicCamera dynamicCamera = UnityEngine.Camera.main.transform.GetComponent <DynamicCamera>();

            dynamicCamera.SwitchCameraState(lastCameraState);
            GameObject.Destroy(spawnIndicator);
            StateMachine.PopState();
        }
Example #21
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>();
    }
 public void FinishGamepieceSpawn()
 {
     settingSpawn = 0;
     if (spawnIndicator != null)
     {
         Destroy(spawnIndicator);
     }
     if (lastCameraState != null)
     {
         DynamicCamera dynamicCamera = Camera.main.transform.GetComponent <DynamicCamera>();
         dynamicCamera.SwitchCameraState(lastCameraState);
         lastCameraState = null;
     }
     //MainState.ControlsDisabled = false;
 }
    public void StartGamepieceSpawn(int index)
    {
        if (definingRelease || definingIntake || addingGamepiece)
        {
            Debug.Log("User Error");                                                       //Message Manager already dispatches error message to user
        }
        else if (settingSpawn == 0)
        {
            if (GameObject.Find(gamepieceNames[index]) != null)
            {
                if (spawnIndicator != null)
                {
                    Destroy(spawnIndicator);
                }
                if (spawnIndicator == null)
                {
                    spawnIndicator      = Instantiate(AuxFunctions.FindObject(gamepieceNames[index]).GetComponentInParent <BRigidBody>().gameObject, new UnityEngine.Vector3(0, 3, 0), UnityEngine.Quaternion.identity);
                    spawnIndicator.name = "SpawnIndicator";
                    Destroy(spawnIndicator.GetComponent <BRigidBody>());
                    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 = gamepieceSpawn[index];
                settingSpawn = index + 1;

                DynamicCamera dynamicCamera = Camera.main.transform.GetComponent <DynamicCamera>();
                lastCameraState = dynamicCamera.cameraState;
                dynamicCamera.SwitchCameraState(new DynamicCamera.SateliteState(dynamicCamera));

                //MainState.ControlsDisabled = true;
            }
            else
            {
                UserMessageManager.Dispatch("You must define the gamepiece first!", 5f);
            }
        }
        else
        {
            FinishGamepieceSpawn();  //if already setting spawn, end editing process
        }
    }
Example #24
0
    void Awake()
    {
        StartCoroutine(OnGameStateChange(GameState));
        StartCoroutine(OnStartupDoneEvent());
        StartCoroutine(OnCocktailModes(selectedCocktailModes.Count));
        StartCoroutine(OnSequenceChangement(ModeSequenceType));
        StartCoroutine(OnEnvironementChromaChangement(environementChroma));

        SetupRewiredPlayers();

        ReInput.ControllerConnectedEvent    += (ControllerStatusChangedEventArgs obj) => UpdateGamepadList();
        ReInput.ControllerDisconnectedEvent += (ControllerStatusChangedEventArgs obj) => UpdateGamepadList();

        //OnPlaying += UpdateGamepadList;
        OnMenu += UpdateGamepadList;

        LoadModeManager.Instance.OnLevelUnloaded += UpdateGamepadList;

        OnPlaying     += () => SetMouseVisibility();
        OnRestartMode += () => SetMouseVisibility();
        OnPlaying     += UpdatePlayedModes;
        OnMenu        += () => Startup = StartupType.Wave;
        OnEndMode     += () => Startup = StartupType.Delayed;
        OnEnvironementChromaChange += SetPlayerMouseCursor;

        MenuManager.Instance.OnStartModeClick += UpdateGamepadList;
        MenuManager.Instance.OnStartModeClick += CreateAIs;

        SetPlayerMouseCursor();

        mainCamera         = GameObject.FindGameObjectWithTag("MainCamera");
        screenShakeCamera  = mainCamera.GetComponent <ScreenShakeCamera>();
        zoomCamera         = mainCamera.GetComponent <ZoomCamera>();
        dynamicCamera      = mainCamera.GetComponent <DynamicCamera>();
        menuCameraMovement = mainCamera.GetComponent <MenuCameraMovement>();
        slowMotionCamera   = mainCamera.GetComponent <SlowMotionCamera>();

        fixedDeltaTime   = Time.fixedDeltaTime;
        fixedDeltaFactor = 1 / fixedDeltaTime;

        GraphicsQualityManager.Instance.OnFixedDeltaTimeChange += (x) =>
        {
            fixedDeltaTime   = x;
            fixedDeltaFactor = 1 / fixedDeltaTime;
        };

        LoadEnvironementChroma();
    }
Example #25
0
 private void Update()
 {
     //Find the dynamic camera
     if (dynamicCamera == null)
     {
         dynamicCamera = GameObject.Find("Main Camera").GetComponent <DynamicCamera>();
     }
     //When the current sensor is ready to be configured, call its UpdateTransformFunction and update its angle, range & node text in the corresponding panels
     if (currentSensor != null && currentSensor.IsChangingPosition)
     {
         currentSensor.UpdateTransform();
         sensorNodeText.text = "Current Node: " + currentSensor.transform.parent.gameObject.name;
         UpdateSensorAnglePanel();
         UpdateSensorRangePanel();
     }
 }
Example #26
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 #27
0
        private void Update()
        {
            //Find the dynamic camera
            if (dynamicCamera == null)
            {
                dynamicCamera = GameObject.Find("Main Camera").GetComponent <DynamicCamera>();
            }
            //When the current sensor is ready to be configured, call its UpdateTransformFunction and update its angle, range & node text in the corresponding panels
            if (currentSensor != null && currentSensor.IsChangingPosition)
            {
                currentSensor.UpdateTransform();
                UpdateSensorAnglePanel();
                UpdateSensorRangePanel();
            }

            //If an increment button is held, increment range or angle
            if (changingRange)
            {
                float temp = currentSensor.GetSensorRange() + rangeIncrement * rangeSign;
                currentSensor.SetSensorRange(temp >= 0 ? temp : 0);
                UpdateSensorRangePanel();
            }
            else if (currentSensor != null && currentSensor.IsChangingRange)
            {
                SyncSensorRange();
            }
            if (changingAngle)
            {
                if (changingAngleX)
                {
                    currentSensor.RotateTransform(angleIncrement * angleSign, 0, 0);
                }
                else if (changingAngleY)
                {
                    currentSensor.RotateTransform(0, angleIncrement * angleSign, 0);
                }
                else if (changingAngleZ)
                {
                    currentSensor.RotateTransform(0, 0, angleIncrement * angleSign);
                }
                UpdateSensorAnglePanel();
            }
            else if (currentSensor != null && currentSensor.IsChangingAngle)
            {
                SyncSensorAngle();
            }
        }
Example #28
0
        private void Update()
        {
            if (toolkit == null)
            {
                camera = GameObject.Find("Main Camera").GetComponent <DynamicCamera>();

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

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

                if (UnityEngine.Input.GetKeyDown(KeyCode.Escape) && !InputControl.freeze)
                {
                    if (!exitPanel.activeSelf)
                    {
                        if (GameObject.Find("Dropdown List"))
                        {
                            GameObject.Destroy(GameObject.Find("Dropdown List"));
                        }
                        MainMenuExit("open");
                    }
                    else
                    {
                        MainMenuExit("cancel");
                    }
                }

                if (KeyButton.Binded() && inputPanelOn)
                {
                    ShowBindedInfoPanel();
                }
            }
            HighlightTabs();
            if (State.isEmulationDownloaded)
            {
                emulationTab.SetActive(true);
            }
        }
Example #29
0
    //New keywords is used to hide the default Unity camera keyword for this one.

    void Start()
    {
        state            = 0;
        round            = 1;
        timer            = 90f;
        scores[0]        = 0;
        scores[1]        = 0;
        currPlayer       = 0;
        currCreator      = 1;
        ranTwice         = false;
        playerReachedEnd = false;
        roundStarted     = false;

        if (maxRounds <= 0)
        {
            maxRounds = 5;
        }

        spawnedContainer = transform.FindChild("spawnedContainer").gameObject;
        camera           = GameObject.Find("Main Camera").GetComponent <DynamicCamera>();
        scoreboardCanvas = Instantiate(scoreboardCanvas);
        scoreboard       = scoreboardCanvas.transform.FindChild("Scoreboard").GetComponent <Scoreboard>();
        scoreboardCanvas.SetActive(false);

        SettingsManager = GameObject.Find("SettingsHolder").GetComponent <MatchSettingsHolder> ();
        player1Color    = SettingsManager.player1Color;
        player2Color    = SettingsManager.player2Color;
        twoControllers  = SettingsManager.useTwoControllers;

        mapSlectionUI = GameObject.Find("MapSelectionCanvas").GetComponent <MapSelection>();
        mapSlectionUI.gameObject.SetActive(false);
        selectingMap = false;

        maxRounds  = SettingsManager.rounds;
        randomMaps = SettingsManager.randomMaps;

        //set up music objects
        createSource = GameObject.Find("CreatorMusic").GetComponent <AudioSource>();
        runnerSource = GameObject.Find("PlayerMusic").GetComponent <AudioSource>();
        menuSource   = GameObject.Find("MenuMusic").GetComponent <AudioSource>();
        startMusic   = true;
        createSource.Play();
        AudioSource temp = GameObject.Find("BackgroundMusic").GetComponent <AudioSource>();

        temp.Stop();
    }
Example #30
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);
            }
        }
    }
Example #31
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 #32
0
        public override void OnFocus()
        {
            Camera = new DynamicCamera ();
            Camera.UseBounds = true;
            Camera.MinimumSize = new Size (800, 600);
            Camera.Position = new Vector2 (0, 0);

            MapBuilder builder = new Map3Builder ();
            Map = builder.Build ();
            Map.ViewCamera = Camera;

            //Map = new MapRoot (128, 128, 64, 64, Moxy.ContentManager.Load<Texture2D> ("fantasytileset"), Camera);

            //InitializeBaseLayer (0);

            drawUI = true;
            IsFocused = true;
        }
Example #33
0
        public override void OnFocus()
        {
            MapBuilder builder = new Map1Builder ();
            map = builder.Build ();
            //map = new MapRoot (64, 64, 64, 64, Moxy.ContentManager.Load<Texture2D> ("tileset"));
            //InitializeBaseLayer (16);

            camera = new DynamicCamera();
            camera.UseBounds = true;
            camera.MinimumSize = new Size(800, 600);
            camera.Position = new Vector2(0, 0);
            map.ViewCamera = camera;
        }
Example #34
0
        private void LoadMap()
        {
            camera = new DynamicCamera ();
            camera.MinimumSize = new Size (800, 600);
            camera.UseBounds = true;

            map = new MapRoot(128, 128, 64, 64, Moxy.ContentManager.Load<Texture2D>("tileset"), camera);
            map = Moxy.Maps[0].Build ();

            texture = new Texture2D (Moxy.Graphics, 1, 1);
            texture.SetData (new[] { new Color (0, 0, 0, map.AmbientColor.A) });
        }
Example #35
0
        private void LoadMap()
        {
            camera = new DynamicCamera ();
            camera.MinimumSize = new Size (800, 600);
            camera.UseBounds = true;

            map = new MapRoot(128, 128, 64, 64, new [] { "tileset" }, camera);
            map = Moxy.Maps[0].Build ();
            map.EnableCollision = false;

            texture = new Texture2D (Moxy.Graphics, 1, 1);
            texture.SetData (new[] { new Color (0, 0, 0, map.AmbientColor.A) });
        }