Exemple #1
0
    float f_update(Pillo.PilloID pillo)
    {
        Vector3    acceleration = PilloController.GetAccelero(pillo);
        float      angleX       = Vector3.Angle(Vector3.right, acceleration) - 90;
        float      angleZ       = Vector3.Angle(Vector3.up, acceleration) - 90;
        Quaternion accelQ       = Quaternion.Euler(angleX, 0, angleZ);
        float      accelZ       = accelQ.eulerAngles.z;

        //Debug.Log (accelZ);
        //Debug.Log("Accelz" + acceleration);
        //Debug.Log (PilloController.GetSensor (pillo));
        PilloController.GetSensor(pillo);
        //if (PilloController.GetSensor (pillo) < 0.05f) {
        //	newSmooth [(int)pillo] = 0.05f;
        //	oldSmooth[(int)pillo] = 0.05f;
        //if (PilloController.GetSensor (pillo) > 0.95f) {
        //	newSmooth [(int)pillo] = 0.95f;
        //	oldSmooth[(int)pillo] = 0.95f;
        //} else {
        newSmooth[(int)pillo] = (PilloController.GetSensor(pillo) / 100) * 100;
        //}


        float tempFloat = newSmooth[(int)pillo] * smoothFactor + oldSmooth[(int)pillo] * (1 - smoothFactor);

        oldSmooth[(int)pillo] = tempFloat;

        //tempfloat = smoothed value
        return(tempFloat);
    }
    // Update is called once per frame
    void Update()
    {
        float pillo1Shake = PilloController.GetAccelero(Pillo.PilloID.Pillo1).magnitude;
        float pillo2Shake = PilloController.GetAccelero(Pillo.PilloID.Pillo2).magnitude;

        if (pillo1Shake < 900 && pillo1Shake != 0 || pillo1Shake > 1100)
        {
            ChangeToTrueForm();
        }
    }
    // Update is called once per frame
    void Update()
    {
        Pilloacc1 = PilloController.GetAccelero(PilloID.Pillo1);
        Pilloacc2 = PilloController.GetAccelero(PilloID.Pillo2);
        Pilloacc3 = PilloController.GetAccelero(PilloID.Pillo3);
        Pilloacc4 = PilloController.GetAccelero(PilloID.Pillo4);


        moveBall1();
        moveBall2();
        moveBall3();
        moveBall4();
    }
Exemple #4
0
    void _update(Pillo.PilloID pillo)
    {
        // set height based on Pillo sensor, and use calibrated values if available
        Vector3 tmp = m_slider[(int)pillo].transform.position;

        tmp.y = 10 * PilloController.GetSensor(pillo, PilloController.IsPilloCalibrated(pillo));
        m_slider[(int)pillo].transform.position = tmp;
        // show Pillo orientation based on accelerometer
        Vector3 acceleration = PilloController.GetAccelero(pillo);
        float   angleX       = Vector3.Angle(Vector3.right, acceleration) - 90;
        float   angleZ       = Vector3.Angle(Vector3.up, acceleration) - 90;

        m_slider [(int)pillo].transform.rotation = Quaternion.Euler(angleX, 0, angleZ);
        Quaternion accelQ = Quaternion.Euler(angleX, 0, angleZ);
        float      accelZ = accelQ.eulerAngles.z;

        Debug.Log(accelZ);
        //Debug.Log ("y" + (Vector3.Angle (Vector3.forward, acceleration) - 90));
    }
Exemple #5
0
 // Update is called once per frame
 void Update()
 {
     move1 = PilloController.GetAccelero(Con1); move2 = PilloController.GetAccelero(Con2);
     usePillo();
     checkShake();
     ShakeTree();
     timer1 += Time.deltaTime;
     timer2 += Time.deltaTime;
     if (appelCon.totalApples <= 0)
     {
         timer += Time.deltaTime;
         if (timer > 3 && !once)
         {
             FinishText.text = "fINISH!!!";
             stopShaking     = true;
             endSound.Play();
             once = true;
         }
     }
 }
Exemple #6
0
    // Update is called once per frame
    void Update()
    {
        float additionRaw = PilloController.GetAccelero(Pillo.PilloID.Pillo1).magnitude - 1000;        // we subtract 1000, since the magnitude will always be around 1000 when the pillo is not moving

        shakerAmount += additionRaw * 0.002f * Time.deltaTime;                                         // use the raw addition to add up to the color lerp value
        shakerAmount -= Time.deltaTime * 0.2f;                                                         // make it decrease over time again
        shakerAmount  = Mathf.Clamp(shakerAmount, 0.0f, 1.0f);                                         // clamp the lerp value
        GetComponent <Renderer> ().material.color = Color.Lerp(Color.grey, Color.green, shakerAmount); //apply the color


        soundcooldown -= Time.deltaTime;
        if (Mathf.Abs(additionRaw) > 100)
        {
            if (soundcooldown <= 0.0f)
            {
                AudioSource.PlayClipAtPoint(shakerSound, transform.position, additionRaw * 0.001f);
                soundcooldown = 0.1f;
            }
        }

        transform.position = PilloController.GetAccelero(Pillo.PilloID.Pillo1) * 0.0001f;          // add some movement to the cube for effect
    }