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); }
void Update() { if (isGameOver) { int LoadedIndexWithModifier = 9 - Application.loadedLevel; Time.timeScale = 0.5f; if (!instantiated) { GameObject ParcleInstance = Instantiate(parcle, Camera.main.ScreenToWorldPoint(new Vector3(-1, levelPositions[0].y, 1)), Quaternion.identity) as GameObject; /*ParcleInstance.transform.position = new Vector3 (Mathf.Lerp(ParcleInstance.transform.position.x, levelPositions[LoadedIndexWithModifier].x, 1), * ParcleInstance.transform.position.y, * ParcleInstance.transform.position.z);*/ ParcleInstance.transform.position = levelPositions[LoadedIndexWithModifier]; instantiated = true; } //GetComponentInChildren<Text>().text = "Level "+ currentlevel; } // replace <PillowAxis1> and <PillowAxis2> with actual pillow controlls if (PilloController.GetSensor(PilloID.Pillo1) > 0 && PilloController.GetSensor(PilloID.Pillo2) > 0) { isGameOver = false; Time.timeScale = 1; Application.LoadLevel(0); } }
void OnPilloDown() { if (!clicked && PilloController.GetSensor(ids) > 0.2f) { if (controller.guss == ColorName) { //dit is goed Debug.Log("goed"); controller.index++; if (controller.index < 4) { controller.guss = controller.colNameGuss [controller.index]; } correct.Play(); controller.newText.text = controller.guss; controller.score++; grav.isKinematic = true; ballScr.gameObjectObj = null; ball.transform.SetParent(null); StartGame = false; transform.position = new Vector3(transform.position.x, 0.15f, transform.position.z); clicked = true; } else { //niet goed. Debug.Log("fout"); controller.index++; if (controller.index < 4) { controller.guss = controller.colNameGuss [controller.index]; } worng.Play(); controller.newText.text = controller.guss; grav.isKinematic = true; ballScr.gameObjectObj = null; ball.transform.SetParent(null); StartGame = false; transform.position = new Vector3(transform.position.x, 0.15f, transform.position.z); clicked = true; } if (controller.colNameGuss.Length == controller.index) { Debug.Log("newRound"); if (controller.amountOfRounds > 0) { controller.StartPlayer = false; controller.startGame = false; controller.index = 0; controller.amountOfRounds--; } else { Debug.Log("game done"); controller.newText.text = "FINISH"; } } } }
void DoMaximumCalibration() { timer += Time.deltaTime; if (timer > 2.0f) { PilloController.SetCalibratedMaximum(PilloController.GetSensor((Pillo.PilloID)selectedPillo, false), (Pillo.PilloID)selectedPillo); SwitchToMinimumCalibration(); } }
private void UpdateCurrentSize() { //PlayerBody.transform.localScale = new Vector3(_currentSize.x * 10, _currentSize.y * 10,1f); // Debug.Log (Mathf.RoundToInt((PilloController.GetSensor (PilloID.Pillo1) * 10)) * 0.1f); PlayerBody.transform.localScale = new Vector3(_minSize.x + Mathf.RoundToInt((PilloController.GetSensor(PilloID.Pillo1)) * 10) * 0.1f * (_maxSize.x - _minSize.x), _minSize.y + Mathf.RoundToInt((PilloController.GetSensor(PilloID.Pillo2)) * 10) * 0.1f * (_maxSize.y - _minSize.y), 1f); anim.SetFloat("X", _minSize.x + Mathf.RoundToInt((PilloController.GetSensor(PilloID.Pillo1)) * 10) * 0.1f * (_maxSize.x - _minSize.x) - 10); anim.SetFloat("Y", _minSize.y + Mathf.RoundToInt((PilloController.GetSensor(PilloID.Pillo2)) * 10) * 0.1f * (_maxSize.y - _minSize.y) - 10); }
void Player2() { if (animState2.activeSelf == true) { if (pumpPressed) { animState3.SetActive(true); } else { animState1.SetActive(true); } animState2.SetActive(false); } //pump up if (PilloController.GetSensor(PilloID.Pillo2) == 0 && pumpPressed == true) { pumpPressed = false; animState3.SetActive(false); animState2.SetActive(true); } //pump down if (PilloController.GetSensor(PilloID.Pillo2) > 0 && pumpPressed == false) { pumpPressed = true; animState1.SetActive(false); animState2.SetActive(true); pumpPressure += addedPressure; if (pumpPressure > maxPressure) { pumpPressure = maxPressure; } } //pressure down if (pumpPressure > 0) { pumpPressure -= pressureLoss * Time.deltaTime; } turnHeight = pumpPressure - 100 * (water.transform.eulerAngles.x / maxHeight); water.transform.Rotate(new Vector3(turnHeight / (100 / maxHeight), 0, 0)); //sounds sounds1.volume = (1 - (pumpPressure / maxPressure)) * audioVolume; sounds2.volume = (pumpPressure / maxPressure) * audioVolume; }
void Player1() { turnDirection = (Mathf.Round(((PilloController.GetSensor(PilloID.Pillo1) - 0.5f) * turnSpeed * Time.deltaTime) * 10)) / 10; if ((this.transform.eulerAngles.y < maxTurnAngle || this.transform.eulerAngles.y > maxTurnAngle + 10.0f) && turnDirection > 0.0f) { this.transform.Rotate(new Vector3(0, turnDirection, 0)); } if ((this.transform.eulerAngles.y > 360 - maxTurnAngle || this.transform.eulerAngles.y < 350 - maxTurnAngle) && turnDirection < 0.0f) { this.transform.Rotate(new Vector3(0, turnDirection, 0)); } }
// Update is called once per frame void Update() { sensitivityPillowOne = PilloController.GetSensor(Pillo.PilloID.Pillo1); sensitivityPillowTwo = PilloController.GetSensor(Pillo.PilloID.Pillo2); if (sensitivityPillowOne >= 0.5f) { timerPillowOne += Time.deltaTime; print(timerPillowOne + "pilloOne"); } if (sensitivityPillowTwo >= 0.5f) { timerPillowTwo += Time.deltaTime; print(timerPillowTwo + "pilloTwo"); } if (timerPillowOne >= 3.0f && timerPillowTwo >= 3.0f) { DontDestroyOnLoad(GameObject.FindGameObjectWithTag("Settings")); //random float random = Random.Range(1, 10); if (random > 5) { Application.LoadLevel("level1"); print("1.1"); //playerOne } else { //playerTwo Application.LoadLevel("level1"); print("2.1"); } } else if (timerPillowOne >= 3.0f && timerPillowTwo <= 3.0f) { DontDestroyOnLoad(GameObject.FindGameObjectWithTag("Settings")); Application.LoadLevel("level1"); //playertextures 1 print("1"); } else if (timerPillowTwo >= 3.0f && timerPillowOne <= 3.0f) { DontDestroyOnLoad(GameObject.FindGameObjectWithTag("Settings")); //playertextures 2 Application.LoadLevel("level1"); print("2"); } }
// Update is called once per frame void FixedUpdate() { gaugeFill.rectTransform.sizeDelta = new Vector2(250 * PilloController.GetSensor((PilloID)m_pilloIndex, true), 24); //use the calibrated value to scale to green bar gaugeFillRaw.rectTransform.sizeDelta = new Vector2(250 * PilloController.GetSensor((PilloID)m_pilloIndex, false), 10); // use the raw value to scale the blue bar if (PilloController.IsPilloCalibrated((PilloID)m_pilloIndex)) { calibratedText.text = "IS CALIBRATED"; calibratedText.color = Color.green; } else { calibratedText.text = "IS NOT CALIBRATED"; calibratedText.color = Color.red; } }
// Update is called once per frame void FixedUpdate() { int i = 0; while (i < rawText.Length) { rawText[i].text = "current raw value = " + PilloController.GetSensor((PilloID)i, false); i++; } i = 0; while (i < calibratedText.Length) { calibratedText[i].text = "current calibrated value = " + PilloController.GetSensor((PilloID)i, true); i++; } }
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)); }
// Update is called once per frame void Update() { speed = 1.2f * Time.deltaTime; if (PilloController.GetSensor(move1) > 0.2f) { basketPillo1.transform.position = Vector3.Lerp(basketPillo1.transform.position, toMarkerR, speed); } else { basketPillo1.transform.position = Vector3.Lerp(basketPillo1.transform.position, startmarkerL, speed); } if (PilloController.GetSensor(move2) > 0.2f) { basketPillo2.transform.position = Vector3.Lerp(basketPillo2.transform.position, toMarkerL, speed); } else { basketPillo2.transform.position = Vector3.Lerp(basketPillo2.transform.position, startMarkerR, speed); } }
void CheckForSelection() { if (PilloController.GetSensor(Pillo.PilloID.Pillo1, false) > PilloController.GetCalibratedMinimum(Pillo.PilloID.Pillo1)) { selectedPillo = 0; timer += Time.deltaTime; } else if (PilloController.GetSensor(Pillo.PilloID.Pillo2, false) > PilloController.GetCalibratedMinimum(Pillo.PilloID.Pillo2)) { selectedPillo = 1; timer += Time.deltaTime; } else { timer = 0.0f; } if (timer >= 2.0f) { StartCountdown(); } }
/// <summary> /// Sets the maximum calibration value of the specified Pillo as the current valu of that pillo /// </summary> /// <param name="pilloIndex">Pillo index.</param> public void SetMaximumPilloValue(int pilloIndex) { PilloController.SetCalibratedMaximum(PilloController.GetSensor((PilloID)pilloIndex), pilloIndex); UpdateText(); }