SetLED() public method

Sets the LED color
public SetLED ( Color color ) : void
color Color Unity's Color type
return void
Exemplo n.º 1
0
    //PLAYER ACTIONS
    public void SetShield(bool active)
    {
        if (active)
        {
            if (shieldEnergy > 0f)
            {
                state           = PlayerState.SHIELDING;
                isShieldActive  = active;
                isHoldingShield = true;

                shieldFadeTime = SHIELD_DURATION;
                StopGlowing();
                move.SetLED(SHIELD * Mathf.Clamp01(shieldEnergy));
            }
            else
            {
                StartBlinking(1f, .2f, BROKEN_SHIELD, defaultColour * .05f);
                isShieldActive = false;
            }
        }
        else
        {
            isHoldingShield = false;
        }
    }
    void buzzMove(UniMoveController move, float amount, Color color, double duration)
    {
        // Play a rumble at a given level and duration.
        move.SetRumble(amount);
        move.SetLED(color);
        if (buzzTimer != null)
        {
            buzzTimer.Dispose();
            buzzTimer = null;
        }

        buzzTimer = new System.Threading.Timer(
            obj => {
            move.SetLED(Color.grey);
            move.SetRumble(0);
            buzzTimer = null;
        },
            null,
            (uint)(duration * 1000),
            System.Threading.Timeout.Infinite);
    }
Exemplo n.º 3
0
    public void SetLED(Color color, float?delay)
    {
        if (setLEDRoutine != null)
        {
            StopCoroutine(setLEDRoutine);
        }

        if (delay != null)
        {
            setLEDRoutine = SetLEDCoroutine(color, (float)delay);
            StartCoroutine(setLEDRoutine);
        }
        else
        {
            if (controller != null)
            {
                controller.SetLED(color);
            }
            debugButton.image.color = color;
        }
    }
Exemplo n.º 4
0
	// Use this for initialization
	void Start () {
		controller = gameObject.AddComponent<UniMoveController>();
		
		if(!controller.Init(playerIndex))
		{
			Debug.Log ("Could not initialize controller "+playerIndex);
		}
		
		controller.InitOrientation();
		controller.ResetOrientation();
		controller.SetLED(playerColor);
		
		
	}
    void Start()
    {
        this.transform.parent        = GameObject.Find("RightHandMiddle4").transform;
        this.transform.localPosition = Vector3.zero;
        Time.maximumDeltaTime        = 0.1f;
        audioSource      = (AudioSource)gameObject.AddComponent("AudioSource");
        audioSource.clip = audioClip;
        audioSource.loop = false;

        handPoint = GameObject.Find("PSMoveController");
        //handPoint.transform.position = GameObject.Find("23_Hand_Right").transform.position + psmoveVec;
        //handPoint.transform.parent = GameObject.Find("23_Hand_Right").transform;
        //handPoint.rigidbody.isKinematic = true;


        int count = UniMoveController.GetNumConnected();

        // Iterate through all connections (USB and Bluetooth)
        for (int i = 0; i < count; i++)
        {
            UniMoveController move = gameObject.AddComponent <UniMoveController>();             // It's a MonoBehaviour, so we can't just call a constructor

            // Remember to initialize!
            if (!move.Init(i))
            {
                Destroy(move);                  // If it failed to initialize, destroy and continue on
                continue;
            }

            // This example program only uses Bluetooth-connected controllers
            PSMoveConnectionType conn = move.ConnectionType;
            if (conn == PSMoveConnectionType.Unknown || conn == PSMoveConnectionType.USB)
            {
                Destroy(move);
            }
            else
            {
                moves.Add(move);

                move.OnControllerDisconnected += HandleControllerDisconnected;

                // Start all controllers with a white LED
                move.SetLED(Color.white);
                Debug.Log(count);
            }
        }

        orig = handPoint.renderer.material.color;
        moves[0].SetLED(Color.red);
    }
Exemplo n.º 6
0
    void Start()
    {
        /* NOTE! We recommend that you limit the maximum frequency between frames.
		 * This is because the controllers use Update() and not FixedUpdate(),
		 * and yet need to update often enough to respond sufficiently fast.
		 * Unity advises to keep this value "between 1/10th and 1/3th of a second."
		 * However, even 100 milliseconds could seem slightly sluggish, so you
		 * might want to experiment w/ reducing this value even more.
		 * Obviously, this should only be relevant in case your framerare is starting
		 * to lag. Most of the time, Update() should be called very regularly.
		 */

        Time.maximumDeltaTime = 0.1f;

        int count = UniMoveController.GetNumConnected();

        Debug.Log("count = " + count);

        // Iterate through all connections (USB and Bluetooth)
        for (int i = 0; i < count; i++)
        {
            UniMoveController move = gameObject.AddComponent<UniMoveController>();  // It's a MonoBehaviour, so we can't just call a constructor

            // Remember to initialize!
            if (!move.Init(i))
            {
                Destroy(move);  // If it failed to initialize, destroy and continue on
                continue;
            }

            // This example program only uses Bluetooth-connected controllers
            PSMoveConnectionType conn = move.ConnectionType;
            if (conn == PSMoveConnectionType.Unknown || conn == PSMoveConnectionType.USB)
            {
                Destroy(move);
            }
            else
            {
                moves.Add(move);

                // Start all controllers with a white LED
                move.SetLED(Color.magenta);

                transform.localRotation = move.Orientation;
                transform.localPosition = move.Position;

            }
        }
    }
    // Use this for initialization
    void Start()
    {
        // Keep the updates coming at 10Hz
        Time.maximumDeltaTime = 0.1f;
        int count = UniMoveController.GetNumConnected();

        // Iterate through all connections (USB and Bluetooth)
        for (int i = 0; i < count; i++)
        {
            UniMoveController move = gameObject.AddComponent <UniMoveController>();             // It's a MonoBehaviour, so we can't just call a constructor

            // Remember to initialize!
            if (!move.Init(i))
            {
                Destroy(move);                  // If it failed to initialize, destroy and continue on
                continue;
            }

            // This example program only uses Bluetooth-connected controllers
            PSMoveConnectionType conn = move.ConnectionType;
            if (conn == PSMoveConnectionType.Unknown || conn == PSMoveConnectionType.USB)
            {
                Destroy(move);
            }
            else
            {
                moves.Add(move);

                move.OnControllerDisconnected += HandleControllerDisconnected;

                // Start all controllers with a white LED
                move.SetLED(Color.grey);
            }
        }

//		rightSensorFusion = new AHRS.MahonyAHRS(Time.deltaTime); // Assume 60Hz update rate
    }
    // Update is called once per frame
    void Update()
    {
        if (droneIndex >= moves.Count)
        {
            return;
        }

        UniMoveController move = moves[droneIndex];

        timer        += Time.deltaTime;
        timerNoPress += Time.deltaTime;

        // Trigger is held down, do control
        if (move.Trigger > 0.9f && !doingAflip)
        {
            move.SetLED(MoveControllerColor);
            if (!isInAir)
            {
                isInAir = true;
                Debug.Log("Lift off");
                SendToNode("/startdrone", 1);
            }
            if (timer > 0.2f)
            {
                if (move.Acceleration.x > 0.02f)
                {
                    SendToNode("/left", move.Acceleration.x * move.Acceleration.x * 2.2f * power);
                }
                else if (move.Acceleration.x < -0.02f)
                {
                    SendToNode("/right", (move.Acceleration.x * move.Acceleration.x * 2.2f * power));
                }
                else
                {
                    SendToNode("/left", 0);
                    SendToNode("/right", 0);
                }

                if (move.Acceleration.y < -0.02f)
                {
                    SendToNode("/front", move.Acceleration.y * move.Acceleration.y * 2.2f * power);
                }
                else if (move.Acceleration.y > 0.02f)
                {
                    SendToNode("/back", move.Acceleration.y * move.Acceleration.y * 2.2f * power);
                }
                else
                {
                    SendToNode("/front", 0);
                    SendToNode("/back", 0);
                }
            }
        }
        if (move.GetButtonDown(PSMoveButton.Square))
        {
            if (timer > 0.2f)
            {
                SendToNode("/counterClockwise", 0.5f);
            }
        }
        else if (move.GetButtonUp(PSMoveButton.Square))
        {
            SendToNode("/counterClockwise", 0);
        }
        else if (move.GetButtonDown(PSMoveButton.Triangle))
        {
            if (timer > 0.2f)
            {
                SendToNode("/clockwise", 0.5f);
            }
        }
        else if (move.GetButtonUp(PSMoveButton.Triangle))
        {
            SendToNode("/clockwise", 0);
        }

        else if (move.GetButtonDown(PSMoveButton.Cross))
        {
            if (timer > 0.2f)
            {
                SendToNode("/down", 0.2f);
            }
        }
        else if (move.GetButtonUp(PSMoveButton.Cross))
        {
            SendToNode("/down", 0);
        }
        else if (move.GetButtonDown(PSMoveButton.Circle))
        {
            if (timer > 0.2f)
            {
                SendToNode("/up", 0.2f);
            }
        }
        else if (move.GetButtonUp(PSMoveButton.Circle))
        {
            SendToNode("/up", 0);
            SendToNode("/stop", 0);
        }
        else if (move.GetButtonUp(PSMoveButton.Move))
        {
            SendToNode("/land", 1);
        }
        else if (move.GetButtonUp(PSMoveButton.Select))
        {
            SendToNode("/flip", 1);
        }
        else if (move.GetButtonUp(PSMoveButton.Start))
        {
            SendToNode("/wave", 1);
        }
        else if (move.Trigger <= 0.8f && !doingAflip)
        {
            if (timer > 0.2f)
            {
                SendToNode("/stop", 0);
            }
            move.SetLED(MoveControllerColor * 0.2f);
        }

        if (move.GetButtonUp(PSMoveButton.PS))
        {
            isInAir = false;
            //TODO: Make panic
            SendToNode("/land", 1);
        }
        prevTrigger = move.Trigger;
    }
Exemplo n.º 9
0
    void Start()
    {
        arrow.transform.position = new Vector3(leftBorder, 0.487829f, 0);

        /* Increase Gravity */
        Physics.gravity = new Vector3(0, -20, 0);
        Player          = GameObject.Find("Player");

        varDifficulty = GameObject.Find("varDifficulty");
        if (varDifficulty != null)
        {
            difficulty = int.Parse(varDifficulty.GetComponent <GUIText> ().text);
        }
        else
        {
            difficulty = 3;
        }

        switch (difficulty)
        {
        case 1: arrowSpeed = 0.001f; break;

        case 2: arrowSpeed = 0.002f; break;

        case 3: arrowSpeed = 0.003f; break;

        case 4: arrowSpeed = 0.004f; break;
        }

        //TimerHUD = GameObject.Find("TimerHUD");
        //timerScript = (TimerScript) TimerHUD.GetComponent(typeof(TimerScript));
        Time.maximumDeltaTime = 0.1f;

        int count = UniMoveController.GetNumConnected();

        // Iterate through all connections (USB and Bluetooth)
        for (int i = 0; i < count; i++)
        {
            UniMoveController move = gameObject.AddComponent <UniMoveController>();             // It's a MonoBehaviour, so we can't just call a constructor

            // Remember to initialize!
            if (!move.Init(i))   // TENTA INICIALIZAR
            {                    // QUANDO RESTARTA O PROGRAMA ELE TENTA INICIALIZAR E NAO CONSEGUE PQ JA ESTA INICIADO
                // ENTAO ELE DESTROI AS CONEXOES ABERTAS
                // E POR ISSO DESLIGA O CONTROLE
                // === EU ACHO... ===
                Destroy(move);                  // If it failed to initialize, destroy and continue on
                continue;
            }

            // This example program only uses Bluetooth-connected controllers
            PSMoveConnectionType conn = move.ConnectionType;
            if (conn == PSMoveConnectionType.Unknown || conn == PSMoveConnectionType.USB)
            {
                Destroy(move);
            }
            else
            {
                moves.Add(move);

                move.OnControllerDisconnected += HandleControllerDisconnected;

                // Start all controllers with a white LED
                move.SetLED(Color.white);
                Debug.Log("PSMove conectado.");
            }
        }
        if (moves.Count <= 0)
        {
            Debug.Log("No Bluetooth-connected controllers found. Make sure one or more are both paired and connected to this computer.");
        }
    }
Exemplo n.º 10
0
    void Start()
    {
        /* NOTE! We recommend that you limit the maximum frequency between frames.
         * This is because the controllers use Update() and not FixedUpdate(),
         * and yet need to update often enough to respond sufficiently fast.
         * Unity advises to keep this value "between 1/10th and 1/3th of a second."
         * However, even 100 milliseconds could seem slightly sluggish, so you
         * might want to experiment w/ reducing this value even more.
         * Obviously, this should only be relevant in case your framerare is starting
         * to lag. Most of the time, Update() should be called very regularly.
         */
        Time.maximumDeltaTime = 0.1f;

        moveControllerPrefab = GameObject.Find("MoveController");
        Destroy(moveControllerPrefab);
        if (moveControllerPrefab == null || moveControllerPrefab.GetComponent <MoveController>() == null)
        {
            Debug.LogError("GameObject with object named \"MoveController\" with script MoveController is missing from the scene");
        }



        int count = UniMoveController.GetNumConnected();

        // Iterate through all connections (USB and Bluetooth)
        for (int i = 0; i < count; i++)
        {
            UniMoveController move = gameObject.AddComponent <UniMoveController>();             // It's a MonoBehaviour, so we can't just call a constructor


            // Remember to initialize!
            if (!move.Init(i))
            {
                Destroy(move);                  // If it failed to initialize, destroy and continue on
                continue;
            }



            // This example program only uses Bluetooth-connected controllers
            PSMoveConnectionType conn = move.ConnectionType;
            if (conn == PSMoveConnectionType.Unknown)            // || conn == PSMoveConnectionType.USB)
            {
                Destroy(move);
            }
            else
            {
                moves.Add(move);

                move.OnControllerDisconnected += HandleControllerDisconnected;

                move.InitOrientation();
                move.ResetOrientation();

                // Start all controllers with a white LED
                move.SetLED(Color.white);

                // adding the MoveController Objects on screen
                GameObject moveController = GameObject.Instantiate(moveControllerPrefab,
                                                                   Vector3.right * count * 2 + Vector3.left * i * 4, Quaternion.identity) as GameObject;
                MoveController moveObj = moveController.GetComponent <MoveController>();
                moveObjs.Add(moveObj);
                moveObj.SetLED(Color.white);
            }
        }
    }
Exemplo n.º 11
0
        void Update()
        {
            for (int i = 0; i < moves.Count; i++)
            {
                UniMoveController move    = moves[i];
                MoveController    moveObj = moveObjs[i];

                // Instead of this somewhat kludge-y check, we'd probably want to remove/destroy
                // the now-defunct controller in the disconnected event handler below.
                if (move.Disconnected)
                {
                    continue;
                }


                //Update state button trigger
                updateButtonTrigger(ref move);


                //Write mode
                if (writeMode)
                {
                    updateWriteMode(ref moveObj, ref move);
                    return;
                }

                // Change the colors of the LEDs based on which button has just been pressed:
                if (move.GetButtonDown(PSMoveButton.Circle))
                {
                    moveObj.SetLED(Color.cyan); move.SetLED(Color.cyan);
                    activedWriteMode();
                }
                else if (move.GetButtonDown(PSMoveButton.Cross))
                {
                    moveObj.SetLED(Color.red); move.SetLED(Color.red);
                    removeObject();
                }
                else if (move.GetButtonDown(PSMoveButton.Square))
                {
                    moveObj.SetLED(Color.yellow); move.SetLED(Color.yellow);
                    addObject();
                }
                else if (move.GetButtonDown(PSMoveButton.Triangle))
                {
                    moveObj.SetLED(Color.magenta); move.SetLED(Color.magenta);

                    if (this.objectSelected != null && !visualisationMode)
                    {
                        activedVisualisationMode(ref moveObj);
                    }
                    else if (this.objectSelected != null)
                    {
                        desactivedVisualisationMode();
                    }
                }
                else if (move.GetButtonDown(PSMoveButton.PS))
                {
                    //Reset orientation
                    move.ResetOrientation();
                    moveObj.SetLED(Color.black);
                    move.SetLED(Color.black);
                }
                else if (move.GetButtonDown(PSMoveButton.Start))
                {
                    base.managerListener.redoAction();
                }
                else if (move.GetButtonDown(PSMoveButton.Select))
                {
                    base.managerListener.undoAction();
                }

                // Set the rumble based on how much the trigger is down
                moveObj.gameObject.transform.localRotation = new Quaternion(move.Orientation.x, -move.Orientation.y, -move.Orientation.z, move.Orientation.w);

                //Update modes
                if (visualisationMode)
                {
                    updateVisualisationMode(ref moveObj);
                }
                else
                {
                    updateRay(ref move, ref moveObj);
                }
            }
        }
Exemplo n.º 12
0
    void Start()
    {
        /* NOTE! We recommend that you limit the maximum frequency between frames.
         * This is because the controllers use Update() and not FixedUpdate(),
         * and yet need to update often enough to respond sufficiently fast.
         * Unity advises to keep this value "between 1/10th and 1/3th of a second."
         * However, even 100 milliseconds could seem slightly sluggish, so you
         * might want to experiment w/ reducing this value even more.
         * Obviously, this should only be relevant in case your framerare is starting
         * to lag. Most of the time, Update() should be called very regularly.
         */

        // If you have changed these names, please replace below "names"

        /*Left = GameObject.Find("LeftWall");
        *  Right = GameObject.Find("RightWall");
        *  Racket = GameObject.Find("Racket");*/
        try {
            Sword       = GameObject.Find("Sword");
            Light       = GameObject.Find("VolumetricLinePrefab");
            Player      = GameObject.Find("player");
            EnemyMaster = GameObject.Find("EnemyMaster");
            Unitychan   = GameObject.Find("unitychan");
            Cube        = GameObject.Find("Cube");
            Enemy0      = GameObject.Find("Enemy0");
            Enemy1      = GameObject.Find("Enemy1");
            Camera      = GameObject.Find("Main Camera");
            text        = GameObject.Find("Text").GetComponent <Text>();
            animator    = Unitychan.GetComponent <Animator>();
            rb          = Unitychan.GetComponent <Rigidbody>();
            opening     = true;
            countdown   = false;
            playing     = false;
            gameover    = false;
            clear       = false;
        } catch (Exception e) {
            Debug.Log("exception");
        }

        Light.SetActive(false);
        Sword.SetActive(false);
        Player.SetActive(false);
        EnemyMaster.SetActive(false);
        Enemy0.SetActive(false);
        Enemy1.SetActive(false);
        Unitychan.SetActive(false);
        Cube.SetActive(false);


        _Style          = new GUIStyle();
        _Style.fontSize = 20;

        Time.maximumDeltaTime = 0.1f;

        int count = UniMoveController.GetNumConnected();

        // Iterate through all connections (USB and Bluetooth)
        for (int i = 0; i < count; i++)
        {
            UniMoveController move = gameObject.AddComponent <UniMoveController>();             // It's a MonoBehaviour, so we can't just call a constructor

            // Remember to initialize!
            if (move.Init(i) == PSMove_Connect_Status.MoveConnect_NoData)
            {
                Destroy(move);                  // If it failed to initialize, destroy and continue on
                continue;
            }

            // This example program only uses Bluetooth-connected controllers
            PSMoveConnectionType conn = move.ConnectionType;
            if (conn == PSMoveConnectionType.Unknown || conn == PSMoveConnectionType.USB)
            {
                Destroy(move);
            }
            else
            {
                _Moves.Add(move);
                move.OnControllerDisconnected += HandleControllerDisconnected;

                // 球体LEDの基本セッティング 赤色
                move.SetLED(Color.red);
            }
        }
        _TimeCount = Time.time;
    }