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 SwitchToWaitingForSelection() { m_state = QuickCalibrationState.WaitingForSelection; PilloController.SaveCalibrationValues(); timer = 0.0f; infoText.text = "Press the Pillo you want to calibrate"; }
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 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"; } } } }
// Use this for initialization void Start() { PilloController.ConfigureSensorRange(0x50, 0x6f); grav = this.GetComponent <Rigidbody> (); controller = GameControllerObj.GetComponent <gameControler> (); ballScr = ball.GetComponent <collision> (); grav.isKinematic = true; }
//This checks if the current PilloController is the first one. //If not it will dispose this PilloController. //If this is the first one it will make this the main PilloController. void Awake() { if(pc != null) { DestroyImmediate(this.gameObject); } else { pc = this; DontDestroyOnLoad(this.gameObject); } }
// Use this for initialization void Start() { PilloController.ConfigureSensorRange(0x50, 0x6f); startmarkerL = basketPillo1.transform.position; toMarkerR = transform.position = new Vector3(-1.2f, basketPillo1.transform.position.y, basketPillo1.transform.position.z); startMarkerR = basketPillo2.transform.position; toMarkerL = transform.position = new Vector3(1.2f, basketPillo2.transform.position.y, basketPillo2.transform.position.z); }
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 DoMaximumCalibration() { timer += Time.deltaTime; if (timer > 2.0f) { PilloController.SetCalibratedMaximum(PilloController.GetSensor((Pillo.PilloID)selectedPillo, false), (Pillo.PilloID)selectedPillo); SwitchToMinimumCalibration(); } }
// Use this for initialization void Start() { PlayerFace = GameObject.FindGameObjectWithTag("FaceObject"); anim = GetComponentInChildren <Animator> (); PilloController.ConfigureSensorRange(0x50, 0x6f); _minSize = new Vector3(10, 10, 0); _maxSize = new Vector3(30, 30, 0); this.transform.localScale = new Vector3(1, 1, 0); PlayerFace.transform.localScale = new Vector3(10, 10, 0); }
// 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(); } }
// Use this for initialization void Start() { PilloController.ConfigureSensorRange(0x40, 0x60); // setup our sliders for this demo m_slider[(int)PilloID.Pillo1] = GameObject.Find("Pillo1"); m_slider[(int)PilloID.Pillo2] = GameObject.Find("Pillo2"); m_slider[(int)PilloID.Pillo3] = GameObject.Find("Pillo3"); m_slider[(int)PilloID.Pillo4] = GameObject.Find("Pillo4"); }
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; }
//This checks if the current PilloController is the first one. //If not it will dispose this PilloController. //If this is the first one it will make this the main PilloController. void Awake() { if (pc != null) { DestroyImmediate(this.gameObject); } else { pc = this; DontDestroyOnLoad(this.gameObject); } }
// 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(); }
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() { PilloController.GetSensors(PilloID.Pillo1); try { _update(PilloID.Pillo1); _update(PilloID.Pillo2); _update(PilloID.Pillo3); _update(PilloID.Pillo4); } catch (Exception) { ; // failsafe; notify user } }
// 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; } }
/// <summary> /// Updates the text that display the calibration values /// </summary> public void UpdateText() { int i = 0; while (i < minimumText.Length) { minimumText[i].text = "current minimum = " + PilloController.GetCalibratedMinimum(i); i++; } i = 0; while (i < maximumText.Length) { maximumText[i].text = "current maximum = " + PilloController.GetCalibratedMaximum(i); i++; } }
// 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() { 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; } } }
// 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(); } }
// 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 }
public void Start() { PilloController.ConfigureSensorRange(0x50, 0x6f); }
/// <summary> /// Deletes the saved calibration values. /// </summary> public void DeleteSavedCalibrationValues() { PilloController.DeleteSavedCalibrationValues(); }
/// <summary> /// Loads the calibration values. /// </summary> public void LoadCalibrationValues() { PilloController.LoadSavedCalibrationValues(); UpdateText(); }
/// <summary> /// Saves the calibration values. /// </summary> public void SaveCalibrationValues() { PilloController.SaveCalibrationValues(); }
/// <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(); }