public void Vibrate(int millisec, float strength) { if (controller != null) { controller.Vibrate(millisec, strength); } }
void Update() { //on traduit la position en position locale pour la freeze _localX = transform.localPosition.x; _localY = transform.localPosition.y; _localZ = transform.localPosition.z; if (_freezeAlongX) { _localX = 0; } if (_freezeAlongY) { _localY = 0; } if (_freezeAlongZ) { _localZ = 0; } gameObject.transform.localPosition = new Vector3(_localX, _localY, _localZ); //sécurité juste en y if (transform.localPosition.x < -limit) { transform.localPosition = new Vector3(-limit, transform.localPosition.y, transform.localPosition.z); } else if (transform.localPosition.x > limit) { transform.localPosition = new Vector3(limit, transform.localPosition.y, transform.localPosition.z); } float newX = gameObject.transform.localPosition.x; //on envoie la valeur à la syncvar si celle ci a changé if (newX != oldX) { sendToSynchVar(-Mathf.Round(Ratio(gameObject.transform.localPosition.x, limit, 0.45f, -limit, -0.45f) * 100) / 100); } if (text_value_display != null) { curValue = Mathf.RoundToInt(Ratio(-Mathf.Round(Ratio(gameObject.transform.localPosition.x, limit, 0.45f, -limit, -0.45f) * 100) / 100, 0.4f, 10, -0.4f, 0)); text_value_display.text = curValue.ToString(); } if (controller != null) { float distance = Mathf.Min(Mathf.Abs(newX - oldX), MAX_VIBRATION_DISTANCE); float vibrationStrength = (distance / MAX_VIBRATION_DISTANCE) * MAX_VIBRATION_STRENGTH; controller.Vibrate(VIBRATION_DURATION_IN_MILLISECONDS, vibrationStrength); } oldX = newX; IsValueOk(); }
void Update() { float newXRotation = transform.eulerAngles.x; if (controller != null) { float distance = Mathf.Min(Mathf.Abs(newXRotation - oldXRotation), MAX_VIBRATION_ANGLE); float vibrationStrength = (distance / MAX_VIBRATION_ANGLE) * MAX_VIBRATION_STRENGTH; controller.Vibrate(VIBRATION_DURATION_IN_MILLISECONDS, vibrationStrength); } oldXRotation = newXRotation; }
void Update() { float newX = transform.position.x; if (controller != null) { float distance = Mathf.Min(Mathf.Abs(newX - oldX), MAX_VIBRATION_DISTANCE); float vibrationStrength = (distance / MAX_VIBRATION_DISTANCE) * MAX_VIBRATION_STRENGTH; controller.Vibrate(VIBRATION_DURATION_IN_MILLISECONDS, vibrationStrength); } oldX = newX; }
void Update() { if (!bubbling) { return; } if (cooldown > 0) { cooldown -= Time.deltaTime; } else { controller.Vibrate(50, 0.1f); CreateBubble(); cooldown = 0.1f; } }
void Slide() { //on traduit la position en position locale pour la freeze _localX = transform.localPosition.x; _localY = transform.localPosition.y; _localZ = transform.localPosition.z; //Freeze Axes if (_freezeAlongX) { _localX = LeftLimit.transform.localPosition.x; } if (_freezeAlongY) { _localY = LeftLimit.transform.localPosition.y; } if (_freezeAlongZ) { _localZ = LeftLimit.transform.localPosition.z; } gameObject.transform.localPosition = new Vector3(_localX, _localY, _localZ); SliderPos = this.transform.position - LeftLimit.transform.position; SliderCurPos = SliderPos.magnitude; //Limite ultime pour que ca sorte pas if (this.transform.localPosition.y > RightLimit.transform.localPosition.y + 0.01f) { this.transform.localPosition = new Vector3(_localX, RightLimit.transform.localPosition.y - 0.01f, _localZ); } else if (this.transform.localPosition.y < LeftLimit.transform.localPosition.y + 0.01f) { this.transform.localPosition = new Vector3(_localX, LeftLimit.transform.localPosition.y + 0.01f, _localZ); } SliderNewRatio = Ratio(SliderCurPos, SliderLenght, 0.45f, 0.0f, -0.45f); //Envoi à la syncVar, stockage de la valeur traduite en int et vibration si changement de cran if (SliderNewRatio != SliderOldRatio) { SendToSynchVar(SliderNewRatio); SyncWeapSystemCalib(Ratio(SliderCurPos, SliderLenght, 1.0f, 0.0f, 0.0f)); curIntValue = (int)((SliderNewRatio + 0.4f) * 6.25f); text_value_display.text = (curIntValue + 1).ToString(); if (oldIntValue != curIntValue) { if (controller != null) { controller.Vibrate(50, 0.3f); } } oldIntValue = curIntValue; } //Vibration if (controller != null) { float distance = Mathf.Min(Mathf.Abs(SliderNewRatio - SliderOldRatio), MAX_VIBRATION_DISTANCE); float vibrationStrength = (distance / MAX_VIBRATION_DISTANCE) * MAX_VIBRATION_STRENGTH; controller.Vibrate(VIBRATION_DURATION_IN_MILLISECONDS, vibrationStrength); } SliderOldRatio = SliderNewRatio; }